diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index bde2125e2..eab3f6f85 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -3066,7 +3066,7 @@ bool CallFunc_MapWarp(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wor return false; } - nextmapoverride = (nextmap + 1); + nextmapoverride = (mapnum_t)(nextmap + 1); if (argV[1] == 0) skipstats = 1; diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index 41967d293..b83c875d4 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -275,7 +275,7 @@ void Environment::loadModule(ACSVM::Module *module) if (name->i) // this module is from a map! { - UINT16 mapnum = G_MapNumber(name->s->str); + mapnum_t mapnum = G_MapNumber(name->s->str); if (mapnum < NEXTMAP_INVALID) lumpnum = mapheaderinfo[mapnum]->lumpnum; } diff --git a/src/d_main.cpp b/src/d_main.cpp index 0cd6991fb..1d1f0f298 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -15,6 +15,7 @@ /// plus functions to parse command line parameters, configure game /// parameters, and call the startup functions. +#include "g_mapnum.h" #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) #include #include @@ -1172,7 +1173,7 @@ void D_StartTitle(void) if (i > nummapheaders) I_Error("D_StartTitle: No valid map ID found!?"); - COM_BufAddText(va("map %s\n", G_BuildMapName(i))); + COM_BufAddText(va("map %s\n", G_BuildMapName((mapnum_t)(i)))); } return; @@ -1456,7 +1457,7 @@ void D_SRB2Main(void) { INT32 p; - INT32 pstartmap = 1; + mapnum_t pstartmap = (mapnum_t)1; boolean autostart = false; /* break the version string into version numbers, for netplay */ @@ -2006,7 +2007,7 @@ void D_SRB2Main(void) // rei/miru: bootmap (Idea: starts the game on a predefined map) if (bootmap && !(M_CheckParm("-warp") && M_IsNextParm())) { - pstartmap = G_MapNumber(bootmap)+1; + pstartmap = (mapnum_t)(G_MapNumber(bootmap)+1); if (pstartmap > nummapheaders) { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e08833fd8..f8797afcf 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3340,7 +3340,7 @@ INT32 mapchangepending = 0; * \sa D_GameTypeChanged, Command_Map_f * \author Graue */ -void D_MapChange(UINT16 mapnum, INT32 newgametype, boolean pencoremode, boolean presetplayers, INT32 delay, boolean skipprecutscene, boolean pforcespecialstage) +void D_MapChange(mapnum_t mapnum, INT32 newgametype, boolean pencoremode, boolean presetplayers, INT32 delay, boolean skipprecutscene, boolean pforcespecialstage) { static char buf[1+1+1+1+1+2+4]; static char *buf_p = buf; @@ -3412,7 +3412,7 @@ void D_SetupVote(void) INT32 i; UINT8 gt = (cv_kartgametypepreference.value == -1) ? gametype : cv_kartgametypepreference.value; UINT8 secondgt = G_SometimesGetDifferentGametype(gt); - UINT16 votebuffer[4] = {NEXTMAP_INVALID,NEXTMAP_INVALID,NEXTMAP_INVALID,0}; + mapnum_t votebuffer[4] = {NEXTMAP_INVALID,NEXTMAP_INVALID,NEXTMAP_INVALID,0}; if (cv_kartencore.value && cv_encorevotes.value == 1 && (gametypes[gt]->rules & GTR_CIRCUIT)) WRITEUINT8(p, (gt|VOTEMODIFIER_ENCORE)); @@ -3923,7 +3923,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) UINT8 skipprecutscene, pforcespecialstage; boolean pencoremode, hasroundqueuedata; UINT16 lastgametype; - UINT16 mapnumber; + mapnum_t mapnumber; forceresetplayers = deferencoremode = false; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 9ebbec6c9..2038284e6 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -16,6 +16,7 @@ #define __D_NETCMD__ #include "command.h" +#include "g_mapnum.h" #ifdef __cplusplus extern "C" { @@ -404,7 +405,7 @@ void D_SendPlayerConfig(UINT8 n); void Command_ExitGame_f(void); void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore -void D_MapChange(UINT16 pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pforcespecialstage); +void D_MapChange(mapnum_t pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pforcespecialstage); void D_SetupVote(void); void D_ModifyClientVote(UINT8 player, SINT8 voted); void D_PickVote(void); diff --git a/src/deh_soc.c b/src/deh_soc.c index 247bb461a..1fc730ddb 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -790,7 +790,7 @@ void readgametype(MYFILE *f, char *gtname) CONS_Printf("Added gametype %s\n", gtname); } -static mapheader_lighting_t *usemaplighting(UINT16 mapnum, const char *word) +static mapheader_lighting_t *usemaplighting(mapnum_t mapnum, const char *word) { if (fastncmp(word, "ENCORE", 6)) { @@ -853,7 +853,7 @@ if (fastcmp(word, name)) \ OUTOFRANGE_CONSTANT(name, word2, minname, maxname); \ } -static void processvector(const char* name, UINT16 mapnum, char *word2, f_vector3_t *vec, float min, float max) +static void processvector(const char* name, mapnum_t mapnum, char *word2, f_vector3_t *vec, float min, float max) { char *tmp = strtok(word2,","); float vector[3]; @@ -878,7 +878,7 @@ static void processvector(const char* name, UINT16 mapnum, char *word2, f_vector } // Handle parsing globalefx info -static void globalmapefxparameters(UINT16 mapnum, INT32 i, char *word, char *word2) +static void globalmapefxparameters(mapnum_t mapnum, INT32 i, char *word, char *word2) { // Take off GLOBALEFX_ word += 10; @@ -1068,7 +1068,7 @@ void readlevelheader(MYFILE *f, char * name) name = va("MAP%s", name); } - UINT16 num = G_MapNumber(name); + mapnum_t num = G_MapNumber(name); if (num >= nummapheaders) { @@ -3166,7 +3166,7 @@ void readunlockable(MYFILE *f, INT32 num) { Z_Free(unlockables[num].stringVar); unlockables[num].stringVar = Z_StrDup(word2); - unlockables[num].variable = (UINT16)G_MapNumber(word2); + unlockables[num].variable = G_MapNumber(word2); } else deh_warning("Unlockable %d: unknown word '%s'", num+1, word); diff --git a/src/doomstat.h b/src/doomstat.h index ae0e53fce..f39100745 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -23,6 +23,8 @@ extern "C" { #endif +#include "g_mapnum.h" + // We need globally shared data structures, for defining the global state variables. #include "doomdata.h" @@ -36,7 +38,7 @@ extern "C" { // ============================= // Selected by user. -extern UINT16 gamemap; +extern mapnum_t gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; extern UINT32 mapmusposition; @@ -284,7 +286,7 @@ struct textprompt_t extern textprompt_t *textprompts[MAX_PROMPTS]; // For the Custom Exit linedef. -extern UINT16 nextmapoverride; +extern mapnum_t nextmapoverride; extern UINT8 skipstats; // Fun extra stuff @@ -347,7 +349,7 @@ struct cupheader_t char icon[9]; ///< Name of the icon patch char *levellist[CUPCACHE_MAX]; ///< List of levels that belong to this cup - UINT16 cachedlevels[CUPCACHE_MAX]; ///< IDs in levellist, bonusgame, and specialstage + mapnum_t cachedlevels[CUPCACHE_MAX]; ///< IDs in levellist, bonusgame, and specialstage UINT8 numlevels; ///< Number of levels defined in levellist UINT8 numbonus; ///< Number of bonus stages defined UINT8 emeraldnum; ///< ID of Emerald to use for special stage (1-7 for Chaos Emeralds, 8-14 for Super Emeralds, 0 for no emerald) diff --git a/src/g_game.c b/src/g_game.c index 5896a1365..cc312c14f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -102,7 +102,7 @@ UINT32 mapmusposition; // Position to jump to UINT32 mapmusresume; UINT8 mapmusrng; // Random selection result -UINT16 gamemap = 1; +mapnum_t gamemap = 1; UINT32 maptol; preciptype_t globalweather = PRECIP_NONE; @@ -179,7 +179,7 @@ boolean exitfadestarted = false; cutscene_t *cutscenes[128] = {}; textprompt_t *textprompts[MAX_PROMPTS]; -UINT16 nextmapoverride; +mapnum_t nextmapoverride; UINT8 skipstats; struct quake quake = {}; @@ -326,7 +326,7 @@ tic_t antibumptime; // Delay before players start bumping into one another. typedef struct { - UINT16 *mapbuffer; // Pointer to zone memory + mapnum_t *mapbuffer; // Pointer to zone memory INT32 lastnummapheaders; // Reset if nummapheaders != this UINT8 counttogametype; // Time to gametype change event } randmaps_t; @@ -337,7 +337,7 @@ static void G_ResetRandMapBuffer(void) INT32 i; Z_Free(randmaps.mapbuffer); randmaps.lastnummapheaders = nummapheaders; - randmaps.mapbuffer = Z_Malloc(randmaps.lastnummapheaders * sizeof(UINT16), PU_STATIC, NULL); + randmaps.mapbuffer = Z_Malloc(randmaps.lastnummapheaders * sizeof(mapnum_t), PU_STATIC, NULL); for (i = 0; i < randmaps.lastnummapheaders; i++) randmaps.mapbuffer[i] = NEXTMAP_INVALID; //intentionally not resetting randmaps.counttogametype here @@ -352,10 +352,10 @@ typedef struct joystickvector2_s INT32 yaxis; } joystickvector2_t; -UINT16 prevmap, nextmap; +mapnum_t prevmap, nextmap; -UINT16 kartmap2native[NEXTMAP_SPECIAL] = {0}, nativemap2kart[NEXTMAP_SPECIAL] = {0}; -UINT16 nextexnum = NUMMAPS; +mapnum_t kartmap2native[NEXTMAP_SPECIAL] = {0}, nativemap2kart[NEXTMAP_SPECIAL] = {0}; +mapnum_t nextexnum = NUMMAPS; // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. @@ -777,7 +777,7 @@ void G_ClearRecords(void) // For easy retrieval of records // TODO: should this work for unloaded maps? -tic_t G_GetBestTime(UINT16 map) +tic_t G_GetBestTime(mapnum_t map) { const char *mapname = G_BuildMapName(map + 1); tic_t besttime = UINT32_MAX; @@ -1006,7 +1006,7 @@ void G_SetGameModified(boolean silent, boolean major) * \return Pointer to a static buffer containing the desired map name. * \sa G_MapNumber */ -const char *G_BuildMapName(UINT16 map) +const char *G_BuildMapName(mapnum_t map) { if (map > 0 && map <= nummapheaders && mapheaderinfo[map - 1] != NULL) { @@ -1024,13 +1024,13 @@ const char *G_BuildMapName(UINT16 map) * \return Map number. * \sa G_BuildMapName, nextmapspecial_t */ -UINT16 G_MapNumber(const char * name) +mapnum_t G_MapNumber(const char * name) { #ifdef NEXTMAPINSOC if (strncasecmp("NEXTMAP_", name, 8) != 0) #endif { - UINT16 map; + mapnum_t map; UINT32 hash = FNV1a_QuickCaseHash(name, MAXMAPLUMPNAME); for (map = 0; map < nummapheaders; ++map) @@ -1067,9 +1067,9 @@ UINT16 G_MapNumber(const char * name) * \return Map number. * \sa G_BuildMapName, nextmapspecial_t */ -UINT16 G_LevelTitleToMapNum(const char * leveltitle) +mapnum_t G_LevelTitleToMapNum(const char * leveltitle) { - UINT16 map; + mapnum_t map; char levelname[48]; for (map = 0; map < nummapheaders; ++map) @@ -1103,7 +1103,7 @@ UINT16 G_LevelTitleToMapNum(const char * leveltitle) } // convert kart map number to native map number -UINT16 G_KartMapToNative(UINT16 mapnum) +mapnum_t G_KartMapToNative(mapnum_t mapnum) { if (mapnum > 0 && mapnum < NEXTMAP_SPECIAL) return kartmap2native[mapnum-1]; @@ -1111,7 +1111,7 @@ UINT16 G_KartMapToNative(UINT16 mapnum) } // convert native map number to kart -UINT16 G_NativeMapToKart(UINT16 mapnum) +mapnum_t G_NativeMapToKart(mapnum_t mapnum) { if (mapnum > 0 && mapnum < NEXTMAP_SPECIAL) return nativemap2kart[mapnum-1]+1; @@ -4374,7 +4374,7 @@ void G_AddTOL(UINT32 newtol, const char *tolname) // Returns TRUE if // the given map is a special stage. // -boolean G_IsSpecialStage(UINT16 mapnum) +boolean G_IsSpecialStage(mapnum_t mapnum) { mapnum--; // gamemap-based to 0 indexed @@ -4556,9 +4556,9 @@ UINT32 G_TOLFlag(INT32 pgametype) return 0; } -INT16 G_GetFirstMapOfGametype(UINT8 pgametype) +mapnum_t G_GetFirstMapOfGametype(UINT8 pgametype) { - UINT16 mapnum = NEXTMAP_INVALID; + mapnum_t mapnum = NEXTMAP_INVALID; /* G: not sure what to do with this if ((gametypes[pgametype]->rules & GTR_CAMPAIGN) && kartcupheaders) @@ -4619,12 +4619,12 @@ static INT32 TOLMaps(UINT8 pgametype) * has those flags. * \author Graue */ -UINT16 G_RandMap(UINT32 tolflags, UINT16 pprevmap, UINT8 ignorebuffer, UINT8 maphell, UINT16 *extbuffer) +mapnum_t G_RandMap(UINT32 tolflags, mapnum_t pprevmap, UINT8 ignorebuffer, UINT8 maphell, mapnum_t *extbuffer) { UINT32 numokmaps = 0; - INT16 ix, bufx; - INT16 *okmaps = NULL; - UINT16 extbufsize = 0; + mapnum_t ix, bufx; + mapnum_t *okmaps = NULL; + mapnum_t extbufsize = 0; boolean usehellmaps; // Only consider Hell maps in this pick if (randmaps.lastnummapheaders != nummapheaders) @@ -4772,10 +4772,10 @@ tryagain: return ix; } -void G_AddMapToBuffer(UINT16 map) +void G_AddMapToBuffer(mapnum_t map) { - INT16 bufx; - INT16 refreshnum = (TOLMaps(gametype))-3; + mapnum_t bufx; + mapnum_t refreshnum = (TOLMaps(gametype))-3; if (refreshnum < 0) refreshnum = 3; @@ -4848,7 +4848,7 @@ static void G_UpdateVisited(void) //CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); } -static boolean CanSaveLevel(UINT16 mapnum) +static boolean CanSaveLevel(mapnum_t mapnum) { // SRB2Kart: No save files yet (void)mapnum; @@ -5354,7 +5354,7 @@ static void G_DoCompleted(void) S_StopSounds(); - prevmap = (UINT16)(gamemap-1); + prevmap = (mapnum_t)(gamemap-1); if (!demo.playback) { @@ -5613,7 +5613,7 @@ static boolean LoadLegacyRecords(savebuffer_t *save) for (UINT32 i = 0; i < numgamedatamapheaders; i++) { char mapname[MAXMAPLUMPNAME]; - //UINT16 mapnum; + //mapnum_t mapnum; tic_t rectime; tic_t reclap; @@ -5987,7 +5987,7 @@ void G_SaveGameData(void) // G_InitFromSavegame // Can be called by the startup code or the menu task. // -void G_LoadGame(UINT32 slot, UINT16 mapoverride) +void G_LoadGame(UINT32 slot, mapnum_t mapoverride) { char vcheck[VERSIONSIZE]; char savename[255]; @@ -6080,7 +6080,7 @@ void G_LoadGame(UINT32 slot, UINT16 mapoverride) // G_SaveGame // Saves your game. // -void G_SaveGame(UINT32 slot, UINT16 mapnum) +void G_SaveGame(UINT32 slot, mapnum_t mapnum) { boolean saved; char savename[256] = ""; @@ -6242,7 +6242,7 @@ cleanup: // Can be called by the startup code or the menu task, // consoleplayer, displayplayers[], playeringame[] should be set. // -void G_DeferedInitNew(boolean pencoremode, UINT16 map, INT32 pickedchar, UINT8 ssplayers, boolean FLS) +void G_DeferedInitNew(boolean pencoremode, mapnum_t map, INT32 pickedchar, UINT8 ssplayers, boolean FLS) { UINT16 color = SKINCOLOR_NONE; INT32 dogametype; @@ -6289,7 +6289,7 @@ void G_DeferedInitNew(boolean pencoremode, UINT16 map, INT32 pickedchar, UINT8 s // This is the map command interpretation something like Command_Map_f // // called at: map cmd execution, doloadgame, doplaydemo -void G_InitNew(UINT8 pencoremode, UINT16 map, boolean resetplayer, boolean skipprecutscene) +void G_InitNew(UINT8 pencoremode, mapnum_t map, boolean resetplayer, boolean skipprecutscene) { const char * mapname = G_BuildMapName(map); @@ -6390,7 +6390,7 @@ void G_InitNew(UINT8 pencoremode, UINT16 map, boolean resetplayer, boolean skipp } -char *G_BuildMapTitle(UINT16 mapnum) +char *G_BuildMapTitle(mapnum_t mapnum) { char *title = NULL; @@ -6463,7 +6463,7 @@ static void measurekeywords(mapsearchfreq_t *fr, } static void writesimplefreq(mapsearchfreq_t *fr, INT32 *frc, - UINT16 mapnum, UINT8 pos, UINT8 siz) + mapnum_t mapnum, UINT8 pos, UINT8 siz) { fr[(*frc)].mapnum = mapnum; fr[(*frc)].matchd = ZZ_Alloc(sizeof (struct searchdim)); @@ -6474,12 +6474,12 @@ static void writesimplefreq(mapsearchfreq_t *fr, INT32 *frc, (*frc)++; } -UINT16 G_FindMap(const char *mapname, char **foundmapnamep, +mapnum_t G_FindMap(const char *mapname, char **foundmapnamep, mapsearchfreq_t **freqp, INT32 *freqcp) { - UINT16 newmapnum = 0; - UINT16 mapnum; - UINT16 apromapnum = 0; + mapnum_t newmapnum = 0; + mapnum_t mapnum; + mapnum_t apromapnum = 0; size_t mapnamelen; char *realmapname = NULL; @@ -6612,9 +6612,9 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) Z_Free(freq); } -UINT16 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) +mapnum_t G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { - INT32 newmapnum; + mapnum_t newmapnum; size_t mapnamelen; diff --git a/src/g_game.h b/src/g_game.h index b86f7d748..a42a90c5e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -14,6 +14,7 @@ #ifndef __G_GAME__ #define __G_GAME__ +#include "g_mapnum.h" #include "doomdef.h" #include "doomstat.h" #include "d_event.h" @@ -38,20 +39,7 @@ extern boolean playeringame[MAXPLAYERS]; extern tic_t levelstarttic; // for modding? -extern UINT16 prevmap, nextmap; - -// see also G_MapNumber -typedef enum -{ - NEXTMAP_RESERVED = UINT16_MAX, // so nextmap+1 doesn't roll over -- remove when gamemap is made 0-indexed - NEXTMAP_TITLE = UINT16_MAX-1, - NEXTMAP_EVALUATION = UINT16_MAX-2, - NEXTMAP_CREDITS = UINT16_MAX-3, - NEXTMAP_CEREMONY = UINT16_MAX-4, - NEXTMAP_VOTING = UINT16_MAX-5, - NEXTMAP_INVALID = UINT16_MAX-6, // Always last - NEXTMAP_SPECIAL = NEXTMAP_INVALID -} nextmapspecial_t; +extern mapnum_t prevmap, nextmap; #define ROUNDQUEUE_MAX 10 // sane max? maybe make dynamically allocated later #define ROUNDQUEUE_CLEAR UINT16_MAX // lives in gametype field of packets @@ -77,8 +65,8 @@ void G_MapSlipIntoRoundQueue(UINT8 position, UINT16 map, UINT8 setgametype, bool void G_MapIntoRoundQueue(UINT16 map, UINT8 setgametype, boolean setencore, boolean rankrestricted); void G_GPCupIntoRoundQueue(cupheader_t *cup, UINT8 setgametype, boolean setencore); -extern UINT16 kartmap2native[NEXTMAP_SPECIAL], nativemap2kart[NEXTMAP_SPECIAL]; -extern UINT16 nextexnum; +extern mapnum_t kartmap2native[NEXTMAP_SPECIAL], nativemap2kart[NEXTMAP_SPECIAL]; +extern mapnum_t nextexnum; extern INT32 gameovertics; extern UINT8 ammoremovaltics; @@ -130,11 +118,11 @@ void weaponPrefChange4(void); #define MAXPLMOVE (50) -const char *G_BuildMapName(UINT16 map); -UINT16 G_MapNumber(const char *mapname); -UINT16 G_LevelTitleToMapNum(const char * leveltitle); -UINT16 G_KartMapToNative(UINT16 mapnum); -UINT16 G_NativeMapToKart(UINT16 mapnum); +const char *G_BuildMapName(mapnum_t map); +mapnum_t G_MapNumber(const char *mapname); +mapnum_t G_LevelTitleToMapNum(const char * leveltitle); +mapnum_t G_KartMapToNative(mapnum_t mapnum); +mapnum_t G_NativeMapToKart(mapnum_t mapnum); void G_ResetAnglePrediction(player_t *player); void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); @@ -189,9 +177,9 @@ boolean G_AxisInDeadzone(UINT8 p, event_t *ev); void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo); void G_DoReborn(INT32 playernum); void G_PlayerReborn(INT32 player, boolean betweenmaps); -void G_InitNew(UINT8 pencoremode, UINT16 map, boolean resetplayer, +void G_InitNew(UINT8 pencoremode, mapnum_t map, boolean resetplayer, boolean skipprecutscene); -char *G_BuildMapTitle(UINT16 mapnum); +char *G_BuildMapTitle(mapnum_t mapnum); struct searchdim { @@ -209,12 +197,12 @@ struct mapsearchfreq_t UINT8 total;/* total hits */ }; -UINT16 G_FindMap(const char *query, char **foundmapnamep, +mapnum_t G_FindMap(const char *query, char **foundmapnamep, mapsearchfreq_t **freqp, INT32 *freqc); void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc); /* Match map name by search + 2 digit map code or map number. */ -UINT16 G_FindMapByNameOrCode(const char *query, char **foundmapnamep); +mapnum_t G_FindMapByNameOrCode(const char *query, char **foundmapnamep); // XMOD spawning mapthing_t *G_FindTeamStart(INT32 playernum); @@ -226,7 +214,7 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost); // Can be called by the startup code or M_Responder. // A normal game starts at map 1, but a warp test can start elsewhere -void G_DeferedInitNew(boolean pencoremode, UINT16 map, INT32 pickedchar, +void G_DeferedInitNew(boolean pencoremode, mapnum_t map, INT32 pickedchar, UINT8 ssplayers, boolean FLS); void G_DoLoadLevel(boolean resetplayer); @@ -235,11 +223,11 @@ void G_PreLevelTitleCard(void); boolean G_IsTitleCardAvailable(void); // Can be called by the startup code or M_Responder, calls P_SetupLevel. -void G_LoadGame(UINT32 slot, UINT16 mapoverride); +void G_LoadGame(UINT32 slot, mapnum_t mapoverride); void G_SaveGameData(void); -void G_SaveGame(UINT32 slot, UINT16 mapnum); +void G_SaveGame(UINT32 slot, mapnum_t mapnum); void G_SaveGameOver(UINT32 slot, boolean modifylives); @@ -250,7 +238,7 @@ void G_UpdateGametypeSelections(void); INT32 G_GetGametypeByName(const char *gametypestr); INT32 G_GuessGametypeByTOL(UINT32 tol); -boolean G_IsSpecialStage(UINT16 mapnum); +boolean G_IsSpecialStage(mapnum_t mapnum); boolean G_GametypeUsesLives(void); boolean G_GametypeHasTeams(void); boolean G_GametypeHasSpectators(void); @@ -381,11 +369,11 @@ maprecord_t *G_GetMapRecord(const char *mapname); maprecordpreset_t *G_AllocateMapRecordPreset(maprecord_t *record, const char *presetname, UINT8 version); maprecordpreset_t *G_GetMapRecordPreset(maprecord_t *record, const char *presetname); void G_ClearRecords(void); -tic_t G_GetBestTime(UINT16 map); +tic_t G_GetBestTime(mapnum_t map); boolean G_EmblemsEnabled(void); char *G_GetRecordReplayFolder(boolean home, boolean breaker); -char *G_GetRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which); -boolean G_CheckRecordReplay(const char *folder, UINT16 mapnum, UINT16 skinnum, recordreplay_e which); +char *G_GetRecordReplay(const char *folder, mapnum_t mapnum, UINT16 skinnum, recordreplay_e which); +boolean G_CheckRecordReplay(const char *folder, mapnum_t mapnum, UINT16 skinnum, recordreplay_e which); FUNCMATH INT32 G_TicsToHours(tic_t tics); FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full); @@ -395,10 +383,10 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); // Don't split up TOL handling UINT32 G_TOLFlag(INT32 pgametype); -INT16 G_GetFirstMapOfGametype(UINT8 pgametype); +mapnum_t G_GetFirstMapOfGametype(UINT8 pgametype); -UINT16 G_RandMap(UINT32 tolflags, UINT16 pprevmap, UINT8 ignorebuffer, UINT8 maphell, UINT16 *extbuffer); -void G_AddMapToBuffer(UINT16 map); +mapnum_t G_RandMap(UINT32 tolflags, mapnum_t pprevmap, UINT8 ignorebuffer, UINT8 maphell, mapnum_t *extbuffer); +void G_AddMapToBuffer(mapnum_t map); typedef struct { diff --git a/src/g_mapnum.h b/src/g_mapnum.h new file mode 100644 index 000000000..fe761e4cb --- /dev/null +++ b/src/g_mapnum.h @@ -0,0 +1,38 @@ +// BLANKART +//----------------------------------------------------------------------------- +// Copyright (C) 2026 by Team BlanKart. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file d_player.h +/// \brief Map number type + +#ifndef __MAPNUM__ +#define __MAPNUM__ + +#include "doomdef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// see also G_MapNumber +typedef enum +{ + NEXTMAP_RESERVED = UINT16_MAX, // so nextmap+1 doesn't roll over -- remove when gamemap is made 0-indexed + NEXTMAP_TITLE = UINT16_MAX-1, + NEXTMAP_EVALUATION = UINT16_MAX-2, + NEXTMAP_CREDITS = UINT16_MAX-3, + NEXTMAP_CEREMONY = UINT16_MAX-4, + NEXTMAP_VOTING = UINT16_MAX-5, + NEXTMAP_INVALID = UINT16_MAX-6, // Always last + NEXTMAP_SPECIAL = NEXTMAP_INVALID +} ATTRPACK mapnum_t; + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/src/k_kart.c b/src/k_kart.c index 8071c1efb..48b3f93c0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6705,7 +6705,7 @@ static void K_RaceStart(player_t *player) } -UINT8 K_RaceLapCount(UINT16 mapNum) +UINT8 K_RaceLapCount(mapnum_t mapNum) { if (!(gametypes[gametype]->rules & GTR_CIRCUIT)) { diff --git a/src/k_kart.h b/src/k_kart.h index 272222d5a..76c70cbdf 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -9,6 +9,7 @@ #include "doomdef.h" #include "d_player.h" // Need for player_t #include "command.h" // Need for player_t +#include "g_game.h" // Need for mapnum_t #ifdef __cplusplus extern "C" { @@ -228,7 +229,7 @@ void K_SpawnBumpEffect(mobj_t *mo); void K_KartMoveAnimation(player_t *player); void K_KartPlayerHUDUpdate(player_t *player); void K_KartResetPlayerColor(player_t *player); -UINT8 K_RaceLapCount(UINT16 mapNum); +UINT8 K_RaceLapCount(mapnum_t mapNum); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerAfterThink(player_t *player); angle_t K_MomentumAngle(mobj_t *mo); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 1cb9f7202..079777626 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -440,7 +440,7 @@ static int lib_pGetColorAfter(lua_State *L) static int lib_gMapNumber(lua_State *L) { const char *arg = luaL_checkstring(L, 1); - UINT16 map; + mapnum_t map; map = G_MapNumber(arg); @@ -3347,7 +3347,7 @@ static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) static int lib_gBuildMapName(lua_State *L) { - UINT16 map = Lcheckmapnumber(L, 1, "G_BuildMapName"); + mapnum_t map = Lcheckmapnumber(L, 1, "G_BuildMapName"); if (lua_compatmode && map == 0) // v1 has undefined behaviour if you return 0, who knew. { @@ -3361,7 +3361,7 @@ static int lib_gBuildMapName(lua_State *L) static int lib_gBuildMapTitle(lua_State *L) { - UINT16 map = Lcheckmapnumber(L, 1, "G_BuildMapTitle"); + mapnum_t map = Lcheckmapnumber(L, 1, "G_BuildMapTitle"); char *name; if (map < 1 || map > nummapheaders) { @@ -3427,7 +3427,7 @@ static int lib_gFindMap(lua_State *L) { const char *query = luaL_checkstring(L, 1); - UINT16 map; + mapnum_t map; char *realname; INT32 frc; mapsearchfreq_t *frv; @@ -3474,7 +3474,7 @@ Returns: static int lib_gFindMapByNameOrCode(lua_State *L) { const char *query = luaL_checkstring(L, 1); - UINT16 map; + mapnum_t map; char *realname; map = G_FindMapByNameOrCode(query, &realname); lua_pushnumber(L, map); @@ -3519,7 +3519,7 @@ static int lib_gSetCustomExitVars(lua_State *L) if (n >= 1) { - nextmapoverride = (UINT16)luaL_optinteger(L, 1, 0); + nextmapoverride = luaL_optinteger(L, 1, 0); skipstats = (INT16)luaL_optinteger(L, 2, 0); if (lua_compatmode && nextmapoverride) nextmapoverride = G_KartMapToNative(nextmapoverride); @@ -3542,7 +3542,7 @@ static int lib_gExitLevel(lua_State *L) static int lib_gIsSpecialStage(lua_State *L) { - UINT16 mapnum = Lcheckmapnumber(L, 1, "G_IsSpecialStage"); + mapnum_t mapnum = Lcheckmapnumber(L, 1, "G_IsSpecialStage"); //HUDSAFE INLEVEL lua_pushboolean(L, G_IsSpecialStage(lua_compatmode ? G_KartMapToNative(mapnum) : mapnum)); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 153b548e1..e564b80e1 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1377,7 +1377,7 @@ static int libd_getStringColormap(lua_State *L) static int libd_getMapThumbnail(lua_State *L) { - UINT16 mapnum; + mapnum_t mapnum; patch_t *patch = NULL; HUDONLY if (lua_type(L, 1) == LUA_TNUMBER) @@ -1393,7 +1393,7 @@ static int libd_getMapThumbnail(lua_State *L) static int libd_getMapMinimap(lua_State *L) { - UINT16 mapnum; + mapnum_t mapnum; patch_t *patch = NULL; HUDONLY if (lua_type(L, 1) == LUA_TNUMBER) diff --git a/src/m_cond.c b/src/m_cond.c index 3454d2bcd..d157b022f 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -403,13 +403,13 @@ UINT8 M_SecretUnlocked(INT32 type) #undef CHADYES } -UINT8 M_MapLocked(UINT16 mapnum) +UINT8 M_MapLocked(mapnum_t mapnum) { #ifdef DEVELOP if (1) return false; -#endif +#endif if (!mapnum || mapnum > nummapheaders) return false; if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0) @@ -517,9 +517,9 @@ INT32 M_UnlockableSkinNum(unlockable_t *unlock) // Pass -1 mapnum to continue from last emblem. // NULL if not found. // note that this goes in reverse!! -emblem_t *M_GetLevelEmblems(UINT16 mapnum) +emblem_t *M_GetLevelEmblems(mapnum_t mapnum) { - static UINT16 map = -1; + static mapnum_t map = NEXTMAP_INVALID; static INT32 i = -1; if (mapnum >= 0) diff --git a/src/m_cond.h b/src/m_cond.h index 2c8d27d0b..fb31299aa 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -14,6 +14,7 @@ #define __M_COND_H__ #include "info.h" +#include "g_mapnum.h" #ifdef __cplusplus extern "C" { @@ -170,11 +171,11 @@ UINT8 M_CheckLevelEmblems(void); // Checking unlockable status UINT8 M_AnySecretUnlocked(void); UINT8 M_SecretUnlocked(INT32 type); -UINT8 M_MapLocked(UINT16 mapnum); +UINT8 M_MapLocked(mapnum_t mapnum); INT32 M_CountEmblems(void); // Emblem shit -emblem_t *M_GetLevelEmblems(UINT16 mapnum); +emblem_t *M_GetLevelEmblems(mapnum_t mapnum); skincolornum_t M_GetEmblemColor(emblem_t *em); const char *M_GetEmblemPatch(emblem_t *em, boolean big); skincolornum_t M_GetExtraEmblemColor(extraemblem_t *em); diff --git a/src/m_menu.c b/src/m_menu.c index 473529cb4..7353858a6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -201,7 +201,7 @@ int M_GetWaitingMode(void); typedef struct { - UINT16 mapnum; + mapnum_t mapnum; char mapname[MAXMAPNAME]; UINT8 color; boolean available; @@ -637,7 +637,7 @@ INT32 HU_GetHighlightColor(void) return highlightflags; } -fixed_t M_GetMapThumbnail(UINT16 mapnum, patch_t **out) +fixed_t M_GetMapThumbnail(mapnum_t mapnum, patch_t **out) { patch_t *patch = NULL; if (mapnum == NEXTMAP_INVALID) @@ -2441,7 +2441,7 @@ static void M_CentreText(INT32 y, const char *string) // // used by pause & statistics to draw a row of emblems for a map // -static void M_DrawMapEmblems(UINT16 mapnum, INT32 x, INT32 y) +static void M_DrawMapEmblems(mapnum_t mapnum, INT32 x, INT32 y) { UINT8 lasttype = UINT8_MAX, curtype; emblem_t *emblem = M_GetLevelEmblems(mapnum); @@ -2746,7 +2746,7 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo { case ITF_THUMBNAIL: { - UINT16 mapnum = G_MapNumber(item->patch); + mapnum_t mapnum = G_MapNumber(item->patch); scale = M_GetMapThumbnail(mapnum < nummapheaders ? mapnum : NEXTMAP_INVALID, &p)/4; break; } @@ -3040,7 +3040,7 @@ static INT32 M_GetLevelListTOL(void) } } -static boolean M_LevelAvailableOnPlatter(UINT16 mapnum) +static boolean M_LevelAvailableOnPlatter(mapnum_t mapnum) { // don't care (void)mapnum; @@ -3052,7 +3052,7 @@ static boolean M_LevelAvailableOnPlatter(UINT16 mapnum) // // Determines whether to show a given map in the various level-select lists. // -static boolean M_CanShowLevelOnPlatter(UINT16 mapnum) +static boolean M_CanShowLevelOnPlatter(mapnum_t mapnum) { // Does the map exist? if (mapnum < 0 || mapnum >= nummapheaders || !mapheaderinfo[mapnum]) @@ -3266,7 +3266,7 @@ static void M_UpdateLevelPlatterCups(void) break; levelselectmap_t *lsmap = &lsrow->maps[lsrow->numcolumns++]; - UINT16 mapnum = cup->cachedlevels[j]; + mapnum_t mapnum = cup->cachedlevels[j]; lsmap->mapnum = mapnum; // putting the map on the platter lsmap->available = M_LevelAvailableOnPlatter(mapnum); @@ -3351,7 +3351,7 @@ static void M_UpdateLevelPlatter(void) for (i = 0; i < numsortedmaps; i++) { - UINT16 mapnum = sortedmaps[i]; + mapnum_t mapnum = sortedmaps[i]; mapheader_t *itermap = mapheaderinfo[mapnum]; boolean wide = false;//(headermap->menuflags & LF2_WIDEICON); @@ -3882,7 +3882,7 @@ void MD_DrawLevelPlatterMenu(void) // Determines whether to show a given map in the various level-select lists. // Set gt = -1 to ignore gametype. // -boolean M_CanShowLevelInList(UINT16 mapnum) +boolean M_CanShowLevelInList(mapnum_t mapnum) { return M_CanShowLevelOnPlatter(mapnum) && M_LevelAvailableOnPlatter(mapnum); } diff --git a/src/m_menu.h b/src/m_menu.h index da24c74e9..243f8ec08 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -129,7 +129,7 @@ typedef enum void M_QuitResponse(INT32 ch); // Determines whether to show a level in the list (platter version does not need to be exposed) -boolean M_CanShowLevelInList(UINT16 mapnum); +boolean M_CanShowLevelInList(mapnum_t mapnum); typedef enum { @@ -450,7 +450,7 @@ void M_RefreshPauseMenu(void); INT32 HU_GetHighlightColor(void); -fixed_t M_GetMapThumbnail(UINT16 mapnum, patch_t **out); +fixed_t M_GetMapThumbnail(mapnum_t mapnum, patch_t **out); // Moviemode menu updating void Moviemode_option_Onchange(void); diff --git a/src/p_saveg.c b/src/p_saveg.c index 9c96bcca8..03eb9119b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3997,7 +3997,7 @@ static inline void P_NetSyncSpecials(savebuffer_t *save) // ======================================================================= // Misc // ======================================================================= -static inline void P_ArchiveMisc(savebuffer_t *save, UINT16 mapnum) +static inline void P_ArchiveMisc(savebuffer_t *save, mapnum_t mapnum) { TracyCZone(__zone, true); @@ -4014,7 +4014,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save, UINT16 mapnum) TracyCZoneEnd(__zone); } -static inline void P_UnArchiveSPGame(savebuffer_t *save, UINT16 mapoverride) +static inline void P_UnArchiveSPGame(savebuffer_t *save, mapnum_t mapoverride) { TracyCZone(__zone, true); @@ -4568,7 +4568,7 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(savebuffer_t *save) return ret; } -void P_SaveGame(savebuffer_t *save, UINT16 mapnum) +void P_SaveGame(savebuffer_t *save, mapnum_t mapnum) { P_ArchiveMisc(save, mapnum); P_ArchivePlayer(save); @@ -4626,7 +4626,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) TracyCZoneEnd(__zone); } -boolean P_LoadGame(savebuffer_t *save, UINT16 mapoverride) +boolean P_LoadGame(savebuffer_t *save, mapnum_t mapoverride) { if (gamestate == GS_INTERMISSION) Y_EndIntermission(); diff --git a/src/p_saveg.h b/src/p_saveg.h index ca4c6907b..e2216ce13 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -14,6 +14,8 @@ #ifndef __P_SAVEG__ #define __P_SAVEG__ +#include "g_mapnum.h" + #ifdef __cplusplus extern "C" { #endif @@ -27,9 +29,9 @@ extern "C" { // Persistent storage/archiving. // These are the load / save game routines. -void P_SaveGame(savebuffer_t *save, UINT16 mapnum); +void P_SaveGame(savebuffer_t *save, mapnum_t mapnum); void P_SaveNetGame(savebuffer_t *save, boolean resending); -boolean P_LoadGame(savebuffer_t *save, UINT16 mapoverride); +boolean P_LoadGame(savebuffer_t *save, mapnum_t mapoverride); boolean P_LoadNetGame(savebuffer_t *save, boolean reloading); mobj_t *P_FindNewPosition(UINT32 oldposition); diff --git a/src/p_setup.c b/src/p_setup.c index 868cb1407..e8848937a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -391,7 +391,7 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) * * \param i The header to set flickies for */ -void P_SetDemoFlickies(UINT16 i) +void P_SetDemoFlickies(mapnum_t i) { mapheaderinfo[i]->numFlickies = 5; mapheaderinfo[i]->flickies = Z_Realloc(mapheaderinfo[i]->flickies, 5*sizeof(mobjtype_t), PU_STATIC, NULL); @@ -406,7 +406,7 @@ void P_SetDemoFlickies(UINT16 i) * * \param i The header to clear flickies for */ -void P_DeleteFlickies(UINT16 i) +void P_DeleteFlickies(mapnum_t i) { if (mapheaderinfo[i]->flickies) Z_Free(mapheaderinfo[i]->flickies); @@ -486,7 +486,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 num) * * \param i Index of header to allocate. */ -void P_AllocMapHeader(UINT16 i) +void P_AllocMapHeader(mapnum_t i) { if (i > nummapheaders) I_Error("P_AllocMapHeader: Called on %d, should be %d", i, nummapheaders); @@ -9394,7 +9394,7 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l } lumpnum_t wadnamelump = LUMPERROR; -UINT16 wadnamemap = 0; // gamemap based +mapnum_t wadnamemap = 0; // gamemap based // Initialising map data... UINT8 P_InitMapData(boolean existingmapheaders) diff --git a/src/p_setup.h b/src/p_setup.h index 7f0626dba..4fb4fc10c 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -14,6 +14,7 @@ #ifndef __P_SETUP__ #define __P_SETUP__ +#include "g_mapnum.h" #include "doomdata.h" #include "doomstat.h" #include "r_defs.h" @@ -98,7 +99,7 @@ boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat, boolean local) #define MAPRET_CURRENTREPLACED (1<<1) UINT8 P_InitMapData(boolean existingmapheaders); extern lumpnum_t wadnamelump; -extern UINT16 wadnamemap; +extern mapnum_t wadnamemap; #define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7)) // WARNING: The following functions should be grouped as follows: @@ -130,10 +131,10 @@ boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); boolean P_SectorUsesDirectionalLighting(const sector_t *sector); size_t P_PrecacheLevelFlats(void); -void P_AllocMapHeader(UINT16 i); +void P_AllocMapHeader(mapnum_t i); -void P_SetDemoFlickies(UINT16 i); -void P_DeleteFlickies(UINT16 i); +void P_SetDemoFlickies(mapnum_t i); +void P_DeleteFlickies(mapnum_t i); // Needed for NiGHTS void P_ReloadRings(void); diff --git a/src/p_spec.c b/src/p_spec.c index d3d02dd29..c596fa5d4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5286,7 +5286,7 @@ static void P_ProcessExitSector(player_t *player, mtag_t sectag) return; } - nextmapoverride = (UINT16)(udmf ? lines[lineindex].args[0] : lines[lineindex].frontsector->floorheight>>FRACBITS); + nextmapoverride = (mapnum_t)(udmf ? lines[lineindex].args[0] : lines[lineindex].frontsector->floorheight>>FRACBITS); if (lines[lineindex].args[1] & TMEF_SKIPTALLY) skipstats = 1; diff --git a/src/p_user.c b/src/p_user.c index c4956d4f1..f2f6a34e3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -310,7 +310,7 @@ boolean P_PlayerMoving(INT32 pnum) // UINT8 P_GetNextEmerald(void) { - UINT16 mapnum = gamemap-1; + mapnum_t mapnum = gamemap-1; if (mapnum > nummapheaders || !mapheaderinfo[mapnum]) return 0; diff --git a/src/y_inter.c b/src/y_inter.c index 469119c84..65ba56a24 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1452,7 +1452,7 @@ void Y_VoteDrawer(void) fixed_t rubyheight = 0; fixed_t scale; patch_t *pic; - UINT16 mapnum; + mapnum_t mapnum; fixed_t picwidth = 160; // CEP: scale by screen hypotenuse for extra voting rows