1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-09 23:00:57 -05:00

small updates to stat handling

various little tweaks
This commit is contained in:
RaidMax
2019-09-09 17:37:57 -05:00
parent 86517fa495
commit a94397680a
12 changed files with 248 additions and 227 deletions

View File

@ -13,7 +13,7 @@ namespace SharedLibraryCore.Helpers
[Key]
public int Vector3Id { get; set; }
public float X { get; protected set; }
public float Y { get; protected set; }
public float Y { get; protected set; }
public float Z { get; protected set; }
// this is for EF and really should be somewhere else
@ -45,8 +45,8 @@ namespace SharedLibraryCore.Helpers
string removeParenthesis = s.Substring(1, s.Length - 2);
string[] eachPoint = removeParenthesis.Split(',');
return new Vector3(float.Parse(eachPoint[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(eachPoint[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture),
return new Vector3(float.Parse(eachPoint[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(eachPoint[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(eachPoint[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture));
}
@ -57,7 +57,7 @@ namespace SharedLibraryCore.Helpers
public static double AbsoluteDistance(Vector3 a, Vector3 b)
{
double deltaX = Math.Abs(b.X -a.X);
double deltaX = Math.Abs(b.X - a.X);
double deltaY = Math.Abs(b.Y - a.Y);
// this 'fixes' the roll-over angles

View File

@ -13,6 +13,13 @@ namespace SharedLibraryCore.RCon
{
class ConnectionState
{
~ConnectionState()
{
OnComplete.Dispose();
OnSentData.Dispose();
OnReceivedData.Dispose();
}
public int ConnectionAttempts { get; set; }
const int BufferSize = 4096;
public readonly byte[] ReceiveBuffer = new byte[BufferSize];
@ -81,7 +88,7 @@ namespace SharedLibraryCore.RCon
bool waitForResponse = Config.WaitForResponse;
string convertEncoding(string text)
{
{
byte[] convertedBytes = Utilities.EncodingType.GetBytes(text);
return defaultEncoding.GetString(convertedBytes);
}
@ -123,7 +130,7 @@ namespace SharedLibraryCore.RCon
catch (OverflowException)
{
connectionState.OnComplete.Release(1);
throw new NetworkException($"Invalid character expected when converting encodings - {parameters}");
throw new NetworkException($"Invalid character encountered when converting encodings - {parameters}");
}
byte[] response = null;
@ -152,7 +159,6 @@ namespace SharedLibraryCore.RCon
throw new NetworkException("Expected response but got 0 bytes back");
}
connectionState.OnComplete.Release(1);
connectionState.ConnectionAttempts = 0;
}
@ -164,9 +170,16 @@ namespace SharedLibraryCore.RCon
goto retrySend;
}
connectionState.OnComplete.Release(1);
throw new NetworkException(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_COMMUNICATION"].FormatExt(Endpoint));
}
finally
{
if (connectionState.OnComplete.CurrentCount == 0)
{
connectionState.OnComplete.Release(1);
}
}
}
string responseString = defaultEncoding.GetString(response, 0, response.Length) + '\n';
@ -258,7 +271,7 @@ namespace SharedLibraryCore.RCon
private void OnDataSent(object sender, SocketAsyncEventArgs e)
{
#if DEBUG == true
Log.WriteDebug($"Sent {e.Buffer.Length} bytes to {e.ConnectSocket.RemoteEndPoint.ToString()}");
Log.WriteDebug($"Sent {e.Buffer?.Length} bytes to {e.ConnectSocket?.RemoteEndPoint?.ToString()}");
#endif
ActiveQueries[this.Endpoint].OnSentData.Set();
}

View File

@ -46,8 +46,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Npgsql" Version="4.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.0" />
<PackageReference Include="Npgsql" Version="4.0.9" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
</ItemGroup>