Simplify patchwork game version test

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

View file

@ -1,5 +1,4 @@
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Types.Users;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
@ -11,27 +10,24 @@ public static class PatchworkHelper
{
string userAgentPrefix = "PatchworkLBP";
char gameVersion = userAgent[userAgentPrefix.Length];
int numericVersion = 0;
if (userAgent.StartsWith(userAgentPrefix))
if (!userAgent.StartsWith(userAgentPrefix))
return false;
if (char.IsLetterOrDigit(gameVersion))
{
if (gameVersion == 'V')
numericVersion = 4;
switch (gameVersion) {
case '1':
case '2':
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('.');
if (int.Parse(patchworkVer[0]) >= patchworkMajorVer && int.Parse(patchworkVer[1]) >= patchworkMinorVer)
return true;
if (int.Parse(patchworkVer[0]) !>= patchworkMajorVer || int.Parse(patchworkVer[1]) !>= patchworkMinorVer)
return false;
return false;
return true;
}
}