minor code improvements

This commit is contained in:
David Rodenkirchen 2023-08-18 16:40:52 +02:00
parent d99cf0d3ef
commit 80ae18c6b2
2 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,4 @@
using System.Diagnostics; using System.Net;
using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Numerics; using System.Numerics;
using System.Text; using System.Text;

View File

@ -1,7 +1,6 @@
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices;
using BattleBitAPI.Common; using BattleBitAPI.Common;
using BattleBitAPI.Common.Extentions; using BattleBitAPI.Common.Extentions;
using BattleBitAPI.Networking; using BattleBitAPI.Networking;
@ -190,12 +189,12 @@ namespace BattleBitAPI.Server
throw new Exception("Incoming package wasn't hail."); throw new Exception("Incoming package wasn't hail.");
} }
//Read the server name //Read the server token
string token; string token;
{ {
readStream.Reset(); readStream.Reset();
if (!await networkStream.TryRead(readStream, 2, source.Token)) if (!await networkStream.TryRead(readStream, 2, source.Token))
throw new Exception("Unable to read the Token Size"); throw new Exception("Unable to read the token Size");
int stringSize = readStream.ReadUInt16(); int stringSize = readStream.ReadUInt16();
if (stringSize > Const.MaxTokenSize) if (stringSize > Const.MaxTokenSize)
@ -339,7 +338,7 @@ namespace BattleBitAPI.Server
throw new Exception("Unable to read the Loading Screen Text Size"); throw new Exception("Unable to read the Loading Screen Text Size");
int stringSize = readStream.ReadUInt16(); int stringSize = readStream.ReadUInt16();
if (stringSize < Const.MinLoadingScreenTextLength || stringSize > Const.MaxLoadingScreenTextLength) if (stringSize > Const.MaxLoadingScreenTextLength)
throw new Exception("Invalid server Loading Screen Text Size"); throw new Exception("Invalid server Loading Screen Text Size");
if (stringSize > 0) if (stringSize > 0)
@ -364,7 +363,7 @@ namespace BattleBitAPI.Server
throw new Exception("Unable to read the Server Rules Text Size"); throw new Exception("Unable to read the Server Rules Text Size");
int stringSize = readStream.ReadUInt16(); int stringSize = readStream.ReadUInt16();
if (stringSize < Const.MinServerRulesTextLength || stringSize > Const.MaxServerRulesTextLength) if (stringSize > Const.MaxServerRulesTextLength)
throw new Exception("Invalid server Server Rules Text Size"); throw new Exception("Invalid server Server Rules Text Size");
if (stringSize > 0) if (stringSize > 0)
@ -546,7 +545,7 @@ namespace BattleBitAPI.Server
{ {
readStream.Reset(); readStream.Reset();
if (!await networkStream.TryRead(readStream, 4, source.Token)) if (!await networkStream.TryRead(readStream, 4, source.Token))
throw new Exception("Unable to read the LoadoutSize"); throw new Exception("Unable to read the Loadout + Wearings size");
int loadoutSize = (int)readStream.ReadUInt32(); int loadoutSize = (int)readStream.ReadUInt32();
readStream.Reset(); readStream.Reset();