Remove the aiUpdateMissionStructure function, and add a bool as parameter to aiUpdateStructure so that it can perform those tasks.
parent
79af9ea1e0
commit
2597f3b47a
|
@ -370,7 +370,7 @@ GAMECODE gameLoop(void)
|
||||||
{
|
{
|
||||||
/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway */
|
/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway */
|
||||||
psNBuilding = psCBuilding->psNext;
|
psNBuilding = psCBuilding->psNext;
|
||||||
structureUpdate(psCBuilding);
|
structureUpdate(psCBuilding, false);
|
||||||
//set animation flag
|
//set animation flag
|
||||||
if (psCBuilding->pStructureType->type == REF_HQ &&
|
if (psCBuilding->pStructureType->type == REF_HQ &&
|
||||||
psCBuilding->status == SS_BUILT)
|
psCBuilding->status == SS_BUILT)
|
||||||
|
@ -394,7 +394,7 @@ GAMECODE gameLoop(void)
|
||||||
{
|
{
|
||||||
/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway. It shouldn't do since its not even on the map!*/
|
/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway. It shouldn't do since its not even on the map!*/
|
||||||
psNBuilding = psCBuilding->psNext;
|
psNBuilding = psCBuilding->psNext;
|
||||||
missionStructureUpdate(psCBuilding);
|
structureUpdate(psCBuilding, true); // update for mission
|
||||||
if (psCBuilding->pStructureType->type == REF_HQ &&
|
if (psCBuilding->pStructureType->type == REF_HQ &&
|
||||||
psCBuilding->status == SS_BUILT)
|
psCBuilding->status == SS_BUILT)
|
||||||
{
|
{
|
||||||
|
|
267
src/mission.c
267
src/mission.c
|
@ -169,7 +169,6 @@ static void endMissionExpandLimbo(void);
|
||||||
static void saveMissionData(void);
|
static void saveMissionData(void);
|
||||||
static void restoreMissionData(void);
|
static void restoreMissionData(void);
|
||||||
static void saveCampaignData(void);
|
static void saveCampaignData(void);
|
||||||
static void aiUpdateMissionStructure(STRUCTURE *psStructure);
|
|
||||||
static void missionResetDroids(void);
|
static void missionResetDroids(void);
|
||||||
static void saveMissionLimboData(void);
|
static void saveMissionLimboData(void);
|
||||||
static void restoreMissionLimboData(void);
|
static void restoreMissionLimboData(void);
|
||||||
|
@ -1635,272 +1634,6 @@ void resetLimboMission(void)
|
||||||
mission.type = LDS_EXPAND;
|
mission.type = LDS_EXPAND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The AI update routine for all Structures left back at base during a Mission*/
|
|
||||||
void aiUpdateMissionStructure(STRUCTURE *psStructure)
|
|
||||||
{
|
|
||||||
BASE_STATS *pSubject = NULL;
|
|
||||||
UDWORD pointsToAdd;
|
|
||||||
PLAYER_RESEARCH *pPlayerRes = asPlayerResList[psStructure->player];
|
|
||||||
UDWORD structureMode = 0;
|
|
||||||
DROID *psNewDroid;
|
|
||||||
UBYTE Quantity;
|
|
||||||
FACTORY *psFactory;
|
|
||||||
RESEARCH_FACILITY *psResFacility;
|
|
||||||
#ifdef INCLUDE_FACTORYLISTS
|
|
||||||
DROID_TEMPLATE *psNextTemplate;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ASSERT( psStructure != NULL,
|
|
||||||
"aiUpdateMissionStructure: invalid Structure pointer" );
|
|
||||||
|
|
||||||
ASSERT( (psStructure->pStructureType->type == REF_FACTORY ||
|
|
||||||
psStructure->pStructureType->type == REF_CYBORG_FACTORY ||
|
|
||||||
psStructure->pStructureType->type == REF_VTOL_FACTORY ||
|
|
||||||
psStructure->pStructureType->type == REF_RESEARCH),
|
|
||||||
"aiUpdateMissionStructure: Structure is not a Factory or Research Facility" );
|
|
||||||
|
|
||||||
//only interested if the Structure "does" something!
|
|
||||||
if (psStructure->pFunctionality == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
accruePower((BASE_OBJECT *)psStructure);
|
|
||||||
|
|
||||||
//determine the Subject
|
|
||||||
switch (psStructure->pStructureType->type)
|
|
||||||
{
|
|
||||||
case REF_RESEARCH:
|
|
||||||
{
|
|
||||||
pSubject = ((RESEARCH_FACILITY*)psStructure->pFunctionality)->psSubject;
|
|
||||||
structureMode = REF_RESEARCH;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case REF_FACTORY:
|
|
||||||
case REF_CYBORG_FACTORY:
|
|
||||||
case REF_VTOL_FACTORY:
|
|
||||||
{
|
|
||||||
pSubject = ((FACTORY*)psStructure->pFunctionality)->psSubject;
|
|
||||||
structureMode = REF_FACTORY;
|
|
||||||
//check here to see if the factory's commander has died
|
|
||||||
if (((FACTORY*)psStructure->pFunctionality)->psCommander &&
|
|
||||||
((FACTORY*)psStructure->pFunctionality)->psCommander->died)
|
|
||||||
{
|
|
||||||
//remove the commander from the factory
|
|
||||||
assignFactoryCommandDroid(psStructure, NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pSubject != NULL)
|
|
||||||
{
|
|
||||||
//if subject is research...
|
|
||||||
if (structureMode == REF_RESEARCH)
|
|
||||||
{
|
|
||||||
psResFacility = (RESEARCH_FACILITY*)psStructure->pFunctionality;
|
|
||||||
|
|
||||||
//if on hold don't do anything
|
|
||||||
if (psResFacility->timeStartHold)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pPlayerRes += (pSubject->ref - REF_RESEARCH_START);
|
|
||||||
//check research has not already been completed by another structure
|
|
||||||
if (IsResearchCompleted(pPlayerRes)==0)
|
|
||||||
{
|
|
||||||
//check to see if enough power to research has accrued
|
|
||||||
if (psResFacility->powerAccrued < ((RESEARCH *)pSubject)->researchPower)
|
|
||||||
{
|
|
||||||
//wait until enough power
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (psResFacility->timeStarted == ACTION_START_TIME)
|
|
||||||
{
|
|
||||||
//set the time started
|
|
||||||
psResFacility->timeStarted = gameTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointsToAdd = (psResFacility->researchPoints * (gameTime -
|
|
||||||
psResFacility->timeStarted)) / GAME_TICKS_PER_SEC;
|
|
||||||
|
|
||||||
//check if Research is complete
|
|
||||||
|
|
||||||
//if ((pointsToAdd + pPlayerRes->currentPoints) > psResFacility->
|
|
||||||
// timeToResearch)
|
|
||||||
if ((pointsToAdd + pPlayerRes->currentPoints) > (
|
|
||||||
(RESEARCH *)pSubject)->researchPoints)
|
|
||||||
|
|
||||||
{
|
|
||||||
//store the last topic researched - if its the best
|
|
||||||
if (psResFacility->psBestTopic == NULL)
|
|
||||||
{
|
|
||||||
psResFacility->psBestTopic = psResFacility->psSubject;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (((RESEARCH *)psResFacility->psSubject)->researchPoints >
|
|
||||||
((RESEARCH *)psResFacility->psBestTopic)->researchPoints)
|
|
||||||
{
|
|
||||||
psResFacility->psSubject = psResFacility->psSubject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
psResFacility->psSubject = NULL;
|
|
||||||
intResearchFinished(psStructure);
|
|
||||||
researchResult(pSubject->ref - REF_RESEARCH_START,
|
|
||||||
psStructure->player, true, psStructure);
|
|
||||||
//check if this result has enabled another topic
|
|
||||||
intCheckResearchButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//cancel this Structure's research since now complete
|
|
||||||
psResFacility->psSubject = NULL;
|
|
||||||
intResearchFinished(psStructure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//check for manufacture
|
|
||||||
else if (structureMode == REF_FACTORY)
|
|
||||||
{
|
|
||||||
psFactory = (FACTORY *)psStructure->pFunctionality;
|
|
||||||
Quantity = psFactory->quantity;
|
|
||||||
|
|
||||||
//if on hold don't do anything
|
|
||||||
if (psFactory->timeStartHold)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (psFactory->timeStarted == ACTION_START_TIME)
|
|
||||||
// {
|
|
||||||
// // also need to check if a command droid's group is full
|
|
||||||
// if ( ( psFactory->psCommander != NULL ) &&
|
|
||||||
// ( grpNumMembers( psFactory->psCommander->psGroup ) >=
|
|
||||||
// cmdDroidMaxGroup( psFactory->psCommander ) ) )
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(CheckHaltOnMaxUnitsReached(psStructure) == true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//check enough power has accrued to build the droid
|
|
||||||
if (psFactory->powerAccrued < ((DROID_TEMPLATE *)pSubject)->
|
|
||||||
powerPoints)
|
|
||||||
{
|
|
||||||
//wait until enough power
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*must be enough power so subtract that required to build*/
|
|
||||||
if (psFactory->timeStarted == ACTION_START_TIME)
|
|
||||||
{
|
|
||||||
//set the time started
|
|
||||||
psFactory->timeStarted = gameTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointsToAdd = (gameTime - psFactory->timeStarted) /
|
|
||||||
GAME_TICKS_PER_SEC;
|
|
||||||
|
|
||||||
//check for manufacture to be complete
|
|
||||||
if (pointsToAdd > psFactory->timeToBuild)
|
|
||||||
{
|
|
||||||
//build droid - store in mission list
|
|
||||||
psNewDroid = buildMissionDroid((DROID_TEMPLATE *)pSubject,
|
|
||||||
psStructure->pos.x, psStructure->pos.y, psStructure->player);
|
|
||||||
|
|
||||||
if (!psNewDroid)
|
|
||||||
{
|
|
||||||
//if couldn't build then cancel the production
|
|
||||||
Quantity = 0;
|
|
||||||
psFactory->psSubject = NULL;
|
|
||||||
intManufactureFinished(psStructure);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (psStructure->player == selectedPlayer)
|
|
||||||
{
|
|
||||||
intRefreshScreen(); // update the interface.
|
|
||||||
}
|
|
||||||
|
|
||||||
setDroidBase(psNewDroid, psStructure);
|
|
||||||
|
|
||||||
//reset the start time
|
|
||||||
psFactory->timeStarted = ACTION_START_TIME;
|
|
||||||
psFactory->powerAccrued = 0;
|
|
||||||
|
|
||||||
#ifdef INCLUDE_FACTORYLISTS
|
|
||||||
//next bit for productionPlayer only
|
|
||||||
if (productionPlayer == psStructure->player)
|
|
||||||
{
|
|
||||||
psNextTemplate = factoryProdUpdate(psStructure,
|
|
||||||
(DROID_TEMPLATE *)pSubject);
|
|
||||||
if (psNextTemplate)
|
|
||||||
{
|
|
||||||
structSetManufacture(psStructure, psNextTemplate,Quantity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//nothing more to manufacture - reset the Subject and Tab on HCI Form
|
|
||||||
psFactory->psSubject = NULL;
|
|
||||||
intManufactureFinished(psStructure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
//decrement the quantity to manufacture if not set to infinity
|
|
||||||
if (Quantity != NON_STOP_PRODUCTION)
|
|
||||||
{
|
|
||||||
psFactory->quantity--;
|
|
||||||
Quantity--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If quantity not 0 then kick of another manufacture.
|
|
||||||
if(Quantity)
|
|
||||||
{
|
|
||||||
// Manufacture another.
|
|
||||||
structSetManufacture(psStructure, (DROID_TEMPLATE*)pSubject,Quantity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//when quantity = 0, reset the Subject and Tab on HCI Form
|
|
||||||
psFactory->psSubject = NULL;
|
|
||||||
intManufactureFinished(psStructure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The update routine for all Structures left back at base during a Mission*/
|
|
||||||
void missionStructureUpdate(STRUCTURE *psBuilding)
|
|
||||||
{
|
|
||||||
|
|
||||||
ASSERT( psBuilding != NULL,
|
|
||||||
"structureUpdate: Invalid Structure pointer" );
|
|
||||||
|
|
||||||
// Update the manufacture/research of the building
|
|
||||||
if (StructIsFactory(psBuilding) || psBuilding->pStructureType->type == REF_RESEARCH)
|
|
||||||
{
|
|
||||||
if (psBuilding->status == SS_BUILT)
|
|
||||||
{
|
|
||||||
aiUpdateMissionStructure(psBuilding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The update routine for all droids left back at home base
|
/* The update routine for all droids left back at home base
|
||||||
Only interested in Transporters at present*/
|
Only interested in Transporters at present*/
|
||||||
void missionDroidUpdate(DROID *psDroid)
|
void missionDroidUpdate(DROID *psDroid)
|
||||||
|
|
|
@ -70,9 +70,6 @@ extern BOOL setUpMission(UDWORD type);
|
||||||
/** This causes the new mission data to be loaded up. */
|
/** This causes the new mission data to be loaded up. */
|
||||||
extern void launchMission(void);
|
extern void launchMission(void);
|
||||||
|
|
||||||
/** The update routine for all Structures left back at base during a Mission. */
|
|
||||||
extern void missionStructureUpdate(STRUCTURE *psBuilding);
|
|
||||||
|
|
||||||
/** The update routine for all droids left back at home base. Only interested in Transporters at present. */
|
/** The update routine for all droids left back at home base. Only interested in Transporters at present. */
|
||||||
extern void missionDroidUpdate(DROID *psDroid);
|
extern void missionDroidUpdate(DROID *psDroid);
|
||||||
|
|
||||||
|
|
|
@ -2792,7 +2792,7 @@ BOOL CheckHaltOnMaxUnitsReached(STRUCTURE *psStructure)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void aiUpdateStructure(STRUCTURE *psStructure)
|
static void aiUpdateStructure(STRUCTURE *psStructure, bool mission)
|
||||||
{
|
{
|
||||||
BASE_STATS *pSubject = NULL;
|
BASE_STATS *pSubject = NULL;
|
||||||
UDWORD pointsToAdd;//, iPower;
|
UDWORD pointsToAdd;//, iPower;
|
||||||
|
@ -2819,6 +2819,20 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
|
||||||
|
|
||||||
CHECK_STRUCTURE(psStructure);
|
CHECK_STRUCTURE(psStructure);
|
||||||
|
|
||||||
|
if (mission)
|
||||||
|
{
|
||||||
|
switch (psStructure->pStructureType->type)
|
||||||
|
{
|
||||||
|
case REF_RESEARCH:
|
||||||
|
case REF_FACTORY:
|
||||||
|
case REF_CYBORG_FACTORY:
|
||||||
|
case REF_VTOL_FACTORY:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return; // nothing to do
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Will go out into a building EVENT stats/text file
|
// Will go out into a building EVENT stats/text file
|
||||||
/* Spin round yer sensors! */
|
/* Spin round yer sensors! */
|
||||||
if (psStructure->numWeaps == 0)
|
if (psStructure->numWeaps == 0)
|
||||||
|
@ -3290,8 +3304,23 @@ static void aiUpdateStructure(STRUCTURE *psStructure)
|
||||||
!IsFactoryCommanderGroupFull(psFactory) &&
|
!IsFactoryCommanderGroupFull(psFactory) &&
|
||||||
!CheckHaltOnMaxUnitsReached(psStructure))
|
!CheckHaltOnMaxUnitsReached(psStructure))
|
||||||
{
|
{
|
||||||
/* Place the droid on the map */
|
if (mission)
|
||||||
bDroidPlaced = structPlaceDroid(psStructure, (DROID_TEMPLATE *)pSubject, &psDroid);
|
{
|
||||||
|
// put it in the mission list
|
||||||
|
psDroid = buildMissionDroid((DROID_TEMPLATE *)pSubject,
|
||||||
|
psStructure->pos.x, psStructure->pos.y,
|
||||||
|
psStructure->player);
|
||||||
|
if (psDroid)
|
||||||
|
{
|
||||||
|
setDroidBase(psDroid, psStructure);
|
||||||
|
bDroidPlaced = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// place it on the map
|
||||||
|
bDroidPlaced = structPlaceDroid(psStructure, (DROID_TEMPLATE *)pSubject, &psDroid);
|
||||||
|
}
|
||||||
|
|
||||||
//reset the start time
|
//reset the start time
|
||||||
psFactory->timeStarted = ACTION_START_TIME;
|
psFactory->timeStarted = ACTION_START_TIME;
|
||||||
|
@ -3599,7 +3628,7 @@ static float CalcStructureSmokeInterval(float damage)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The main update routine for all Structures */
|
/* The main update routine for all Structures */
|
||||||
void structureUpdate(STRUCTURE *psBuilding)
|
void structureUpdate(STRUCTURE *psBuilding, bool mission)
|
||||||
{
|
{
|
||||||
UDWORD widthScatter,breadthScatter;
|
UDWORD widthScatter,breadthScatter;
|
||||||
UDWORD emissionInterval, iPointsToAdd, iPointsRequired;
|
UDWORD emissionInterval, iPointsToAdd, iPointsRequired;
|
||||||
|
@ -3618,7 +3647,7 @@ void structureUpdate(STRUCTURE *psBuilding)
|
||||||
//update the manufacture/research of the building once complete
|
//update the manufacture/research of the building once complete
|
||||||
if (psBuilding->status == SS_BUILT)
|
if (psBuilding->status == SS_BUILT)
|
||||||
{
|
{
|
||||||
aiUpdateStructure(psBuilding);
|
aiUpdateStructure(psBuilding, mission);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(psBuilding->status!=SS_BUILT)
|
if(psBuilding->status!=SS_BUILT)
|
||||||
|
|
|
@ -131,7 +131,7 @@ extern STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWO
|
||||||
/// Create a blueprint structure, with just enough information to render it
|
/// Create a blueprint structure, with just enough information to render it
|
||||||
extern STRUCTURE *buildBlueprint(STRUCTURE_STATS *psStats, float x, float y, STRUCT_STATES state);
|
extern STRUCTURE *buildBlueprint(STRUCTURE_STATS *psStats, float x, float y, STRUCT_STATES state);
|
||||||
/* The main update routine for all Structures */
|
/* The main update routine for all Structures */
|
||||||
void structureUpdate(STRUCTURE *psBuilding);
|
void structureUpdate(STRUCTURE *psBuilding, bool mission);
|
||||||
|
|
||||||
/* Release all resources associated with a structure */
|
/* Release all resources associated with a structure */
|
||||||
void structureRelease(STRUCTURE *psBuilding);
|
void structureRelease(STRUCTURE *psBuilding);
|
||||||
|
|
Loading…
Reference in New Issue