Fixes crash issue when psWeapStats is still set to NULL (on init), when this pointer was referenced again.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6733 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
f0d0bd7ebe
commit
ca447ad076
19
src/action.c
19
src/action.c
|
@ -1525,15 +1525,18 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
actionAddVtolAttackRun( psDroid );
|
actionAddVtolAttackRun( psDroid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if the vtol is far enough away head for the target again
|
// in case psWeapStats is still NULL
|
||||||
else if (rangeSq > (SDWORD)(psWeapStats->longRange * psWeapStats->longRange))
|
else if (psWeapStats)
|
||||||
{
|
{ // if the vtol is far enough away head for the target again
|
||||||
// don't do another attack run if already heading for the target
|
if (rangeSq > (SDWORD)(psWeapStats->longRange * psWeapStats->longRange))
|
||||||
const int xdiff = (SDWORD)psDroid->sMove.DestinationX - (SDWORD)psDroid->psActionTarget[0]->pos.x;
|
|
||||||
const int ydiff = (SDWORD)psDroid->sMove.DestinationY - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
|
||||||
if ((xdiff*xdiff + ydiff*ydiff) > (VTOL_ATTACK_TARDIST*VTOL_ATTACK_TARDIST))
|
|
||||||
{
|
{
|
||||||
moveDroidToDirect(psDroid, psDroid->psActionTarget[0]->pos.x,psDroid->psActionTarget[0]->pos.y);
|
// don't do another attack run if already heading for the target
|
||||||
|
const int xdiff = (SDWORD)psDroid->sMove.DestinationX - (SDWORD)psDroid->psActionTarget[0]->pos.x;
|
||||||
|
const int ydiff = (SDWORD)psDroid->sMove.DestinationY - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
||||||
|
if ((xdiff*xdiff + ydiff*ydiff) > (VTOL_ATTACK_TARDIST*VTOL_ATTACK_TARDIST))
|
||||||
|
{
|
||||||
|
moveDroidToDirect(psDroid, psDroid->psActionTarget[0]->pos.x,psDroid->psActionTarget[0]->pos.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue