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

Conversation

rankynbass
Copy link
Contributor

@rankynbass rankynbass commented Jul 27, 2024

With the recent changes to the Free Trial / Demo, some users are having problems getting or keeping FFXIV Free Trial in their library. This allows the user to override the first AppID tried with some other number.

AppID will still fall back to the free trial if an invalid number is used, and if the value passed is not a number (or a number <= 0) it will be ignored.

Fun fact, using proton ids such as XL_APPID=2805730 for proton 9.0 does work. Not sure that would be the best idea, however.

reiichi001
reiichi001 previously approved these changes Jul 27, 2024
public static int GetAltAppId(string? appid)
{
int result;
if (int.TryParse(appid, out result))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use if (int.TryParse(appid, out var result)) to make the code a bit more concise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, did this (with uint.TryParse() instead).

@@ -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 int AltAppID => GetAltAppId(System.Environment.GetEnvironmentVariable("XL_APPID"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually nullability is used here to indicate an env var not existing, instead of using a special value (like -1).

@rankynbass
Copy link
Contributor Author

Alright, simplified the logic to use uint.TryParse(). If the conversion fails or the value is zero, AltAppId will be set to 0. I could use a nullable here, but the simple fact is that using an AppId of 0 is invalid anyway, so it's just as easy to make sure AltAppId is > 0 instead of checking for 0 and null.

@reiichi001 reiichi001 merged commit 48d54d7 into goatcorp:main Aug 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants