mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-23 13:41:31 +00:00
Simplify patchwork game version test
This commit is contained in:
parent
c29eb380be
commit
b838d805e2
1 changed files with 12 additions and 16 deletions
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue