Fix infinite loop when modifying a template in infinite production.

If a factory was set to infinite production, but no templates were in the production queue, there was an infinite loop looking for something to produce.
master
Cyp 2010-10-23 08:33:58 +02:00
parent 29413f5a01
commit db58c7c5f9
1 changed files with 8 additions and 0 deletions

View File

@ -7009,6 +7009,7 @@ DROID_TEMPLATE * factoryProdUpdate(STRUCTURE *psStructure, DROID_TEMPLATE *psTem
{
UDWORD inc, factoryType, factoryInc;
FACTORY *psFactory;
bool somethingInQueue = false;
CHECK_STRUCTURE(psStructure);
ASSERT_OR_RETURN(NULL, psStructure->player == productionPlayer, "%s called for incorrect player", __FUNCTION__);
@ -7022,6 +7023,8 @@ DROID_TEMPLATE * factoryProdUpdate(STRUCTURE *psStructure, DROID_TEMPLATE *psTem
//find the entry in the array for this template
for (inc=0; inc < MAX_PROD_RUN; inc++)
{
somethingInQueue = somethingInQueue || asProductionRun[factoryType][factoryInc][inc].quantity != 0;
if (asProductionRun[factoryType][factoryInc][inc].psTemplate != NULL && asProductionRun[factoryType][factoryInc][inc].psTemplate->multiPlayerID == psTemplate->multiPlayerID)
{
asProductionRun[factoryType][factoryInc][inc].built++;
@ -7043,6 +7046,11 @@ DROID_TEMPLATE * factoryProdUpdate(STRUCTURE *psStructure, DROID_TEMPLATE *psTem
return asProductionRun[factoryType][factoryInc][inc].psTemplate;
}
}
// Check that we aren't looping doing nothing.
if (!somethingInQueue)
{
psFactory->productionLoops = 0; // Don't do nothing infinitely many times.
}
/*If you've got here there's nothing left to build unless factory is
on loop production*/
if (psFactory->productionLoops != 0)