diff --git a/src/d_main.c b/src/d_main.c index 9652f0d10..fd05bc3cd 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1514,7 +1514,8 @@ void D_SRB2Main(void) // // search for mainwad maps // - P_InitMapData(false); + P_InitMapData(); + basenummapheaders = nummapheaders; CON_SetLoadingProgress(LOADED_IWAD); @@ -1525,7 +1526,7 @@ void D_SRB2Main(void) // // search for pwad maps // - P_InitMapData(true); + P_InitMapData(); CON_SetLoadingProgress(LOADED_PWAD); diff --git a/src/dehacked.c b/src/dehacked.c index 6d44b87fb..66567fb05 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -605,7 +605,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) } // end while if (gamedataadded) + { + basenummapheaders = nummapheaders; G_LoadGameData(); + } if (gamestate == GS_MENU || gamestate == GS_TITLESCREEN) { diff --git a/src/doomstat.h b/src/doomstat.h index 7d14f1d5a..26ea96cdb 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -551,7 +551,7 @@ struct mapheader_t #define LF2_FINISHNEEDED (1<<3) ///< Not available in Time Attack modes until you beat the level extern mapheader_t** mapheaderinfo; -extern INT32 nummapheaders, mapallocsize; +extern INT32 nummapheaders, basenummapheaders, mapallocsize; struct unloaded_mapheader_t { diff --git a/src/g_game.c b/src/g_game.c index 17d16b47a..36de12b56 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -193,6 +193,7 @@ quake_t *g_quakes = NULL; // Map Header Information mapheader_t** mapheaderinfo = {NULL}; INT32 nummapheaders = 0; +INT32 basenummapheaders = 0; INT32 mapallocsize = 0; unloaded_mapheader_t *unloadedmapheaders = NULL; diff --git a/src/p_inter.c b/src/p_inter.c index 2b9542295..0d99598dc 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -642,6 +642,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; } + // See also P_SprayCanInit UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan; if (can_id < gamedata->numspraycans) @@ -649,7 +650,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Assigned to this level, has been grabbed return; } - //else + // Prevent footguns - these won't persist when custom levels are unloaded + else if (gamemap-1 < basenummapheaders) { // Unassigned, get the next grabbable colour can_id = gamedata->gotspraycans; diff --git a/src/p_mobj.c b/src/p_mobj.c index d4823700c..76ae716a3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12437,6 +12437,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) void P_SprayCanInit(mobj_t* mobj) { + // See also P_TouchSpecialThing UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan; if (can_id < gamedata->numspraycans) @@ -12444,7 +12445,8 @@ void P_SprayCanInit(mobj_t* mobj) // Assigned to this level, has been grabbed mobj->renderflags = (tr_trans50 << RF_TRANSSHIFT); } - else + // Prevent footguns - these won't persist when custom levels are unloaded + else if (gamemap-1 < basenummapheaders) { // Unassigned, get the next grabbable colour can_id = gamedata->gotspraycans; diff --git a/src/p_setup.c b/src/p_setup.c index f5461fa35..f55c13b09 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8564,7 +8564,7 @@ lumpnum_t wadnamelump = LUMPERROR; INT16 wadnamemap = 0; // gamemap based // Initialising map data (and catching replacements)... -UINT8 P_InitMapData(boolean existingmapheaders) +UINT8 P_InitMapData(void) { UINT8 ret = 0; INT32 i, j; @@ -8616,7 +8616,7 @@ UINT8 P_InitMapData(boolean existingmapheaders) if (maplump == LUMPERROR) { #ifndef DEVELOP - if (!existingmapheaders) + if (!basenummapheaders) { I_Error("P_InitMapData: Base map %s has a header but no level\n", name); } @@ -8633,7 +8633,7 @@ UINT8 P_InitMapData(boolean existingmapheaders) ret |= MAPRET_ADDED; CONS_Printf("%s\n", name); - if (existingmapheaders && mapheaderinfo[i]->lumpnum != LUMPERROR) + if (basenummapheaders && mapheaderinfo[i]->lumpnum != LUMPERROR) { G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you @@ -8950,7 +8950,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) if (partadd_stage == 2) { - UINT8 mapsadded = P_InitMapData(true); + UINT8 mapsadded = P_InitMapData(); if (!mapsadded) CONS_Printf(M_GetText("No maps added\n")); diff --git a/src/p_setup.h b/src/p_setup.h index 1d474dd10..bcffd85b2 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -114,7 +114,7 @@ boolean P_AddWadFile(const char *wadfilename); #define MAPRET_ADDED (1) #define MAPRET_CURRENTREPLACED (1<<1) -UINT8 P_InitMapData(boolean existingmapheaders); +UINT8 P_InitMapData(void); extern lumpnum_t wadnamelump; extern INT16 wadnamemap; #define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7))