Revert approach to detect offline players without remembering disconnect messages, since it doesn't work for entities of unassigned players. Refs #3677.

Remove unused AIManager.
Inline playerData.

This was SVN commit r17780.
This commit is contained in:
elexis 2016-02-20 17:37:19 +00:00
parent 6e9fd4ccf2
commit 6006edf031
3 changed files with 8 additions and 10 deletions

View File

@ -346,7 +346,7 @@ function handleNotifications()
*/
function updateDiplomacy()
{
g_Players = getPlayerData(g_PlayerAssignments);
g_Players = getPlayerData(g_PlayerAssignments, g_Players);
if (g_IsDiplomacyOpen)
openDiplomacy();

View File

@ -1,5 +1,5 @@
// Get the basic player data
function getPlayerData(playerAssignments)
function getPlayerData(playerAssignments, previousData = undefined)
{
let players = [];
@ -23,13 +23,12 @@ function getPlayerData(playerAssignments)
"teamsLocked": playerState.teamsLocked,
"cheatsEnabled": playerState.cheatsEnabled,
"state": playerState.state,
"isAI": playerState.isAI,
"isAlly": playerState.isAlly,
"isMutualAlly": playerState.isMutualAlly,
"isNeutral": playerState.isNeutral,
"isEnemy": playerState.isEnemy,
"guid": undefined, // network guid for players controlled by hosts
"offline": i != 0 && !playerState.isAI
"offline": previousData && !!previousData[i].offline
});
}
@ -41,7 +40,6 @@ function getPlayerData(playerAssignments)
continue;
players[playerAssignment.player].guid = playerGuid;
players[playerAssignment.player].name = playerAssignment.name;
players[playerAssignment.player].offline = false;
}
return players;

View File

@ -56,7 +56,7 @@ GuiInterface.prototype.GetSimulationState = function(player)
let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
let numPlayers = cmpPlayerManager.GetNumPlayers();
let cmpAIManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIManager);
for (let i = 0; i < numPlayers; ++i)
{
let playerEnt = cmpPlayerManager.GetPlayerByID(i);
@ -81,6 +81,7 @@ GuiInterface.prototype.GetSimulationState = function(player)
let mutualAllies = [];
let neutrals = [];
let enemies = [];
for (let j = 0; j < numPlayers; ++j)
{
allies[j] = cmpPlayer.IsAlly(j);
@ -88,7 +89,8 @@ GuiInterface.prototype.GetSimulationState = function(player)
neutrals[j] = cmpPlayer.IsNeutral(j);
enemies[j] = cmpPlayer.IsEnemy(j);
}
let playerData = {
ret.players.push({
"name": cmpPlayer.GetName(),
"civ": cmpPlayer.GetCiv(),
"color": cmpPlayer.GetColor(),
@ -105,7 +107,6 @@ GuiInterface.prototype.GetSimulationState = function(player)
"cheatsEnabled": cmpPlayer.GetCheatsEnabled(),
"disabledTemplates": cmpPlayer.GetDisabledTemplates(),
"phase": phase,
"isAI": cmpPlayer.IsAI(),
"isAlly": allies,
"isMutualAlly": mutualAllies,
"isNeutral": neutrals,
@ -118,8 +119,7 @@ GuiInterface.prototype.GetSimulationState = function(player)
"researchedTechs": cmpTechnologyManager ? cmpTechnologyManager.GetResearchedTechs() : null,
"classCounts": cmpTechnologyManager ? cmpTechnologyManager.GetClassCounts() : null,
"typeCountsByClass": cmpTechnologyManager ? cmpTechnologyManager.GetTypeCountsByClass() : null
};
ret.players.push(playerData);
});
}
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);