Try another fix for bug #11293 that may work better for networked games.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4139 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-03-17 23:05:17 +00:00
parent cc70d235ac
commit 51d5b30e3e
1 changed files with 7 additions and 5 deletions

View File

@ -293,7 +293,7 @@ void runLimitScreen(void)
// //////////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////////
void createLimitSet(void) void createLimitSet(void)
{ {
UDWORD i, numchanges = 0, bufSize; UDWORD i, numchanges = 0, bufSize, idx = 0;
MULTISTRUCTLIMITS *pEntry; MULTISTRUCTLIMITS *pEntry;
// Free the old set if required // Free the old set if required
@ -315,7 +315,7 @@ void createLimitSet(void)
} }
// Allocate some memory for the changes // Allocate some memory for the changes
bufSize = numStructureStats * sizeof(MULTISTRUCTLIMITS); bufSize = numchanges * sizeof(MULTISTRUCTLIMITS);
pEntry = malloc(bufSize); pEntry = malloc(bufSize);
memset(pEntry, 255, bufSize); memset(pEntry, 255, bufSize);
@ -325,8 +325,10 @@ void createLimitSet(void)
{ {
if (asStructLimits[0][i].limit != LOTS_OF) if (asStructLimits[0][i].limit != LOTS_OF)
{ {
pEntry[i].id = i; ASSERT(idx < numchanges, "Bad number of changed limits");
pEntry[i].limit = asStructLimits[0][i].limit; pEntry[idx].id = i;
pEntry[idx].limit = asStructLimits[0][i].limit;
idx++;
} }
} }
@ -348,7 +350,7 @@ void applyLimitSet(void)
} }
// Get the limits and decode // Get the limits and decode
for (i = 0; i < numStructureStats; i++) for (i = 0; i < ingame.numStructureLimits; i++)
{ {
UBYTE id = pEntry[i].id; UBYTE id = pEntry[i].id;