newnet: Fix production queues.

Rename quantity variable which was used for two completely different things in a confusing manner. Disable stopping/resuming unsynchronised production and research.
master
Cyp 2010-02-23 18:43:18 +01:00
parent 073e367e20
commit 7eed990301
14 changed files with 120 additions and 110 deletions

View File

@ -21,14 +21,14 @@ Fix production completed and research completed sounds.
********************
* src/structure.c: *
********************
structPlaceDroid now sets ppsDroid to NULL. Check that that's ok with cbNewDroid. Since cbNewDroid is only called when the factory runs out of things to build, not every time a new droid is built, it smells like a giant hack, and maybe the droid can just be set to NULL.
Clean up structPlaceDroid. After which, the GAME_SECONDARY_ALL message type will be unused, and should be removed...
Check what validLocation is used for, make sure that putting delivery points under locations where buildings are going to be placed can't cause synch errors.
In destroyStruct, check that psTile->illumination can't affect the game state. Or make it consistent, so all players see the same scorch marks.
Allow holding/releasing/cancelling production.
*****************
* src/keybind.c *
*****************
@ -44,7 +44,14 @@ Check that this file doesn't modify droids directly...
******************
Check the researchResult function. Should a message be sent there, and if so, then should wait for it?
Allow holding/releasing research.
***************
* src/order.c *
***************
Just before transporterAddDroid, it changes the droid state directly. Should either not test for selectedPlayer, or should not change the droid state directly. See also: unloadTransporter.
*********************
* src/scriptfuncs.c *
*********************
Sanity check that this file doesn't do anything stupid, such as modifying the game state directly.

View File

@ -4458,7 +4458,7 @@ void deleteTemplateFromProduction(DROID_TEMPLATE *psTemplate, UBYTE player)
//power is returned by factoryProdAdjust()
if (psNextTemplate)
{
structSetManufacture(psStruct, psNextTemplate,psFactory->quantity);
structSetManufacture(psStruct, psNextTemplate);
}
else
{
@ -4485,9 +4485,8 @@ void deleteTemplateFromProduction(DROID_TEMPLATE *psTemplate, UBYTE player)
//not the production player, so check not being built in the factory for the template player
if (psFactory->psSubject == (BASE_STATS *)psTemplate)
{
//clear the factories subject and quantity
// Clear the factory's subject.
psFactory->psSubject = NULL;
psFactory->quantity = 0;
//return any accrued power
if (psFactory->powerAccrued)
{

View File

@ -7259,7 +7259,7 @@ BOOL loadSaveStructureV19(char *pFileData, UDWORD filesize, UDWORD numStructures
psFactory->capacity = 0;//capacity reset during module build (UBYTE)psSaveStructure->capacity;
//this is set up during module build - if the stats have changed it will also set up with the latest value
//psFactory->productionOutput = (UBYTE)psSaveStructure->output;
psFactory->quantity = (UBYTE)psSaveStructure->quantity;
psFactory->productionLoops = (UBYTE)psSaveStructure->quantity;
psFactory->timeStarted = psSaveStructure->droidTimeStarted;
psFactory->powerAccrued = psSaveStructure->powerAccrued;
psFactory->timeToBuild = psSaveStructure->timeToBuild;
@ -7667,7 +7667,7 @@ BOOL loadSaveStructureV(char *pFileData, UDWORD filesize, UDWORD numStructures,
psFactory->capacity = 0;//capacity reset during module build (UBYTE)psSaveStructure->capacity;
//this is set up during module build - if the stats have changed it will also set up with the latest value
//psFactory->productionOutput = (UBYTE)psSaveStructure->output;
psFactory->quantity = (UBYTE)psSaveStructure->quantity;
psFactory->productionLoops = (UBYTE)psSaveStructure->quantity;
psFactory->timeStarted = psSaveStructure->droidTimeStarted;
psFactory->powerAccrued = psSaveStructure->powerAccrued;
psFactory->timeToBuild = psSaveStructure->timeToBuild;
@ -7994,7 +7994,7 @@ BOOL writeStructFile(char *pFileName)
case REF_VTOL_FACTORY:
psFactory = ((FACTORY *)psCurr->pFunctionality);
psSaveStruct->capacity = psFactory->capacity;
psSaveStruct->quantity = psFactory->quantity;
psSaveStruct->quantity = psFactory->productionLoops;
psSaveStruct->droidTimeStarted = psFactory->timeStarted;
psSaveStruct->powerAccrued = psFactory->powerAccrued;
psSaveStruct->timeToBuild = psFactory->timeToBuild;

View File

@ -2335,7 +2335,6 @@ static void intRunStats(void)
ProductionRun = Quantity;
}
#endif
#ifdef INCLUDE_FACTORYLISTS
BASE_OBJECT *psOwner;
STRUCTURE *psStruct;
@ -2351,13 +2350,11 @@ static void intRunStats(void)
psFactory = (FACTORY *)psStruct->pFunctionality;
//adjust the loop button if necessary
if (psFactory->psSubject && psFactory->quantity)
if (psFactory->psSubject != NULL && psFactory->productionLoops != 0)
{
widgSetButtonState(psWScreen, IDSTAT_LOOP_BUTTON, WBUT_CLICKLOCK);
}
}
#endif
}
@ -2769,9 +2766,7 @@ static void intProcessStats(UDWORD id)
STRUCTURE *psStruct;
FLAG_POSITION *psFlag;
#ifdef INCLUDE_FACTORYLISTS
DROID_TEMPLATE *psNext;
#endif
ASSERT( widgGetFromID(psWScreen,IDOBJ_TABFORM) != NULL,"intProcessStats, missing form\n" );
@ -2789,7 +2784,6 @@ static void intProcessStats(UDWORD id)
/* deal with LMB clicks */
else
{
#ifdef INCLUDE_FACTORYLISTS
//manufacture works differently!
if(objMode == IOBJ_MANUFACTURE)
{
@ -2854,7 +2848,6 @@ static void intProcessStats(UDWORD id)
}
}
else
#endif
{
/* See if this was a click on an already selected stat */
psStats = objGetStatsFunc(psObjSelected);
@ -3017,8 +3010,7 @@ static void intProcessStats(UDWORD id)
{
factoryLoopAdjust(psStruct, false);
}
if (((FACTORY *)psStruct->pFunctionality)->psSubject &&
((FACTORY *)psStruct->pFunctionality)->quantity)
if (((FACTORY *)psStruct->pFunctionality)->psSubject != NULL && ((FACTORY *)psStruct->pFunctionality)->productionLoops != 0)
{
//lock the button
widgSetButtonState(psWScreen, IDSTAT_LOOP_BUTTON, WBUT_CLICKLOCK);
@ -5501,8 +5493,6 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats,
}
#endif
#ifdef INCLUDE_FACTORYLISTS
// Add the quantity slider ( if it's a factory ).
if(objMode == IOBJ_MANUFACTURE)
{
@ -5547,7 +5537,7 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats,
if ( psOwner != NULL )
{
psFactory = (FACTORY *)((STRUCTURE *)psOwner)->pFunctionality;
if (psFactory->psSubject && psFactory->quantity)
if (psFactory->psSubject != NULL && psFactory->productionLoops != 0)
{
widgSetButtonState(psWScreen, IDSTAT_LOOP_BUTTON, WBUT_CLICKLOCK);
}
@ -5586,10 +5576,6 @@ static BOOL intAddStats(BASE_STATS **ppsStatsList, UDWORD numStats,
sLabInit.pCallback = intAddProdQuantity;
}
#endif
/* Add the close button */
memset(&sButInit, 0, sizeof(W_BUTINIT));
@ -6269,7 +6255,6 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
"setManufactureStats: invalid Structure pointer" );
/* psStats might be NULL if the operation is canceled in the middle */
#ifdef INCLUDE_FACTORYLISTS
Structure = (STRUCTURE*)psObj;
//check to see if the factory was already building something
if (!((FACTORY *)Structure->pFunctionality)->psSubject)
@ -6278,13 +6263,12 @@ static BOOL setManufactureStats(BASE_OBJECT *psObj, BASE_STATS *psStats)
if (psStats != NULL)
{
/* Set the factory to build droid(s) */
if (!structSetManufacture(Structure, (DROID_TEMPLATE *)psStats, 1))
if (!structSetManufacture(Structure, (DROID_TEMPLATE *)psStats))
{
return false;
}
}
}
#endif
#ifdef INCLUDE_PRODSLIDER
if (ProductionRun == 0)
@ -6442,9 +6426,7 @@ static BOOL intAddCommand(DROID *psSelected)
static void intStatsRMBPressed(UDWORD id)
{
DROID_TEMPLATE *psStats;
#ifdef INCLUDE_FACTORYLISTS
DROID_TEMPLATE *psNext;
#endif
ASSERT( id - IDSTAT_START < numStatsListEntries,
"intStatsRMBPressed: Invalid structure stats id" );
@ -6454,7 +6436,6 @@ static void intStatsRMBPressed(UDWORD id)
psStats = (DROID_TEMPLATE *)ppsStatsList[id - IDSTAT_START];
//this now causes the production run to be decreased by one
#ifdef INCLUDE_FACTORYLISTS
ASSERT( psObjSelected != NULL,
"intStatsRMBPressed: Invalid structure pointer" );
@ -6512,7 +6493,7 @@ static void intStatsRMBPressed(UDWORD id)
}
}
}
#else
#if 0
// set the current Template
psCurrTemplate = apsDroidTemplates[selectedPlayer];
while (psStats != psCurrTemplate)

View File

@ -278,8 +278,6 @@ typedef enum {
//NOT ANYMORE! 10/08/98 AB
//#define INCLUDE_PRODSLIDER // Include quantity slider in manufacture window.
#define INCLUDE_FACTORYLISTS
extern INTMODE intMode;
/* The widget screen */

View File

@ -447,13 +447,13 @@ void intAddLoopQuantity(WIDGET *psWidget, W_CONTEXT *psContext)
{
FACTORY *psFactory = (FACTORY *)psStruct->pFunctionality;
if (psFactory->quantity == INFINITE_PRODUCTION)
if (psFactory->productionLoops == INFINITE_PRODUCTION)
{
sstrcpy(Label->aText, "");
}
else
{
snprintf(Label->aText, sizeof(Label->aText), "%02u", psFactory->quantity + DEFAULT_LOOP);
snprintf(Label->aText, sizeof(Label->aText), "%02u", psFactory->productionLoops + DEFAULT_LOOP);
}
Label->style &= ~WIDG_HIDDEN;
}
@ -1824,7 +1824,7 @@ void intDisplayNumber(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DECL_
if (psFactory && !psStruct->died)
{
Quantity = psFactory->quantity;
Quantity = psFactory->productionLoops;
}
}

View File

@ -1249,7 +1249,7 @@ static void structureSaveTagged(STRUCTURE *psStruct)
tagWriteEnter(0x0d, 1); // FACTORY GROUP
tagWrite(0x01, psFactory->capacity);
tagWrite(0x02, psFactory->quantity);
tagWrite(0x02, psFactory->productionLoops);
tagWrite(0x03, psFactory->loopsPerformed);
//tagWrite(0x04, psFactory->productionOutput); // not used in original code, recalculated instead
tagWrite(0x05, psFactory->powerAccrued);

View File

@ -165,7 +165,7 @@ extern BOOL sendBuildStarted (STRUCTURE *psStruct, DROID *psDroid);
extern BOOL SendDestroyStructure(STRUCTURE *s);
extern BOOL SendBuildFinished (STRUCTURE *psStruct);
extern BOOL sendLasSat (UBYTE player, STRUCTURE *psStruct, BASE_OBJECT *psObj);
void sendManufactureStatus (STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, UBYTE quantity);
void sendManufactureStatus (STRUCTURE *psStruct, DROID_TEMPLATE *psTempl);
// droids . multibot
extern BOOL SendDroid (const DROID_TEMPLATE* pTemplate, uint32_t x, uint32_t y, uint8_t player, uint32_t id, const INITIAL_DROID_ORDERS *initialOrders);

View File

@ -412,18 +412,20 @@ BOOL recvLasSat(NETQUEUE queue)
return true;
}
void sendManufactureStatus(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, UBYTE quantity)
void sendManufactureStatus(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl)
{
uint8_t player = psStruct->player;
uint32_t structId = psStruct->id;
uint32_t templateId = psTempl->multiPlayerID;
BOOL isManufacturing = psTempl != NULL;
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_MANUFACTURESTATUS);
NETuint8_t(&player);
NETuint32_t(&structId);
NETuint8_t(&quantity);
if (quantity != 0)
NETbool(&isManufacturing);
if (isManufacturing)
{
uint32_t templateId = psTempl->multiPlayerID;
NETuint32_t(&templateId);
}
NETend();
@ -434,15 +436,15 @@ void recvManufactureStatus(NETQUEUE queue)
uint8_t player = 0;
uint32_t structId = 0;
uint32_t templateId = 0;
uint8_t quantity = 0;
BOOL isManufacturing = 0;
STRUCTURE * psStruct;
DROID_TEMPLATE *psTempl = NULL;
NETbeginDecode(queue, GAME_MANUFACTURESTATUS);
NETuint8_t(&player);
NETuint32_t(&structId);
NETuint8_t(&quantity);
if (quantity != 0)
NETbool(&isManufacturing);
if (isManufacturing)
{
NETuint32_t(&templateId);
}
@ -455,7 +457,7 @@ void recvManufactureStatus(NETQUEUE queue)
return;
}
if (quantity != 0)
if (isManufacturing)
{
psTempl = IdToTemplate(templateId, player);
if (psTempl == NULL)
@ -466,6 +468,6 @@ void recvManufactureStatus(NETQUEUE queue)
}
turnOffMultiMsg(true);
structSetManufacture(psStruct, psTempl, quantity);
structSetManufacture(psStruct, psTempl);
turnOffMultiMsg(false);
}

View File

@ -1875,6 +1875,12 @@ void holdResearch(STRUCTURE *psBuilding)
ASSERT( psBuilding->pStructureType->type == REF_RESEARCH,
"holdResearch: structure not a research facility" );
if (bMultiMessages)
{
debug(LOG_WARNING, "TODO: holdResearch disabled in multiplayer.");
return;
}
psResFac = (RESEARCH_FACILITY *)psBuilding->pFunctionality;
if (psResFac->psSubject)
@ -1898,6 +1904,12 @@ void releaseResearch(STRUCTURE *psBuilding)
ASSERT( psBuilding->pStructureType->type == REF_RESEARCH,
"releaseResearch: structure not a research facility" );
if (bMultiMessages)
{
debug(LOG_WARNING, "TODO: releaseResearch disabled in multiplayer.");
return;
}
psResFac = (RESEARCH_FACILITY *)psBuilding->pFunctionality;
if (psResFac->psSubject && psResFac->timeStartHold)

View File

@ -1551,7 +1551,11 @@ BOOL scrBuildDroid(void)
ASSERT_OR_RETURN(false, validTemplateForFactory(psTemplate, psFactory), "Invalid template - %s for factory - %s",
psTemplate->aName, psFactory->pStructureType->pName);
structSetManufacture(psFactory, psTemplate, (UBYTE)productionRun);
if (productionRun != 1)
{
debug(LOG_WARNING, "A script is trying to build a different number (%d) than 1 droid.", productionRun);
}
structSetManufacture(psFactory, psTemplate);
return true;
}
@ -10673,6 +10677,7 @@ BOOL scrPursueResearch(void)
pResearch = (asResearch + foundIndex);
pPlayerRes = asPlayerResList[player]+ foundIndex;
psResFacilty->psSubject = (BASE_STATS*)pResearch; //set the subject up
debug(LOG_ERROR, "FIXME! Not synchronised! And probably duplicate code!");
if (IsResearchCancelled(pPlayerRes))
{

View File

@ -1314,7 +1314,7 @@ BOOL structureRepair(STRUCTURE *psStruct, DROID *psDroid, int buildPoints)
}
/* Set the type of droid for a factory to build */
BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, UBYTE quantity)
BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl)
{
FACTORY *psFact;
@ -1328,7 +1328,7 @@ BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, UBYTE qu
if (bMultiMessages)
{
sendManufactureStatus(psStruct, psTempl, quantity);
sendManufactureStatus(psStruct, psTempl);
return true; // Wait for our message before doing anything.
}
@ -1343,7 +1343,7 @@ BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, UBYTE qu
if (psStruct->player != selectedPlayer)
{
//set quantity to produce
psFact->quantity = quantity;
psFact->productionLoops = 1;
}
psFact->timeStarted = ACTION_START_TIME;//gameTime;
@ -1923,7 +1923,9 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
++psBuilding->pFunctionality->factory.capacity;
bUpgraded = true;
//put any production on hold
turnOffMultiMsg(true);
holdProduction(psBuilding);
turnOffMultiMsg(false);
//quick check not trying to add too much
ASSERT_OR_RETURN(NULL, psBuilding->pFunctionality->factory.productionOutput +
@ -1994,7 +1996,9 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
if (psBuilding->pFunctionality->researchFacility.psSubject)
{
//cancel the topic
turnOffMultiMsg(true);
holdResearch(psBuilding);
turnOffMultiMsg(false);
}
//need to change which IMD is used for player 0
@ -2861,7 +2865,6 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
DROID *psDroid;
BASE_OBJECT *psChosenObjs[STRUCT_MAXWEAPS] = {NULL};
BASE_OBJECT *psChosenObj = NULL;
UBYTE Quantity;
SDWORD iDt;
FACTORY *psFactory;
REPAIR_FACILITY *psRepairFac = NULL;
@ -2870,9 +2873,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
BOOL bFinishAction,bDroidPlaced;
WEAPON_STATS *psWStats;
SDWORD xdiff,ydiff, mindist, currdist;
#ifdef INCLUDE_FACTORYLISTS
DROID_TEMPLATE *psNextTemplate;
#endif
UDWORD i;
float secondsToBuild, powerNeeded;
int secondsElapsed;
@ -3445,7 +3446,6 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
else if (structureMode == REF_FACTORY)
{
psFactory = &psStructure->pFunctionality->factory;
Quantity = psFactory->quantity;
//if on hold don't do anything
if (psFactory->timeStartHold)
@ -3524,50 +3524,36 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
//reset the start time
psFactory->timeStarted = ACTION_START_TIME;
psFactory->psSubject = NULL;
//decrement the quantity to manufacture if not set to infinity
/*if (Quantity && Quantity != NON_STOP_PRODUCTION)
{
psFactory->quantity--;
Quantity--;
}*/
// If quantity not 0 then kick of another manufacture.
turnOffMultiMsg(true); // Do instantly, since quantity is synchronised.
structSetManufacture(psStructure, (DROID_TEMPLATE *)pSubject);
turnOffMultiMsg(false);
//script callback, must be called after factory was flagged as idle
if (bDroidPlaced)
{
cbNewDroid(psStructure, psDroid);
}
#ifdef INCLUDE_FACTORYLISTS
//next bit for productionPlayer only
if (productionPlayer == psStructure->player)
{
psNextTemplate = factoryProdUpdate(psStructure, (DROID_TEMPLATE *)pSubject);
psFactory->psSubject = NULL;
structSetManufacture(psStructure, psNextTemplate, Quantity);
structSetManufacture(psStructure, psNextTemplate);
if (!psNextTemplate)
{
//nothing more to manufacture - reset the Subject and Tab on HCI Form
intManufactureFinished(psStructure);
//script callback, must be called after factory was flagged as idle
if(bDroidPlaced)
{
cbNewDroid(psStructure, psDroid);
}
}
}
else
#endif
{
//decrement the quantity to manufacture if not set to infinity
if (Quantity && Quantity != NON_STOP_PRODUCTION)
{
psFactory->quantity--;
Quantity--;
}
// If quantity not 0 then kick of another manufacture.
psFactory->psSubject = NULL;
structSetManufacture(psStructure, (DROID_TEMPLATE*)pSubject,Quantity);
if (Quantity == 0)
{
//when quantity = 0, reset the Subject and Tab on HCI Form
intManufactureFinished(psStructure);
//script callback, must be called after factory was flagged as idle
if(bDroidPlaced)
{
cbNewDroid(psStructure, psDroid);
}
}
}
}
@ -6012,13 +5998,17 @@ void buildingComplete(STRUCTURE *psBuilding)
case REF_RESEARCH:
intCheckResearchButton();
//this deals with researc facilities that are upgraded whilst mid-research
turnOffMultiMsg(true);
releaseResearch(psBuilding);
turnOffMultiMsg(false);
break;
case REF_FACTORY:
case REF_CYBORG_FACTORY:
case REF_VTOL_FACTORY:
//this deals with factories that are upgraded whilst mid-production
turnOffMultiMsg(true);
releaseProduction(psBuilding);
turnOffMultiMsg(false);
break;
case REF_SAT_UPLINK:
revealAll(psBuilding->player);
@ -6922,6 +6912,12 @@ void cancelProduction(STRUCTURE *psBuilding)
ASSERT_OR_RETURN( , StructIsFactory(psBuilding), "structure not a factory");
if (bMultiMessages)
{
debug(LOG_WARNING, "TODO: cancelProduction disabled in multiplayer.");
return;
}
psFactory = &psBuilding->pFunctionality->factory;
//check its the correct factory
@ -6947,7 +6943,7 @@ void cancelProduction(STRUCTURE *psBuilding)
MAX_PROD_RUN);
//clear the factories subject and quantity
psFactory->psSubject = NULL;
psFactory->quantity = 0;
psFactory->productionLoops = 0;
//tell the interface
intManufactureFinished(psBuilding);
}
@ -6962,6 +6958,12 @@ void holdProduction(STRUCTURE *psBuilding)
ASSERT_OR_RETURN( , StructIsFactory(psBuilding), "structure not a factory");
if (bMultiMessages)
{
debug(LOG_WARNING, "TODO: holdProduction disabled in multiplayer.");
return;
}
psFactory = &psBuilding->pFunctionality->factory;
if (psFactory->psSubject)
@ -6984,6 +6986,12 @@ void releaseProduction(STRUCTURE *psBuilding)
ASSERT_OR_RETURN( , StructIsFactory(psBuilding), "structure not a factory");
if (bMultiMessages)
{
debug(LOG_WARNING, "TODO: releaseProduction disabled in multiplayer.");
return;
}
psFactory = &psBuilding->pFunctionality->factory;
if (psFactory->psSubject && psFactory->timeStartHold)
@ -7017,7 +7025,7 @@ 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++)
{
if (asProductionRun[factoryType][factoryInc][inc].psTemplate == psTemplate)
if (asProductionRun[factoryType][factoryInc][inc].psTemplate != NULL && asProductionRun[factoryType][factoryInc][inc].psTemplate->multiPlayerID == psTemplate->multiPlayerID)
{
asProductionRun[factoryType][factoryInc][inc].built++;
if (asProductionRun[factoryType][factoryInc][inc].built <
@ -7040,12 +7048,12 @@ DROID_TEMPLATE * factoryProdUpdate(STRUCTURE *psStructure, DROID_TEMPLATE *psTem
}
/*If you've got here there's nothing left to build unless factory is
on loop production*/
if (psFactory->quantity)
if (psFactory->productionLoops != 0)
{
//reduce the loop count if not infinite
if (psFactory->quantity != INFINITE_PRODUCTION)
if (psFactory->productionLoops != INFINITE_PRODUCTION)
{
psFactory->quantity--;
psFactory->productionLoops--;
}
//need to reset the quantity built for each entry in the production list
@ -7057,7 +7065,7 @@ DROID_TEMPLATE * factoryProdUpdate(STRUCTURE *psStructure, DROID_TEMPLATE *psTem
}
}
//get the first to build again
return (factoryProdUpdate(psStructure, NULL));
return factoryProdUpdate(psStructure, NULL);
}
//if got to here then nothing left to produce so clear the array
memset(asProductionRun[factoryType][factoryInc], 0,
@ -7168,7 +7176,7 @@ void factoryProdAdjust(STRUCTURE *psStructure, DROID_TEMPLATE *psTemplate, BOOL
if (inc == MAX_PROD_RUN)
{
//must have cancelled eveything - so tell the struct
psFactory->quantity = 0;
psFactory->productionLoops = 0;
}
}
}
@ -7384,31 +7392,31 @@ void factoryLoopAdjust(STRUCTURE *psStruct, BOOL add)
if (add)
{
//check for wrapping to infinite production
if (psFactory->quantity == MAX_IN_RUN)
if (psFactory->productionLoops == MAX_IN_RUN)
{
psFactory->quantity = 0;
psFactory->productionLoops = 0;
}
else
{
//increment the count
psFactory->quantity++;
psFactory->productionLoops++;
//check for limit - this caters for when on infinite production and want to wrap around
if (psFactory->quantity > MAX_IN_RUN)
if (psFactory->productionLoops > MAX_IN_RUN)
{
psFactory->quantity = INFINITE_PRODUCTION;
psFactory->productionLoops = INFINITE_PRODUCTION;
}
}
}
else
{
//decrement the count
if (psFactory->quantity == 0)
if (psFactory->productionLoops == 0)
{
psFactory->quantity = INFINITE_PRODUCTION;
psFactory->productionLoops = INFINITE_PRODUCTION;
}
else
{
psFactory->quantity--;
psFactory->productionLoops--;
}
}
}

View File

@ -122,8 +122,7 @@ extern void structureBuild(STRUCTURE *psStructure, DROID *psDroid, int buildPoin
extern void structureDemolish(STRUCTURE *psStructure, DROID *psDroid, int buildPoints);
extern BOOL structureRepair(STRUCTURE *psStruct, DROID *psDroid, int buildPoints);
/* Set the type of droid for a factory to build */
extern BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl,
UBYTE quantity);
extern BOOL structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl);
//temp test function for creating structures at the start of the game
extern void createTestStructures(void);

View File

@ -190,8 +190,7 @@ typedef struct _factory
UBYTE capacity; /* The max size of body the factory
can produce*/
UBYTE quantity; /* The number of droids to produce OR for
selectedPlayer, how many loops to perform*/
uint8_t productionLoops; ///< Number of loops to perform. Not synchronised, and only meaningful for selectedPlayer.
UBYTE loopsPerformed; /* how many times the loop has been performed*/
//struct _propulsion_types* propulsionType;
//UBYTE propulsionType; /* The type of propulsion the facility