* Use decent assertion expressions for some asserts (e.g. !"string", so that debuggers actually display something more interesting than 'FALSE')
* modify createDroid, createFeature and createStruct to use a NULL pointer as failure notification rather than FALSE * get rid of createStructFunc and removeStructFunc which where nothing more than fancy malloc and free wrappers git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1864 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
74ab4f8787
commit
b2b33bbed4
13
src/droid.c
13
src/droid.c
|
@ -3215,10 +3215,11 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
|
||||||
ASSERT(!bMultiPlayer || worldOnMap(x,y), "the build locations are not on the map");
|
ASSERT(!bMultiPlayer || worldOnMap(x,y), "the build locations are not on the map");
|
||||||
|
|
||||||
//allocate memory
|
//allocate memory
|
||||||
if (!createDroid(player, &psDroid))
|
psDroid = createDroid(player);
|
||||||
|
if (psDroid == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_NEVER, "unit build: unable to create\n" );
|
debug(LOG_NEVER, "unit build: unable to create\n");
|
||||||
ASSERT( FALSE,"Cannot get the memory for the unit" );
|
ASSERT(!"out of memory", "Cannot get the memory for the unit");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3249,8 +3250,8 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
|
||||||
{
|
{
|
||||||
if (!grpCreate(&psGrp))
|
if (!grpCreate(&psGrp))
|
||||||
{
|
{
|
||||||
debug( LOG_NEVER, "unit build: unable to create group\n" );
|
debug(LOG_NEVER, "unit build: unable to create group\n");
|
||||||
ASSERT( FALSE,"Can't create unit because can't create group" );
|
ASSERT(!"unable to create group", "Can't create unit because can't create group");
|
||||||
free(psDroid);
|
free(psDroid);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5629,7 +5630,7 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "giftSingleUnit: unable to build a unit" );
|
ASSERT(!"failed building a droid", "giftSingleUnit: unable to build a unit" );
|
||||||
}
|
}
|
||||||
return psNewDroid;
|
return psNewDroid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ static void featureType(FEATURE_STATS* psFeature, char *pType)
|
||||||
psFeature->subType = FEAT_SKYSCRAPER;
|
psFeature->subType = FEAT_SKYSCRAPER;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT( FALSE, "Unknown Feature Type" );
|
ASSERT(!"unknown feature type", "Unknown Feature Type");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the feature stats */
|
/* Load the feature stats */
|
||||||
|
@ -329,7 +329,6 @@ void setFeatTileDraw(FEATURE *psFeat)
|
||||||
/* Create a feature on the map */
|
/* Create a feature on the map */
|
||||||
FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
|
FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
|
||||||
{
|
{
|
||||||
FEATURE *psFeature;
|
|
||||||
UDWORD mapX, mapY;
|
UDWORD mapX, mapY;
|
||||||
UDWORD width,breadth, foundationMin,foundationMax, height;
|
UDWORD width,breadth, foundationMin,foundationMax, height;
|
||||||
UDWORD startX,startY,max,min;
|
UDWORD startX,startY,max,min;
|
||||||
|
@ -337,7 +336,8 @@ FEATURE * buildFeature(FEATURE_STATS *psStats, UDWORD x, UDWORD y,BOOL FromSave)
|
||||||
UBYTE vis;
|
UBYTE vis;
|
||||||
|
|
||||||
//try and create the Feature
|
//try and create the Feature
|
||||||
if (!createFeature(&psFeature))
|
FEATURE* psFeature = createFeature();
|
||||||
|
if (psFeature == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
258
src/objmem.c
258
src/objmem.c
|
@ -365,14 +365,9 @@ static inline void releaseAllObjectsInList(BASE_OBJECT *list[], OBJECT_DESTRUCTO
|
||||||
/*************************** DROID *********************************/
|
/*************************** DROID *********************************/
|
||||||
|
|
||||||
/* Create a new droid */
|
/* Create a new droid */
|
||||||
BOOL createDroid(UDWORD player, DROID **ppsNew)
|
DROID* createDroid(UDWORD player)
|
||||||
{
|
{
|
||||||
*ppsNew = (DROID*)createObject(player, OBJ_DROID);
|
return (DROID*)createObject(player, OBJ_DROID);
|
||||||
|
|
||||||
if (*ppsNew == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the droid to the Droid Lists */
|
/* add the droid to the Droid Lists */
|
||||||
|
@ -449,14 +444,9 @@ void freeAllLimboDroids(void)
|
||||||
/************************** STRUCTURE *******************************/
|
/************************** STRUCTURE *******************************/
|
||||||
|
|
||||||
/* Create a new structure */
|
/* Create a new structure */
|
||||||
BOOL createStruct(UDWORD player, STRUCTURE **ppsNew)
|
STRUCTURE* createStruct(UDWORD player)
|
||||||
{
|
{
|
||||||
*ppsNew = (STRUCTURE*)createObject(player, OBJ_STRUCTURE);
|
return (STRUCTURE*)createObject(player, OBJ_STRUCTURE);
|
||||||
|
|
||||||
if (*ppsNew == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the structure to the Structure Lists */
|
/* add the structure to the Structure Lists */
|
||||||
|
@ -494,14 +484,9 @@ void removeStructureFromList(STRUCTURE *psStructToRemove, STRUCTURE *pList[MAX_P
|
||||||
/************************** FEATURE *********************************/
|
/************************** FEATURE *********************************/
|
||||||
|
|
||||||
/* Create a new Feature */
|
/* Create a new Feature */
|
||||||
BOOL createFeature(FEATURE **ppsNew)
|
FEATURE* createFeature()
|
||||||
{
|
{
|
||||||
*ppsNew = (FEATURE*)createObject(0, OBJ_FEATURE);
|
return (FEATURE*)createObject(0, OBJ_FEATURE);
|
||||||
|
|
||||||
if (*ppsNew == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the feature to the Feature Lists */
|
/* add the feature to the Feature Lists */
|
||||||
|
@ -653,18 +638,6 @@ void checkFactoryFlags(void)
|
||||||
|
|
||||||
/************************** STRUC FUNCTIONALITY ********************************/
|
/************************** STRUC FUNCTIONALITY ********************************/
|
||||||
|
|
||||||
/* Create a new Structure Functionality*/
|
|
||||||
BOOL createStructFunc(FUNCTIONALITY **ppsNew)
|
|
||||||
{
|
|
||||||
*ppsNew = malloc(sizeof(FUNCTIONALITY));
|
|
||||||
if (*ppsNew == NULL)
|
|
||||||
{
|
|
||||||
debug(LOG_ERROR, "createStructFunc: Out of memory");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*remove a structure Functionality from the heap*/
|
/*remove a structure Functionality from the heap*/
|
||||||
void removeStructFunc(FUNCTIONALITY *psDel)
|
void removeStructFunc(FUNCTIONALITY *psDel)
|
||||||
{
|
{
|
||||||
|
@ -677,63 +650,64 @@ void removeStructFunc(FUNCTIONALITY *psDel)
|
||||||
//this function is similar to BOOL scrvGetBaseObj(UDWORD id, BASE_OBJECT **ppsObj)
|
//this function is similar to BOOL scrvGetBaseObj(UDWORD id, BASE_OBJECT **ppsObj)
|
||||||
BASE_OBJECT *getBaseObjFromId(UDWORD id)
|
BASE_OBJECT *getBaseObjFromId(UDWORD id)
|
||||||
{
|
{
|
||||||
UDWORD i;
|
unsigned int i;
|
||||||
UDWORD player;
|
UDWORD player;
|
||||||
BASE_OBJECT *psObj;
|
BASE_OBJECT *psObj;
|
||||||
DROID *psTrans;
|
DROID *psTrans;
|
||||||
|
|
||||||
for(i=0; i<7; i++)
|
for(i = 0; i < 7; ++i)
|
||||||
{
|
{
|
||||||
for(player=0; player<MAX_PLAYERS; player++)
|
for(player = 0; player < MAX_PLAYERS; ++player)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
psObj=(BASE_OBJECT *)apsDroidLists[player];
|
psObj=(BASE_OBJECT *)apsDroidLists[player];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
psObj=(BASE_OBJECT *)apsStructLists[player];
|
psObj=(BASE_OBJECT *)apsStructLists[player];
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (player == 0)
|
if (player == 0)
|
||||||
{
|
{
|
||||||
psObj=(BASE_OBJECT *)apsFeatureLists[0];
|
psObj=(BASE_OBJECT *)apsFeatureLists[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsDroidLists[player];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsStructLists[player];
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (player == 0)
|
||||||
|
{
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsFeatureLists[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (player == 0)
|
||||||
|
{
|
||||||
|
psObj=(BASE_OBJECT *)apsLimboDroids[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
psObj = NULL;
|
psObj = NULL;
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsDroidLists[player];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsStructLists[player];
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (player == 0)
|
|
||||||
{
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsFeatureLists[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
psObj = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (player == 0)
|
|
||||||
{
|
|
||||||
psObj=(BASE_OBJECT *)apsLimboDroids[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
psObj = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
psObj = NULL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (psObj)
|
while (psObj)
|
||||||
{
|
{
|
||||||
if (psObj->id == id)
|
if (psObj->id == id)
|
||||||
|
@ -755,14 +729,14 @@ BASE_OBJECT *getBaseObjFromId(UDWORD id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT( FALSE,"getBaseObjFromId() failed for id %d", id );
|
ASSERT(!"couldn't find a BASE_OBJ with ID", "getBaseObjFromId() failed for id %d", id);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag)
|
UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag)
|
||||||
{
|
{
|
||||||
UDWORD i;
|
unsigned int i;
|
||||||
UDWORD player;
|
UDWORD player;
|
||||||
STRUCTURE *psObj;
|
STRUCTURE *psObj;
|
||||||
REPAIR_FACILITY *psRepair;
|
REPAIR_FACILITY *psRepair;
|
||||||
|
@ -771,20 +745,21 @@ UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag)
|
||||||
player = psFlag->player;
|
player = psFlag->player;
|
||||||
|
|
||||||
//probably dont need to check mission list
|
//probably dont need to check mission list
|
||||||
for(i=0; i<2; i++)
|
for(i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
psObj=(STRUCTURE *)apsStructLists[player];
|
psObj=(STRUCTURE *)apsStructLists[player];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
psObj=(STRUCTURE *)mission.apsStructLists[player];
|
psObj=(STRUCTURE *)mission.apsStructLists[player];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
psObj = NULL;
|
psObj = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (psObj)
|
while (psObj)
|
||||||
{
|
{
|
||||||
if (psObj->pFunctionality)
|
if (psObj->pFunctionality)
|
||||||
|
@ -802,7 +777,7 @@ UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag)
|
||||||
psObj = psObj->psNext;
|
psObj = psObj->psNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT( FALSE,"getRepairIdFromFlag() failed" );
|
ASSERT(!"unable to find repair id for FLAG_POSITION", "getRepairIdFromFlag() failed");
|
||||||
|
|
||||||
return UDWORD_MAX;
|
return UDWORD_MAX;
|
||||||
}
|
}
|
||||||
|
@ -811,63 +786,64 @@ UDWORD getRepairIdFromFlag(FLAG_POSITION *psFlag)
|
||||||
// check a base object exists for an ID
|
// check a base object exists for an ID
|
||||||
BOOL checkValidId(UDWORD id)
|
BOOL checkValidId(UDWORD id)
|
||||||
{
|
{
|
||||||
UDWORD i;
|
unsigned int i;
|
||||||
UDWORD player;
|
UDWORD player;
|
||||||
BASE_OBJECT *psObj;
|
BASE_OBJECT *psObj;
|
||||||
DROID *psTrans;
|
DROID *psTrans;
|
||||||
|
|
||||||
for(i=0; i<7; i++)
|
for(i = 0; i < 7; ++i)
|
||||||
{
|
{
|
||||||
for(player=0; player<MAX_PLAYERS; player++)
|
for(player = 0; player < MAX_PLAYERS; ++player)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
psObj=(BASE_OBJECT *)apsDroidLists[player];
|
psObj=(BASE_OBJECT *)apsDroidLists[player];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
psObj=(BASE_OBJECT *)apsStructLists[player];
|
psObj=(BASE_OBJECT *)apsStructLists[player];
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (player == 0)
|
if (player == 0)
|
||||||
{
|
{
|
||||||
psObj=(BASE_OBJECT *)apsFeatureLists[0];
|
psObj=(BASE_OBJECT *)apsFeatureLists[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsDroidLists[player];
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsStructLists[player];
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
if (player == 0)
|
||||||
|
{
|
||||||
|
psObj=(BASE_OBJECT *)mission.apsFeatureLists[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
if (player == 0)
|
||||||
|
{
|
||||||
|
psObj=(BASE_OBJECT *)apsLimboDroids[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psObj = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
psObj = NULL;
|
psObj = NULL;
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsDroidLists[player];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsStructLists[player];
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (player == 0)
|
|
||||||
{
|
|
||||||
psObj=(BASE_OBJECT *)mission.apsFeatureLists[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
psObj = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (player == 0)
|
|
||||||
{
|
|
||||||
psObj=(BASE_OBJECT *)apsLimboDroids[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
psObj = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
psObj = NULL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (psObj)
|
while (psObj)
|
||||||
{
|
{
|
||||||
if (psObj->id == id)
|
if (psObj->id == id)
|
||||||
|
@ -889,7 +865,7 @@ BOOL checkValidId(UDWORD id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT( FALSE,"checkValidId() failed for id %d", id );
|
ASSERT(!"invalid ID for BASE_OBJ", "checkValidId() failed for id %d", id);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
11
src/objmem.h
11
src/objmem.h
|
@ -50,7 +50,7 @@ extern void objmemShutdown(void);
|
||||||
extern void objmemUpdate(void);
|
extern void objmemUpdate(void);
|
||||||
|
|
||||||
/* Create a new droid */
|
/* Create a new droid */
|
||||||
extern BOOL createDroid(UDWORD player, DROID **ppsNew);
|
extern DROID* createDroid(UDWORD player);
|
||||||
|
|
||||||
/* add the droid to the Droid Lists */
|
/* add the droid to the Droid Lists */
|
||||||
extern void addDroid(DROID *psDroidToAdd, DROID *pList[MAX_PLAYERS]);
|
extern void addDroid(DROID *psDroidToAdd, DROID *pList[MAX_PLAYERS]);
|
||||||
|
@ -71,7 +71,7 @@ extern void freeAllMissionDroids(void);
|
||||||
extern void freeAllLimboDroids(void);
|
extern void freeAllLimboDroids(void);
|
||||||
|
|
||||||
/* Create a new structure */
|
/* Create a new structure */
|
||||||
extern BOOL createStruct(UDWORD player, STRUCTURE **ppsNew);
|
extern STRUCTURE* createStruct(UDWORD player);
|
||||||
|
|
||||||
/* add the structure to the Structure Lists */
|
/* add the structure to the Structure Lists */
|
||||||
extern void addStructure(STRUCTURE *psStructToAdd);
|
extern void addStructure(STRUCTURE *psStructToAdd);
|
||||||
|
@ -87,7 +87,7 @@ extern void removeStructureFromList(STRUCTURE *psStructToRemove,
|
||||||
STRUCTURE *pList[MAX_PLAYERS]);
|
STRUCTURE *pList[MAX_PLAYERS]);
|
||||||
|
|
||||||
/* Create a new Feature */
|
/* Create a new Feature */
|
||||||
extern BOOL createFeature(FEATURE **ppsNew);
|
extern FEATURE* createFeature(void);
|
||||||
|
|
||||||
/* add the feature to the Feature Lists */
|
/* add the feature to the Feature Lists */
|
||||||
extern void addFeature(FEATURE *psFeatureToAdd);
|
extern void addFeature(FEATURE *psFeatureToAdd);
|
||||||
|
@ -108,11 +108,6 @@ extern void removeFlagPosition(FLAG_POSITION *psDel);
|
||||||
extern void freeAllFlagPositions(void);
|
extern void freeAllFlagPositions(void);
|
||||||
extern void freeAllAssemblyPoints(void);
|
extern void freeAllAssemblyPoints(void);
|
||||||
|
|
||||||
/* Create a new Structure Functionality*/
|
|
||||||
extern BOOL createStructFunc(FUNCTIONALITY **ppsNew);
|
|
||||||
/*remove a structure Functionality from the heap*/
|
|
||||||
extern void removeStructFunc(FUNCTIONALITY *psDel);
|
|
||||||
|
|
||||||
// Find a base object from it's id
|
// Find a base object from it's id
|
||||||
extern BASE_OBJECT *getBaseObjFromId(UDWORD id);
|
extern BASE_OBJECT *getBaseObjFromId(UDWORD id);
|
||||||
extern BOOL checkValidId(UDWORD id);
|
extern BOOL checkValidId(UDWORD id);
|
||||||
|
|
153
src/structure.c
153
src/structure.c
|
@ -462,7 +462,7 @@ static void structureType(STRUCTURE_STATS *pStructure, char *pType)
|
||||||
pStructure->type = REF_SAT_UPLINK;
|
pStructure->type = REF_SAT_UPLINK;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ASSERT( FALSE, "Unknown Structure Type" );
|
ASSERT(!"unknown structure type", "structureType: Unknown Structure Type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1680,7 +1680,7 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
max = pStructureType - asStructureStats;
|
max = pStructureType - asStructureStats;
|
||||||
if (max > numStructureStats)
|
if (max > numStructureStats)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "buildStructure: Invalid structure type" );
|
ASSERT(!"invalid structure type", "buildStructure: Invalid structure type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1694,7 +1694,7 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
//NEVER EVER EVER WANT MORE THAN 5 FACTORIES
|
//NEVER EVER EVER WANT MORE THAN 5 FACTORIES
|
||||||
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_FACTORY)
|
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_FACTORY)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: trying to build too many factories (%d max)", MAX_FACTORY);
|
ASSERT(!"attempting to construct too many factories", "buildStructure: trying to build too many factories (%d max)", MAX_FACTORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1703,14 +1703,14 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
//can only cope with MAX_OBJECTS research facilities
|
//can only cope with MAX_OBJECTS research facilities
|
||||||
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_OBJECTS)
|
if (asStructLimits[selectedPlayer][max].currentQuantity > MAX_OBJECTS)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: trying to build too many research facilities (%d max)", MAX_OBJECTS);
|
ASSERT(!"attempting to construct too many research facilities", "buildStructure: trying to build too many research facilities (%d max)", MAX_OBJECTS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//HARD_CODE don't ever want more than one Las Sat structure
|
//HARD_CODE don't ever want more than one Las Sat structure
|
||||||
if (isLasSat(pStructureType) && getLasSatExists(selectedPlayer))
|
if (isLasSat(pStructureType) && getLasSatExists(selectedPlayer))
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: trying to build too many Las Sat (1 max)");
|
ASSERT(!"attempting to build more than 1 Las Sat center", "buildStructure: trying to build too many Las Sat (1 max)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
//HARD_CODE don't ever want more than one Sat Uplink structure
|
//HARD_CODE don't ever want more than one Sat Uplink structure
|
||||||
|
@ -1718,7 +1718,7 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
{
|
{
|
||||||
if (asStructLimits[selectedPlayer][max].currentQuantity > 0)
|
if (asStructLimits[selectedPlayer][max].currentQuantity > 0)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: trying to build too many Sat Uplinks (1 max)");
|
ASSERT(!"attempting to build more than 1 Sat Uplink", "buildStructure: trying to build too many Sat Uplinks (1 max)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1732,13 +1732,13 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
if(((x >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((x >> TILE_SHIFT) > (
|
if(((x >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((x >> TILE_SHIFT) > (
|
||||||
mapWidth - TOO_NEAR_EDGE)))
|
mapWidth - TOO_NEAR_EDGE)))
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: x coord (%u) too near edge (req. distance is %u)", x, TOO_NEAR_EDGE);
|
ASSERT(!"attempting to build too closely to map-edge", "buildStructure: x coord (%u) too near edge (req. distance is %u)", x, TOO_NEAR_EDGE);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if(((y >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((y >> TILE_SHIFT) > (
|
if(((y >> TILE_SHIFT) < TOO_NEAR_EDGE) || ((y >> TILE_SHIFT) > (
|
||||||
mapHeight - TOO_NEAR_EDGE)))
|
mapHeight - TOO_NEAR_EDGE)))
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "buildStructure: y coord (%u) too near edge (req. distance is %u)", y, TOO_NEAR_EDGE);
|
ASSERT(!"attempting to build too closely to map-edge", "buildStructure: y coord (%u) too near edge (req. distance is %u)", y, TOO_NEAR_EDGE);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1755,7 +1755,8 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate memory for and initialize a structure object
|
// allocate memory for and initialize a structure object
|
||||||
if (!createStruct(player, &psBuilding))
|
psBuilding = createStruct(player);
|
||||||
|
if (psBuilding == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2039,7 +2040,7 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
||||||
|
|
||||||
if (psBuilding == NULL)
|
if (psBuilding == NULL)
|
||||||
{
|
{
|
||||||
ASSERT(FALSE, "No owning structure for this module - %s", getStructName(pStructureType));
|
ASSERT(!"module has no owning structure", "No owning structure for this module - %s", getStructName(pStructureType));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (pStructureType->type == REF_FACTORY_MODULE)
|
if (pStructureType->type == REF_FACTORY_MODULE)
|
||||||
|
@ -2256,9 +2257,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
//allocate the necessary space
|
//allocate the necessary space
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2292,17 +2294,17 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
addFlagPosition(psFactory->psAssemblyPoint);
|
addFlagPosition(psFactory->psAssemblyPoint);
|
||||||
switch(functionType)
|
switch(functionType)
|
||||||
{
|
{
|
||||||
case REF_FACTORY:
|
case REF_FACTORY:
|
||||||
setFlagPositionInc(psFactory, psBuilding->player, FACTORY_FLAG);
|
setFlagPositionInc(psFactory, psBuilding->player, FACTORY_FLAG);
|
||||||
break;
|
break;
|
||||||
case REF_CYBORG_FACTORY:
|
case REF_CYBORG_FACTORY:
|
||||||
setFlagPositionInc(psFactory, psBuilding->player, CYBORG_FLAG);
|
setFlagPositionInc(psFactory, psBuilding->player, CYBORG_FLAG);
|
||||||
break;
|
break;
|
||||||
case REF_VTOL_FACTORY:
|
case REF_VTOL_FACTORY:
|
||||||
setFlagPositionInc(psFactory, psBuilding->player, VTOL_FLAG);
|
setFlagPositionInc(psFactory, psBuilding->player, VTOL_FLAG);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT( FALSE, "setFunctionality: Invalid factory type" );
|
ASSERT(!"invalid factory type", "setFunctionality: Invalid factory type");
|
||||||
}
|
}
|
||||||
|
|
||||||
psFactory->psFormation = NULL;
|
psFactory->psFormation = NULL;
|
||||||
|
@ -2319,9 +2321,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//try and create the Structure
|
//try and create the Structure
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2346,9 +2349,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
//try and create the Structure
|
//try and create the Structure
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2377,9 +2381,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
//try and create the Structure
|
//try and create the Structure
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2432,9 +2437,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
}
|
}
|
||||||
|
|
||||||
//try and create the Structure
|
//try and create the Structure
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2485,9 +2491,10 @@ BOOL setFunctionality(STRUCTURE *psBuilding, UDWORD functionType)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//try and create the Structure
|
//try and create the Structure
|
||||||
if (!createStructFunc(&psBuilding->pFunctionality))
|
psBuilding->pFunctionality = malloc(sizeof(FUNCTIONALITY));
|
||||||
|
if (psBuilding->pFunctionality == NULL)
|
||||||
{
|
{
|
||||||
debug( LOG_ERROR, "Out of memory" );
|
debug(LOG_ERROR, "setFunctionality: Out of memory");
|
||||||
abort();
|
abort();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2519,19 +2526,19 @@ void assignFactoryCommandDroid(STRUCTURE *psStruct, DROID *psCommander)
|
||||||
|
|
||||||
switch(psStruct->pStructureType->type)
|
switch(psStruct->pStructureType->type)
|
||||||
{
|
{
|
||||||
case REF_FACTORY:
|
case REF_FACTORY:
|
||||||
typeFlag = FACTORY_FLAG;
|
typeFlag = FACTORY_FLAG;
|
||||||
break;
|
break;
|
||||||
case REF_VTOL_FACTORY:
|
case REF_VTOL_FACTORY:
|
||||||
typeFlag = VTOL_FLAG;
|
typeFlag = VTOL_FLAG;
|
||||||
break;
|
break;
|
||||||
case REF_CYBORG_FACTORY:
|
case REF_CYBORG_FACTORY:
|
||||||
typeFlag = CYBORG_FLAG;
|
typeFlag = CYBORG_FLAG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT( FALSE,"assignfactorycommandUnit: unknown factory type" );
|
ASSERT(!"unknown factory type", "assignfactorycommandUnit: unknown factory type");
|
||||||
typeFlag = FACTORY_FLAG;
|
typeFlag = FACTORY_FLAG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// removing a commander from a factory
|
// removing a commander from a factory
|
||||||
|
@ -4083,7 +4090,7 @@ void structureRelease(STRUCTURE *psBuilding)
|
||||||
}
|
}
|
||||||
|
|
||||||
//free up the space used by the functionality array
|
//free up the space used by the functionality array
|
||||||
removeStructFunc(psBuilding->pFunctionality);
|
free(psBuilding->pFunctionality);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the object from the grid
|
// remove the object from the grid
|
||||||
|
@ -4438,7 +4445,7 @@ BOOL validLocation(BASE_STATS *psStats, UDWORD x, UDWORD y, UDWORD player,
|
||||||
break;
|
break;
|
||||||
case NUM_DIFF_BUILDINGS:
|
case NUM_DIFF_BUILDINGS:
|
||||||
case REF_BRIDGE:
|
case REF_BRIDGE:
|
||||||
ASSERT(FALSE, "validLocation: Bad structure type %u", psBuilding->type);
|
ASSERT(!"invalid structure type", "validLocation: Bad structure type %u", psBuilding->type);
|
||||||
break;
|
break;
|
||||||
case REF_HQ:
|
case REF_HQ:
|
||||||
case REF_FACTORY:
|
case REF_FACTORY:
|
||||||
|
@ -5551,7 +5558,7 @@ void findAssemblyPointPosition(UDWORD *pX, UDWORD *pY, UDWORD player)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* If we got this far, then we failed - passed in values will be unchanged */
|
/* If we got this far, then we failed - passed in values will be unchanged */
|
||||||
ASSERT( FALSE, "findAssemblyPointPosition: unable to find a valid location!" );
|
ASSERT(!"unable to find a valid location", "findAssemblyPointPosition: unable to find a valid location!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5610,23 +5617,23 @@ void setFlagPositionInc(void *pFunctionality, UDWORD player, UBYTE factoryType)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
switch (factoryType)
|
switch (factoryType)
|
||||||
{
|
{
|
||||||
case FACTORY_FLAG:
|
case FACTORY_FLAG:
|
||||||
pType = "Factory";
|
pType = "Factory";
|
||||||
break;
|
break;
|
||||||
case CYBORG_FLAG:
|
case CYBORG_FLAG:
|
||||||
pType = "Cyborg Factory";
|
pType = "Cyborg Factory";
|
||||||
break;
|
break;
|
||||||
case VTOL_FLAG:
|
case VTOL_FLAG:
|
||||||
pType = "VTOL Factory";
|
pType = "VTOL Factory";
|
||||||
break;
|
break;
|
||||||
case REPAIR_FLAG:
|
case REPAIR_FLAG:
|
||||||
pType = "Repair Facility";
|
pType = "Repair Facility";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pType = "";
|
pType = "";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT( FALSE, "Building more than %d %s for player %d", MAX_FACTORY, pType, player );
|
ASSERT(!"building more factories than allowed", "Building more than %d %s for player %d", MAX_FACTORY, pType, player);
|
||||||
#endif
|
#endif
|
||||||
inc = 1;
|
inc = 1;
|
||||||
}
|
}
|
||||||
|
@ -5877,7 +5884,7 @@ void checkForResExtractors(STRUCTURE *psBuilding)
|
||||||
|
|
||||||
if (psBuilding->pStructureType->type != REF_POWER_GEN)
|
if (psBuilding->pStructureType->type != REF_POWER_GEN)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "checkForResExtractors: invalid structure type" );
|
ASSERT(!"invalid structure type", "checkForResExtractors: invalid structure type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
psPowerGen = (POWER_GEN *)psBuilding->pFunctionality;
|
psPowerGen = (POWER_GEN *)psBuilding->pFunctionality;
|
||||||
|
@ -5956,7 +5963,7 @@ void checkForPowerGen(STRUCTURE *psBuilding)
|
||||||
|
|
||||||
if (psBuilding->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
if (psBuilding->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "checkForPowerGen: invalid structure type" );
|
ASSERT(!"invalid structure type", "checkForPowerGen: invalid structure type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
psRE = (RES_EXTRACTOR *)psBuilding->pFunctionality;
|
psRE = (RES_EXTRACTOR *)psBuilding->pFunctionality;
|
||||||
|
@ -6011,7 +6018,7 @@ void informPowerGen(STRUCTURE *psStruct)
|
||||||
|
|
||||||
if (psStruct->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
if (psStruct->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "informPowerGen: invalid structure type" );
|
ASSERT(!"invalid structure type", "informPowerGen: invalid structure type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6042,7 +6049,7 @@ void releaseResExtractor(STRUCTURE *psRelease)
|
||||||
|
|
||||||
if (psRelease->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
if (psRelease->pStructureType->type != REF_RESOURCE_EXTRACTOR)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "releaseResExtractor:Invalid structure type" );
|
ASSERT(!"invalid structure type", "releaseResExtractor:Invalid structure type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6081,7 +6088,7 @@ void releasePowerGen(STRUCTURE *psRelease)
|
||||||
|
|
||||||
if (psRelease->pStructureType->type != REF_POWER_GEN)
|
if (psRelease->pStructureType->type != REF_POWER_GEN)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "releasePowerGen:Invalid structure type" );
|
ASSERT(!"invalid structure type", "releasePowerGen: Invalid structure type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6367,14 +6374,14 @@ BOOL electronicDamage(BASE_OBJECT *psTarget, UDWORD damage, UBYTE attackPlayer)
|
||||||
psDroid = (DROID *)psTarget;
|
psDroid = (DROID *)psTarget;
|
||||||
bCompleted = FALSE;
|
bCompleted = FALSE;
|
||||||
|
|
||||||
ASSERT( psDroid != NULL, "electronicDamage: Invalid Droid pointer" );
|
ASSERT(psDroid != NULL, "electronicDamage: Invalid Droid pointer");
|
||||||
|
|
||||||
//in multiPlayer cannot attack a Transporter with EW
|
//in multiPlayer cannot attack a Transporter with EW
|
||||||
if (bMultiPlayer)
|
if (bMultiPlayer)
|
||||||
{
|
{
|
||||||
if (psDroid->droidType == DROID_TRANSPORTER)
|
if (psDroid->droidType == DROID_TRANSPORTER)
|
||||||
{
|
{
|
||||||
ASSERT( FALSE, "electronicDamage: Cannot attack a Transporter in multiPlayer" );
|
ASSERT(!"can't attack a Transporter while in multiplayer", "electronicDamage: Cannot attack a Transporter in multiPlayer");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7355,7 +7362,7 @@ void checkDeliveryPoints(UDWORD version)
|
||||||
// add an assembly point
|
// add an assembly point
|
||||||
if (!createFlagPosition(&psRepair->psDeliveryPoint, psStruct->player))
|
if (!createFlagPosition(&psRepair->psDeliveryPoint, psStruct->player))
|
||||||
{
|
{
|
||||||
ASSERT( FALSE,"checkDeliveryPoints: unable to create new delivery point for repair facility" );
|
ASSERT(!"can't create new deilivery point for repair facility", "checkDeliveryPoints: unable to create new delivery point for repair facility");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addFlagPosition(psRepair->psDeliveryPoint);
|
addFlagPosition(psRepair->psDeliveryPoint);
|
||||||
|
|
Loading…
Reference in New Issue