mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-25 20:06:17 +00:00
Add option to ignore game patch (#3039)
* impl * fix * cleanup * more * clang + * why
This commit is contained in:
parent
e0c930f2d8
commit
9981c8df03
5 changed files with 39 additions and 28 deletions
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
namespace Core::FileSys {
|
namespace Core::FileSys {
|
||||||
|
|
||||||
|
bool MntPoints::ignore_game_patches = false;
|
||||||
|
|
||||||
std::string RemoveTrailingSlashes(const std::string& path) {
|
std::string RemoveTrailingSlashes(const std::string& path) {
|
||||||
// Remove trailing slashes to make comparisons simpler.
|
// Remove trailing slashes to make comparisons simpler.
|
||||||
std::string path_sanitized = path;
|
std::string path_sanitized = path;
|
||||||
|
@ -77,7 +79,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
||||||
patch_path /= rel_path;
|
patch_path /= rel_path;
|
||||||
|
|
||||||
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
|
if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) &&
|
||||||
!force_base_path && std::filesystem::exists(patch_path)) {
|
!force_base_path && !ignore_game_patches && std::filesystem::exists(patch_path)) {
|
||||||
return patch_path;
|
return patch_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +139,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
||||||
return std::optional<std::filesystem::path>(current_path);
|
return std::optional<std::filesystem::path>(current_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!force_base_path) {
|
if (!force_base_path && !ignore_game_patches) {
|
||||||
if (const auto path = search(patch_path)) {
|
if (const auto path = search(patch_path)) {
|
||||||
return *path;
|
return *path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ class MntPoints {
|
||||||
static constexpr bool NeedsCaseInsensitiveSearch = true;
|
static constexpr bool NeedsCaseInsensitiveSearch = true;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
|
static bool ignore_game_patches;
|
||||||
struct MntPair {
|
struct MntPair {
|
||||||
std::filesystem::path host_path;
|
std::filesystem::path host_path;
|
||||||
std::string mount; // e.g /app0
|
std::string mount; // e.g /app0
|
||||||
|
|
|
@ -75,7 +75,7 @@ void Emulator::Run(std::filesystem::path file, const std::vector<std::string> ar
|
||||||
game_folder_name.ends_with("-UPDATE") || game_folder_name.ends_with("-patch")) {
|
game_folder_name.ends_with("-UPDATE") || game_folder_name.ends_with("-patch")) {
|
||||||
// If an executable was launched from a separate update directory,
|
// If an executable was launched from a separate update directory,
|
||||||
// use the base game directory as the game folder.
|
// use the base game directory as the game folder.
|
||||||
const auto base_name = game_folder_name.substr(0, game_folder_name.size() - 7);
|
const std::string base_name = game_folder_name.substr(0, game_folder_name.rfind('-'));
|
||||||
const auto base_path = game_folder.parent_path() / base_name;
|
const auto base_path = game_folder.parent_path() / base_name;
|
||||||
if (std::filesystem::is_directory(base_path)) {
|
if (std::filesystem::is_directory(base_path)) {
|
||||||
game_folder = base_path;
|
game_folder = base_path;
|
||||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -35,17 +35,19 @@ int main(int argc, char* argv[]) {
|
||||||
std::unordered_map<std::string, std::function<void(int&)>> arg_map = {
|
std::unordered_map<std::string, std::function<void(int&)>> arg_map = {
|
||||||
{"-h",
|
{"-h",
|
||||||
[&](int&) {
|
[&](int&) {
|
||||||
std::cout << "Usage: shadps4 [options] <elf or eboot.bin path>\n"
|
std::cout
|
||||||
"Options:\n"
|
<< "Usage: shadps4 [options] <elf or eboot.bin path>\n"
|
||||||
" -g, --game <path|ID> Specify game path to launch\n"
|
"Options:\n"
|
||||||
" -- ... Parameters passed to the game ELF. "
|
" -g, --game <path|ID> Specify game path to launch\n"
|
||||||
"Needs to be at the end of the line, and everything after \"--\" is a "
|
" -- ... Parameters passed to the game ELF. "
|
||||||
"game argument.\n"
|
"Needs to be at the end of the line, and everything after \"--\" is a "
|
||||||
" -p, --patch <patch_file> Apply specified patch file\n"
|
"game argument.\n"
|
||||||
" -f, --fullscreen <true|false> Specify window initial fullscreen "
|
" -p, --patch <patch_file> Apply specified patch file\n"
|
||||||
"state. Does not overwrite the config file.\n"
|
" -i, --ignore-game-patch Disable automatic loading of game patch\n"
|
||||||
" --add-game-folder <folder> Adds a new game folder to the config.\n"
|
" -f, --fullscreen <true|false> Specify window initial fullscreen "
|
||||||
" -h, --help Display this help message\n";
|
"state. Does not overwrite the config file.\n"
|
||||||
|
" --add-game-folder <folder> Adds a new game folder to the config.\n"
|
||||||
|
" -h, --help Display this help message\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}},
|
}},
|
||||||
{"--help", [&](int& i) { arg_map["-h"](i); }},
|
{"--help", [&](int& i) { arg_map["-h"](i); }},
|
||||||
|
@ -72,6 +74,8 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{"--patch", [&](int& i) { arg_map["-p"](i); }},
|
{"--patch", [&](int& i) { arg_map["-p"](i); }},
|
||||||
|
{"-i", [&](int&) { Core::FileSys::MntPoints::ignore_game_patches = true; }},
|
||||||
|
{"--ignore-game-patch", [&](int& i) { arg_map["-i"](i); }},
|
||||||
{"-f",
|
{"-f",
|
||||||
[&](int& i) {
|
[&](int& i) {
|
||||||
if (++i >= argc) {
|
if (++i >= argc) {
|
||||||
|
|
|
@ -41,20 +41,22 @@ int main(int argc, char* argv[]) {
|
||||||
std::unordered_map<std::string, std::function<void(int&)>> arg_map = {
|
std::unordered_map<std::string, std::function<void(int&)>> arg_map = {
|
||||||
{"-h",
|
{"-h",
|
||||||
[&](int&) {
|
[&](int&) {
|
||||||
std::cout << "Usage: shadps4 [options]\n"
|
std::cout
|
||||||
"Options:\n"
|
<< "Usage: shadps4 [options]\n"
|
||||||
" No arguments: Opens the GUI.\n"
|
"Options:\n"
|
||||||
" -g, --game <path|ID> Specify <eboot.bin or elf path> or "
|
" No arguments: Opens the GUI.\n"
|
||||||
"<game ID (CUSAXXXXX)> to launch\n"
|
" -g, --game <path|ID> Specify <eboot.bin or elf path> or "
|
||||||
" -- ... Parameters passed to the game ELF. "
|
"<game ID (CUSAXXXXX)> to launch\n"
|
||||||
"Needs to be at the end of the line, and everything after \"--\" is a "
|
" -- ... Parameters passed to the game ELF. "
|
||||||
"game argument.\n"
|
"Needs to be at the end of the line, and everything after \"--\" is a "
|
||||||
" -p, --patch <patch_file> Apply specified patch file\n"
|
"game argument.\n"
|
||||||
" -s, --show-gui Show the GUI\n"
|
" -p, --patch <patch_file> Apply specified patch file\n"
|
||||||
" -f, --fullscreen <true|false> Specify window initial fullscreen "
|
" -i, --ignore-game-patch Disable automatic loading of game patch\n"
|
||||||
"state. Does not overwrite the config file.\n"
|
" -s, --show-gui Show the GUI\n"
|
||||||
" --add-game-folder <folder> Adds a new game folder to the config.\n"
|
" -f, --fullscreen <true|false> Specify window initial fullscreen "
|
||||||
" -h, --help Display this help message\n";
|
"state. Does not overwrite the config file.\n"
|
||||||
|
" --add-game-folder <folder> Adds a new game folder to the config.\n"
|
||||||
|
" -h, --help Display this help message\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}},
|
}},
|
||||||
{"--help", [&](int& i) { arg_map["-h"](i); }}, // Redirect --help to -h
|
{"--help", [&](int& i) { arg_map["-h"](i); }}, // Redirect --help to -h
|
||||||
|
@ -84,6 +86,8 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{"--patch", [&](int& i) { arg_map["-p"](i); }},
|
{"--patch", [&](int& i) { arg_map["-p"](i); }},
|
||||||
|
{"-i", [&](int&) { Core::FileSys::MntPoints::ignore_game_patches = true; }},
|
||||||
|
{"--ignore-game-patch", [&](int& i) { arg_map["-i"](i); }},
|
||||||
{"-f",
|
{"-f",
|
||||||
[&](int& i) {
|
[&](int& i) {
|
||||||
if (++i >= argc) {
|
if (++i >= argc) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue