diff --git a/Source/g_game.c b/Source/g_game.c index 83dc0004..0b3a3065 100644 --- a/Source/g_game.c +++ b/Source/g_game.c @@ -77,8 +77,6 @@ static size_t maxdemosize; static byte *demo_p; static short consistancy[MAXPLAYERS][BACKUPTICS]; -static mapentry_t *G_LookupMapinfo(int episode, int map); - static int G_GameOptionSize(void); gameaction_t gameaction; @@ -2623,7 +2621,7 @@ void G_SetFastParms(int fast_pending) } } -static mapentry_t *G_LookupMapinfo(int episode, int map) +mapentry_t *G_LookupMapinfo(int episode, int map) { char lumpname[9]; unsigned i; @@ -2662,6 +2660,9 @@ int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap) epi = 1; } + if (epi > 4) + EpiCustom = true; + if (pEpi) *pEpi = epi; if (pMap) *pMap = map; return !strcmp(mapuname, lumpname); @@ -2672,8 +2673,6 @@ int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap) // Can be called by the startup code or the menu task, // consoleplayer, displayplayer, playeringame[] should be set. -extern int EpiCustom; - void G_InitNew(skill_t skill, int episode, int map) { int i; diff --git a/Source/m_cheat.c b/Source/m_cheat.c index a53d0040..ac3a2ebd 100644 --- a/Source/m_cheat.c +++ b/Source/m_cheat.c @@ -38,6 +38,7 @@ #include "dstrings.h" #include "d_deh.h" // Ty 03/27/98 - externalized strings #include "d_io.h" // haleyjd +#include "u_mapinfo.h" #define plyr (players+consoleplayer) /* the console player */ @@ -438,6 +439,7 @@ static void cheat_clev(buf) char buf[3]; { int epsd, map; + mapentry_t* entry; if (gamemode == commercial) { @@ -450,6 +452,11 @@ char buf[3]; map = buf[1] - '0'; } + // First check if we have a mapinfo entry for the requested level. + // If this is present the remaining checks should be skipped. + entry = G_LookupMapinfo(epsd, map); + if (!entry) + { // Catch invalid maps. if (epsd < 1 || map < 1 || // Ohmygod - this is not going to work. (gamemode == retail && (epsd > 4 || map > 9 )) || @@ -457,6 +464,7 @@ char buf[3]; (gamemode == shareware && (epsd > 1 || map > 9 )) || (gamemode == commercial && (epsd > 1 || map > 32 )) ) return; + } // So be it. diff --git a/Source/u_mapinfo.h b/Source/u_mapinfo.h index 5117c6f1..80bd94e0 100644 --- a/Source/u_mapinfo.h +++ b/Source/u_mapinfo.h @@ -21,6 +21,8 @@ #ifndef __UMAPINFO_H #define __UMAPINFO_H +#include "doomtype.h" + typedef struct { int type; @@ -60,6 +62,9 @@ typedef struct extern umapinfo_t U_mapinfo; +extern boolean EpiCustom; +mapentry_t *G_LookupMapinfo(int episode, int map); + int U_ParseMapInfo(const char *buffer, size_t length); void U_FreeMapInfo();