diff --git a/src/levels.c b/src/levels.c index 928b2e086..c509c071b 100644 --- a/src/levels.c +++ b/src/levels.c @@ -63,7 +63,7 @@ static LEVEL_DATASET *psBaseData; static LEVEL_DATASET *psCurrLevel; // dummy level data for single WRF loads -static LEVEL_DATASET sSingleWRF; +static LEVEL_DATASET sSingleWRF = { 0, 0, 0, 0, 0, { 0 }, 0, 0, 0 }; // return values from the lexer char *pLevToken; @@ -138,7 +138,7 @@ void levError(const char *pError) } // find the level dataset -BOOL levFindDataSet(char *pName, LEVEL_DATASET **ppsDataSet) +BOOL levFindDataSet(const char* name, LEVEL_DATASET **ppsDataSet) { LEVEL_DATASET *psNewLevel; @@ -146,7 +146,7 @@ BOOL levFindDataSet(char *pName, LEVEL_DATASET **ppsDataSet) { if (psNewLevel->pName != NULL) { - if (strcmp(psNewLevel->pName, pName) == 0) + if (strcmp(psNewLevel->pName, name) == 0) { *ppsDataSet = psNewLevel; return true; @@ -525,14 +525,19 @@ BOOL levReleaseAll(void) } // load up a single wrf file -static BOOL levLoadSingleWRF(char *pName) +static BOOL levLoadSingleWRF(const char* name) { // free the old data levReleaseAll(); // create the dummy level data + if (sSingleWRF.pName) + { + free(sSingleWRF.pName); + } + memset(&sSingleWRF, 0, sizeof(LEVEL_DATASET)); - sSingleWRF.pName = pName; + sSingleWRF.pName = strdup(name); // load up the WRF if (!stageOneInitialise()) @@ -541,8 +546,8 @@ static BOOL levLoadSingleWRF(char *pName) } // load the data - debug(LOG_WZ, "levLoadSingleWRF: Loading %s ...", pName); - if (!resLoad(pName, 0)) + debug(LOG_WZ, "levLoadSingleWRF: Loading %s ...", name); + if (!resLoad(name, 0)) { return false; } @@ -565,25 +570,25 @@ char *getLevelName( void ) // load up the data for a level -BOOL levLoadData(char *pName, char *pSaveName, SDWORD saveType) +BOOL levLoadData(const char* name, char *pSaveName, SDWORD saveType) { LEVEL_DATASET *psNewLevel, *psBaseData, *psChangeLevel; SDWORD i; BOOL bCamChangeSaveGame; - debug(LOG_WZ, "Loading level %s (%s)", pName, pSaveName); + debug(LOG_WZ, "Loading level %s (%s)", name, pSaveName); levelLoadType = saveType; // find the level dataset - if (!levFindDataSet(pName, &psNewLevel)) + if (!levFindDataSet(name, &psNewLevel)) { - debug( LOG_NEVER, "levLoadData: dataset %s not found - trying to load as WRF", pName ); - return levLoadSingleWRF(pName); + debug(LOG_NEVER, "levLoadData: dataset %s not found - trying to load as WRF", name); + return levLoadSingleWRF(name); } /* Keep a copy of the present level name */ - strlcpy(currentLevelName, pName, sizeof(currentLevelName)); + strlcpy(currentLevelName, name, sizeof(currentLevelName)); bCamChangeSaveGame = false; if (pSaveName && saveType == GTYPE_SAVE_START) @@ -952,7 +957,7 @@ BOOL levLoadData(char *pName, char *pSaveName, SDWORD saveType) return true; } -static void levTestLoad(char *level) +static void levTestLoad(const char* level) { static char savegameName[80]; bool retval; diff --git a/src/levels.h b/src/levels.h index 5ea827cd1..df11f8807 100644 --- a/src/levels.h +++ b/src/levels.h @@ -84,10 +84,10 @@ extern void levShutDown(void); extern BOOL levInitialise(void); // load up the data for a level -extern BOOL levLoadData(char *pName, char *pSaveName, SDWORD saveType); +extern BOOL levLoadData(const char* name, char *pSaveName, SDWORD saveType); // find the level dataset -extern BOOL levFindDataSet(char *pName, LEVEL_DATASET **ppsDataSet); +extern BOOL levFindDataSet(const char* name, LEVEL_DATASET **ppsDataSet); // free the currently loaded dataset extern BOOL levReleaseAll(void); diff --git a/src/structure.c b/src/structure.c index cb7fd1973..a89793a99 100644 --- a/src/structure.c +++ b/src/structure.c @@ -5296,9 +5296,6 @@ void setFlagPositionInc(FUNCTIONALITY* pFunctionality, UDWORD player, UBYTE fact UBYTE mask = 1; FACTORY *psFactory; REPAIR_FACILITY *psRepair; -#ifdef DEBUG - char *pType; //if you are going to do this, then make SURE you also do the same to anything -#endif //that uses the variable. ASSERT( player < MAX_PLAYERS, "setFlagPositionInc: invalid player number" ); //find the first vacant slot @@ -5315,6 +5312,8 @@ void setFlagPositionInc(FUNCTIONALITY* pFunctionality, UDWORD player, UBYTE fact { //this may happen now with electronic warfare #ifdef DEBUG + const char* pType; + switch (factoryType) { case FACTORY_FLAG: