Fix bug introduced in r7737 where we would iterate wrongly over uninitialized effects during

shutdown, and badly initialize new nodes in the effect chunks. This caused a counter underflow
and crash during any game save. This closes ticket:640 for real this time.


git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7801 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2009-06-21 07:38:56 +00:00 committed by Git SVN Gateway
parent fc78b8326e
commit 63c94de726
1 changed files with 8 additions and 12 deletions

View File

@ -266,7 +266,6 @@ static void initEffectPool(EFFECT *first, EFFECT *last)
EFFECT *it;
for (it = first; it < last; it++)
{
killEffect(it); // We must clear the fire bit on tiles.
// We do not need a double-linked-list for inactiveeffects, since we always pick from the front:
it->prev = NULL;
it->next = it+1;
@ -370,24 +369,21 @@ static void Effect_free(void *self)
/* Adjust counts */
inactiveList.num++;
ASSERT_OR_RETURN(, activeList.num > 0, "Underflow");
activeList.num--;
}
void shutdownEffectsSystem(void)
{
EffectChunk *chunk;
int i = 0;
EFFECT *eff;
for (chunk = chunkList.first; chunk != NULL;)
/* Traverse the list */
for (eff = activeList.first; eff;)
{
EffectChunk *chunkNext = chunk->next;
for (i=0; i < EFFECT_CHUNK_SIZE; i++)
{
// clear the blasted fire effects!
killEffect(&chunk->effects[i]);
}
free(chunk);
chunk = chunkNext;
EFFECT *effNext = eff->next;
killEffect(eff);
eff = effNext;
}
chunkList.first = NULL;
chunkList.last = NULL;