When playing Mayhem mode, burning scavengers can crash (or rather, lead to assert failure)

the game because they may have nowhere to run when burning, and may trigger checks because 
they die while doing orders ("burn out"). The former should be properly fixed in scripts 
by always setting retreat coordinates, and the latter is rather bad design, but not 
changing it now.  Close bug #296. Reviewed by Gerard.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6820 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-03-08 17:57:44 +00:00
parent 7a9da735e2
commit 3905de35cb
4 changed files with 28 additions and 4 deletions

View File

@ -875,8 +875,11 @@ void aiUpdateDroid(DROID *psDroid)
SECONDARY_STATE state;
BOOL lookForTarget,updateTarget;
ASSERT( psDroid != NULL,
"updateUnitAI: invalid Unit pointer" );
ASSERT(psDroid != NULL, "Invalid droid pointer");
if (!psDroid || isDead((BASE_OBJECT *)psDroid))
{
return;
}
// HACK: we always want to update orders when NOT running a MP game,
// and we don't want to update when the droid belongs to another human player

View File

@ -854,8 +854,12 @@ void droidUpdate(DROID *psDroid)
// ai update droid
aiUpdateDroid(psDroid);
// update the droids order
// Update the droids order. The droid may be killed here due to burn out.
orderUpdateDroid(psDroid);
if (isDead((BASE_OBJECT *)psDroid))
{
return; // FIXME: Workaround for babarians that were burned to death
}
// update the action of the droid
actionUpdateDroid(psDroid);
@ -977,6 +981,12 @@ void droidUpdate(DROID *psDroid)
}
}
// At this point, the droid may be dead due to burn damage.
if (isDead((BASE_OBJECT *)psDroid))
{
return;
}
droidUpdateRecoil(psDroid);
calcDroidIllumination(psDroid);

View File

@ -2159,7 +2159,7 @@ static void moveUpdateDroidPos( DROID *psDroid, float dx, float dy )
CHECK_DROID(psDroid);
if (psDroid->sMove.Status == MOVEPAUSE)
if (psDroid->sMove.Status == MOVEPAUSE || isDead((BASE_OBJECT *)psDroid))
{
// don't actually move if the move is paused
return;

View File

@ -291,6 +291,11 @@ void orderUpdateDroid(DROID *psDroid)
// check for died objects in the list
orderCheckList(psDroid);
if (isDead((BASE_OBJECT *)psDroid))
{
return;
}
switch (psDroid->order)
{
case DORDER_NONE:
@ -1734,6 +1739,12 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
psDroid->orderX = (UWORD)asRunData[psDroid->player].sPos.x;
psDroid->orderY = (UWORD)asRunData[psDroid->player].sPos.y;
}
if (psDroid->orderX == 0 || psDroid->orderY)
{
// We have still not managed to find a valid place to run.
objTrace(psDroid->id, "Wants to run, but has no designated retreat point - standing still.");
break;
}
actionDroidLoc(psDroid, DACTION_MOVE, psDroid->orderX,psDroid->orderY);
break;
case DORDER_DESTRUCT: