Index: ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -650,7 +650,11 @@ */ GuiInterface.prototype.GetIncomingAttacks = function(player) { - return QueryPlayerIDInterface(player, IID_AttackDetection).GetIncomingAttacks(); + let cmpAttackDetection = QueryPlayerIDInterface(player, IID_AttackDetection); + if (!cmpAttackDetection) + return []; + + return cmpAttackDetection.GetIncomingAttacks(); }; /** @@ -658,7 +662,8 @@ */ GuiInterface.prototype.GetNeededResources = function(player, data) { - return QueryPlayerIDInterface(data.player !== undefined ? data.player : player).GetNeededResources(data.cost); + let cmpPlayer = QueryPlayerIDInterface(data.player !== undefined ? data.player : player); + return cmpPlayer ? cmpPlayer.GetNeededResources(data.cost) : {}; }; /** @@ -766,7 +771,11 @@ GuiInterface.prototype.GetAvailableFormations = function(player, wantedPlayer) { - return QueryPlayerIDInterface(wantedPlayer).GetFormations(); + let cmpPlayer = QueryPlayerIDInterface(wantedPlayer); + if (!cmpPlayer) + return []; + + return cmpPlayer.GetFormations(); }; GuiInterface.prototype.GetFormationRequirements = function(player, data) @@ -1956,7 +1965,11 @@ GuiInterface.prototype.GetTradingGoods = function(player) { - return QueryPlayerIDInterface(player).GetTradingGoods(); + let cmpPlayer = QueryPlayerIDInterface(player); + if (!cmpPlayer) + return []; + + return cmpPlayer.GetTradingGoods(); }; GuiInterface.prototype.OnGlobalEntityRenamed = function(msg) Index: ps/trunk/binaries/data/mods/public/simulation/components/PlayerManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/PlayerManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/PlayerManager.js @@ -91,11 +91,11 @@ if (id in this.playerEntities) return this.playerEntities[id]; - // All players at or below ID 0 get gaia-level data. (Observers for example) - if (id <= 0) - return this.playerEntities[0]; + // Observers don't have player data. + if (id == INVALID_PLAYER) + return INVALID_ENTITY; - var stack = new Error().stack.trimRight().replace(/^/mg, ' '); // indent each line + let stack = new Error().stack.trimRight().replace(/^/mg, ' '); // indent each line warn("GetPlayerByID: no player defined for id '"+id+"'\n"+stack); return INVALID_ENTITY;