Add new functionality list for all oil resource/derrick objects for quick iteration
of them. This is intended to be accessed from scripts. git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@10857 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
579fd2970d
commit
541df6442d
|
@ -256,14 +256,15 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
|
|||
UDWORD startX,startY,max,min;
|
||||
SDWORD i;
|
||||
UBYTE vis;
|
||||
|
||||
//try and create the Feature
|
||||
FEATURE* psFeature = createFeature();
|
||||
|
||||
if (psFeature == NULL)
|
||||
{
|
||||
debug(LOG_WARNING, "Feature couldn't be built.");
|
||||
return NULL;
|
||||
}
|
||||
psFeature->psStats = psStats;
|
||||
// features are not in the cluster system
|
||||
// this will cause an assert when they still end up there
|
||||
psFeature->cluster = ~0;
|
||||
|
@ -310,10 +311,7 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
|
|||
{
|
||||
psFeature->rot.direction = 0;
|
||||
}
|
||||
//psFeature->damage = featureDamage;
|
||||
psFeature->selected = false;
|
||||
psFeature->psStats = psStats;
|
||||
//psFeature->subType = psStats->subType;
|
||||
psFeature->body = psStats->body;
|
||||
psFeature->player = MAX_PLAYERS+1; //set the player out of range to avoid targeting confusions
|
||||
objSensorCache((BASE_OBJECT *)psFeature, NULL);
|
||||
|
|
|
@ -2401,6 +2401,7 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
|
|||
//clear all the messages?
|
||||
apsProxDisp[player] = NULL;
|
||||
apsSensorList[0] = NULL;
|
||||
apsOilList[0] = NULL;
|
||||
}
|
||||
initFactoryNumFlag();
|
||||
}
|
||||
|
@ -2416,6 +2417,8 @@ BOOL loadGame(const char *pGameToLoad, BOOL keepObjects, BOOL freeMem, BOOL User
|
|||
mission.apsFeatureLists[player] = NULL;
|
||||
mission.apsFlagPosLists[player] = NULL;
|
||||
}
|
||||
mission.apsOilList[0] = NULL;
|
||||
mission.apsSensorList[0] = NULL;
|
||||
|
||||
//JPS 25 feb
|
||||
//initialise upgrades
|
||||
|
|
|
@ -255,6 +255,7 @@ void initMission(void)
|
|||
apsLimboDroids[inc] = NULL;
|
||||
}
|
||||
mission.apsSensorList[0] = NULL;
|
||||
mission.apsOilList[0] = NULL;
|
||||
offWorldKeepLists = false;
|
||||
mission.time = -1;
|
||||
setMissionCountDown();
|
||||
|
@ -327,7 +328,9 @@ BOOL missionShutDown(void)
|
|||
mission.apsFlagPosLists[inc] = NULL;
|
||||
}
|
||||
apsSensorList[0] = mission.apsSensorList[0];
|
||||
apsOilList[0] = mission.apsOilList[0];
|
||||
mission.apsSensorList[0] = NULL;
|
||||
mission.apsOilList[0] = NULL;
|
||||
|
||||
psMapTiles = mission.psMapTiles;
|
||||
mapWidth = mission.mapWidth;
|
||||
|
@ -804,6 +807,7 @@ static void saveMissionData(void)
|
|||
mission.apsFlagPosLists[inc] = apsFlagPosLists[inc];
|
||||
}
|
||||
mission.apsSensorList[0] = apsSensorList[0];
|
||||
mission.apsOilList[0] = apsOilList[0];
|
||||
|
||||
mission.playerX = player.p.x;
|
||||
mission.playerY = player.p.z;
|
||||
|
@ -868,6 +872,7 @@ void restoreMissionData(void)
|
|||
mission.apsFlagPosLists[inc] = NULL;
|
||||
}
|
||||
apsSensorList[0] = mission.apsSensorList[0];
|
||||
apsOilList[0] = mission.apsOilList[0];
|
||||
mission.apsSensorList[0] = NULL;
|
||||
//swap mission data over
|
||||
|
||||
|
@ -1458,6 +1463,9 @@ void swapMissionPointers(void)
|
|||
pVoid = (void*)apsSensorList[0];
|
||||
apsSensorList[0] = mission.apsSensorList[0];
|
||||
mission.apsSensorList[0] = (BASE_OBJECT *)pVoid;
|
||||
pVoid = (void*)apsOilList[0];
|
||||
apsOilList[0] = mission.apsOilList[0];
|
||||
mission.apsOilList[0] = (BASE_OBJECT *)pVoid;
|
||||
}
|
||||
|
||||
void endMission(void)
|
||||
|
|
|
@ -67,6 +67,7 @@ typedef struct _mission
|
|||
DROID *apsDroidLists[MAX_PLAYERS];
|
||||
FEATURE *apsFeatureLists[MAX_PLAYERS];
|
||||
BASE_OBJECT *apsSensorList[1];
|
||||
BASE_OBJECT *apsOilList[1];
|
||||
//struct _proximity_display *apsProxDisp[MAX_PLAYERS];
|
||||
FLAG_POSITION *apsFlagPosLists[MAX_PLAYERS];
|
||||
PLAYER_POWER asPower[MAX_PLAYERS];
|
||||
|
|
28
src/objmem.c
28
src/objmem.c
|
@ -63,6 +63,7 @@ DROID *apsDroidLists[MAX_PLAYERS];
|
|||
STRUCTURE *apsStructLists[MAX_PLAYERS];
|
||||
FEATURE *apsFeatureLists[MAX_PLAYERS]; ///< Only player zero is valid for features. TODO: Reduce to single list.
|
||||
BASE_OBJECT *apsSensorList[1]; ///< List of sensors in the game.
|
||||
BASE_OBJECT *apsOilList[1];
|
||||
|
||||
/*The list of Flag Positions allocated */
|
||||
FLAG_POSITION *apsFlagPosLists[MAX_PLAYERS];
|
||||
|
@ -566,6 +567,10 @@ void addStructure(STRUCTURE *psStructToAdd)
|
|||
{
|
||||
addObjectToFuncList(apsSensorList, (BASE_OBJECT*)psStructToAdd, 0);
|
||||
}
|
||||
else if (psStructToAdd->type == REF_RESOURCE_EXTRACTOR)
|
||||
{
|
||||
addObjectToFuncList(apsOilList, (BASE_OBJECT*)psStructToAdd, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy a structure */
|
||||
|
@ -583,6 +588,10 @@ void killStruct(STRUCTURE *psBuilding)
|
|||
{
|
||||
removeObjectFromFuncList(apsSensorList, (BASE_OBJECT*)psBuilding, 0);
|
||||
}
|
||||
else if (psBuilding->type == REF_RESOURCE_EXTRACTOR)
|
||||
{
|
||||
removeObjectFromFuncList(apsOilList, (BASE_OBJECT*)psBuilding, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < STRUCT_MAXWEAPS; i++)
|
||||
{
|
||||
|
@ -643,6 +652,10 @@ void removeStructureFromList(STRUCTURE *psStructToRemove, STRUCTURE *pList[MAX_P
|
|||
{
|
||||
removeObjectFromFuncList(apsSensorList, (BASE_OBJECT*)psStructToRemove, 0);
|
||||
}
|
||||
else if (psStructToRemove->type == REF_RESOURCE_EXTRACTOR)
|
||||
{
|
||||
removeObjectFromFuncList(apsOilList, (BASE_OBJECT*)psStructToRemove, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/************************** FEATURE *********************************/
|
||||
|
@ -654,10 +667,14 @@ FEATURE* createFeature()
|
|||
}
|
||||
|
||||
/* add the feature to the Feature Lists */
|
||||
void addFeature(FEATURE *psFeatureToAdd)
|
||||
{
|
||||
void addFeature(FEATURE *psFeatureToAdd)
|
||||
{
|
||||
addObjectToList((BASE_OBJECT**)apsFeatureLists, (BASE_OBJECT*)psFeatureToAdd, 0);
|
||||
}
|
||||
if (psFeatureToAdd->psStats->subType == FEAT_OIL_RESOURCE)
|
||||
{
|
||||
addObjectToFuncList(apsOilList, (BASE_OBJECT*)psFeatureToAdd, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Destroy a feature */
|
||||
// set the player to 0 since features have player = maxplayers+1. This screws up destroyObject
|
||||
|
@ -668,6 +685,11 @@ void killFeature(FEATURE *psDel)
|
|||
"killFeature: pointer is not a feature" );
|
||||
psDel->player = 0;
|
||||
destroyObject((BASE_OBJECT**)apsFeatureLists, (BASE_OBJECT*)psDel);
|
||||
|
||||
if (psDel->psStats->subType == FEAT_OIL_RESOURCE)
|
||||
{
|
||||
removeObjectFromFuncList(apsOilList, (BASE_OBJECT*)psDel, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all features */
|
||||
|
|
|
@ -37,6 +37,7 @@ extern STRUCTURE *apsStructLists[MAX_PLAYERS];
|
|||
extern FEATURE *apsFeatureLists[MAX_PLAYERS];
|
||||
extern FLAG_POSITION *apsFlagPosLists[MAX_PLAYERS];
|
||||
extern BASE_OBJECT *apsSensorList[1];
|
||||
extern BASE_OBJECT *apsOilList[1];
|
||||
|
||||
/* The list of destroyed objects */
|
||||
extern BASE_OBJECT *psDestroyedObj;
|
||||
|
|
Loading…
Reference in New Issue