private void ValidateModel(List<CPlayerInfo> players, String revWhy)
{
if (fLastValidationTimestamp != DateTime.MinValue) {
TimeSpan elapsed = DateTime.Now.Subtract(fLastValidationTimestamp);
if (elapsed.TotalSeconds < 90.0) {
DebugWrite("Skipping revalidation: too soon, only " + elapsed.TotalSeconds.ToString("F0") + " seconds since last ValidateModel", 4);
return;
}
}
fLastValidationTimestamp = DateTime.Now;
DebugWrite("Revalidating all players and teams: " + revWhy, 3);
// forget the active list, might be incorrect
lock (fAllPlayers) {
fAllPlayers.Clear();
}
fUnassigned.Clear();
if (fGotLogin || fServerCrashed || (fTimeOutOfJoint > 0 && GetTimeInRoundMinutes() - fTimeOutOfJoint > 3.0)) {
fMoving.Clear();
fReassigned.Clear();
}
if (players.Count == 0) {
// no players, so waiting state
fGameState = GameState.Warmup;
} else {
fPluginState = PluginState.Reconnected;
// rebuild the data model and cancel any pending moves
foreach (CPlayerInfo p in players) {
try {
int bf4Type = (fGameVersion != GameVersion.BF3) ? p.Type : ROLE_PLAYER;
UpdatePlayerModel(p.SoldierName, p.TeamID, p.SquadID, p.GUID, p.Score, p.Kills, p.Deaths, p.Rank, bf4Type);
CheckAbortMove(p.SoldierName);
} catch (Exception e) {
ConsoleException(e);
}
}
/* Special handling for Reconnected state */
fGameState = (TotalPlayerCount() < 4) ? GameState.Warmup : GameState.Unknown;
UpdateTeams();
UpdateAllFromWhitelist();
}
if (fServerCrashed) fRoundStartTimestamp = DateTime.Now;
fPluginState = PluginState.Active;
DebugWrite("^9ValidateModel: ^b^3State = " + fPluginState, 6);
DebugWrite("^9ValidateModel: ^b^3Game state = " + fGameState, 6);
}