Only permit Spray Cans to be grabbed on base game levels

I would not be so heavy handed against preventing players from grabbing Spray Cans on custom levels, but designing a system that permits unloaded headers to retain their cans is frankly overkill. There are plenty of other ways the same kind of level-scouring play can be experienced on custom levels.
This commit is contained in:
toaster 2023-08-23 17:16:07 +01:00
parent 53549bfa2d
commit a3640110ae
8 changed files with 19 additions and 10 deletions

View file

@ -1514,7 +1514,8 @@ void D_SRB2Main(void)
// //
// search for mainwad maps // search for mainwad maps
// //
P_InitMapData(false); P_InitMapData();
basenummapheaders = nummapheaders;
CON_SetLoadingProgress(LOADED_IWAD); CON_SetLoadingProgress(LOADED_IWAD);
@ -1525,7 +1526,7 @@ void D_SRB2Main(void)
// //
// search for pwad maps // search for pwad maps
// //
P_InitMapData(true); P_InitMapData();
CON_SetLoadingProgress(LOADED_PWAD); CON_SetLoadingProgress(LOADED_PWAD);

View file

@ -605,7 +605,10 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
} // end while } // end while
if (gamedataadded) if (gamedataadded)
{
basenummapheaders = nummapheaders;
G_LoadGameData(); G_LoadGameData();
}
if (gamestate == GS_MENU || gamestate == GS_TITLESCREEN) if (gamestate == GS_MENU || gamestate == GS_TITLESCREEN)
{ {

View file

@ -551,7 +551,7 @@ struct mapheader_t
#define LF2_FINISHNEEDED (1<<3) ///< Not available in Time Attack modes until you beat the level #define LF2_FINISHNEEDED (1<<3) ///< Not available in Time Attack modes until you beat the level
extern mapheader_t** mapheaderinfo; extern mapheader_t** mapheaderinfo;
extern INT32 nummapheaders, mapallocsize; extern INT32 nummapheaders, basenummapheaders, mapallocsize;
struct unloaded_mapheader_t struct unloaded_mapheader_t
{ {

View file

@ -193,6 +193,7 @@ quake_t *g_quakes = NULL;
// Map Header Information // Map Header Information
mapheader_t** mapheaderinfo = {NULL}; mapheader_t** mapheaderinfo = {NULL};
INT32 nummapheaders = 0; INT32 nummapheaders = 0;
INT32 basenummapheaders = 0;
INT32 mapallocsize = 0; INT32 mapallocsize = 0;
unloaded_mapheader_t *unloadedmapheaders = NULL; unloaded_mapheader_t *unloadedmapheaders = NULL;

View file

@ -642,6 +642,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return; return;
} }
// See also P_SprayCanInit
UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan; UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan;
if (can_id < gamedata->numspraycans) 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 // Assigned to this level, has been grabbed
return; return;
} }
//else // Prevent footguns - these won't persist when custom levels are unloaded
else if (gamemap-1 < basenummapheaders)
{ {
// Unassigned, get the next grabbable colour // Unassigned, get the next grabbable colour
can_id = gamedata->gotspraycans; can_id = gamedata->gotspraycans;

View file

@ -12437,6 +12437,7 @@ static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj)
void P_SprayCanInit(mobj_t* mobj) void P_SprayCanInit(mobj_t* mobj)
{ {
// See also P_TouchSpecialThing
UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan; UINT16 can_id = mapheaderinfo[gamemap-1]->cache_spraycan;
if (can_id < gamedata->numspraycans) if (can_id < gamedata->numspraycans)
@ -12444,7 +12445,8 @@ void P_SprayCanInit(mobj_t* mobj)
// Assigned to this level, has been grabbed // Assigned to this level, has been grabbed
mobj->renderflags = (tr_trans50 << RF_TRANSSHIFT); 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 // Unassigned, get the next grabbable colour
can_id = gamedata->gotspraycans; can_id = gamedata->gotspraycans;

View file

@ -8564,7 +8564,7 @@ lumpnum_t wadnamelump = LUMPERROR;
INT16 wadnamemap = 0; // gamemap based INT16 wadnamemap = 0; // gamemap based
// Initialising map data (and catching replacements)... // Initialising map data (and catching replacements)...
UINT8 P_InitMapData(boolean existingmapheaders) UINT8 P_InitMapData(void)
{ {
UINT8 ret = 0; UINT8 ret = 0;
INT32 i, j; INT32 i, j;
@ -8616,7 +8616,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
if (maplump == LUMPERROR) if (maplump == LUMPERROR)
{ {
#ifndef DEVELOP #ifndef DEVELOP
if (!existingmapheaders) if (!basenummapheaders)
{ {
I_Error("P_InitMapData: Base map %s has a header but no level\n", name); 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; ret |= MAPRET_ADDED;
CONS_Printf("%s\n", name); 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 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) if (partadd_stage == 2)
{ {
UINT8 mapsadded = P_InitMapData(true); UINT8 mapsadded = P_InitMapData();
if (!mapsadded) if (!mapsadded)
CONS_Printf(M_GetText("No maps added\n")); CONS_Printf(M_GetText("No maps added\n"));

View file

@ -114,7 +114,7 @@ boolean P_AddWadFile(const char *wadfilename);
#define MAPRET_ADDED (1) #define MAPRET_ADDED (1)
#define MAPRET_CURRENTREPLACED (1<<1) #define MAPRET_CURRENTREPLACED (1<<1)
UINT8 P_InitMapData(boolean existingmapheaders); UINT8 P_InitMapData(void);
extern lumpnum_t wadnamelump; extern lumpnum_t wadnamelump;
extern INT16 wadnamemap; extern INT16 wadnamemap;
#define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7)) #define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7))