forked from 0ad/0ad
Check for "Destroy" messages beforehand in the base manager to avoid a rare error.
This was SVN commit r14320.
This commit is contained in:
parent
ed93cebd28
commit
a44e88fa42
@ -192,7 +192,11 @@ BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (events[i].type == "ConstructionFinished")
|
||||
}
|
||||
}
|
||||
for (i in events)
|
||||
{
|
||||
if (events[i].type == "ConstructionFinished")
|
||||
{
|
||||
// let's check we haven't lost an important building here.
|
||||
var evt = events[i];
|
||||
@ -200,7 +204,10 @@ BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
||||
{
|
||||
// TODO: we ought to add new resources or do something.
|
||||
var ent = gameState.getEntityById(evt.msg.newentity);
|
||||
|
||||
|
||||
if (ent === undefined)
|
||||
continue;
|
||||
|
||||
if (ent.getMetadata(PlayerID,"base") == this.ID)
|
||||
{
|
||||
if(ent.hasTerritoryInfluence())
|
||||
@ -219,7 +226,11 @@ BaseManager.prototype.checkEvents = function (gameState, events, queues) {
|
||||
if (evt.msg && evt.msg.entity)
|
||||
{
|
||||
var ent = gameState.getEntityById(evt.msg.entity);
|
||||
if (ent && ent.resourceSupplyAmount() && ent.owner() == 0)
|
||||
|
||||
if (ent === undefined)
|
||||
continue;
|
||||
|
||||
if (ent.resourceSupplyAmount() && ent.owner() == 0)
|
||||
this.assignResourceToDP(gameState,ent);
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +186,11 @@ HQ.prototype.checkEvents = function (gameState, events, queues) {
|
||||
if (evt.msg && evt.msg.entity)
|
||||
{
|
||||
var ent = gameState.getEntityById(evt.msg.entity);
|
||||
if (ent && ent.isOwn(PlayerID) && ent.getMetadata(PlayerID, "base") === -1)
|
||||
|
||||
if (ent === undefined)
|
||||
continue; // happens when this message is right before a "Destroy" one for the same entity.
|
||||
|
||||
if (ent.isOwn(PlayerID) && ent.getMetadata(PlayerID, "base") === -1)
|
||||
{
|
||||
// Okay so let's try to create a new base around this.
|
||||
var bID = uniqueIDBases;
|
||||
@ -213,7 +217,11 @@ HQ.prototype.checkEvents = function (gameState, events, queues) {
|
||||
if (evt.msg && evt.msg.newentity)
|
||||
{
|
||||
var ent = gameState.getEntityById(evt.msg.newentity);
|
||||
if (ent && ent.isOwn(PlayerID) && ent.getMetadata(PlayerID, "baseAnchor") == true)
|
||||
|
||||
if (ent === undefined)
|
||||
continue; // happens when this message is right before a "Destroy" one for the same entity.
|
||||
|
||||
if (ent.isOwn(PlayerID) && ent.getMetadata(PlayerID, "baseAnchor") == true)
|
||||
{
|
||||
var base = ent.getMetadata(PlayerID, "base");
|
||||
if (this.baseManagers[base].constructing)
|
||||
|
Loading…
Reference in New Issue
Block a user