diff --git a/Application/Application.csproj b/Application/Application.csproj
index a107ed192..7ce46227d 100644
--- a/Application/Application.csproj
+++ b/Application/Application.csproj
@@ -6,7 +6,7 @@
2.2.2
false
RaidMax.IW4MAdmin.Application
- 2.2.7.0
+ 2.2.7.1
RaidMax
Forever None
IW4MAdmin
@@ -21,6 +21,7 @@
Debug;Release;Prerelease
IW4MAdmin.Application
+ false
@@ -31,8 +32,8 @@
true
true
- 2.2.7.0
- 2.2.7.0
+ 2.2.7.1
+ 2.2.7.1
diff --git a/Application/ApplicationManager.cs b/Application/ApplicationManager.cs
index 88d9d457d..428d10be8 100644
--- a/Application/ApplicationManager.cs
+++ b/Application/ApplicationManager.cs
@@ -28,7 +28,6 @@ namespace IW4MAdmin.Application
{
private List _servers;
public List Servers => _servers.OrderByDescending(s => s.ClientNum).ToList();
- public Dictionary PrivilegedClients { get; set; }
public ILogger Logger => GetLogger(0);
public bool Running { get; private set; }
public bool IsInitialized { get; private set; }
@@ -41,8 +40,7 @@ namespace IW4MAdmin.Application
public IList AdditionalRConParsers { get; }
public IList AdditionalEventParsers { get; }
- public ITokenAuthentication TokenAuthenticator => Authenticator;
- public ITokenAuthentication Authenticator => _authenticator;
+ public ITokenAuthentication TokenAuthenticator { get; }
public string ExternalIPAddress { get; private set; }
static ApplicationManager Instance;
@@ -58,7 +56,6 @@ namespace IW4MAdmin.Application
readonly IPageList PageList;
readonly SemaphoreSlim ProcessingEvent = new SemaphoreSlim(1, 1);
readonly Dictionary Loggers = new Dictionary();
- readonly ITokenAuthentication _authenticator;
private readonly MetaService _metaService;
private readonly TimeSpan _throttleTimeout = new TimeSpan(0, 1, 0);
@@ -79,7 +76,7 @@ namespace IW4MAdmin.Application
AdditionalRConParsers = new List();
OnServerEvent += OnGameEvent;
OnServerEvent += EventApi.OnGameEvent;
- _authenticator = new TokenAuthentication();
+ TokenAuthenticator = new TokenAuthentication();
_metaService = new MetaService();
}
@@ -734,10 +731,7 @@ namespace IW4MAdmin.Application
return ConfigHandler;
}
- public IDictionary GetPrivilegedClients()
- {
- return PrivilegedClients;
- }
+ public IDictionary PrivilegedClients { get; private set; }
public bool ShutdownRequested()
{
diff --git a/Application/EventParsers/BaseEventParser.cs b/Application/EventParsers/BaseEventParser.cs
index e337c28a2..177c123df 100644
--- a/Application/EventParsers/BaseEventParser.cs
+++ b/Application/EventParsers/BaseEventParser.cs
@@ -81,10 +81,11 @@ namespace IW4MAdmin.Application.EventParsers
string[] lineSplit = logLine.Split(';');
string eventType = lineSplit[0];
+ // this is a "custom callback" event
if (eventType == "JoinTeam")
{
var origin = server.GetClientsAsList()
- .FirstOrDefault(c => c.NetworkId == lineSplit[1].ConvertLong());
+ .FirstOrDefault(c => c.NetworkId == lineSplit[1].ConvertGuidToLong());
return new GameEvent()
{
@@ -107,29 +108,32 @@ namespace IW4MAdmin.Application.EventParsers
.Replace("\x15", "")
.Trim();
- var origin = server.GetClientsAsList()
- .First(c => c.NetworkId == matchResult.Groups[Configuration.Say.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertLong());
-
- if (message[0] == '!' || message[0] == '@')
+ if (message.Length > 0)
{
+ var origin = server.GetClientsAsList()
+ .First(c => c.NetworkId == matchResult.Groups[Configuration.Say.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong());
+
+ if (message[0] == '!' || message[0] == '@')
+ {
+ return new GameEvent()
+ {
+ Type = GameEvent.EventType.Command,
+ Data = message,
+ Origin = origin,
+ Owner = server,
+ Message = message
+ };
+ }
+
return new GameEvent()
{
- Type = GameEvent.EventType.Command,
+ Type = GameEvent.EventType.Say,
Data = message,
Origin = origin,
Owner = server,
Message = message
};
}
-
- return new GameEvent()
- {
- Type = GameEvent.EventType.Say,
- Data = message,
- Origin = origin,
- Owner = server,
- Message = message
- };
}
}
@@ -145,11 +149,11 @@ namespace IW4MAdmin.Application.EventParsers
string targetId = match.Groups[Configuration.Kill.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].Value.ToString();
var origin = !string.IsNullOrEmpty(originId) ? server.GetClientsAsList()
- .First(c => c.NetworkId == originId.ConvertLong()) :
+ .First(c => c.NetworkId == originId.ConvertGuidToLong()) :
Utilities.IW4MAdminClient(server);
var target = !string.IsNullOrEmpty(targetId) ? server.GetClientsAsList()
- .First(c => c.NetworkId == targetId.ConvertLong()) :
+ .First(c => c.NetworkId == targetId.ConvertGuidToLong()) :
Utilities.IW4MAdminClient(server);
return new GameEvent()
@@ -166,8 +170,8 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "ScriptKill")
{
- long originId = lineSplit[1].ConvertLong();
- long targetId = lineSplit[2].ConvertLong();
+ long originId = lineSplit[1].ConvertGuidToLong();
+ long targetId = lineSplit[2].ConvertGuidToLong();
var origin = originId == long.MinValue ? Utilities.IW4MAdminClient(server) :
server.GetClientsAsList().First(c => c.NetworkId == originId);
@@ -186,8 +190,8 @@ namespace IW4MAdmin.Application.EventParsers
if (eventType == "ScriptDamage")
{
- long originId = lineSplit[1].ConvertLong();
- long targetId = lineSplit[2].ConvertLong();
+ long originId = lineSplit[1].ConvertGuidToLong();
+ long targetId = lineSplit[2].ConvertGuidToLong();
var origin = originId == long.MinValue ? Utilities.IW4MAdminClient(server) :
server.GetClientsAsList().First(c => c.NetworkId == originId);
@@ -217,11 +221,11 @@ namespace IW4MAdmin.Application.EventParsers
string targetId = regexMatch.Groups[Configuration.Damage.GroupMapping[ParserRegex.GroupType.TargetNetworkId]].ToString();
var origin = !string.IsNullOrEmpty(originId) ? server.GetClientsAsList()
- .First(c => c.NetworkId == originId.ConvertLong()) :
+ .First(c => c.NetworkId == originId.ConvertGuidToLong()) :
Utilities.IW4MAdminClient(server);
var target = !string.IsNullOrEmpty(targetId) ? server.GetClientsAsList()
- .First(c => c.NetworkId == targetId.ConvertLong()) :
+ .First(c => c.NetworkId == targetId.ConvertGuidToLong()) :
Utilities.IW4MAdminClient(server);
return new GameEvent()
@@ -255,7 +259,7 @@ namespace IW4MAdmin.Application.EventParsers
{
Name = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().StripColors(),
},
- NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertLong(),
+ NetworkId = regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Join.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Connecting,
CurrentServer = server,
@@ -281,7 +285,7 @@ namespace IW4MAdmin.Application.EventParsers
{
Name = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginName]].ToString().StripColors()
},
- NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertLong(),
+ NetworkId = regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginNetworkId]].ToString().ConvertGuidToLong(),
ClientNumber = Convert.ToInt32(regexMatch.Groups[Configuration.Quit.GroupMapping[ParserRegex.GroupType.OriginClientNumber]].ToString()),
State = EFClient.ClientState.Disconnecting
}
diff --git a/Application/IW4MServer.cs b/Application/IW4MServer.cs
index 30f1825dd..5f9e29964 100644
--- a/Application/IW4MServer.cs
+++ b/Application/IW4MServer.cs
@@ -95,18 +95,18 @@ namespace IW4MAdmin
if (client.ClientNumber >= 0)
{
#endif
- Logger.WriteInfo($"Client {client} [{client.State.ToString().ToLower()}] disconnecting...");
- Clients[client.ClientNumber] = null;
- await client.OnDisconnect();
+ Logger.WriteInfo($"Client {client} [{client.State.ToString().ToLower()}] disconnecting...");
+ Clients[client.ClientNumber] = null;
+ await client.OnDisconnect();
- var e = new GameEvent()
- {
- Origin = client,
- Owner = this,
- Type = GameEvent.EventType.Disconnect
- };
+ var e = new GameEvent()
+ {
+ Origin = client,
+ Owner = this,
+ Type = GameEvent.EventType.Disconnect
+ };
- Manager.GetEventHandler().AddEvent(e);
+ Manager.GetEventHandler().AddEvent(e);
#if DEBUG == true
}
#endif
@@ -201,22 +201,22 @@ namespace IW4MAdmin
{
var newPermission = (Permission)E.Extra;
- if (newPermission < Permission.Moderator)
+ if (newPermission < Permission.Moderator &&
+ !Manager.PrivilegedClients.Remove(E.Target.ClientId, out _))
{
- // remove banned or demoted privileged user
- Manager.GetPrivilegedClients().Remove(E.Target.ClientId);
+ Logger.WriteWarning($"Could not remove {E.Target}-{newPermission} from privileged users");
}
else
{
- if (Manager.GetPrivilegedClients().ContainsKey(E.Target.ClientId))
+ if (Manager.PrivilegedClients.ContainsKey(E.Target.ClientId))
{
- Manager.GetPrivilegedClients()[E.Target.ClientId] = E.Target;
+ Manager.PrivilegedClients[E.Target.ClientId] = E.Target;
}
- else
+ else if (!Manager.PrivilegedClients.TryAdd(E.Target.ClientId, E.Target))
{
- Manager.GetPrivilegedClients().Add(E.Target.ClientId, E.Target);
+ Logger.WriteWarning($"Could not add {E.Target}-{newPermission} to privileged clients");
}
}
diff --git a/Application/RconParsers/BaseRConParser.cs b/Application/RconParsers/BaseRConParser.cs
index 23647c00a..4de44627b 100644
--- a/Application/RconParsers/BaseRConParser.cs
+++ b/Application/RconParsers/BaseRConParser.cs
@@ -139,7 +139,17 @@ namespace IW4MAdmin.Application.RconParsers
ping = int.Parse(regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConPing]].Value);
}
- long networkId = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]].Value.ConvertLong();
+ long networkId;
+ try
+ {
+ networkId = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConNetworkId]].Value.ConvertGuidToLong();
+ }
+
+ catch (FormatException)
+ {
+ continue;
+ }
+
string name = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConName]].Value.StripColors().Trim();
int? ip = regex.Groups[Configuration.Status.GroupMapping[ParserRegex.GroupType.RConIpAddress]].Value.Split(':')[0].ConvertToIP();
diff --git a/Plugins/IW4ScriptCommands/GscApiController.cs b/Plugins/IW4ScriptCommands/GscApiController.cs
index 1ef0aaf35..460d0f9cd 100644
--- a/Plugins/IW4ScriptCommands/GscApiController.cs
+++ b/Plugins/IW4ScriptCommands/GscApiController.cs
@@ -17,7 +17,7 @@ namespace WebfrontCore.Controllers.API
public IActionResult ClientInfo(string networkId)
{
var clientInfo = Manager.GetActiveClients()
- .FirstOrDefault(c => c.NetworkId == networkId.ConvertLong());
+ .FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong());
if (clientInfo != null)
{
@@ -40,7 +40,7 @@ namespace WebfrontCore.Controllers.API
return Unauthorized();
var client = Manager.GetActiveClients()
- .FirstOrDefault(c => c.NetworkId == networkId.ConvertLong());
+ .FirstOrDefault(c => c.NetworkId == networkId.ConvertGuidToLong());
var server = Manager.GetServers().First(c => c.EndPoint == serverId);
diff --git a/Plugins/Login/Commands/CLogin.cs b/Plugins/Login/Commands/CLogin.cs
index af8ffdf06..658eea799 100644
--- a/Plugins/Login/Commands/CLogin.cs
+++ b/Plugins/Login/Commands/CLogin.cs
@@ -18,7 +18,7 @@ namespace IW4MAdmin.Plugins.Login.Commands
public override async Task ExecuteAsync(GameEvent E)
{
- var client = E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId];
+ var client = E.Owner.Manager.PrivilegedClients[E.Origin.ClientId];
bool success = E.Owner.Manager.TokenAuthenticator.AuthorizeToken(E.Origin.NetworkId, E.Data);
if (!success)
diff --git a/Plugins/Login/Plugin.cs b/Plugins/Login/Plugin.cs
index d2deff4c1..8101ac202 100644
--- a/Plugins/Login/Plugin.cs
+++ b/Plugins/Login/Plugin.cs
@@ -42,7 +42,7 @@ namespace IW4MAdmin.Plugins.Login
E.Origin.Level == EFClient.Permission.Console)
return Task.CompletedTask;
- E.Owner.Manager.GetPrivilegedClients().TryGetValue(E.Origin.ClientId, out EFClient client);
+ E.Owner.Manager.PrivilegedClients.TryGetValue(E.Origin.ClientId, out EFClient client);
if (((Command)E.Extra).Name == new SharedLibraryCore.Commands.CSetPassword().Name &&
client?.Password == null)
diff --git a/Plugins/Stats/Cheat/Detection.cs b/Plugins/Stats/Cheat/Detection.cs
index 118b24510..939e1ee94 100644
--- a/Plugins/Stats/Cheat/Detection.cs
+++ b/Plugins/Stats/Cheat/Detection.cs
@@ -201,18 +201,18 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
// ban on headshot
if (currentHeadshotRatio > maxHeadshotLerpValueForBan)
{
- Log.WriteDebug("**Maximum Headshot Ratio Reached For Ban**");
- Log.WriteDebug($"ClientId: {hit.AttackerId}");
- Log.WriteDebug($"**HitCount: {HitCount}");
- Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
- Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
- var sb = new StringBuilder();
- foreach (var kvp in HitLocationCount)
- {
- sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
- }
+ //Log.WriteDebug("**Maximum Headshot Ratio Reached For Ban**");
+ //Log.WriteDebug($"ClientId: {hit.AttackerId}");
+ //Log.WriteDebug($"**HitCount: {HitCount}");
+ //Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
+ //Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
+ //var sb = new StringBuilder();
+ //foreach (var kvp in HitLocationCount)
+ //{
+ // sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
+ //}
- Log.WriteDebug(sb.ToString());
+ //Log.WriteDebug(sb.ToString());
result = new DetectionPenaltyResult()
{
@@ -225,18 +225,18 @@ namespace IW4MAdmin.Plugins.Stats.Cheat
}
else
{
- Log.WriteDebug("**Maximum Headshot Ratio Reached For Flag**");
- Log.WriteDebug($"ClientId: {hit.AttackerId}");
- Log.WriteDebug($"**HitCount: {HitCount}");
- Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
- Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
- var sb = new StringBuilder();
- foreach (var kvp in HitLocationCount)
- {
- sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
- }
+ //Log.WriteDebug("**Maximum Headshot Ratio Reached For Flag**");
+ //Log.WriteDebug($"ClientId: {hit.AttackerId}");
+ //Log.WriteDebug($"**HitCount: {HitCount}");
+ //Log.WriteDebug($"**Ratio {currentHeadshotRatio}");
+ //Log.WriteDebug($"**MaxRatio {maxHeadshotLerpValueForFlag}");
+ //var sb = new StringBuilder();
+ //foreach (var kvp in HitLocationCount)
+ //{
+ // sb.Append($"HitLocation: {kvp.Key} -> {kvp.Value}\r\n");
+ //}
- Log.WriteDebug(sb.ToString());
+ //Log.WriteDebug(sb.ToString());
result = new DetectionPenaltyResult()
{
diff --git a/Plugins/Stats/Plugin.cs b/Plugins/Stats/Plugin.cs
index 3fade2cc1..08fc5d4bf 100644
--- a/Plugins/Stats/Plugin.cs
+++ b/Plugins/Stats/Plugin.cs
@@ -491,7 +491,7 @@ namespace IW4MAdmin.Plugins.Stats
///
private bool ShouldIgnoreEvent(EFClient origin, EFClient target)
{
- return ((origin.ClientId <= 1 && target.ClientId <= 1) || (target.IsBot || origin.IsBot) && ServerManager.GetApplicationSettings().Configuration().IgnoreBots);
+ return ((origin.ClientId <= 1 && target.ClientId <= 1) || ((target.IsBot || origin.IsBot) && ServerManager.GetApplicationSettings().Configuration().IgnoreBots));
}
}
}
diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs
index 5ce31bf9f..b531cc8f0 100644
--- a/SharedLibraryCore/Commands/NativeCommands.cs
+++ b/SharedLibraryCore/Commands/NativeCommands.cs
@@ -1119,8 +1119,8 @@ namespace SharedLibraryCore.Commands
E.Origin.PasswordSalt = hashedPassword[1];
// update the password for the client in privileged
- E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId].Password = hashedPassword[0];
- E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId].PasswordSalt = hashedPassword[1];
+ E.Owner.Manager.PrivilegedClients[E.Origin.ClientId].Password = hashedPassword[0];
+ E.Owner.Manager.PrivilegedClients[E.Origin.ClientId].PasswordSalt = hashedPassword[1];
await E.Owner.Manager.GetClientService().Update(E.Origin);
E.Origin.Tell(Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_PASSWORD_SUCCESS"]);
diff --git a/SharedLibraryCore/Interfaces/IManager.cs b/SharedLibraryCore/Interfaces/IManager.cs
index e471f5813..3f79c0b72 100644
--- a/SharedLibraryCore/Interfaces/IManager.cs
+++ b/SharedLibraryCore/Interfaces/IManager.cs
@@ -6,6 +6,7 @@ using SharedLibraryCore.Services;
using SharedLibraryCore.Configuration;
using System.Reflection;
using SharedLibraryCore.Database.Models;
+using System.Collections.Concurrent;
namespace SharedLibraryCore.Interfaces
{
@@ -23,7 +24,7 @@ namespace SharedLibraryCore.Interfaces
ClientService GetClientService();
AliasService GetAliasService();
PenaltyService GetPenaltyService();
- IDictionary GetPrivilegedClients();
+ IDictionary PrivilegedClients { get; }
///
/// Get the event handlers
///
diff --git a/SharedLibraryCore/Objects/EFClient.cs b/SharedLibraryCore/Objects/EFClient.cs
index c7ca5d98a..ff2260795 100644
--- a/SharedLibraryCore/Objects/EFClient.cs
+++ b/SharedLibraryCore/Objects/EFClient.cs
@@ -103,7 +103,7 @@ namespace SharedLibraryCore.Database.Models
Data = message
};
- this.CurrentServer?.Manager.GetEventHandler().AddEvent(e);
+ CurrentServer?.Manager.GetEventHandler().AddEvent(e);
return e;
}
@@ -125,14 +125,14 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (this.Level > sender.Level)
+ if (Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
else
{
- this.Warnings++;
+ Warnings++;
}
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
@@ -156,13 +156,13 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (sender.Level <= this.Level)
+ if (sender.Level <= Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
return e;
}
- this.Warnings = 0;
+ Warnings = 0;
sender.CurrentServer.Manager.GetEventHandler().AddEvent(e);
return e;
@@ -188,12 +188,12 @@ namespace SharedLibraryCore.Database.Models
int reportCount = sender.GetAdditionalProperty("_reportCount");
- if (this.Level > sender.Level)
+ if (Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
- else if (this.Equals(sender))
+ else if (Equals(sender))
{
e.FailReason = GameEvent.EventFailReason.Invalid;
}
@@ -204,7 +204,7 @@ namespace SharedLibraryCore.Database.Models
}
else if (CurrentServer.Reports.Count(report => (report.Origin.NetworkId == sender.NetworkId &&
- report.Target.NetworkId == this.NetworkId)) > 0)
+ report.Target.NetworkId == NetworkId)) > 0)
{
e.FailReason = GameEvent.EventFailReason.Exception;
}
@@ -232,12 +232,12 @@ namespace SharedLibraryCore.Database.Models
Owner = sender.CurrentServer
};
- if (this.Level >= sender.Level)
+ if (Level >= sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
- else if (this.Level == Permission.Flagged)
+ else if (Level == Permission.Flagged)
{
e.FailReason = GameEvent.EventFailReason.Invalid;
}
@@ -264,12 +264,12 @@ namespace SharedLibraryCore.Database.Models
Owner = sender.CurrentServer
};
- if (sender.Level <= this.Level)
+ if (sender.Level <= Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
- else if (this.Level != Permission.Flagged)
+ else if (Level != Permission.Flagged)
{
e.FailReason = GameEvent.EventFailReason.Invalid;
}
@@ -296,7 +296,7 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (this.Level > sender.Level)
+ if (Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
@@ -325,7 +325,7 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (sender.Level <= this.Level)
+ if (sender.Level <= Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
@@ -353,7 +353,7 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (sender.Level <= this.Level)
+ if (sender.Level <= Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
@@ -381,7 +381,7 @@ namespace SharedLibraryCore.Database.Models
};
// enforce level restrictions
- if (this.Level > sender.Level)
+ if (Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
@@ -407,7 +407,7 @@ namespace SharedLibraryCore.Database.Models
Owner = sender.CurrentServer
};
- if (this.Level > sender.Level)
+ if (Level > sender.Level)
{
e.FailReason = GameEvent.EventFailReason.Permission;
}
@@ -675,7 +675,7 @@ namespace SharedLibraryCore.Database.Models
}
[NotMapped]
- Dictionary _additionalProperties;
+ readonly Dictionary _additionalProperties;
public T GetAdditionalProperty(string name)
{
diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs
index 1d926f5e9..78655e127 100644
--- a/SharedLibraryCore/Services/ClientService.cs
+++ b/SharedLibraryCore/Services/ClientService.cs
@@ -217,7 +217,7 @@ namespace SharedLibraryCore.Services
using (var ctx = new DatabaseContext())
{
var entity = await ctx.Clients
- .Where(_client => _client.AliasLinkId == temporalClient.AliasLinkId)
+ .Where(_client => _client.ClientId == temporalClient.ClientId)
.FirstAsync();
var oldPermission = entity.Level;
@@ -451,7 +451,7 @@ namespace SharedLibraryCore.Services
using (var context = new DatabaseContext(disableTracking: true))
{
- long networkId = identifier.ConvertLong();
+ long networkId = identifier.ConvertGuidToLong();
int? ipAddress = identifier.ConvertToIP();
IQueryable iqLinkIds = context.Aliases.Where(_alias => _alias.Active);
diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj
index ad3c9afe6..14e377fb4 100644
--- a/SharedLibraryCore/SharedLibraryCore.csproj
+++ b/SharedLibraryCore/SharedLibraryCore.csproj
@@ -11,6 +11,7 @@
RaidMax
Forever None
Debug;Release;Prerelease
+ false
diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs
index 8e451ffd3..10506a117 100644
--- a/SharedLibraryCore/Utilities.cs
+++ b/SharedLibraryCore/Utilities.cs
@@ -266,33 +266,35 @@ namespace SharedLibraryCore
}
}
- public static long ConvertLong(this string str)
+ public static long ConvertGuidToLong(this string str)
{
str = str.Substring(0, Math.Min(str.Length, 16));
- int maxBots = 18;
- long id;
-
- if (str.Length <= 11) // 10 numeric characters + signed character
- {
- if (long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out id))
- {
- return (uint)id;
- }
- }
-
- if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))
- {
- return id;
- }
-
var bot = Regex.Match(str, @"bot[0-9]+").Value;
- if (!string.IsNullOrEmpty(bot))
+ int maxBots = 18;
+
+ // this is a special case for Plutonium T6
+ if (str.Length <= 11 &&
+ long.TryParse(str, NumberStyles.Integer, CultureInfo.InvariantCulture, out long id)) // 10 numeric characters + signed character
+ {
+ id = (uint)id;
+ }
+
+ else if (long.TryParse(str, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out id))
+ {
+ }
+
+ else if (!string.IsNullOrEmpty(bot))
{
// should set their GUID to the negation of their 1 based index (-1 - -18)
- return -(Convert.ToInt64(bot.Substring(3)) + 1) % maxBots;
+ id = -(Convert.ToInt64(bot.Substring(3)) + 1) % maxBots;
}
- return long.MinValue;
+ if (id == 0)
+ {
+ throw new FormatException($"Could not parse client GUID - {str}");
+ }
+
+ return id;
}
public static int? ConvertToIP(this string str)
diff --git a/WebfrontCore/Controllers/AccountController.cs b/WebfrontCore/Controllers/AccountController.cs
index a5c100f12..d7f98fe1f 100644
--- a/WebfrontCore/Controllers/AccountController.cs
+++ b/WebfrontCore/Controllers/AccountController.cs
@@ -25,14 +25,9 @@ namespace WebfrontCore.Controllers
try
{
-//#if DEBUG == true
-// var client = Utilities.IW4MAdminClient();
-// bool loginSuccess = true;
-//#else
- var privilegedClient = Manager.GetPrivilegedClients()[clientId];
+ var privilegedClient = Manager.PrivilegedClients[clientId];
bool loginSuccess = Manager.TokenAuthenticator.AuthorizeToken(privilegedClient.NetworkId, password) ||
(await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, privilegedClient.PasswordSalt)))[0] == privilegedClient.Password;
-//#endif
if (loginSuccess)
{
diff --git a/WebfrontCore/Controllers/BaseController.cs b/WebfrontCore/Controllers/BaseController.cs
index c46c71e1b..a25700f6f 100644
--- a/WebfrontCore/Controllers/BaseController.cs
+++ b/WebfrontCore/Controllers/BaseController.cs
@@ -71,7 +71,7 @@ namespace WebfrontCore.Controllers
if (clientId > 0)
{
Client.ClientId = clientId;
- Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertLong();
+ Client.NetworkId = User.Claims.First(_claim => _claim.Type == ClaimTypes.PrimarySid).Value.ConvertGuidToLong();
Client.Level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), User.Claims.First(c => c.Type == ClaimTypes.Role).Value);
Client.CurrentAlias = new EFAlias() { Name = User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value };
Authorized = Client.ClientId >= 0;
diff --git a/WebfrontCore/Controllers/PenaltyController.cs b/WebfrontCore/Controllers/PenaltyController.cs
index 866950578..4f9fea708 100644
--- a/WebfrontCore/Controllers/PenaltyController.cs
+++ b/WebfrontCore/Controllers/PenaltyController.cs
@@ -22,7 +22,7 @@ namespace WebfrontCore.Controllers
ViewBag.Title = Localization["WEBFRONT_PENALTY_TITLE"];
ViewBag.Keywords = "IW4MAdmin, penalties, ban, kick, warns";
- return View((SharedLibraryCore.Objects.Penalty.PenaltyType)showOnly);
+ return View(showOnly);
}
public async Task ListAsync(int offset = 0, PenaltyType showOnly = PenaltyType.Any)
diff --git a/WebfrontCore/wwwroot/js/penalty.js b/WebfrontCore/wwwroot/js/penalty.js
index 1f0de3878..2af7c6f95 100644
--- a/WebfrontCore/wwwroot/js/penalty.js
+++ b/WebfrontCore/wwwroot/js/penalty.js
@@ -1,4 +1,4 @@
-let offset = 12;
+let offset = 15;
let isLoading = false;
function loadMorePenalties() {
@@ -21,17 +21,15 @@ function loadMorePenalties() {
errorLoader();
isLoading = false;
});
- offset += 12;
+ offset += 15;
}
if ($('#penalty_table').length === 1) {
$('#penalty_filter_selection').change(function() {
- // if (offset === 0) {
location = location.href.split('?')[0] + "?showOnly=" + $('#penalty_filter_selection').val();
- // }
});
-/*
+ /*
https://stackoverflow.com/questions/19731730/jquery-js-detect-users-scroll-attempt-without-any-window-overflow-to-scroll
*/