removed code that mysteriously caused player count to be inaccurate.

fixed unrepresentable datetime when minute rounded to 60 (forgot to copy changes to release code)

fixed the player graph render time (apparently canvasjs doesn't like big numbers

hopefully fixed duplicate 'stats' pages from appearing.
This commit is contained in:
RaidMax 2017-10-15 20:40:27 -05:00
parent 0bdec1147b
commit 4c813b18d6
7 changed files with 41 additions and 21 deletions

View File

@ -328,7 +328,7 @@ namespace IW4MAdmin
try try
{ {
ClientNum = await PollPlayersAsync(); await PollPlayersAsync();
if (ConnectionErrors > 0) if (ConnectionErrors > 0)
{ {
@ -375,7 +375,9 @@ namespace IW4MAdmin
start = DateTime.Now; start = DateTime.Now;
} }
//logFile = new IFile(); if (LogFile == null)
return;
if (l_size != LogFile.Length()) if (l_size != LogFile.Length())
{ {
// this should be the longest running task // this should be the longest running task

Binary file not shown.

View File

@ -1,6 +1,13 @@
<script> <script>
function getPlayerHistoryChart(playerHistory, i) { function getPlayerHistoryChart(playerHistory, i) {
/////////////////////////////////////// ///////////////////////////////////////
// thanks to cnavas js :(
playerHistory.forEach(function(item, i) {
playerHistory[i].x = new Date(playerHistory[i].x);
});
return new CanvasJS.Chart(`graph-player-history-${i}`, { return new CanvasJS.Chart(`graph-player-history-${i}`, {
backgroundColor: "#191919", backgroundColor: "#191919",
height: 100, height: 100,
@ -8,7 +15,7 @@
toolTip: { toolTip: {
contentFormatter: function (e) { contentFormatter: function (e) {
var date = new Date(e.entries[0].dataPoint.x * 1000); var date = new Date(e.entries[0].dataPoint.x);
return date.toLocaleTimeString('en-US', { timeZone: 'America/New_York', hour12: true }) + " - " + e.entries[0].dataPoint.y + " players"; return date.toLocaleTimeString('en-US', { timeZone: 'America/New_York', hour12: true }) + " - " + e.entries[0].dataPoint.y + " players";
} }
}, },

View File

@ -154,7 +154,7 @@ namespace StatsPlugin
public static List<StatTracking> statLists; public static List<StatTracking> statLists;
public struct StatTracking public class StatTracking
{ {
public StatsDB playerStats; public StatsDB playerStats;
public DateTime[] lastKill, connectionTime; public DateTime[] lastKill, connectionTime;
@ -222,8 +222,11 @@ namespace StatsPlugin
if (ManagerInstance == null) if (ManagerInstance == null)
{ {
ManagerInstance = S.Manager; ManagerInstance = S.Manager;
WebService.PageList.Add(new StatsPage()); lock (WebService.PageList)
WebService.PageList.Add(new KillStatsJSON()); {
WebService.PageList.Add(new StatsPage());
WebService.PageList.Add(new KillStatsJSON());
}
} }
statLists.Add(new StatTracking(S.GetPort())); statLists.Add(new StatTracking(S.GetPort()));
@ -292,7 +295,8 @@ namespace StatsPlugin
if (E.Origin == E.Target || E.Origin == null) if (E.Origin == E.Target || E.Origin == null)
return; return;
string[] killInfo = E.Data.Split(';'); string[] killInfo = (E.Data != null) ? E.Data.Split(';') : new string[0];
if (killInfo.Length >= 9 && killInfo[0].Contains("ScriptKill")) if (killInfo.Length >= 9 && killInfo[0].Contains("ScriptKill"))
{ {
var killEvent = new KillInfo(E.Origin.DatabaseID, E.Target.DatabaseID, S.CurrentMap.Name, killInfo[7], killInfo[8], killInfo[5], killInfo[6], killInfo[3], killInfo[4]) var killEvent = new KillInfo(E.Origin.DatabaseID, E.Target.DatabaseID, S.CurrentMap.Name, killInfo[7], killInfo[8], killInfo[5], killInfo[6], killInfo[3], killInfo[4])
@ -305,7 +309,7 @@ namespace StatsPlugin
ServerStats[S.GetPort()].GetKillQueue().Dequeue(); ServerStats[S.GetPort()].GetKillQueue().Dequeue();
ServerStats[S.GetPort()].GetKillQueue().Enqueue(killEvent); ServerStats[S.GetPort()].GetKillQueue().Enqueue(killEvent);
//S.Logger.WriteInfo($"{E.Origin.Name} killed {E.Target.Name} with a {killEvent.Weapon} from a distance of {Vector3.Distance(killEvent.KillOrigin, killEvent.DeathOrigin)} with {killEvent.Damage} damage, at {killEvent.HitLoc}"); //S.Logger.WriteInfo($"{E.Origin.Name} killed {E.Target.Name} with a {killEvent.Weapon} from a distance of {Vector3.Distance(killEvent.KillOrigin, killEvent.DeathOrigin)} with {killEvent.Damage} damage, at {killEvent.HitLoc}");
var cs= statLists.Find(x => x.Port == S.GetPort()); var cs = statLists.Find(x => x.Port == S.GetPort());
cs.playerStats.AddKill(killEvent); cs.playerStats.AddKill(killEvent);
return; return;
} }
@ -415,6 +419,8 @@ namespace StatsPlugin
{ {
StatTracking selectedPlayers = statLists.Find(x => x.Port == serverPort); StatTracking selectedPlayers = statLists.Find(x => x.Port == serverPort);
if (selectedPlayers == null)
return;
selectedPlayers.Kills[cID] = 0; selectedPlayers.Kills[cID] = 0;
selectedPlayers.connectionTime[cID] = DateTime.Now; selectedPlayers.connectionTime[cID] = DateTime.Now;
selectedPlayers.inactiveMinutes[cID] = 0; selectedPlayers.inactiveMinutes[cID] = 0;
@ -640,7 +646,7 @@ namespace StatsPlugin
} }
} }
public struct PlayerStats public class PlayerStats
{ {
public PlayerStats(int K, int D, double DR, double S, double sc, int P) public PlayerStats(int K, int D, double DR, double S, double sc, int P)
{ {

View File

@ -5,7 +5,7 @@ _______
### Setup ### Setup
IW4MAdmin requires minimal configuration to run. There is only one prerequisite. IW4MAdmin requires minimal configuration to run. There is only one prerequisite.
2. [.NET Framework 4.5](https://www.microsoft.com/en-us/download/details.aspx?id=30653) *or better* 1. [.NET Framework 4.5](https://www.microsoft.com/en-us/download/details.aspx?id=30653) *or newer*
Extract `IW4MAdmin.zip` Extract `IW4MAdmin.zip`
Run `IW4MAdmin.exe` Run `IW4MAdmin.exe`

View File

@ -7,7 +7,7 @@ namespace SharedLibrary.Helpers
public PlayerHistory(int cNum) public PlayerHistory(int cNum)
{ {
DateTime t = DateTime.UtcNow; DateTime t = DateTime.UtcNow;
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, 5 * (int)Math.Round(t.Minute / 5.0), 0); When = new DateTime(t.Year, t.Month, t.Day, t.Hour, Math.Min(59, 15 * (int)Math.Round(t.Minute / 15.0)), 0);
PlayerCount = cNum; PlayerCount = cNum;
} }
@ -25,11 +25,11 @@ namespace SharedLibrary.Helpers
/// <summary> /// <summary>
/// Used by CanvasJS as a point on the x axis /// Used by CanvasJS as a point on the x axis
/// </summary> /// </summary>
public double x public string x
{ {
get get
{ {
return (When - DateTime.MinValue).TotalSeconds; return When.ToString("yyyy-MM-ddTHH:mm:ssZ");
} }
} }

View File

@ -31,7 +31,6 @@ namespace SharedLibrary
Port = config.Port; Port = config.Port;
Manager = mgr; Manager = mgr;
Logger = Manager.GetLogger(); Logger = Manager.GetLogger();
ClientNum = 0;
Config = config; Config = config;
Players = new List<Player>(new Player[18]); Players = new List<Player>(new Player[18]);
@ -117,7 +116,7 @@ namespace SharedLibrary
{ {
return null; return null;
} }
/// <summary> /// <summary>
/// Legacy method for the alias command /// Legacy method for the alias command
/// </summary> /// </summary>
@ -164,7 +163,7 @@ namespace SharedLibrary
{ {
#if DEBUG #if DEBUG
//if (!Target.lastEvent.Remote) //if (!Target.lastEvent.Remote)
// return; // return;
#endif #endif
string tellCommand = (GameName == Game.IW4) ? "tellraw" : "tell"; string tellCommand = (GameName == Game.IW4) ? "tellraw" : "tell";
@ -270,7 +269,7 @@ namespace SharedLibrary
Maps.Add(map); Maps.Add(map);
} }
} }
} }
else else
Logger.WriteInfo("Maps configuration appears to be empty - skipping..."); Logger.WriteInfo("Maps configuration appears to be empty - skipping...");
} }
@ -300,7 +299,7 @@ namespace SharedLibrary
MessageTime = 60; MessageTime = 60;
else else
MessageTime = mTime; MessageTime = mTime;
foreach (String l in lines) foreach (String l in lines)
{ {
if (lines[0] != l && l.Length > 1) if (lines[0] != l && l.Length > 1)
@ -310,7 +309,7 @@ namespace SharedLibrary
messageCFG.Close(); messageCFG.Close();
//if (Program.Version != Program.latestVersion && Program.latestVersion != 0) //if (Program.Version != Program.latestVersion && Program.latestVersion != 0)
// messages.Add("^5IW4M Admin ^7is outdated. Please ^5update ^7to version " + Program.latestVersion); // messages.Add("^5IW4M Admin ^7is outdated. Please ^5update ^7to version " + Program.latestVersion);
} }
/// <summary> /// <summary>
@ -349,7 +348,7 @@ namespace SharedLibrary
public ServerConfiguration Config { get; private set; } public ServerConfiguration Config { get; private set; }
public List<Map> Maps { get; protected set; } public List<Map> Maps { get; protected set; }
public List<string> Rules { get; protected set; } public List<string> Rules { get; protected set; }
public List<Report> Reports { get; set; } public List<Report> Reports { get; set; }
public List<Chat> ChatHistory { get; protected set; } public List<Chat> ChatHistory { get; protected set; }
public Queue<Helpers.PlayerHistory> PlayerHistory { get; private set; } public Queue<Helpers.PlayerHistory> PlayerHistory { get; private set; }
public Game GameName { get; protected set; } public Game GameName { get; protected set; }
@ -359,7 +358,13 @@ namespace SharedLibrary
public string Website { get; protected set; } public string Website { get; protected set; }
public string Gametype { get; protected set; } public string Gametype { get; protected set; }
public Map CurrentMap { get; protected set; } public Map CurrentMap { get; protected set; }
public int ClientNum { get; protected set; } public int ClientNum
{
get
{
return Players.Where(p => p != null).Count();
}
}
public int MaxClients { get; protected set; } public int MaxClients { get; protected set; }
public List<Player> Players { get; protected set; } public List<Player> Players { get; protected set; }
public string Password { get; private set; } public string Password { get; private set; }