mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 08:52:36 +00:00
Fix -g flag with --; and avoid overindexing if -- is set but no arguments are added
This commit is contained in:
parent
39c87f4d2b
commit
4aad1940a0
21
src/main.cpp
21
src/main.cpp
@ -127,19 +127,32 @@ int main(int argc, char* argv[]) {
|
||||
auto it = arg_map.find(cur_arg);
|
||||
if (it != arg_map.end()) {
|
||||
it->second(i); // Call the associated lambda function
|
||||
} else if (i == argc - 1 && !has_game_argument) {
|
||||
// Assume the last argument is the game file if not specified via -g/--game
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
} else if (std::string(argv[i]) == "--") {
|
||||
if (i + 1 == argc) {
|
||||
std::cerr << "Warning: -- is set, but no game arguments are added!\n";
|
||||
break;
|
||||
}
|
||||
for (int j = i + 1; j < argc; j++) {
|
||||
game_args.push_back(argv[j]);
|
||||
}
|
||||
break;
|
||||
} else if (std::string(argv[i + 1]) == "--") {
|
||||
if (!has_game_argument) {
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
}
|
||||
if (i + 2 == argc) {
|
||||
std::cerr << "Warning: -- is set, but no game arguments are added!\n";
|
||||
break;
|
||||
}
|
||||
for (int j = i + 2; j < argc; j++) {
|
||||
game_args.push_back(argv[j]);
|
||||
}
|
||||
break;
|
||||
} else if (i == argc - 1 && !has_game_argument) {
|
||||
// Assume the last argument is the game file if not specified via -g/--game
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
} else {
|
||||
std::cerr << "Unknown argument: " << cur_arg << ", see --help for info.\n";
|
||||
return 1;
|
||||
|
@ -131,19 +131,32 @@ int main(int argc, char* argv[]) {
|
||||
auto it = arg_map.find(cur_arg);
|
||||
if (it != arg_map.end()) {
|
||||
it->second(i); // Call the associated lambda function
|
||||
} else if (i == argc - 1 && !has_game_argument) {
|
||||
// Assume the last argument is the game file if not specified via -g/--game
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
} else if (std::string(argv[i]) == "--") {
|
||||
if (i + 1 == argc) {
|
||||
std::cerr << "Warning: -- is set, but no game arguments are added!\n";
|
||||
break;
|
||||
}
|
||||
for (int j = i + 1; j < argc; j++) {
|
||||
game_args.push_back(argv[j]);
|
||||
}
|
||||
break;
|
||||
} else if (std::string(argv[i + 1]) == "--") {
|
||||
if (!has_game_argument) {
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
}
|
||||
if (i + 2 == argc) {
|
||||
std::cerr << "Warning: -- is set, but no game arguments are added!\n";
|
||||
break;
|
||||
}
|
||||
for (int j = i + 2; j < argc; j++) {
|
||||
game_args.push_back(argv[j]);
|
||||
}
|
||||
break;
|
||||
} else if (i == argc - 1 && !has_game_argument) {
|
||||
// Assume the last argument is the game file if not specified via -g/--game
|
||||
game_path = argv[i];
|
||||
has_game_argument = true;
|
||||
} else {
|
||||
std::cerr << "Unknown argument: " << cur_arg << ", see --help for info.\n";
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user