Skip to content

Commit

Permalink
Simplify AppID logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rankynbass committed Jul 27, 2024
1 parent 221a5df commit c16b9d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class CoreEnvironmentSettings
public static bool ClearAll => CheckEnvBool("XL_CLEAR_ALL");
public static bool? UseSteam => CheckEnvBoolOrNull("XL_USE_STEAM"); // Fix for Steam Deck users who lock themselves out
public static bool IsSteamCompatTool => CheckEnvBool("XL_SCT");
public static int AltAppID => GetAltAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));
public static uint AltAppID => GetAltAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));

private static bool CheckEnvBool(string key)
{
Expand All @@ -40,13 +40,13 @@ public static string GetCleanEnvironmentVariable(string envvar, string badstring
return string.Join(separator, Array.FindAll<string>(dirty.Split(separator, StringSplitOptions.RemoveEmptyEntries), s => !s.Contains(badstring)));
}

public static int GetAltAppId(string? appid)
public static uint GetAltAppId(string? appid)
{
int result;
if (int.TryParse(appid, out result))
return result;
else
return -1;
uint result;
uint.TryParse(appid, out result);

// Will return 0 if appid is invalid (or zero).
return result;
}

public static string GetCType()
Expand Down
3 changes: 2 additions & 1 deletion src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ private static void Main(string[] args)

uint appId, altId;
string appName, altName;
// AppId of 0 is invalid (though still a valid uint)
if (CoreEnvironmentSettings.AltAppID > 0)
{
appId = (uint)CoreEnvironmentSettings.AltAppID;
appId = CoreEnvironmentSettings.AltAppID;
altId = STEAM_APP_ID_FT;
appName = $"Override AppId={appId.ToString()}";
altName = "FFXIV Free Trial";
Expand Down

0 comments on commit c16b9d8

Please sign in to comment.