From a1d02fec76df0f7ff2e7c1b511deaad506b9301a Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Sun, 1 Apr 2007 18:22:27 +0000 Subject: [PATCH] Prune some dead code git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1320 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/droid.c | 46 +--- src/mechanics.c | 559 +----------------------------------------------- src/mechanics.h | 3 - src/research.c | 112 +--------- src/stats.c | 76 +------ src/stats.h | 2 - 6 files changed, 14 insertions(+), 784 deletions(-) diff --git a/src/droid.c b/src/droid.c index affb1a1cc..e0a093724 100644 --- a/src/droid.c +++ b/src/droid.c @@ -2794,7 +2794,6 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) #endif UDWORD id; - /* init default template */ memset( &sDefaultDesignTemplate, 0, sizeof(DROID_TEMPLATE) ); @@ -2806,14 +2805,11 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) { if (!HEAP_ALLOC(psTemplateHeap, (void**) &pDroidDesign)) { - debug( LOG_ERROR, "Out of memory - Droid Templates" ); - abort(); + debug(LOG_ERROR, "Out of memory - Droid Templates"); return FALSE; } memset(pDroidDesign, 0, sizeof(DROID_TEMPLATE)); - //pDroidDesign->pName = pDroidDesign->aName; - //only fill in aName now pDroidDesign->pName = NULL; //read the data into the storage - the data is delimited using comma's @@ -2821,44 +2817,11 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) sscanf(pDroidData, "%[^','],%d,%n", componentName, &templateID, &cnt); pDroidData += cnt; - - //We ain't EVER going back to the way it was so..just store the long (translated) name in aName -/*#ifdef RESOURCE_NAMES - //get the name associated with the resource - if (!strresGetIDNum(psStringRes, componentName, &id)) - { - DBERROR(("Unable to find string resource for %s", componentName)); - return FALSE; - } - - //get the string from the id and copy into the MALLOC'ed area - strcpy(droidName,strresGetString(psStringRes, id)); - -#elif defined STORE_RESOURCE_ID - //find the pointer where the string ID is stored - if (!strresGetIDString(psStringRes, componentName, &pDroidName)) - { - DBERROR(("Unable to find string resource for %s", componentName)); - return FALSE; - } - strcpy(droidName,pDroidName); -#else - strcpy(droidName,componentName); -#endif - //get the string from the id and copy into the MALLOC'ed area - strcpy(droidName,strresGetString(psStringRes, id)); - - //allocate storage for the name - constant array now (aName) - strncpy(pDroidDesign->pName,droidName, DROID_MAXNAME); - pDroidDesign->pName[DROID_MAXNAME-1]=0;*/ - - /*ALWAYS get the name associated with the resource for PC regardless of STORE_RESOURCE_ID or RESOURCE_NAMES! - 25/06/98 AB*/ if (!strresGetIDNum(psStringRes, componentName, &id)) { - debug( LOG_ERROR, "Unable to find string resource for %s", componentName ); - abort(); + debug(LOG_ERROR, "Unable to find string resource for %s", componentName); return FALSE; } @@ -2867,10 +2830,8 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) pDroidDesign->aName[DROID_MAXNAME-1] = 0; //store the unique template id - pDroidDesign->multiPlayerID = templateID; - //read in Body Name componentName[0] = '\0'; sscanf(pDroidData, "%[^','],%n", componentName, &cnt); @@ -3030,9 +2991,6 @@ BOOL loadDroidTemplates(char *pDroidData, UDWORD bufferSize) sscanf(pDroidData, "%d,%n", &player,&cnt); pDroidData += cnt; - - - //read in Propulsion Name found = FALSE; componentName[0] = '\0'; diff --git a/src/mechanics.c b/src/mechanics.c index 33ebe95aa..8387ce7a2 100644 --- a/src/mechanics.c +++ b/src/mechanics.c @@ -24,9 +24,6 @@ * */ -/* extra structures required for demo */ -//#define DEMO - #include "lib/framework/frame.h" #include "mechanics.h" #include "stats.h" @@ -40,118 +37,16 @@ #include "astar.h" #include "visibility.h" -BOOL gameStatStart(void); -void gameStatEnd(void); - - -/* Initialise the mechanics system */ -//BOOL mechInitialise(void) -//{ -// UBYTE *pFileData; -// UDWORD fileSize; - - /* Initialise the map */ - /*if (!loadFile("blank.map", &pFileData, &fileSize)) - { - return FALSE; - } - - if (!mapLoad(pFileData, fileSize)) - { - return FALSE; - } - - FREE(pFileData); */ - - //load all the component stats from the access database - /*if (!loadStats()) - { - return FALSE; - }*/ - - //load the droid Templates - /*if (!loadDroidTemplates()) - { - return FALSE; - }*/ - - /*if (!loadFunctionStats()) - { - return FALSE; - }*/ - - /*if (!loadStructureStats()) - { - return FALSE; - }*/ - - /*if (!loadStructureWeapons()) - { - return FALSE; - } - - if (!loadStructureFunctions()) - { - return FALSE; - }*/ - - //load the research stats - must have loaded the structure and functions stats first -/* if (!loadResearch()) - { - return FALSE; - } -*/ - /*the template weapons and programs should have been read in through the wrf file by now - so calculate build points and power points*/ - //initTemplatePoints(); DONE IN SAVE GAME NOW SINCE ALWAYS STARTING IN ONE - - //sets up the initial game stats - what the player's got etc -// gameStatStart(); - moved to data.c when stats are loaded from WRF - John. - - /*set up the Power levels for each player - again this is set up in load game now*/ - //initPlayerPower(); - -// return TRUE; -//} - - /* Shutdown the mechanics system */ BOOL mechShutdown(void) { -// UDWORD i; -// DROID *psCurr; - BASE_OBJECT *psObj, *psNext; - - /* for(i=0; ipsNext) - { - FREE(psCurr->pName); - if (psCurr->numWeaps > 0) - { - FREE(psCurr->asWeaps); - } - if (psCurr->numProgs > 0) - { - FREE(psCurr->asProgs); - } - } - }*/ + BASE_OBJECT *psObj, *psNext; for(psObj = psDestroyedObj; psObj; psObj = psNext) { psNext = psObj->psNext; if (psObj->type == OBJ_DROID) { - /* FREE(((DROID *)psObj)->pName); - if (((DROID *)psObj)->numWeaps > 0) - { - FREE(((DROID *)psObj)->asWeaps); - } - if (((DROID *)psObj)->numProgs > 0) - { - FREE(((DROID *)psObj)->asProgs); - }*/ droidRelease((DROID *)psObj); heapFree(psDroidHeap, (DROID *)psObj); } @@ -168,9 +63,6 @@ BOOL mechShutdown(void) } psDestroyedObj = NULL; - //Free the space allocated for the players lists -// gameStatEnd(); - return TRUE; } @@ -268,455 +160,6 @@ void freeStructureLists(void) } -//initialises the players list for the start of the DEMO -BOOL gameStatStart(void) -{ -// UDWORD inc, comp, stat; -// BOOL builtRes = FALSE, builtGen = FALSE; -#if 0 - STRUCTURE *psStructure; - DROID_TEMPLATE *pTemplate; - DROID_TEMPLATE *pNewTempl, *pCurrTempl; - UDWORD posX, posY; -#endif - -/********************************************************************** - * All this gets done by calls from data.c to - * allocComponentList and allocStructLists (above) - * John. - - //allocate the space for the Players' component lists - for (inc=0; inc < MAX_PLAYERS; inc++) - { - apCompLists[inc][COMP_BODY] = (UDWORD *) MALLOC(sizeof(UDWORD) * numBodyStats); - if (apCompLists[inc][COMP_BODY] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_BRAIN] = (UDWORD *) MALLOC(sizeof(UDWORD) * numBrainStats); - if (apCompLists[inc][COMP_BRAIN] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_ECM] = (UDWORD *) MALLOC(sizeof(UDWORD) * numECMStats); - if (apCompLists[inc][COMP_ECM] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_PROPULSION] = (UDWORD *) MALLOC(sizeof(UDWORD) * numPropulsionStats); - if (apCompLists[inc][COMP_PROPULSION] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_SENSOR] = (UDWORD *) MALLOC(sizeof(UDWORD) * numSensorStats); - if (apCompLists[inc][COMP_SENSOR] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_REPAIRUNIT] = (UDWORD *) MALLOC(sizeof(UDWORD) * numRepairStats); - if (apCompLists[inc][COMP_REPAIRUNIT] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_CONSTRUCT] = (UDWORD *) MALLOC(sizeof(UDWORD) * numConstructStats); - if (apCompLists[inc][COMP_REPAIRUNIT] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_WEAPON] = (UDWORD *) MALLOC(sizeof(UDWORD) * numWeaponStats); - if (apCompLists[inc][COMP_WEAPON] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - apCompLists[inc][COMP_PROGRAM] = (UDWORD *) MALLOC(sizeof(UDWORD) * numProgramStats); - if (apCompLists[inc][COMP_PROGRAM] == NULL) - { - DBERROR(("Out of memory assigning Player Component Lists")); - return FALSE; - } - } - - //initialise the players' lists - for (inc = 0; inc < MAX_PLAYERS; inc++) - { - for (comp=0; comp status = SS_BUILT; - builtRes = TRUE; - } - if (asStructureStats[comp].type == REF_POWER_GEN) - { -// apStructTypeLists[inc][comp] = AVAILABLE; - do - { - posX = rand()%mapWidth/2+mapWidth/4; - posY = rand()%mapHeight/2+mapHeight/4; - } - while(blockingTile(posX,posY,TER_ALL)); -/* psStructure = buildStructure(&asStructureStats[comp], posX << - TILE_SHIFT + TILE_UNITS/2, (posY << TILE_SHIFT) + TILE_UNITS/2, - inc); */ - psStructure = buildStructure(&asStructureStats[comp], - posX << TILE_SHIFT, posY << TILE_SHIFT, inc,FALSE); - psStructure->status = SS_BUILT; - builtGen = TRUE; - } - if (builtRes & builtGen) - { - break; - } - } - } -#endif - -//#ifdef DEMO -#if 0 - for (inc = 1; inc < MAX_PLAYERS; inc++) - { - pCurrTempl = NULL; - for(pTemplate = apsDroidTemplates[0]; pTemplate; pTemplate=pTemplate->psNext) - { - if (createTemplate(pTemplate, &pNewTempl)) - { - if (pCurrTempl == NULL) - { - apsDroidTemplates[inc] = pNewTempl; - } - else - { - pCurrTempl->psNext = pNewTempl; - } - pCurrTempl = pNewTempl; - } - } - } -#endif - - return TRUE; -} - - -void gameStatEnd(void) -{ - UDWORD inc; - - for (inc=0; inc < MAX_PLAYERS; inc++) - { - //free the component lists - FREE(apCompLists[inc][COMP_BODY]); - FREE(apCompLists[inc][COMP_BRAIN]); - FREE(apCompLists[inc][COMP_PROPULSION]); - FREE(apCompLists[inc][COMP_SENSOR]); - FREE(apCompLists[inc][COMP_ECM]); - FREE(apCompLists[inc][COMP_REPAIRUNIT]); - FREE(apCompLists[inc][COMP_CONSTRUCT]); - FREE(apCompLists[inc][COMP_WEAPON]); - //FREE(apCompLists[inc][COMP_PROGRAM]); - - //free the structure lists - if(apStructTypeLists[inc]) { - FREE(apStructTypeLists[inc]); - } - } -} - - - - //TEST FUNCTION - MAKE EVERYTHING AVAILABLE void makeAllAvailable(void) { diff --git a/src/mechanics.h b/src/mechanics.h index fa519af30..777a3ad76 100644 --- a/src/mechanics.h +++ b/src/mechanics.h @@ -38,9 +38,6 @@ #include "research.h" #include "visibility.h" -/* Initialise the mechanics system */ -//extern BOOL mechInitialise(void); - /* Shutdown the mechanics system */ extern BOOL mechShutdown(void); diff --git a/src/research.c b/src/research.c index a2e00f2b0..d61105212 100644 --- a/src/research.c +++ b/src/research.c @@ -2712,12 +2712,10 @@ RESEARCH * getResearch(char *pName, BOOL resName) /* looks through the players lists of structures and droids to see if any are using the old component - if any then replaces them with the new component */ -void replaceComponent(COMP_BASE_STATS *pNewComponent, COMP_BASE_STATS *pOldComponent, +static void replaceComponent(COMP_BASE_STATS *pNewComponent, COMP_BASE_STATS *pOldComponent, UBYTE player) { - //DROID *psDroid; DROID_TEMPLATE *psTemplates; - //STRUCTURE *psStructure; UDWORD inc, oldType, newType, oldCompInc, newCompInc; @@ -2734,57 +2732,11 @@ void replaceComponent(COMP_BASE_STATS *pNewComponent, COMP_BASE_STATS *pOldCompo return; } - replaceDroidComponent(apsDroidLists[player], oldType, oldCompInc, newCompInc); - replaceDroidComponent(mission.apsDroidLists[player], oldType, oldCompInc, newCompInc); - replaceDroidComponent(apsLimboDroids[player], oldType, oldCompInc, newCompInc); - //check thru the droids - /*for (psDroid = apsDroidLists[player]; psDroid != NULL; psDroid = psDroid->psNext) - { - switch(oldType) - { - case COMP_BODY: - case COMP_BRAIN: - case COMP_PROPULSION: - case COMP_REPAIRUNIT: - case COMP_ECM: - case COMP_SENSOR: - case COMP_CONSTRUCT: - if (psDroid->asBits[oldType].nStat == oldCompInc) - { - psDroid->asBits[oldType].nStat = (UBYTE)newCompInc; - } - break; - //case COMP_PROGRAM: - // for (inc=0; inc < psDroid->numProgs; inc++) - // { - // if ((psDroid->asProgs[inc].psStats->ref - REF_PROGRAM_START) == - // oldCompInc) - // { - // psDroid->asProgs[inc].psStats = (asProgramStats + newCompInc); - // } - // } - // break; - case COMP_WEAPON: - //can only be one weapon now - //for (inc=0; inc < psDroid->numWeaps; inc++) - if (psDroid->asWeaps[0].nStat > 0) - { - //if (psDroid->asWeaps[inc].nStat == oldCompInc) - if (psDroid->asWeaps[0].nStat == oldCompInc) - { - //psDroid->asWeaps[inc].nStat = newCompInc; - psDroid->asWeaps[0].nStat = newCompInc; - } - } - break; - default: - //unknown comp type - DBERROR(("Unknown component type - invalid droid")); - return; - } - }*/ + replaceDroidComponent(apsDroidLists[player], oldType, oldCompInc, newCompInc); + replaceDroidComponent(mission.apsDroidLists[player], oldType, oldCompInc, newCompInc); + replaceDroidComponent(apsLimboDroids[player], oldType, oldCompInc, newCompInc); - //check thru the templates + //check thru the templates for (psTemplates = apsDroidTemplates[player]; psTemplates != NULL; psTemplates = psTemplates->psNext) { @@ -2828,54 +2780,8 @@ void replaceComponent(COMP_BASE_STATS *pNewComponent, COMP_BASE_STATS *pOldCompo } } - replaceStructureComponent(apsStructLists[player], oldType, oldCompInc, - newCompInc, player); - replaceStructureComponent(mission.apsStructLists[player], oldType, - oldCompInc, newCompInc, player); - - //check thru the structures - /*for (psStructure = apsStructLists[player]; psStructure != NULL; psStructure = - psStructure->psNext) - { - switch (oldType) - { - case COMP_ECM: - if (psStructure->pStructureType->pECM == (asECMStats + oldCompInc)) - { - psStructure->ecmPower = (UWORD)(asECMStats + newCompInc)->power; - } - break; - case COMP_SENSOR: - if (psStructure->pStructureType->pSensor == (asSensorStats + oldCompInc)) - { - //psStructure->sensorPower = (asSensorStats + newCompInc)->power; - psStructure->sensorPower = (UWORD)sensorPower(asSensorStats + - newCompInc,player); - //psStructure->sensorRange = (asSensorStats + newCompInc)->range; - psStructure->sensorRange = (UWORD)sensorRange(asSensorStats + - newCompInc,player); - } - break; - case COMP_WEAPON: - //for (inc=0; inc < psStructure->numWeaps; inc++) - //can only be one weapon now - if (psStructure->asWeaps[0].nStat > 0) - { - //if (psStructure->asWeaps[inc].nStat == oldCompInc) - //{ - // psStructure->asWeaps[inc].nStat = newCompInc; - //} - if (psStructure->asWeaps[0].nStat == oldCompInc) - { - psStructure->asWeaps[0].nStat = newCompInc; - } - } - break; - default: - //ignore all other component types - break; - } - }*/ + replaceStructureComponent(apsStructLists[player], oldType, oldCompInc, newCompInc, player); + replaceStructureComponent(mission.apsStructLists[player], oldType, oldCompInc, newCompInc, player); } /*Looks through all the currently allocated stats to check the name is not @@ -3301,8 +3207,8 @@ void replaceStructureComponent(STRUCTURE *pList, UDWORD oldType, UDWORD oldCompI } /*swaps the old component for the new one for a specific droid*/ -void switchComponent(DROID *psDroid, UDWORD oldType, UDWORD oldCompInc, - UDWORD newCompInc) +static void switchComponent(DROID *psDroid, UDWORD oldType, UDWORD oldCompInc, + UDWORD newCompInc) { ASSERT( PTRVALID(psDroid, sizeof(DROID)), diff --git a/src/stats.c b/src/stats.c index a09000804..fea08e6b1 100644 --- a/src/stats.c +++ b/src/stats.c @@ -337,78 +337,6 @@ UDWORD numCR(char *pFileBuffer, UDWORD fileSize) return lines; } -/*Load the stats from the Access database*/ -//BOOL loadStats(void) -//{ - /*if (!loadWeaponStats()) - { - DBERROR(("Unable to load weapon stats")); - return FALSE; - }*/ - /*if (!loadBodyStats()) - { - DBERROR(("Unable to load body stats")); - return FALSE; - }*/ - /*if (!loadBrainStats()) - { - DBERROR(("Unable to load brain stats")); - return FALSE; - }*/ - /*if (!loadPropulsionStats()) - { - DBERROR(("Unable to load propulsion stats")); - return FALSE; - }*/ - /*if (!loadSensorStats()) - { - DBERROR(("Unable to load sensor stats")); - return FALSE; - }*/ - /*if (!loadECMStats()) - { - DBERROR(("Unable to load ecm stats")); - return FALSE; - }*/ - /*if (!loadRepairStats()) - { - DBERROR(("Unable to load repair stats")); - return FALSE; - }*/ - /*if (!loadProgramStats()) - { - DBERROR(("Unable to load program stats")); - return FALSE; - }*/ - /*if(!loadConstructStats()) - { - DBERROR(("Unable to load construct stats")); - return FALSE; - }*/ - /*if (!loadPropulsionTypes()) - { - DBERROR(("Unable to load propulsion types")); - return FALSE; - }*/ - /*if (!loadTerrainTable()) - { - DBERROR(("Unable to load terrain table")); - return FALSE; - }*/ - /*if (!loadSpecialAbility()) - { - DBERROR(("Unable to load special ability stats")); - return FALSE; - }*/ - - /*if (!loadFeatureStats()) - { - DBERROR(("Unable to load feature stats")); - return FALSE; - }*/ - -// return TRUE; -//} /******************************************************************************* * Allocate stats functions @@ -725,7 +653,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) else if (!strcmp(weaponClass,"EXPLOSIVE")) { //psStats->weaponClass = WC_EXPLOSIVE; - psStats->weaponClass = WC_KINETIC; + psStats->weaponClass = WC_KINETIC; // explosives were removed from release version of Warzone } else if (!strcmp(weaponClass,"HEAT")) { @@ -734,7 +662,7 @@ BOOL loadWeaponStats(char *pWeaponData, UDWORD bufferSize) else if (!strcmp(weaponClass,"MISC")) { //psStats->weaponClass = WC_MISC; - psStats->weaponClass = WC_HEAT; + psStats->weaponClass = WC_HEAT; // removed from release version of Warzone } else { diff --git a/src/stats.h b/src/stats.h index 84e04eb53..2e24da265 100644 --- a/src/stats.h +++ b/src/stats.h @@ -268,8 +268,6 @@ extern CONSTRUCT_STATS *statsGetConstruct(UDWORD ref); /******************************************************************************* * Generic stats functions *******************************************************************************/ -/*Load the stats from the Access database*/ -//extern BOOL loadStats(void); /*calls the STATS_DEALLOC macro for each set of stats*/ extern BOOL statsShutDown(void);