Simplify patchwork game version test

This commit is contained in:
FeTetra 2025-05-26 19:54:33 -04:00
commit b838d805e2

View file

@ -1,5 +1,4 @@
using LBPUnion.ProjectLighthouse.Configuration; using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Types.Users;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers; namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
@ -11,27 +10,24 @@ public static class PatchworkHelper
{ {
string userAgentPrefix = "PatchworkLBP"; string userAgentPrefix = "PatchworkLBP";
char gameVersion = userAgent[userAgentPrefix.Length]; char gameVersion = userAgent[userAgentPrefix.Length];
int numericVersion = 0;
if (userAgent.StartsWith(userAgentPrefix)) if (!userAgent.StartsWith(userAgentPrefix))
return false; return false;
if (char.IsLetterOrDigit(gameVersion)) switch (gameVersion) {
{ case '1':
if (gameVersion == 'V') case '2':
numericVersion = 4; case '3':
case 'V':
break;
default:
return false;
} }
else
numericVersion = gameVersion - '0';
// Don't want it to be 0 still because of Unknown (-1) in GameVersion
if (numericVersion - 1 == 0 || !Enum.IsDefined(typeof(GameVersion), numericVersion))
return false;
string[] patchworkVer = userAgent.Split(' ')[1].Split('.'); string[] patchworkVer = userAgent.Split(' ')[1].Split('.');
if (int.Parse(patchworkVer[0]) >= patchworkMajorVer && int.Parse(patchworkVer[1]) >= patchworkMinorVer) if (int.Parse(patchworkVer[0]) !>= patchworkMajorVer || int.Parse(patchworkVer[1]) !>= patchworkMinorVer)
return true;
return false; return false;
return true;
} }
} }