Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XL_APPID as an override for using Free Trial #175

Merged
merged 4 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/XIVLauncher.Core/CoreEnvironmentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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 uint AltAppID => GetAltAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));

private static bool CheckEnvBool(string key)
{
Expand All @@ -39,6 +40,14 @@ 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 uint GetAltAppId(string? appid)
{
uint.TryParse(appid, out var result);

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

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

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