Skip to content

Commit

Permalink
Update Source.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Feb 7, 2024
1 parent 16f46a3 commit 9abb1d0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions OpenGSQ/Protocols/Source.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public async Task<PartialInfo> GetInfo()
Players = br.ReadByte(),
MaxPlayers = br.ReadByte(),
Bots = br.ReadByte(),
ServerType = (ServerType)br.ReadByte(),
Environment = GetEnvironment(br.ReadByte()),
ServerType = ParseServerType(br.ReadByte()),
Environment = ParseEnvironment(br.ReadByte()),
Visibility = (Visibility)br.ReadByte(),
VAC = (VAC)br.ReadByte()
};
Expand Down Expand Up @@ -143,8 +143,8 @@ public async Task<PartialInfo> GetInfo()
Players = br.ReadByte(),
MaxPlayers = br.ReadByte(),
Protocol = br.ReadByte(),
ServerType = (ServerType)char.ToLower(Convert.ToChar(br.ReadByte())),
Environment = (Environment)char.ToLower(Convert.ToChar(br.ReadByte())),
ServerType = ParseServerType(br.ReadByte()),
Environment = ParseEnvironment(br.ReadByte()),
Visibility = (Visibility)br.ReadByte(),
Mod = br.ReadByte()
};
Expand Down Expand Up @@ -418,9 +418,16 @@ private async Task<byte[]> ParseGoldSourcePackets(System.Net.Sockets.UdpClient u
return combinedPayload.Skip(4).ToArray();
}

private Environment GetEnvironment(byte environmentByte)
private ServerType ParseServerType(byte b)
{
switch (environmentByte)
return (ServerType)Convert.ToByte(char.ToLower(Convert.ToChar(b)));
}

private Environment ParseEnvironment(byte b)
{
b = Convert.ToByte(char.ToLower(Convert.ToChar(b)));

switch (b)
{
case (byte)Environment.Linux:
return Environment.Linux;
Expand Down

0 comments on commit 9abb1d0

Please sign in to comment.