diff --git a/Admin/Command.cs b/Admin/Command.cs index d7a74219a..88d4c982a 100644 --- a/Admin/Command.cs +++ b/Admin/Command.cs @@ -11,7 +11,7 @@ namespace IW4MAdmin public override void Execute(Event E) { - if (E.Owner.owner == null) + if (E.Owner.clientDB.getOwner() == null) { E.Origin.setLevel(Player.Permission.Owner); E.Origin.Tell("Congratulations, you have claimed ownership of this server!"); diff --git a/Admin/Manager.cs b/Admin/Manager.cs index a365753aa..1c7e75240 100644 --- a/Admin/Manager.cs +++ b/Admin/Manager.cs @@ -60,12 +60,9 @@ namespace IW4MAdmin if (S == null) continue; - if (!isIW4MStillRunning(S.pID()) || !S.isRunning) + if (!isIW4MStillRunning(S.pID())) { Thread Defunct = ThreadList[S.pID()]; - - if (!S.isRunning) - Utilities.shutdownInterface(S.pID()); S.isRunning = false; if (Defunct != null) @@ -73,6 +70,10 @@ namespace IW4MAdmin Defunct.Join(); ThreadList[S.pID()] = null; } + + if (!S.isRunning) + Utilities.shutdownInterface(S.pID()); + mainLog.Write("Server with PID #" + S.pID() + " can no longer be monitored.", Log.Level.Debug); activePIDs.Remove(S.pID()); defunctServers.Add(S); diff --git a/Admin/Server.cs b/Admin/Server.cs index 45aa43e0f..b66ef3123 100644 --- a/Admin/Server.cs +++ b/Admin/Server.cs @@ -16,8 +16,7 @@ namespace IW4MAdmin { commandQueue = new Queue(); } - - + private void getAliases(List returnAliases, Aliases currentAlias) { foreach(String IP in currentAlias.IPS) @@ -47,43 +46,7 @@ namespace IW4MAdmin return allAliases; getAliases(allAliases, currentIdentityAliases); - return allAliases; - - /* - List aliasAliases = new List(); - Aliases currentAliases = aliasDB.getPlayer(Origin.databaseID); - - if (currentAliases == null) - { - Log.Write("No aliases found for " + Origin.Name, Log.Level.Debug); - return; - } - - foreach (String IP in currentAliases.getIPS()) - { - List tmp = aliasDB.getPlayer(IP); - if (tmp != null) - aliasAliases = tmp; - - foreach (Aliases a in aliasAliases) - { - if (a == null) - continue; - - Player aliasPlayer = clientDB.getPlayer(a.getNumber()); - - if (aliasPlayer != null) - { - aliasPlayer.Alias = a; - - if (returnPlayers.Exists(p => p.databaseID == aliasPlayer.databaseID == false)) - { - returnPlayers.Add(aliasPlayer); - getAliases(returnPlayers, aliasPlayer); - } - } - } - } */ + return allAliases; } //Add player object p to `players` list @@ -411,7 +374,7 @@ namespace IW4MAdmin override public void setDvar(String Dvar, String Value) { - lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + Value, lastDvarPointer); + lastDvarPointer = Utilities.executeCommand(PID, Dvar + " " + "\"" + Value + "\"", lastDvarPointer); } [DllImport("kernel32.dll")] @@ -427,6 +390,10 @@ namespace IW4MAdmin if (events.Count > 0) { Event curEvent = events.Peek(); + + if (curEvent == null) + continue; + processEvent(curEvent); foreach (Plugin P in PluginImporter.potentialPlugins) { @@ -610,6 +577,9 @@ namespace IW4MAdmin { try { + // clear out any lingering instances + Utilities.shutdownInterface(PID); + // inject our dll if (!Utilities.initalizeInterface(PID)) { @@ -646,8 +616,19 @@ namespace IW4MAdmin } // our settings - setDvar("sv_kickBanTime", "3600"); // 1 hour - setDvar("g_logSync", "1"); // yas + setDvar("sv_kickbantime", "3600"); // 1 hour + + int logSync = -1; + Int32.TryParse(getDvar("g_logSync").current, out oneLog); + + if (logSync == 0) + { + Log.Write("g_logsync is not set to 1, restarting map..."); + setDvar("g_logSync", "1"); // yas + executeCommand("map_restart"); + SharedLibrary.Utilities.Wait(10); + } + if (Mod == String.Empty || oneLog == 1) logPath = Basepath + '\\' + "m2demo" + '\\' + logPath; @@ -799,7 +780,17 @@ namespace IW4MAdmin { Log.Write("New map loaded - " + clientnum + " active players", Log.Level.Debug); - String newMapName = getDvar("mapname").current; + String newMapName = "0"; + String newGametype = "0"; + String newHostName = "0"; + + while(newMapName == "0" || newGametype == "0" || newHostName == "0") // weird anomaly here. + { + newMapName = getDvar("mapname").current; + newGametype = getDvar("g_gametype").current; + newHostName = getDvar("sv_hostname").current; + } + Map newMap = maps.Find(m => m.Name.Equals(newMapName)); if (newMap != null) @@ -807,6 +798,9 @@ namespace IW4MAdmin else mapname = newMapName; + Gametype = newGametype; + hostname = SharedLibrary.Utilities.stripColors(newHostName); + return true; } @@ -912,6 +906,8 @@ namespace IW4MAdmin commands = new List(); + owner = clientDB.getOwner(); + if(owner == null) commands.Add(new Owner("owner", "claim ownership of the server", "owner", Player.Permission.User, 0, false)); diff --git a/Admin/Utilities.cs b/Admin/Utilities.cs index 608f3d165..6d6c9b4a0 100644 --- a/Admin/Utilities.cs +++ b/Admin/Utilities.cs @@ -288,7 +288,7 @@ namespace IW4MAdmin } } - IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + "\0"), ProcessHandle); // this gets disposed next call + IntPtr memoryForDvarName = allocateAndWrite(Encoding.ASCII.GetBytes(Command + '\0'), ProcessHandle); // this gets disposed next call if (memoryForDvarName == IntPtr.Zero) { @@ -343,49 +343,45 @@ namespace IW4MAdmin return false; } - IntPtr baseAddress = IntPtr.Zero; + List baseAddresses = new List(); System.Diagnostics.Process P = System.Diagnostics.Process.GetProcessById(pID); foreach (System.Diagnostics.ProcessModule M in P.Modules) { - if (M.ModuleName == "AdminInterface.dll") - baseAddress = M.BaseAddress; + if (M.ModuleName == "AdminInterface.dll" && M.BaseAddress != IntPtr.Zero) + baseAddresses.Add(M.BaseAddress); } - if (baseAddress == IntPtr.Zero) - { - Program.getManager().mainLog.Write("Base address was not found!"); - return false; - } - - IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibrary"); - + IntPtr lpLLAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "FreeLibraryAndExitThread"); if (lpLLAddress == IntPtr.Zero) { - Program.getManager().mainLog.Write("Could not obtain address of function address"); + Program.getManager().mainLog.Write("Could not obtain address of freelibary"); return false; } 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) + foreach (IntPtr baseAddress in baseAddresses) { - Program.getManager().mainLog.Write("Could not create remote thread"); - return false; - } + 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 ID is " + threadID); #endif - uint responseCode = WaitForSingleObject(threadID, 3000); + uint responseCode = WaitForSingleObject(threadID, 3000); - if (responseCode != 0x00000000L) - { - Program.getManager().mainLog.Write("Thread did not finish in a timely manner!"); - Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error()); - return false; + if (responseCode != 0x00000000L) + { + Program.getManager().mainLog.Write("Thread did not finish in a timely manner!", Log.Level.Debug); + Program.getManager().mainLog.Write("Last error is: " + Marshal.GetLastWin32Error(), Log.Level.Debug); + return false; + } } CloseHandle(ProcessHandle); diff --git a/Admin/lib/SharedLibary.dll b/Admin/lib/SharedLibary.dll index 9c9a72cb1..12c352472 100644 Binary files a/Admin/lib/SharedLibary.dll and b/Admin/lib/SharedLibary.dll differ diff --git a/Admin/plugins/$SimpleStatsPlugin.dll b/Admin/plugins/$SimpleStatsPlugin.dll new file mode 100644 index 000000000..77abc61eb Binary files /dev/null and b/Admin/plugins/$SimpleStatsPlugin.dll differ diff --git a/Admin/plugins/SamplePlugin.dll b/Admin/plugins/SamplePlugin.dll index 5eb61a6df..4ae5be118 100644 Binary files a/Admin/plugins/SamplePlugin.dll and b/Admin/plugins/SamplePlugin.dll differ diff --git a/Admin/plugins/WebfrontPlugin.dll b/Admin/plugins/WebfrontPlugin.dll index 8ac2cbfed..13768a93d 100644 Binary files a/Admin/plugins/WebfrontPlugin.dll and b/Admin/plugins/WebfrontPlugin.dll differ diff --git a/Admin/webfront/footer.html b/Admin/webfront/footer.html index da3249f3f..419ab8ccc 100644 --- a/Admin/webfront/footer.html +++ b/Admin/webfront/footer.html @@ -24,6 +24,34 @@ $("#history_dialog").load(this.href); }); }); + + \ No newline at end of file diff --git a/Admin/webfront/header.html b/Admin/webfront/header.html index 71dc83cda..17d7dbb2c 100644 --- a/Admin/webfront/header.html +++ b/Admin/webfront/header.html @@ -278,7 +278,6 @@ border-radius: 0px 0px 11px 11px; } - .players { float: left; width: 400px; @@ -331,6 +330,11 @@ font-size: 14pt; width: 505px; } + + .playerAlias, .playerIPs + { + display: none; + } .chatFormat_submit, .chatFormat_submit:hover { diff --git a/Release Build/lib/SharedLibary.dll b/Release Build/lib/SharedLibary.dll index 9c9a72cb1..12c352472 100644 Binary files a/Release Build/lib/SharedLibary.dll and b/Release Build/lib/SharedLibary.dll differ diff --git a/Release Build/plugins/SamplePlugin.dll b/Release Build/plugins/SamplePlugin.dll index 5eb61a6df..4ae5be118 100644 Binary files a/Release Build/plugins/SamplePlugin.dll and b/Release Build/plugins/SamplePlugin.dll differ diff --git a/SamplePlugin/Main.cs b/SamplePlugin/Main.cs index 1a5f7e81f..018e6ec10 100644 --- a/SamplePlugin/Main.cs +++ b/SamplePlugin/Main.cs @@ -98,7 +98,12 @@ namespace SamplePlugin killerStats.KDR = killerStats.Kills / killerStats.Deaths; playerStats.updateStats(Killer, killerStats); + + killerStats.killStreak++; + killerStats.deathStreak = 0; } + + Killer.Tell(messageOnStreak(killerStats.killStreak, killerStats.deathStreak)); } if (E.Type == Event.GType.Death) @@ -110,6 +115,11 @@ namespace SamplePlugin victimStats.KDR = victimStats.Kills / victimStats.Deaths; playerStats.updateStats(Victim, victimStats); + + victimStats.deathStreak++; + victimStats.killStreak = 0; + + Victim.Tell(messageOnStreak(victimStats.killStreak, victimStats.deathStreak)); } } @@ -123,6 +133,32 @@ namespace SamplePlugin } + private String messageOnStreak(int killStreak, int deathStreak) + { + String Message = ""; + switch (killStreak) + { + case 5: + Message = "Great job! You're on a ^55 killstreak!"; + break; + case 10: + Message = "Amazing! ^510 ^7kills without dying!"; + break; + } + + switch (deathStreak) + { + case 5: + Message = "Pick it up soldier, you've died 5 times in a row..."; + break; + case 10: + Message = "Seriously? ^510 ^7deaths without getting a kill?"; + break; + } + + return Message; + } + public override string Name { get { return "Basic Stats"; } @@ -204,11 +240,15 @@ namespace SamplePlugin Deaths = D; KDR = DR; Skill = S; + deathStreak = 0; + killStreak = 0; } public int Kills; public int Deaths; public double KDR; public double Skill; + public int deathStreak; + public int killStreak; } } \ No newline at end of file diff --git a/SamplePlugin/SamplePlugin.csproj b/SamplePlugin/SamplePlugin.csproj index af79b039c..d6b4f2969 100644 --- a/SamplePlugin/SamplePlugin.csproj +++ b/SamplePlugin/SamplePlugin.csproj @@ -47,7 +47,7 @@ - copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$(TargetName).dll" + copy /Y "$(TargetDir)$(TargetName).dll" "$(SolutionDir)Admin\plugins\$SimpleStatsPlugin.dll"