diff --git a/Admin/Command.cs b/Admin/Command.cs index 23b4a0f9e..fb82f8d29 100644 --- a/Admin/Command.cs +++ b/Admin/Command.cs @@ -525,7 +525,7 @@ namespace IW4MAdmin foreach (Stats S in Top) { - Player P = E.Owner.clientDB.getPlayer(S.Kills); // BAD + Player P = E.Owner.clientDB.getPlayer(S.statIndex); if (P != null && P.getLevel() != Player.Permission.Banned) { P.stats = S; @@ -740,20 +740,17 @@ namespace IW4MAdmin List playerAliases = new List(); E.Owner.getAliases(playerAliases, E.Target); - // if (E.Target.Alias.getNames() != null) - { - message.Append("Aliases: "); + message.Append("Aliases: "); - foreach (Player P in playerAliases) + foreach (Player P in playerAliases) + { + foreach (String S in P.Alias.getNames()) { - foreach (String S in P.Alias.getNames()) - { - if (S != String.Empty && S != E.Target.getName()) - message.Append(S + " | "); - } + if (S != String.Empty && S != E.Target.getName()) + message.Append(S + " | "); } - E.Origin.Tell(message.ToString()); } + E.Origin.Tell(message.ToString()); message = new StringBuilder(); diff --git a/Admin/Database.cs b/Admin/Database.cs index 7a2833ce1..8ffa28914 100644 --- a/Admin/Database.cs +++ b/Admin/Database.cs @@ -129,7 +129,6 @@ namespace IW4MAdmin return; } - //END protected String FileName; protected String DBCon; @@ -391,9 +390,7 @@ namespace IW4MAdmin { String Query = String.Format("DELETE FROM BANS WHERE npID = '{0}' or IP= '%{1}%'", GUID, IP); ExecuteNonQuery(Query); - } - - + } } class StatsDB : Database @@ -465,10 +462,10 @@ namespace IW4MAdmin Update("STATS", updatedPlayer, String.Format("Number = '{0}'", P.getDBID())); } - //Returns top 8 players (we filter through them later) + //Returns top 5 players (we filter through them later) public List topStats() { - String Query = String.Format("SELECT * FROM STATS WHERE SKILL > '{0}' ORDER BY SKILL DESC LIMIT 5", 230); + String Query = String.Format("SELECT * FROM STATS WHERE KILLS > '{0}' AND KDR < '{1}' AND SKILL > '{2}' ORDER BY SKILL DESC LIMIT 5", 250, 7, 245); DataTable Result = GetDataTable(Query); List Top = new List(); @@ -477,17 +474,11 @@ namespace IW4MAdmin { foreach (DataRow D in Result.Rows) { - if (D["MEAN"] == DBNull.Value) - continue; - if (D["DEV"] == DBNull.Value) + if (D["MEAN"] == DBNull.Value || D["DEV"] == DBNull.Value || D["SKILL"] == DBNull.Value) continue; - if (D["SKILL"] == DBNull.Value) - D["SKILL"] = 0; - - Stats S = new Stats(Convert.ToInt32(D["Number"]), Convert.ToInt32(D["KILLS"]), Convert.ToInt32(D["DEATHS"]), Convert.ToDouble(D["KDR"]), Convert.ToDouble(D["SKILL"]), Convert.ToDouble(D["MEAN"]), Convert.ToDouble(D["DEV"])); - if (S.Skill > 230) - Top.Add(S); + Stats S = new Stats(Convert.ToInt32(D["Number"]), Convert.ToInt32(D["KILLS"]), Convert.ToInt32(D["DEATHS"]), Convert.ToDouble(D["KDR"]), Convert.ToDouble(D["SKILL"]), Convert.ToDouble(D["MEAN"]), Convert.ToDouble(D["DEV"])); + Top.Add(S); } } diff --git a/Admin/Main.cs b/Admin/Main.cs index 0b36a7f4c..dd6b0029f 100644 --- a/Admin/Main.cs +++ b/Admin/Main.cs @@ -50,9 +50,11 @@ namespace IW4MAdmin if (serverManager.getServers() != null) Console.WriteLine("IW4M Now Initialized! Visit http://127.0.0.1:1624 for server overview."); - //this is blocking so if it goes down :( - IW4MAdmin_Web.WebFront frontEnd = new IW4MAdmin_Web.WebFront(); - frontEnd.Init(); + if (serverManager.getServers().Count > 0) + { + IW4MAdmin_Web.WebFront frontEnd = new IW4MAdmin_Web.WebFront(); + frontEnd.Init(); + } } #if DEBUG static void setupConfig() diff --git a/Admin/Manager.cs b/Admin/Manager.cs index 4d282b8fe..7f79f67ce 100644 --- a/Admin/Manager.cs +++ b/Admin/Manager.cs @@ -43,8 +43,6 @@ namespace IW4MAdmin Thread IW4MServerThread = new Thread(IW4MServer.Monitor); ThreadList.Add(IW4MServer.pID(), IW4MServerThread); IW4MServerThread.Start(); - - //mainLog.Write("Now monitoring the server running on port " + IW4MServer.getPort(), Log.Level.All); } initialized = true; diff --git a/Admin/Server.cs b/Admin/Server.cs index f74dd3a5c..3a44098dc 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -236,7 +236,7 @@ namespace IW4MAdmin aliasDB.updatePlayer(NewPlayer.Alias); clientDB.updatePlayer(NewPlayer); - Utilities.Wait(10); // they're loading in. + // Utilities.Wait(10); // they're loading in. if (NewPlayer.getLevel() == Player.Permission.Banned) // their guid is already banned so no need to check aliases { @@ -513,7 +513,6 @@ namespace IW4MAdmin events.Enqueue(E); } - //process new event every 50 milliseconds private void manageEventQueue() { @@ -540,7 +539,7 @@ namespace IW4MAdmin private void setDvar(String Dvar, String Value) { - // Utilities.setDvar(PID, Dvar, Value); + Utilities.executeCommand(PID, Dvar + " " + Value); } [DllImport("kernel32.dll")] @@ -572,19 +571,11 @@ namespace IW4MAdmin if (!intializeBasics()) { - Log.Write("Stopping " + Port + " due to uncorrectable errors (check log)" + logPath, Log.Level.Production); + Log.Write("Stopping " + Port + " due to uncorrectable errors (check log)", Log.Level.Production); isRunning = false; - Utilities.Wait(10); return; } - - -#if DEBUG - //Thread to handle polling server for IP's - Thread statusUpdate = new Thread(new ThreadStart(pollServer)); - statusUpdate.Start(); -#endif //Handles new events in a fashionable manner Thread eventQueue = new Thread(new ThreadStart(manageEventQueue)); eventQueue.Start(); @@ -651,17 +642,19 @@ namespace IW4MAdmin { Byte[] buff = new Byte[681872]; // struct size ( 0.68MB :( ) ReadProcessMemory((int)Handle, 0x31D9390 + (buff.Length)*(i), buff, buff.Length, ref numberRead); // svs_clients start + current client - client_s eachClient = (client_s)Helpers.ReadStruct(buff); + if (eachClient.isBot == 1) continue; if (eachClient.state == 0) removePlayer(i); - else if (eachClient.state > 1) + + else if (eachClient.state > 2) + { addPlayer(new Player(Utilities.stripColors(Utilities.cleanChars(eachClient.name)), eachClient.steamid.ToString("x16"), i, 0, i, null, 0, Helpers.NET_AdrToString(eachClient.adr).Split(':')[0])); - if (eachClient.state > 2) activeClients++; + } } lastPoll = DateTime.Now; @@ -1090,9 +1083,13 @@ namespace IW4MAdmin { Target.setLevel(Player.Permission.Banned); Ban newBan = new Ban(Target.getLastO(), Target.getID(), Origin.getID(), DateTime.Now, Target.getIP()); - Bans.Add(newBan); + clientDB.addBan(newBan); clientDB.updatePlayer(Target); + + foreach (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 { List toRemove = new List(); @@ -1123,7 +1120,8 @@ namespace IW4MAdmin P.setLevel(Player.Permission.User); clientDB.updatePlayer(P); - Bans = clientDB.getBans(); + foreach (Server S in Program.getServers()) + S.Bans = S.clientDB.getBans(); return true; } } diff --git a/Admin/WebFront.cs b/Admin/WebFront.cs index 2264d0151..7d9dd06ee 100644 --- a/Admin/WebFront.cs +++ b/Admin/WebFront.cs @@ -450,7 +450,12 @@ namespace IW4MAdmin_Web Int32.TryParse(req[1], out page); } - if (request.QueryString == "bans") + if (IW4MAdmin.Program.getServers().Length < 1) + { + body = "

IT SEEMS LIKE THERE ARE NO LONGER ANY SERVERS BEING MONITORED!

"; + } + + else if (request.QueryString == "bans") { IW4MAdmin.file Bans = new IW4MAdmin.file("webfront\\bans.html"); var bans = Bans.getLines(); @@ -513,8 +518,6 @@ namespace IW4MAdmin_Web IW4MAdmin.Player P = IW4MAdmin.Program.getServers()[server].clientDB.getPlayer(IP); if (P == null) P = new IW4MAdmin.Player("Guest", "Guest", 0, 0); - // if (P.getLevel() > IW4MAdmin.Player.Permission.Flagged) - // Console.WriteLine(P.getName() + " is authenticate"); Client toSend = new Client(WebFront.Page.player, page, request.Headers, Data, P); body = Macro.findMacros(header + player + footer, toSend, server); diff --git a/Admin/lib/AdminInterface.dll b/Admin/lib/AdminInterface.dll index b16bcd923..c237df605 100644 Binary files a/Admin/lib/AdminInterface.dll and b/Admin/lib/AdminInterface.dll differ diff --git a/Admin/version.txt b/Admin/version.txt index 928202d55..627172890 100644 --- a/Admin/version.txt +++ b/Admin/version.txt @@ -3,7 +3,9 @@ CHANGELOG: -fixed issue with `history` timelime -fixed issue with mapname not being updated -fixed rare crash related to !list --now reads memory for player info! ( experimental debug only ) +-fixed topstats issues ( prevents cheaters from jumping to the top ) +-fixed webfront banlist not updating until tool restart +-now reads memory for player info! VERSION: 0.9 CHANGELOG: