launch module fallback

This commit is contained in:
Adrian 2023-10-17 18:36:51 +01:00 committed by Radosław Gliński
parent d84df6e47f
commit 9f1605a2e7
2 changed files with 34 additions and 21 deletions

View File

@ -329,7 +329,10 @@ const std::unique_ptr<vfs::Device> Emulator::CreateVfsDeviceBasedOnPath(
auto parent_path = path.parent_path(); auto parent_path = path.parent_path();
return std::make_unique<vfs::HostPathDevice>( return std::make_unique<vfs::HostPathDevice>(
mount_path, parent_path, !cvars::allow_game_relative_writes); mount_path, parent_path, !cvars::allow_game_relative_writes);
} else if (extension == ".7z" || extension == ".zip" || extension == ".rar" || } else if (extension == ".zar") {
return std::make_unique<vfs::DiscZarchiveDevice>(mount_path, path);
}
else if (extension == ".7z" || extension == ".zip" || extension == ".rar" ||
extension == ".tar" || extension == ".gz") { extension == ".tar" || extension == ".gz") {
xe::ShowSimpleMessageBox( xe::ShowSimpleMessageBox(
xe::SimpleMessageBoxType::Error, xe::SimpleMessageBoxType::Error,
@ -422,6 +425,7 @@ X_STATUS Emulator::LaunchPath(const std::filesystem::path& path) {
return LaunchXexFile(path); return LaunchXexFile(path);
} else if (extension == ".zar") { } else if (extension == ".zar") {
// Assume a disc image. // Assume a disc image.
MountPath(path, "\\Device\\Cdrom0");
return LaunchDiscArchive(path); return LaunchDiscArchive(path);
} else { } else {
// Assume a disc image. // Assume a disc image.
@ -446,35 +450,42 @@ X_STATUS Emulator::LaunchXexFile(const std::filesystem::path& path) {
} }
X_STATUS Emulator::LaunchDiscImage(const std::filesystem::path& path) { X_STATUS Emulator::LaunchDiscImage(const std::filesystem::path& path) {
auto module_path(FindLaunchModule()); std::string module_path = FindLaunchModule();
return CompleteLaunch(path, module_path); X_STATUS result = CompleteLaunch(path, module_path);
if (result == X_STATUS_NOT_FOUND && !cvars::launch_module.empty()) {
return LaunchDefaultModule(path);
}
return result;
} }
X_STATUS Emulator::LaunchDiscArchive(const std::filesystem::path& path) { X_STATUS Emulator::LaunchDiscArchive(const std::filesystem::path& path) {
auto mount_path = "\\Device\\Cdrom0"; std::string module_path = FindLaunchModule();
X_STATUS result = CompleteLaunch(path, module_path);
// Register the disc image in the virtual filesystem. if (result == X_STATUS_NOT_FOUND && !cvars::launch_module.empty()) {
auto device = std::make_unique<vfs::DiscZarchiveDevice>(mount_path, path); return LaunchDefaultModule(path);
if (!device->Initialize()) {
xe::FatalError("Unable to mount disc image; file not found or corrupt.");
return X_STATUS_NO_SUCH_FILE;
}
if (!file_system_->RegisterDevice(std::move(device))) {
xe::FatalError("Unable to register disc image.");
return X_STATUS_NO_SUCH_FILE;
} }
// Create symlinks to the device. return result;
file_system_->RegisterSymbolicLink("game:", mount_path);
file_system_->RegisterSymbolicLink("d:", mount_path);
// Launch the game.
auto module_path(FindLaunchModule());
return CompleteLaunch(path, module_path);
} }
X_STATUS Emulator::LaunchStfsContainer(const std::filesystem::path& path) { X_STATUS Emulator::LaunchStfsContainer(const std::filesystem::path& path) {
auto module_path(FindLaunchModule()); std::string module_path = FindLaunchModule();
X_STATUS result = CompleteLaunch(path, module_path);
if (result == X_STATUS_NOT_FOUND && !cvars::launch_module.empty()) {
return LaunchDefaultModule(path);
}
return result;
}
X_STATUS Emulator::LaunchDefaultModule(const std::filesystem::path& path) {
cvars::launch_module = "";
std::string module_path = FindLaunchModule();
return CompleteLaunch(path, module_path); return CompleteLaunch(path, module_path);
} }

View File

@ -202,6 +202,8 @@ class Emulator {
// Launches a game from an STFS container file. // Launches a game from an STFS container file.
X_STATUS LaunchStfsContainer(const std::filesystem::path& path); X_STATUS LaunchStfsContainer(const std::filesystem::path& path);
X_STATUS LaunchDefaultModule(const std::filesystem::path& path);
// Extract content of package to content specific directory. // Extract content of package to content specific directory.
X_STATUS InstallContentPackage(const std::filesystem::path& path); X_STATUS InstallContentPackage(const std::filesystem::path& path);