Skip to content

Commit 229fd80

Browse files
committed
steam whitelist check
1 parent 7bbabc6 commit 229fd80

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

Launcher/Launcher.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<Company>ClassicCounter Team</Company>
9-
<Version>2.2.2.0</Version>
9+
<Version>2.2.3.0</Version>
1010
<AssemblyVersion>$(Version)</AssemblyVersion>
1111
<FileVersion>$(Version)</FileVersion>
1212
<AssemblyName>launcher</AssemblyName>

Launcher/Utils/Api.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public interface IClassicCounter
3232
Task<string> GetFullGameValidate();
3333

3434
[Headers("User-Agent: ClassicCounter Launcher")]
35-
[Get("/game/full?steam_id={recentSteamID}")]
36-
Task<FullGameDownloadResponse> GetFullGameDownload(string recentSteamID);
35+
[Get("/game/full?steam_id={recentSteamID2}")]
36+
Task<FullGameDownloadResponse> GetFullGameDownload(string recentSteamID2);
3737
}
3838

3939
public static class Api

Launcher/Utils/Download.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ public static async Task DownloadFullGame(StatusContext ctx)
127127
try
128128
{
129129
await Steam.GetRecentLoggedInSteamID();
130-
if (string.IsNullOrEmpty(Steam.recentSteamID))
130+
if (string.IsNullOrEmpty(Steam.recentSteamID2))
131131
{
132-
Terminal.Error("Discord not connected. Please make sure Discord is running.");
132+
Terminal.Error("Steam does not seem to be installed. Please make sure that you have Steam installed.");
133133
Terminal.Error("Closing launcher in 5 seconds...");
134134
await Task.Delay(5000);
135135
Environment.Exit(1);
136136
return;
137137
}
138138

139139
// pass steam id to api
140-
var gameFiles = await Api.ClassicCounter.GetFullGameDownload(Steam.recentSteamID);
140+
var gameFiles = await Api.ClassicCounter.GetFullGameDownload(Steam.recentSteamID2);
141141

142142
int totalFiles = gameFiles.Files.Count;
143143
int completedFiles = 0;
@@ -217,7 +217,7 @@ await _downloader.DownloadFileTaskAsync(
217217
catch (ApiException ex) when (ex.StatusCode == System.Net.HttpStatusCode.Forbidden)
218218
{
219219
Terminal.Error("You are not whitelisted on ClassicCounter! (https://classiccounter.cc/whitelist)");
220-
Terminal.Error("If you are whitelisted, check if Discord is open and if you're logged into the whitelisted account.");
220+
Terminal.Error("If you are whitelisted, check if you have Steam installed and that you're logged into the whitelisted account.");
221221
Terminal.Error("If you're still facing issues, use one of our other download links to download the game.");
222222
Terminal.Warning("Closing launcher in 10 seconds...");
223223
await Task.Delay(10000);

Launcher/Utils/Steam.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Launcher/Utils/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Launcher.Utils
44
{
55
public static class Version
66
{
7-
public static string Current = "2.2.2";
7+
public static string Current = "2.2.3";
88

99
public async static Task<string> GetLatestVersion()
1010
{

0 commit comments

Comments
 (0)