@@ -672,45 +672,53 @@ async fn prep_launch(
672672 #[ cfg( not( target_os = "windows" ) ) ]
673673 {
674674 // Compat setup
675- let mut compat_data_dir = util:: get_compat_data_dir ( & cmd) ;
676- if compat_data_dir. is_none ( ) {
677- // not specified; use launcher compat data dir
678- let mut launcher_compat_dir = app_statics. compat_data_dir . clone ( ) ;
679- launcher_compat_dir. push ( profile. get_id ( ) . to_string ( ) ) ;
680-
681- if cmd. get_program ( ) . to_string_lossy ( ) . ends_with ( "proton" ) {
682- #[ cfg( target_os = "linux" ) ]
683- {
675+ let mut ensure_compat_dir = true ;
676+ let mut compat_data_dir = app_statics. compat_data_dir . clone ( ) ;
677+ compat_data_dir. push ( profile. get_id ( ) . to_string ( ) ) ;
678+
679+ let compat_program = std:: path:: Path :: new ( cmd. get_program ( ) )
680+ . file_name ( )
681+ . and_then ( |s| s. to_str ( ) )
682+ . unwrap_or ( "" ) ;
683+
684+ if compat_program. contains ( "proton" ) {
685+ #[ cfg( target_os = "linux" ) ]
686+ {
687+ if util:: get_env_var_value ( & cmd, "STEAM_COMPAT_CLIENT_INSTALL_PATH" ) . is_none ( ) {
684688 if let Some ( steam_client_dir) = protontools:: get_steam_client_path ( ) {
685689 cmd. env (
686690 "STEAM_COMPAT_CLIENT_INSTALL_PATH" ,
687- steam_client_dir. to_string_lossy ( ) . to_string ( ) ,
691+ steam_client_dir. into_os_string ( ) ,
688692 ) ;
689693 } else {
690694 return Err ( "Proton requires Steam to be installed" . into ( ) ) ;
691695 }
696+ }
692697
693- cmd. env (
694- "STEAM_COMPAT_DATA_PATH" ,
695- launcher_compat_dir. to_string_lossy ( ) . to_string ( ) ,
696- ) ;
697- // proton sets WINEPREFIX internally
698+ if let Some ( proton_prefix) =
699+ util:: get_env_var_value ( & cmd, "STEAM_COMPAT_DATA_PATH" )
700+ {
701+ compat_data_dir = proton_prefix. into ( ) ;
702+ } else {
703+ cmd. env ( "STEAM_COMPAT_DATA_PATH" , & compat_data_dir) ;
698704 }
705+ // proton sets WINEPREFIX internally
706+ }
699707
700- #[ cfg( not( target_os = "linux" ) ) ]
701- return Err ( "Proton is only supported on Linux" . into ( ) ) ;
708+ #[ cfg( not( target_os = "linux" ) ) ]
709+ return Err ( "Proton is only supported on Linux" . into ( ) ) ;
710+ } else if compat_program. contains ( "wine" ) {
711+ if let Some ( wine_prefix) = util:: get_env_var_value ( & cmd, "WINEPREFIX" ) {
712+ compat_data_dir = wine_prefix. into ( ) ;
702713 } else {
703- // assume wine
704- cmd. env (
705- "WINEPREFIX" ,
706- launcher_compat_dir. to_string_lossy ( ) . to_string ( ) ,
707- ) ;
714+ cmd. env ( "WINEPREFIX" , & compat_data_dir. clone ( ) . into_os_string ( ) ) ;
708715 }
709- compat_data_dir = Some ( launcher_compat_dir) ;
716+ } else {
717+ // unknown compat layer
718+ ensure_compat_dir = false ;
710719 }
711720
712- let compat_data_dir = compat_data_dir. unwrap ( ) ;
713- if !compat_data_dir. exists ( ) {
721+ if ensure_compat_dir && !compat_data_dir. exists ( ) {
714722 debug ! ( "Creating prefix at {}" , compat_data_dir. to_string_lossy( ) ) ;
715723 std:: fs:: create_dir_all ( & compat_data_dir) ?;
716724 }
0 commit comments