umapinfo: fix idclev (#318)

* umapinfo: fix idclev

* set EpiCustom if episode > 4

* move EpiCustom and G_LookupMapinfo to u_mapinfo.h

* fix clang build
This commit is contained in:
Roman Fomin 2021-10-19 18:39:18 +07:00 committed by GitHub
parent fd8781bad6
commit 423ac8e20d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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();