update anti-cheat offset calculation

This commit is contained in:
RaidMax
2019-06-12 10:27:15 -05:00
parent e86904b11e
commit 10829b32ad
3 changed files with 48 additions and 26 deletions

View File

@ -360,7 +360,7 @@ namespace SharedLibraryCore.Services
{
using (var context = new DatabaseContext())
{
if (temporalClient.LastConnection == DateTime.MinValue || temporalClient.Connections == 0 || temporalClient.TotalConnectionTime == 0)
if (temporalClient.LastConnection == DateTime.MinValue || temporalClient.FirstConnection == DateTime.MinValue)
{
throw new InvalidOperationException($"client {temporalClient} trying to update but parameters are invalid");
}
@ -369,6 +369,12 @@ namespace SharedLibraryCore.Services
var entity = context.Clients
.First(client => client.ClientId == temporalClient.ClientId);
if (entity.TotalConnectionTime > temporalClient.TotalConnectionTime || entity.Connections > temporalClient.Connections ||
entity.LastConnection > temporalClient.LastConnection || entity.FirstConnection > temporalClient.FirstConnection)
{
throw new InvalidOperationException($"client {temporalClient} trying to update but new parameters don't match saved parameters");
}
entity.LastConnection = temporalClient.LastConnection;
entity.Connections = temporalClient.Connections;
entity.FirstConnection = temporalClient.FirstConnection;
@ -462,7 +468,6 @@ namespace SharedLibraryCore.Services
}
// want to find them by name (wildcard)
// todo maybe not make it start with wildcard?
else
{
iqLinkIds = iqLinkIds.Where(_alias => EF.Functions.Like(_alias.Name.ToLower(), $"%{identifier.ToLower()}%"));