diff --git a/Admin/Manager.cs b/Admin/Manager.cs index be42ad5a9..56014d90b 100644 --- a/Admin/Manager.cs +++ b/Admin/Manager.cs @@ -19,6 +19,7 @@ namespace IW4MAdmin public List Servers { get; private set; } List TaskStatuses; Database ClientDatabase; + Database AliasesDatabase; SharedLibrary.Interfaces.IPenaltyList ClientPenalties; List Commands; Kayak.IScheduler webServiceTask; @@ -33,15 +34,13 @@ namespace IW4MAdmin private Manager() { - //IFile logFile = new IFile("Logs/IW4MAdminManager.log", true); Logger = new Logger("Logs/IW4MAdmin.log"); - //Logger = new Log(logFile, Log.Level.Production, 0); Servers = new List(); Commands = new List(); TaskStatuses = new List(); - ClientDatabase = new ClientsDB("Database/clients.rm"); + AliasesDatabase = new AliasesDB("Database/aliases.rm"); ClientPenalties = new PenaltyList(); } @@ -149,6 +148,11 @@ namespace IW4MAdmin return ClientDatabase as ClientsDB; } + public AliasesDB GetAliasesDatabase() + { + return AliasesDatabase as AliasesDB; + } + public SharedLibrary.Interfaces.IPenaltyList GetClientPenalties() { return ClientPenalties; diff --git a/Admin/Server.cs b/Admin/Server.cs index 1048be0a6..f4d4b5606 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -17,17 +17,17 @@ namespace IW4MAdmin initCommands(); } - private void getAliases(List returnAliases, Aliases currentAlias) + private void GetAliases(List returnAliases, Aliases currentAlias) { foreach(String IP in currentAlias.IPS) { - List Matching = aliasDB.getPlayer(IP); + List Matching = Manager.GetAliasesDatabase().getPlayer(IP); foreach(Aliases I in Matching) { if (!returnAliases.Contains(I) && returnAliases.Find(x => x.Number == I.Number) == null) { returnAliases.Add(I); - getAliases(returnAliases, I); + GetAliases(returnAliases, I); } } } @@ -40,12 +40,12 @@ namespace IW4MAdmin if (Origin == null) return allAliases; - Aliases currentIdentityAliases = aliasDB.getPlayer(Origin.databaseID); + Aliases currentIdentityAliases = Manager.GetAliasesDatabase().getPlayer(Origin.databaseID); if (currentIdentityAliases == null) return allAliases; - getAliases(allAliases, currentIdentityAliases); + GetAliases(allAliases, currentIdentityAliases); return allAliases; } @@ -62,11 +62,8 @@ namespace IW4MAdmin } Logger.WriteDebug($"Client slot #{P.clientID} now reserved"); - - -#if DEBUG == false + try -#endif { Player NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID); @@ -75,7 +72,7 @@ namespace IW4MAdmin Logger.WriteDebug($"Client slot #{P.clientID} first time connecting"); Manager.GetClientDatabase().addPlayer(P); NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID); - aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP)); + Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP)); } @@ -88,12 +85,12 @@ namespace IW4MAdmin // below this needs to be optimized ~ 425ms runtime NewPlayer.updateName(P.Name.Trim()); - NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID); + NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID); if (NewPlayer.Alias == null) { - aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP)); - NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID); + Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP)); + NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID); } if (P.lastEvent == null || P.lastEvent.Owner == null) @@ -116,7 +113,7 @@ namespace IW4MAdmin NewPlayer.updateIP(P.IP); - aliasDB.updatePlayer(NewPlayer.Alias); + Manager.GetAliasesDatabase().updatePlayer(NewPlayer.Alias); Manager.GetClientDatabase().updatePlayer(NewPlayer); await ExecuteEvent(new Event(Event.GType.Connect, "", NewPlayer, null, this)); @@ -171,13 +168,13 @@ namespace IW4MAdmin ClientNum++; return true; } -#if DEBUG == false + catch (Exception E) { - Manager.GetLogger().WriteError("Unable to add player " + P.Name + " - " + E.Message); + Manager.GetLogger().WriteError($"Unable to add player {P.Name}::{P.npID}"); + Manager.GetLogger().WriteDebug(E.StackTrace); return false; } -#endif } //Remove player by CLIENT NUMBER diff --git a/Admin/lib/SharedLibrary.dll b/Admin/lib/SharedLibrary.dll index 31b09fd00..d6717c60c 100644 Binary files a/Admin/lib/SharedLibrary.dll and b/Admin/lib/SharedLibrary.dll differ diff --git a/SharedLibrary/Commands/NativeCommands.cs b/SharedLibrary/Commands/NativeCommands.cs index cfc45eb1d..edc0f3432 100644 --- a/SharedLibrary/Commands/NativeCommands.cs +++ b/SharedLibrary/Commands/NativeCommands.cs @@ -406,8 +406,7 @@ namespace SharedLibrary.Commands return; } - //var db_players = E.Owner.Manager.GetClientDatabase().findPlayers(E.Data.Trim()); - var db_aliases = E.Owner.aliasDB.findPlayers(E.Data); + var db_aliases = E.Owner.Manager.GetAliasesDatabase().findPlayers(E.Data); if (db_aliases == null) { @@ -625,7 +624,7 @@ namespace SharedLibrary.Commands public override async Task ExecuteAsync(Event E) { - E.Target.Alias = E.Owner.aliasDB.getPlayer(E.Target.databaseID); + E.Target.Alias = E.Owner.Manager.GetAliasesDatabase().getPlayer(E.Target.databaseID); if (E.Target.Alias == null) { diff --git a/SharedLibrary/Interfaces/IManager.cs b/SharedLibrary/Interfaces/IManager.cs index 119b943be..74725bee0 100644 --- a/SharedLibrary/Interfaces/IManager.cs +++ b/SharedLibrary/Interfaces/IManager.cs @@ -16,5 +16,6 @@ namespace SharedLibrary.Interfaces List GetCommands(); IPenaltyList GetClientPenalties(); ClientsDB GetClientDatabase(); + AliasesDB GetAliasesDatabase(); } } diff --git a/SharedLibrary/Server.cs b/SharedLibrary/Server.cs index 10a371681..2804b443c 100644 --- a/SharedLibrary/Server.cs +++ b/SharedLibrary/Server.cs @@ -21,8 +21,7 @@ namespace SharedLibrary Port = port; Manager = mgr; Logger = Manager.GetLogger(); - ClientNum = 0; - aliasDB = new AliasesDB("Database/aliases.rm"); + ClientNum = 0; Players = new List(new Player[18]); events = new Queue(); @@ -221,6 +220,7 @@ namespace SharedLibrary /// Message to be sent to all players public async Task Broadcast(String Message) { + return; await this.ExecuteCommandAsync($"sayraw {Message}"); } @@ -231,6 +231,7 @@ namespace SharedLibrary /// Player to send message to public async Task Tell(String Message, Player Target) { + return; if (Target.clientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote) await this.ExecuteCommandAsync($"tellraw {Target.clientID} {Message}^7"); @@ -467,7 +468,7 @@ namespace SharedLibrary // Databases //public ClientsDB clientDB; - public AliasesDB aliasDB; + //public AliasesDB aliasDB; //Remote public Queue commandResult = new Queue();