diff --git a/Admin/Command.cs b/Admin/Command.cs index 292f03bc0..dddf40baf 100644 --- a/Admin/Command.cs +++ b/Admin/Command.cs @@ -424,65 +424,6 @@ namespace IW4MAdmin } } - class _Stats : Command - { - public _Stats(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { } - - public override void Execute(Event E) - { - if (E.Target == null) - { - if (E.Target.stats == null) - E.Origin.Tell("You do not have any stats!"); - else - E.Origin.Tell(String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Origin.stats.Kills, E.Origin.stats.Deaths, E.Origin.stats.KDR, E.Origin.stats.Skill)); - } - - else - { - E.Target.stats = E.Owner.statDB.getStats(E.Target.databaseID); - if (E.Target.stats == null) - E.Origin.Tell("That person does not have any stats at this time!"); - else - E.Origin.Tell(String.Format("[^3{4}^7] ^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", E.Target.stats.Kills, E.Target.stats.Deaths, E.Target.stats.KDR, E.Target.stats.Skill, E.Target.Name)); - } - } - } - - class TopStats : Command - { - public TopStats(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { } - - public override void Execute(Event E) - { - List Top = E.Owner.statDB.topStats(); - List TopP = new List(); - - foreach (Stats S in Top) - { - Player P = E.Owner.clientDB.getPlayer(S.statIndex); - if (P != null && P.Level != Player.Permission.Banned) - { - P.stats = S; - TopP.Add(P); - } - } - - if (TopP.Count > 0) - { - E.Origin.Tell("^1TOP PLAYERS"); - foreach (Player P in TopP) - { - if (P != null) - E.Origin.Tell(String.Format("^3{0}^7 - ^5{1} ^7KDR | ^5{2} ^7SKILL", P.Name, P.stats.KDR, P.stats.Skill)); - } - } - - else - E.Origin.Tell("There are no top players yet!"); - } - } - class Reload : Command { public Reload(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { } diff --git a/Admin/IW4M ADMIN.csproj b/Admin/IW4M ADMIN.csproj index 635d8c628..49eed84f2 100644 --- a/Admin/IW4M ADMIN.csproj +++ b/Admin/IW4M ADMIN.csproj @@ -128,15 +128,15 @@ - - PreserveNewest - PreserveNewest Always + + PreserveNewest + PreserveNewest diff --git a/Admin/Main.cs b/Admin/Main.cs index bcd799679..80cf95f76 100644 --- a/Admin/Main.cs +++ b/Admin/Main.cs @@ -10,14 +10,14 @@ namespace IW4MAdmin { class Program { - static public double Version = 0.92; - static public double latestVersion; - static public bool usingMemory = true; + static public double Version { get; private set; } static private Manager serverManager; static private IW4MAdmin_Web.WebFront frontEnd; static void Main(string[] args) { + Version = 0.95; + double latestVersion = 0; handler = new ConsoleEventDelegate(OnProcessExit); SetConsoleCtrlHandler(handler, true); @@ -66,6 +66,7 @@ namespace IW4MAdmin if (S == null) continue; + S.Broadcast("^5IW4MAdmin ^7is going ^1offline^7"); S.isRunning = false; if (Utilities.shutdownInterface(S.pID())) @@ -77,14 +78,13 @@ namespace IW4MAdmin Program.getManager().shutDown(); frontEnd.webSchedule.Stop(); frontEnd.webSchedule.Dispose(); + return false; } catch { return true; } - - return false; } private delegate bool ConsoleEventDelegate(int eventType); diff --git a/Admin/Manager.cs b/Admin/Manager.cs index 932879389..289276849 100644 --- a/Admin/Manager.cs +++ b/Admin/Manager.cs @@ -216,7 +216,8 @@ namespace IW4MAdmin return null; } - SharedLibrary.Utilities.Wait(2); + if (timeWaiting > 5) + SharedLibrary.Utilities.Wait(2); dvar net_ip = Utilities.getDvarOld(0x64A1DF8, (int)Handle); dvar net_port = Utilities.getDvarOld(0x64A3004, (int)Handle); diff --git a/Admin/Plugins.cs b/Admin/Plugins.cs index 550ddfad8..cc68916d7 100644 --- a/Admin/Plugins.cs +++ b/Admin/Plugins.cs @@ -8,17 +8,17 @@ namespace IW4MAdmin { public class PluginImporter { - public static List potentialPlugins = new List(); - public static List potentialNotifies = new List(); + public static List potentialCommands; + public static List potentialNotifies; public static bool Load() { string[] dllFileNames = null; + potentialCommands = new List(); + potentialNotifies = new List(); if (Directory.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\plugins")) - { dllFileNames = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\plugins", "*.dll"); - } else { @@ -52,6 +52,7 @@ namespace IW4MAdmin Object notifyObject = Activator.CreateInstance(assemblyType); EventNotify newNotify = (EventNotify)notifyObject; potentialNotifies.Add(newNotify); + newNotify.onLoad(); Program.getManager().mainLog.Write("Loaded event plugin \"" + assemblyType.Name + "\"", Log.Level.All); } @@ -59,7 +60,7 @@ namespace IW4MAdmin { Object commandObject = Activator.CreateInstance(assemblyType); Command newCommand = (Command)commandObject; - potentialPlugins.Add(newCommand); + potentialCommands.Add(newCommand); Program.getManager().mainLog.Write("Loaded command plugin \"" + newCommand.Name + "\"", Log.Level.All); } diff --git a/Admin/Server.cs b/Admin/Server.cs index 8128dafa3..678c6a4ed 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -83,12 +83,9 @@ namespace IW4MAdmin clientDB.addPlayer(P); NewPlayer = clientDB.getPlayer(P.npID, P.clientID); aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP)); - statDB.addPlayer(NewPlayer); } NewPlayer.updateName(P.Name.Trim()); - - NewPlayer.stats = statDB.getStats(NewPlayer.databaseID); NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID); if (NewPlayer.Alias == null) @@ -204,12 +201,6 @@ namespace IW4MAdmin if (NewPlayer.Level > Player.Permission.Moderator) NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!"); - if (NewPlayer.stats == null) // there seems to be an issue with stats with multiple servers. I think this should fix it - { - statDB.addPlayer(NewPlayer); - NewPlayer.stats = statDB.getStats(NewPlayer.databaseID); - } - return true; } #if DEBUG == false @@ -235,7 +226,6 @@ namespace IW4MAdmin Player Leaving = players[cNum]; Leaving.Connections++; clientDB.updatePlayer(Leaving); - statDB.updatePlayer(Leaving); Log.Write("Client at " + cNum + " disconnecting...", Log.Level.Debug); events.Enqueue(new Event(Event.GType.Disconnect, "", Leaving, null, this)); @@ -674,27 +664,9 @@ namespace IW4MAdmin return false; } - if (E.Target == null) - { - Log.Write("Kill event triggered, but no target found!", Log.Level.Debug); - return false; - } - - if (E.Origin.stats == null) - { - Log.Write("Kill event triggered, but no stats found for origin!", Log.Level.Debug); - return false; - } - - if (E.Target.stats == null) - { - Log.Write("Kill event triggered, but no stats found for target!", Log.Level.Debug); - return false; - } - if (E.Origin != E.Target) { - E.Origin.stats.Kills += 1; + /*E.Origin.stats.Kills += 1; E.Origin.stats.updateKDR(); E.Target.stats.Deaths += 1; @@ -704,17 +676,15 @@ namespace IW4MAdmin statDB.updatePlayer(E.Origin); statDB.updatePlayer(E.Target); - totalKills++; + totalKills++;*/ Log.Write(E.Origin.Name + " killed " + E.Target.Name + " with a " + E.Data, Log.Level.Debug); events.Enqueue(new Event(Event.GType.Death, E.Data, E.Target, null, this)); } else // suicide/falling { - E.Origin.stats.Deaths++; - E.Origin.stats.updateKDR(); - statDB.updatePlayer(E.Origin); Log.Write(E.Origin.Name + " suicided...", Log.Level.Debug); + events.Enqueue(new Event(Event.GType.Death, "suicide", E.Target, null, this)); } } @@ -820,13 +790,6 @@ namespace IW4MAdmin if (E.Type == Event.GType.MapEnd) { Log.Write("Game ending...", Log.Level.Debug); - foreach (Player P in players) - { - if (P == null || P.stats == null) - continue; - statDB.updatePlayer(P); - Log.Write("Updated stats for client " + P.databaseID, Log.Level.Debug); - } return true; } @@ -846,8 +809,8 @@ namespace IW4MAdmin clientDB.addBan(newBan); clientDB.updatePlayer(Target); - // foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront - // S.Bans = S.clientDB.getBans(); + foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront + S.Bans = S.clientDB.getBans(); lock (Reports) // threading seems to do something weird here { @@ -879,12 +842,37 @@ namespace IW4MAdmin P.setLevel(Player.Permission.User); clientDB.updatePlayer(P); + foreach (SharedLibrary.Server S in Program.getServers()) // make sure bans show up on the webfront + S.Bans = S.clientDB.getBans(); + return true; } } return false; } + override public bool Reload() + { + try + { + messages = null; + maps = null; + rules = null; + initMaps(); + initMessages(); + initRules(); + PluginImporter.Load(); + return true; + } + catch (Exception E) + { + Log.Write("Unable to reload configs! - " + E.Message, Log.Level.Debug); + messages = new List(); + maps = new List(); + rules = new List(); + return false; + } + } override public void initMacros() { @@ -923,8 +911,8 @@ namespace IW4MAdmin commands.Add(new Find("find", "find player in database. syntax: !find ", "f", Player.Permission.SeniorAdmin, 1, false)); commands.Add(new Rules("rules", "list server rules. syntax: !rules", "r", Player.Permission.User, 0, false)); commands.Add(new PrivateMessage("privatemessage", "send message to other player. syntax: !pm ", "pm", Player.Permission.User, 2, true)); - commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true)); - commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false)); + //commands.Add(new _Stats("stats", "view your stats or another player's. syntax: !stats", "xlrstats", Player.Permission.User, 0, true)); + //commands.Add(new TopStats("topstats", "view the top 4 players on this server. syntax: !topstats", "xlrtopstats", Player.Permission.User, 0, false)); commands.Add(new Reload("reload", "reload configurations. syntax: !reload", "reload", Player.Permission.Owner, 0, false)); commands.Add(new Balance("balance", "balance teams. syntax !balance", "bal", Player.Permission.Moderator, 0, false)); commands.Add(new GoTo("goto", "teleport to selected player. syntax !goto", "go", Player.Permission.SeniorAdmin, 1, true)); @@ -938,7 +926,7 @@ namespace IW4MAdmin commands.Add(new _RCON("rcon", "send rcon command to server. syntax: !rcon ", "rcon", Player.Permission.Owner, 1, false)); commands.Add(new FindAll("findall", "find a player by their aliase(s). syntax: !findall ", "fa", Player.Permission.Moderator, 1, false)); - foreach (Command C in PluginImporter.potentialPlugins) + foreach (Command C in PluginImporter.potentialCommands) commands.Add(C); } diff --git a/Admin/Utilities.cs b/Admin/Utilities.cs index e2bd70bd6..608f3d165 100644 --- a/Admin/Utilities.cs +++ b/Admin/Utilities.cs @@ -367,21 +367,16 @@ namespace IW4MAdmin return false; } - //ClientId clientid = new ClientId(); - //threadID = new IntPtr(); - uint ThreadID2; - threadID = IntPtr.Zero; - //RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid); - //SCreateRemoteThread(ProcessHandle, IntPtr.Zero, 0, lpLLAddress, baseAddress, 0, out ThreadID2); - return true; + ClientId clientid = new ClientId(); + threadID = new IntPtr(); + RtlCreateUserThread(ProcessHandle, IntPtr.Zero, false, 0, (uint)0, IntPtr.Zero, lpLLAddress, baseAddress, out threadID, out clientid); if (threadID == IntPtr.Zero) { Program.getManager().mainLog.Write("Could not create remote thread"); return false; } #if DEBUG - //Program.getManager().mainLog.Write("Thread Status is " + threadStatus); Program.getManager().mainLog.Write("Thread ID is " + threadID); #endif uint responseCode = WaitForSingleObject(threadID, 3000); @@ -399,8 +394,8 @@ namespace IW4MAdmin { if (Pointer != IntPtr.Zero) { - // if (!VirtualFreeEx(ProcessHandle, Pointer, 0, AllocationType.Release)) - // Program.getManager().mainLog.Write("Virtual Free Failed During Exit Cleanup -- Error #" + Marshal.GetLastWin32Error()); + if (!VirtualFreeEx(ProcessHandle, Pointer, 0, AllocationType.Release)) + Program.getManager().mainLog.Write("Virtual Free Failed During Exit Cleanup -- Error #" + Marshal.GetLastWin32Error()); } } diff --git a/Admin/WebFront.cs b/Admin/WebFront.cs index 15edcb2de..6c0d33b4d 100644 --- a/Admin/WebFront.cs +++ b/Admin/WebFront.cs @@ -228,7 +228,7 @@ namespace IW4MAdmin_Web buffer.Append("
"); return buffer.ToString(); case "STATS": - int totalStats = Servers[server].statDB.totalStats(); + int totalStats = 0; buffer.Append("

Starting at #{{TOP}}


"); buffer.Append(""); @@ -239,10 +239,10 @@ namespace IW4MAdmin_Web range = (totalStats - start); else range = 30; - List Stats = Servers[server].statDB.getMultipleStats(start, range).OrderByDescending(x => x.Skill).ToList(); + //List Stats = Servers[server].statDB.getMultipleStats(start, range).OrderByDescending(x => x.Skill).ToList(); buffer.Append(""); cycleFix = 0; - for (int i = 0; i < totalStats; i++) + /*for (int i = 0; i < totalStats; i++) { if (i >= Stats.Count -1 || Stats[i] == null ) continue; @@ -267,7 +267,7 @@ namespace IW4MAdmin_Web buffer.AppendFormat("", P.Name, P.stats.Kills, P.stats.Deaths, P.stats.KDR, P.stats.Skill, Prefix, Link); cycleFix++; } - } + }*/ buffer.Append("
NameKillsDeathsKDRRating
{0}{1}{2}{3}{4}

"); buffer.Append(parsePagination(server, totalStats, 30, Pagination, "stats")); return buffer.ToString().Replace("{{TOP}}", (start + 1).ToString()); @@ -327,14 +327,6 @@ namespace IW4MAdmin_Web str.AppendFormat("{0}
", a.Name); } - Player.stats = Servers[server].statDB.getStats(Player.databaseID); - String Rating = String.Empty; - - if (Player.stats == null) - Rating = "Not Available"; - else - Rating = Player.stats.Skill.ToString(); - StringBuilder IPs = new StringBuilder(); if (logged) @@ -364,7 +356,7 @@ namespace IW4MAdmin_Web if (logged) Screenshot = String.Format("
", forumID, Player.Name); - buffer.AppendFormat("{0}{10}{1}{2}{3}{4}{5}{6} ago{8}", Player.Name, str, IPs, Rating, SharedLibrary.Utilities.nameHTMLFormatted(Player), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/0/" + Player.databaseID + "/userip/?player", Screenshot); + buffer.AppendFormat("{0}{10}{1}{2}{3}{4}{5}{6} ago{8}", Player.Name, str, IPs, 0, SharedLibrary.Utilities.nameHTMLFormatted(Player), Player.Connections, Player.getLastConnection(), forumID, Player.Name, "/0/" + Player.databaseID + "/userip/?player", Screenshot); buffer.Append(""); } diff --git a/Admin/lib/AdminInterface.dll b/Admin/lib/AdminInterface.dll index b6dd3012f..caef8306d 100644 Binary files a/Admin/lib/AdminInterface.dll and b/Admin/lib/AdminInterface.dll differ diff --git a/Admin/lib/SharedLibary.dll b/Admin/lib/SharedLibary.dll index cab58081a..5c8a3a209 100644 Binary files a/Admin/lib/SharedLibary.dll and b/Admin/lib/SharedLibary.dll differ diff --git a/Admin/plugins/SamplePlugin.dll b/Admin/plugins/SamplePlugin.dll index 923af901b..595f1b276 100644 Binary files a/Admin/plugins/SamplePlugin.dll and b/Admin/plugins/SamplePlugin.dll differ diff --git a/Release Build/lib/AdminInterface.dll b/Release Build/lib/AdminInterface.dll new file mode 100644 index 000000000..caef8306d Binary files /dev/null and b/Release Build/lib/AdminInterface.dll differ diff --git a/Release Build/lib/SharedLibary.dll b/Release Build/lib/SharedLibary.dll new file mode 100644 index 000000000..5c8a3a209 Binary files /dev/null and b/Release Build/lib/SharedLibary.dll differ diff --git a/SamplePlugin/Main.cs b/SamplePlugin/Main.cs index ecb30cdfd..3e00badc3 100644 --- a/SamplePlugin/Main.cs +++ b/SamplePlugin/Main.cs @@ -1,9 +1,13 @@ using System; using SharedLibrary; using System.Text; +using System.IO; +using System.Collections.Generic; +using System.Data; namespace SamplePlugin { +#if SAMPLE_CODE public class SampleCommand : Command { public SampleCommand() : base("testplugin", "sample plugin command. syntax !testplugin", "tp", Player.Permission.User, 0, false) { } @@ -35,11 +39,17 @@ namespace SamplePlugin for (int i = 0; i < 10; i++) originatingServer.Broadcast(String.Format("^7{0}: ^{1}{2}^7", Sender, i, Message)); + + originatingServer.Log.Write("This line is coming from the plugin " + this.Name, Log.Level.Production); } } public class SampleEvent : EventNotify { + public override void onLoad() + { + Console.WriteLine("The sample event plugin was loaded!"); + } public override void onEvent(Event E) { E.Owner.Broadcast("An event occured of type: ^1" + E.Type); @@ -48,9 +58,142 @@ namespace SamplePlugin E.Origin.Tell(E.Data); } } - + public class InvalidCommandExample { private void doNotDoThis() { } } +#endif + + public class StatCommand: Command + { + public StatCommand() : base("stats", "view your stats. syntax !stats", "xlrstats", Player.Permission.User, 0, false) { } + + public override void Execute(Event E) + { + PlayerStats pStats = Stats.playerStats.getStats(E.Origin); + String statLine = String.Format("^5{0} ^7KILLS | ^5{1} ^7DEATHS | ^5{2} ^7KDR | ^5{3} ^7SKILL", pStats.Kills, pStats.Deaths, pStats.KDR, pStats.Skill); + E.Origin.Tell(statLine); + } + } + + public class Stats : EventNotify + { + public static StatsDB playerStats { get; private set; } + + public override void onEvent(Event E) + { + Console.WriteLine("event type is " + E.Type); + if (E.Type == Event.GType.Kill) + { + Player Killer = E.Origin; + PlayerStats killerStats = playerStats.getStats(Killer); + + if (Killer != E.Target) + { + killerStats.Kills++; + + if (killerStats.Deaths == 0) + killerStats.KDR = killerStats.Kills; + else + killerStats.KDR = killerStats.Kills / killerStats.Deaths; + + playerStats.updateStats(Killer, killerStats); + } + } + + if (E.Type == Event.GType.Death) + { + Player Victim = E.Origin; + PlayerStats victimStats = playerStats.getStats(Victim); + + victimStats.Deaths++; + victimStats.KDR = victimStats.Kills / victimStats.Deaths; + playerStats.updateStats(Victim, victimStats); + } + } + + public override void onLoad() + { + playerStats = new StatsDB("stats.rm"); + } + } + + public class StatsDB : Database + { + public StatsDB(String FN) : base(FN) { } + + public override void Init() + { + if (!File.Exists(FileName)) + { + String Create = "CREATE TABLE [STATS] ( [npID] TEXT, [KILLS] INTEGER DEFAULT 0, [DEATHS] INTEGER DEFAULT 0, [KDR] REAL DEFAULT 0, [SKILL] REAL DEFAULT 0, [MEAN] REAL DEFAULT 0, [DEV] REAL DEFAULT 0 );"; + ExecuteNonQuery(Create); + } + } + + public void addPlayer(Player P) + { + Dictionary newPlayer = new Dictionary(); + + newPlayer.Add("npID", P.npID); + newPlayer.Add("KILLS", 0); + newPlayer.Add("DEATHS", 0); + newPlayer.Add("KDR", 0); + newPlayer.Add("SKILL", 0); + + Insert("STATS", newPlayer); + } + + public PlayerStats getStats(Player P) + { + String Query = String.Format("SELECT * FROM STATS WHERE npID = '{0}'", P.npID); + DataTable Result = GetDataTable(Query); + + if (Result != null && Result.Rows.Count > 0) + { + DataRow ResponseRow = Result.Rows[0]; + return new PlayerStats( + Convert.ToInt32(ResponseRow["KILLS"]), + Convert.ToInt32(ResponseRow["DEATHS"]), + Convert.ToDouble(ResponseRow["KDR"]), + Convert.ToDouble(ResponseRow["SKILL"]) + ); + } + + else + { + addPlayer(P); + return getStats(P); + } + } + + public void updateStats(Player P, PlayerStats S) + { + Dictionary updatedPlayer = new Dictionary(); + + updatedPlayer.Add("KILLS", S.Kills); + updatedPlayer.Add("DEATHS", S.Deaths); + updatedPlayer.Add("KDR", Math.Round(S.KDR, 2)); + updatedPlayer.Add("SKILL", S.Skill); + + Update("STATS", updatedPlayer, String.Format("npID = '{0}'", P.npID)); + } + } + + public struct PlayerStats + { + public PlayerStats(int K, int D, double DR, double S) + { + Kills = K; + Deaths = D; + KDR = DR; + Skill = S; + } + + public int Kills; + public int Deaths; + public double KDR; + public double Skill; + } } \ No newline at end of file diff --git a/SharedLibary/Database.cs b/SharedLibary/Database.cs index d6dd6435d..840c0d3d3 100644 --- a/SharedLibary/Database.cs +++ b/SharedLibary/Database.cs @@ -125,7 +125,7 @@ namespace SharedLibrary catch (Exception e) { Console.WriteLine(e.Message); - throw new Exception(e.Message); + return new DataTable(); } return dt; } @@ -403,7 +403,7 @@ namespace SharedLibrary } } - public class StatsDB : Database + /*public class StatsDB : Database { public StatsDB(String FN) : base(FN) { } @@ -539,7 +539,7 @@ namespace SharedLibrary Update("STATS", new Dictionary() { { "SKILL", 1 } }, String.Format("Number = '{0}'", D["Number"])); } } - } + }*/ public class AliasesDB : Database { diff --git a/SharedLibary/Event.cs b/SharedLibary/Event.cs index 89fb4272e..158f1bd28 100644 --- a/SharedLibary/Event.cs +++ b/SharedLibary/Event.cs @@ -130,5 +130,6 @@ namespace SharedLibrary public abstract class EventNotify { public abstract void onEvent(Event E); + public abstract void onLoad(); } } diff --git a/SharedLibary/Player.cs b/SharedLibary/Player.cs index 84652cf41..2b9ac82fc 100644 --- a/SharedLibary/Player.cs +++ b/SharedLibary/Player.cs @@ -4,37 +4,6 @@ using System.Text; namespace SharedLibrary { - public class Stats - { - public Stats(int n, int K, int D, double kdr, double skill, double mean, double dev) - { - statIndex = n; - Kills = K; - Deaths = D; - KDR = Math.Round(kdr, 2); - - //Rating = new Moserware.Skills.Rating(mean, dev); - //Skill = Math.Round(Rating.ConservativeRating, 3) * 10; - - } - - public void updateKDR() - { - int tempDeaths = Deaths; // cuz we don't want undefined! - if (Deaths == 0) - tempDeaths = 1; - - KDR = Math.Round((double)((double)Kills / (double)tempDeaths), 2); - } - - public int Kills; - public int Deaths; - public double KDR; - public double Skill; - public int statIndex; - // public Moserware.Skills.Rating Rating; - } - public class Aliases { public Aliases(int Num, String N, String I) @@ -228,7 +197,6 @@ namespace SharedLibrary public Event lastEvent; public String lastOffense; public int Warnings; - public Stats stats; public Aliases Alias; public bool Masked; } diff --git a/SharedLibary/Server.cs b/SharedLibary/Server.cs index 275937540..2ac49b1b5 100644 --- a/SharedLibary/Server.cs +++ b/SharedLibary/Server.cs @@ -21,7 +21,6 @@ namespace SharedLibrary Log = new Log(logFile, Log.Level.Production, port); #endif clientDB = new ClientsDB("clients.rm"); - statDB = new StatsDB("stats_" + Port + ".rm"); aliasDB = new AliasesDB("aliases.rm"); players = new List(new Player[18]); @@ -211,27 +210,7 @@ namespace SharedLibrary /// Reloads all the server configurations /// /// True on sucess - public bool Reload() - { - try - { - messages = null; - maps = null; - rules = null; - initMaps(); - initMessages(); - initRules(); - return true; - } - catch (Exception E) - { - Log.Write("Unable to reload configs! - " + E.Message, Log.Level.Debug); - messages = new List(); - maps = new List(); - rules = new List(); - return false; - } - } + abstract public bool Reload(); /// /// Send a message to all players @@ -384,7 +363,7 @@ namespace SharedLibrary /// /// Read the map configuration /// - private void initMaps() + protected void initMaps() { maps = new List(); @@ -410,7 +389,7 @@ namespace SharedLibrary /// /// Initialize the messages to be broadcasted /// - private void initMessages() + protected void initMessages() { messages = new List(); @@ -447,7 +426,7 @@ namespace SharedLibrary /// /// Initialize the rules configuration /// - private void initRules() + protected void initRules() { rules = new List(); @@ -474,7 +453,7 @@ namespace SharedLibrary abstract public void initCommands(); //Objects - public Log Log; + public Log Log { get; private set; } public List Bans; public Player owner; public List maps; @@ -519,6 +498,5 @@ namespace SharedLibrary // Databases public ClientsDB clientDB; public AliasesDB aliasDB; - public StatsDB statDB; } }