fix: Games not launching due to string semantics

This commit is contained in:
quexeky
2025-01-20 23:12:57 +11:00
parent 6ad383799d
commit 4ef49cc832

View File

@ -276,6 +276,7 @@ impl ProcessManager<'_> {
let launch_process = game_launcher let launch_process = game_launcher
.launch_process( .launch_process(
&meta, &meta,
command.to_string_lossy().to_string(),
game_version, game_version,
target_current_dir, target_current_dir,
log_file, log_file,
@ -331,6 +332,7 @@ pub trait ProcessHandler: Send + 'static {
fn launch_process( fn launch_process(
&self, &self,
meta: &DownloadableMetadata, meta: &DownloadableMetadata,
launch_command: String,
game_version: &GameVersion, game_version: &GameVersion,
current_dir: &str, current_dir: &str,
log_file: File, log_file: File,
@ -343,12 +345,13 @@ impl ProcessHandler for NativeGameLauncher {
fn launch_process( fn launch_process(
&self, &self,
_meta: &DownloadableMetadata, _meta: &DownloadableMetadata,
launch_command: String,
game_version: &GameVersion, game_version: &GameVersion,
current_dir: &str, current_dir: &str,
log_file: File, log_file: File,
error_file: File, error_file: File,
) -> Result<Child, Error> { ) -> Result<Child, Error> {
Command::new(game_version.launch_command.clone()) Command::new(PathBuf::from(launch_command))
.current_dir(current_dir) .current_dir(current_dir)
.stdout(log_file) .stdout(log_file)
.stderr(error_file) .stderr(error_file)
@ -363,13 +366,20 @@ impl ProcessHandler for UMULauncher {
fn launch_process( fn launch_process(
&self, &self,
_meta: &DownloadableMetadata, _meta: &DownloadableMetadata,
launch_command: String,
game_version: &GameVersion, game_version: &GameVersion,
_current_dir: &str, _current_dir: &str,
_log_file: File, _log_file: File,
_error_file: File, _error_file: File,
) -> Result<Child, Error> { ) -> Result<Child, Error> {
UmuCommandBuilder::new(UMU_LAUNCHER_EXECUTABLE, game_version.launch_command.clone()) println!("Game override: .{:?}.", &game_version.umu_id_override);
.game_id(String::from(game_version.umu_id_override.clone().unwrap_or(game_version.game_id.clone()))) let game_id = match &game_version.umu_id_override {
Some(game_override) => game_override.is_empty().then_some(game_version.game_id.clone()).unwrap_or(game_override.clone()) ,
None => game_version.game_id.clone()
};
info!("Game ID: {}", game_id);
UmuCommandBuilder::new(UMU_LAUNCHER_EXECUTABLE, launch_command)
.game_id(game_id)
.launch_args(game_version.launch_args.clone()) .launch_args(game_version.launch_args.clone())
.build() .build()
.spawn() .spawn()