@@ -5,7 +5,9 @@ namespace Launcher.Utils
55{
66 public class Steam
77 {
8- public static string ? recentSteamID { get ; private set ; }
8+ public static string ? recentSteamID64 { get ; private set ; }
9+ public static string ? recentSteamID2 { get ; private set ; }
10+
911 private static string ? steamPath { get ; set ; }
1012 private static async Task GetSteamInstallPath ( )
1113 {
@@ -24,25 +26,37 @@ public static async Task GetRecentLoggedInSteamID()
2426 await GetSteamInstallPath ( ) ;
2527 if ( string . IsNullOrEmpty ( steamPath ) )
2628 {
27- Terminal . Error ( "Steam not found. Get Steam ." ) ;
29+ Terminal . Error ( "Your Steam install couldn't be found ." ) ;
2830 Terminal . Error ( "Closing launcher in 5 seconds..." ) ;
2931 await Task . Delay ( 5000 ) ;
3032 Environment . Exit ( 1 ) ;
3133 }
32-
3334 var loginUsersPath = Path . Combine ( steamPath , "config" , "loginusers.vdf" ) ;
3435 dynamic loginUsers = VdfConvert . Deserialize ( File . ReadAllText ( loginUsersPath ) ) ;
35-
36- foreach ( var user in loginUsers . Value )
36+ foreach ( var user in loginUsers . Value )
3737 {
3838 var mostRecent = user . Value . MostRecent . Value ;
3939 if ( mostRecent == "1" )
4040 {
41- recentSteamID = user . Key ;
41+ recentSteamID64 = user . Key ;
42+ recentSteamID2 = ConvertToSteamID2 ( user . Key ) ;
4243 }
4344 }
44- if ( Debug . Enabled ( ) && ! string . IsNullOrEmpty ( recentSteamID ) )
45- Terminal . Debug ( $ "Most recent Steam account: { recentSteamID } ") ;
45+ if ( Debug . Enabled ( ) && ! string . IsNullOrEmpty ( recentSteamID64 ) )
46+ {
47+ Terminal . Debug ( $ "Most recent Steam account (SteamID64): { recentSteamID64 } ") ;
48+ Terminal . Debug ( $ "Most recent Steam account (SteamID2): { recentSteamID2 } ") ;
49+ }
50+ }
51+
52+ private static string ConvertToSteamID2 ( string steamID64 )
53+ {
54+ ulong id64 = ulong . Parse ( steamID64 ) ;
55+ ulong constValue = 76561197960265728 ;
56+ ulong accountID = id64 - constValue ;
57+ ulong y = accountID % 2 ;
58+ ulong z = accountID / 2 ;
59+ return $ "STEAM_1:{ y } :{ z } ";
4660 }
4761 }
4862}
0 commit comments