Differential D2810 Diff 13519 ps/trunk/binaries/data/mods/public/simulation/components/PlayerManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/PlayerManager.js
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | |||||
* Returns the player entity ID for the given player ID. | * Returns the player entity ID for the given player ID. | ||||
* The player ID must be valid (else there will be an error message). | * The player ID must be valid (else there will be an error message). | ||||
*/ | */ | ||||
PlayerManager.prototype.GetPlayerByID = function(id) | PlayerManager.prototype.GetPlayerByID = function(id) | ||||
{ | { | ||||
if (id in this.playerEntities) | if (id in this.playerEntities) | ||||
return this.playerEntities[id]; | return this.playerEntities[id]; | ||||
// All players at or below ID 0 get gaia-level data. (Observers for example) | // Observers don't have player data. | ||||
if (id <= 0) | if (id == INVALID_PLAYER) | ||||
return this.playerEntities[0]; | 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); | warn("GetPlayerByID: no player defined for id '"+id+"'\n"+stack); | ||||
return INVALID_ENTITY; | return INVALID_ENTITY; | ||||
}; | }; | ||||
/** | /** | ||||
* Returns the number of players including gaia. | * Returns the number of players including gaia. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator