mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 17:02:40 +00:00
Fix SDL version cannot launch game using game ID
Missing from https://github.com/shadps4-emu/shadPS4/pull/1507.
This commit is contained in:
parent
8447d6ea1c
commit
96521640f6
30
src/main.cpp
30
src/main.cpp
@ -9,6 +9,7 @@
|
||||
#include <fmt/core.h>
|
||||
#include "common/config.h"
|
||||
#include "common/memory_patcher.h"
|
||||
#include "common/path_util.h"
|
||||
#include "emulator.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -20,6 +21,10 @@ int main(int argc, char* argv[]) {
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
#endif
|
||||
|
||||
// Load configurations
|
||||
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::load(user_dir / "config.toml");
|
||||
|
||||
bool has_game_argument = false;
|
||||
std::string game_path;
|
||||
|
||||
@ -111,14 +116,29 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// Check if the game path or ID exists
|
||||
if (!std::filesystem::exists(game_path)) {
|
||||
std::cerr << "Error: Game file not found\n";
|
||||
return -1;
|
||||
std::filesystem::path eboot_path(game_path);
|
||||
|
||||
// Check if the provided path is a valid file
|
||||
if (!std::filesystem::exists(eboot_path)) {
|
||||
// If not a file, treat it as a game ID and search in install directories
|
||||
bool game_found = false;
|
||||
for (const auto& install_dir : Config::getGameInstallDirs()) {
|
||||
const auto candidate_path = install_dir / game_path / "eboot.bin";
|
||||
if (std::filesystem::exists(candidate_path)) {
|
||||
eboot_path = candidate_path;
|
||||
game_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!game_found) {
|
||||
std::cerr << "Error: Game ID or file path not found: " << game_path << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Run the emulator with the specified game
|
||||
// Run the emulator with the resolved eboot path
|
||||
Core::Emulator emulator;
|
||||
emulator.Run(game_path);
|
||||
emulator.Run(eboot_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user