Fix bug #12400: assert in droid.c (r6104). First issue is that we check against DROID_MAXWEAPS on

a structure, which has potentially one more weapon that this. Second and more serious issue is that 
if a building is demolished, it will no longer be updated in regards to dead targets.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6136 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-10-12 09:48:52 +00:00
parent dcc87a0973
commit 4f33dfa994
1 changed files with 10 additions and 11 deletions

View File

@ -2762,14 +2762,6 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
CHECK_STRUCTURE(psStructure);
for (i = 0; i < DROID_MAXWEAPS; i++)
{
if (psStructure->psTarget[i] && psStructure->psTarget[i]->died)
{
setStructureTarget(psStructure, NULL, i);
}
}
// Will go out into a building EVENT stats/text file
/* Spin round yer sensors! */
if (psStructure->numWeaps == 0)
@ -3612,6 +3604,16 @@ void structureUpdate(STRUCTURE *psBuilding)
UDWORD widthScatter,breadthScatter;
UDWORD emissionInterval, iPointsToAdd, iPointsRequired;
Vector3i dv;
int i;
// Remove invalid targets. This must be done each frame.
for (i = 0; i < STRUCT_MAXWEAPS; i++)
{
if (psBuilding->psTarget[i] && psBuilding->psTarget[i]->died)
{
setStructureTarget(psBuilding, NULL, i);
}
}
//update the manufacture/research of the building once complete
if (psBuilding->status == SS_BUILT)
@ -3619,9 +3621,6 @@ void structureUpdate(STRUCTURE *psBuilding)
aiUpdateStructure(psBuilding);
}
// must be after aiUpdateStructure because this is where we clean out dead targets
CHECK_STRUCTURE(psBuilding);
if(psBuilding->status!=SS_BUILT)
{
if(psBuilding->selected)