diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index 317fc6018..41967d293 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! { - INT32 mapnum = G_MapNumber(name->s->str); + UINT16 mapnum = G_MapNumber(name->s->str); if (mapnum < NEXTMAP_INVALID) lumpnum = mapheaderinfo[mapnum]->lumpnum; } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 368c83aff..fee2f5a4f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3340,18 +3340,13 @@ INT32 mapchangepending = 0; * \sa D_GameTypeChanged, Command_Map_f * \author Graue */ -void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean presetplayers, INT32 delay, boolean skipprecutscene, boolean pforcespecialstage) +void D_MapChange(UINT16 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; // The supplied data are assumed to be good. I_Assert(delay >= 0 && delay <= 2); - if (mapnum != -1) - { - CV_SetValue(&cv_nextmap, mapnum); - } - CONS_Debug(DBG_GAMELOGIC, "Map change: mapnum=%d gametype=%d pencoremode=%d presetplayers=%d delay=%d skipprecutscene=%d pforcespecialstage = %d\n", mapnum, newgametype, pencoremode, presetplayers, delay, skipprecutscene, pforcespecialstage); @@ -3384,7 +3379,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean p // new gametype value WRITEUINT16(buf_p, newgametype); - WRITEINT16(buf_p, mapnum); + WRITEUINT16(buf_p, mapnum); } if (delay == 1) @@ -3928,7 +3923,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) UINT8 skipprecutscene, pforcespecialstage; boolean pencoremode, hasroundqueuedata; UINT16 lastgametype; - INT16 mapnumber; + UINT16 mapnumber; forceresetplayers = deferencoremode = false; @@ -4007,7 +4002,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) if (!(gametypes[gametype]->rules & GTR_ENCORE) && !bossinfo.boss) pencoremode = false; - mapnumber = READINT16(*cp); + mapnumber = READUINT16(*cp); // Handle some Grand Prix state. if (grandprixinfo.gp) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 2924fc2cf..9ebbec6c9 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -404,7 +404,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(INT32 pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pforcespecialstage); +void D_MapChange(UINT16 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 4eaa51263..247bb461a 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(INT32 mapnum, const char *word) +static mapheader_lighting_t *usemaplighting(UINT16 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, INT32 mapnum, char *word2, f_vector3_t *vec, float min, float max) +static void processvector(const char* name, UINT16 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, INT32 mapnum, char *word2, f_vector3 } // Handle parsing globalefx info -static void globalmapefxparameters(INT32 mapnum, INT32 i, char *word, char *word2) +static void globalmapefxparameters(UINT16 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); } - INT32 num = G_MapNumber(name); + UINT16 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 = (INT16)G_MapNumber(word2); + unlockables[num].variable = (UINT16)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 6413d612a..e230d0e26 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -36,7 +36,7 @@ extern "C" { // ============================= // Selected by user. -extern INT16 gamemap; +extern UINT16 gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; extern UINT32 mapmusposition; @@ -347,7 +347,7 @@ struct cupheader_t char icon[9]; ///< Name of the icon patch char *levellist[CUPCACHE_MAX]; ///< List of levels that belong to this cup - INT16 cachedlevels[CUPCACHE_MAX]; ///< IDs in levellist, bonusgame, and specialstage + UINT16 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 142db29d9..8b01b5597 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 -INT16 gamemap = 1; +UINT16 gamemap = 1; UINT32 maptol; preciptype_t globalweather = PRECIP_NONE; @@ -352,10 +352,10 @@ typedef struct joystickvector2_s INT32 yaxis; } joystickvector2_t; -INT16 prevmap, nextmap; +UINT16 prevmap, nextmap; -INT16 kartmap2native[NEXTMAP_SPECIAL] = {0}, nativemap2kart[NEXTMAP_SPECIAL] = {0}; -INT16 nextexnum = NUMMAPS; +UINT16 kartmap2native[NEXTMAP_SPECIAL] = {0}, nativemap2kart[NEXTMAP_SPECIAL] = {0}; +UINT16 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(INT16 map) +tic_t G_GetBestTime(UINT16 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(INT32 map) +const char *G_BuildMapName(UINT16 map) { if (map > 0 && map <= nummapheaders && mapheaderinfo[map - 1] != NULL) { @@ -1024,13 +1024,13 @@ const char *G_BuildMapName(INT32 map) * \return Map number. * \sa G_BuildMapName, nextmapspecial_t */ -INT32 G_MapNumber(const char * name) +UINT16 G_MapNumber(const char * name) { #ifdef NEXTMAPINSOC if (strncasecmp("NEXTMAP_", name, 8) != 0) #endif { - INT32 map; + UINT16 map; UINT32 hash = FNV1a_QuickCaseHash(name, MAXMAPLUMPNAME); for (map = 0; map < nummapheaders; ++map) @@ -1067,9 +1067,9 @@ INT32 G_MapNumber(const char * name) * \return Map number. * \sa G_BuildMapName, nextmapspecial_t */ -INT32 G_LevelTitleToMapNum(const char * leveltitle) +UINT16 G_LevelTitleToMapNum(const char * leveltitle) { - INT32 map; + UINT16 map; char levelname[48]; for (map = 0; map < nummapheaders; ++map) @@ -1099,11 +1099,11 @@ INT32 G_LevelTitleToMapNum(const char * leveltitle) } } - return INT32_MIN; + return NEXTMAP_INVALID; } // convert kart map number to native map number -INT16 G_KartMapToNative(INT16 mapnum) +UINT16 G_KartMapToNative(UINT16 mapnum) { if (mapnum > 0 && mapnum < NEXTMAP_SPECIAL) return kartmap2native[mapnum-1]; @@ -1111,7 +1111,7 @@ INT16 G_KartMapToNative(INT16 mapnum) } // convert native map number to kart -INT16 G_NativeMapToKart(INT16 mapnum) +UINT16 G_NativeMapToKart(UINT16 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(INT32 mapnum) +boolean G_IsSpecialStage(UINT16 mapnum) { mapnum--; // gamemap-based to 0 indexed @@ -4558,7 +4558,7 @@ UINT32 G_TOLFlag(INT32 pgametype) INT16 G_GetFirstMapOfGametype(UINT8 pgametype) { - INT16 mapnum = NEXTMAP_INVALID; + UINT16 mapnum = NEXTMAP_INVALID; /* G: not sure what to do with this if ((gametypes[pgametype]->rules & GTR_CAMPAIGN) && kartcupheaders) @@ -4772,7 +4772,7 @@ tryagain: return ix; } -void G_AddMapToBuffer(INT16 map) +void G_AddMapToBuffer(UINT16 map) { INT16 bufx; INT16 refreshnum = (TOLMaps(gametype))-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(INT32 mapnum) +static boolean CanSaveLevel(UINT16 mapnum) { // SRB2Kart: No save files yet (void)mapnum; @@ -5001,13 +5001,13 @@ void G_GetNextMap(void) deferencoremode = (cv_kartencore.value == 1); forceresetplayers = forcespecialstage = false; - INT16 newmap, curmap = gamestate == GS_LEVEL ? gamemap-1 : prevmap; + UINT16 newmap, curmap = gamestate == GS_LEVEL ? gamemap-1 : prevmap; // go to next level // nextmap is 0-based, unlike gamemap if (nextmapoverride != 0) { - newmap = (INT16)(nextmapoverride-1); + newmap = (UINT16)(nextmapoverride-1); setalready = true; } else if (roundqueue.size > 0) @@ -5559,7 +5559,7 @@ static boolean LoadLegacyRecords(savebuffer_t *save) for (UINT32 i = 0; i < numgamedatamapheaders; i++) { char mapname[MAXMAPLUMPNAME]; - //INT16 mapnum; + //UINT16 mapnum; tic_t rectime; tic_t reclap; @@ -5933,7 +5933,7 @@ void G_SaveGameData(void) // G_InitFromSavegame // Can be called by the startup code or the menu task. // -void G_LoadGame(UINT32 slot, INT16 mapoverride) +void G_LoadGame(UINT32 slot, UINT16 mapoverride) { char vcheck[VERSIONSIZE]; char savename[255]; @@ -6026,7 +6026,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) // G_SaveGame // Saves your game. // -void G_SaveGame(UINT32 slot, INT16 mapnum) +void G_SaveGame(UINT32 slot, UINT16 mapnum) { boolean saved; char savename[256] = ""; @@ -6188,7 +6188,7 @@ cleanup: // Can be called by the startup code or the menu task, // consoleplayer, displayplayers[], playeringame[] should be set. // -void G_DeferedInitNew(boolean pencoremode, INT32 map, INT32 pickedchar, UINT8 ssplayers, boolean FLS) +void G_DeferedInitNew(boolean pencoremode, UINT16 map, INT32 pickedchar, UINT8 ssplayers, boolean FLS) { UINT16 color = SKINCOLOR_NONE; INT32 dogametype; @@ -6235,7 +6235,7 @@ void G_DeferedInitNew(boolean pencoremode, INT32 map, INT32 pickedchar, UINT8 ss // This is the map command interpretation something like Command_Map_f // // called at: map cmd execution, doloadgame, doplaydemo -void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skipprecutscene) +void G_InitNew(UINT8 pencoremode, UINT16 map, boolean resetplayer, boolean skipprecutscene) { const char * mapname = G_BuildMapName(map); @@ -6336,7 +6336,7 @@ void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skippr } -char *G_BuildMapTitle(INT32 mapnum) +char *G_BuildMapTitle(UINT16 mapnum) { char *title = NULL; @@ -6409,7 +6409,7 @@ static void measurekeywords(mapsearchfreq_t *fr, } static void writesimplefreq(mapsearchfreq_t *fr, INT32 *frc, - INT32 mapnum, UINT8 pos, UINT8 siz) + UINT16 mapnum, UINT8 pos, UINT8 siz) { fr[(*frc)].mapnum = mapnum; fr[(*frc)].matchd = ZZ_Alloc(sizeof (struct searchdim)); @@ -6420,12 +6420,12 @@ static void writesimplefreq(mapsearchfreq_t *fr, INT32 *frc, (*frc)++; } -INT32 G_FindMap(const char *mapname, char **foundmapnamep, +UINT16 G_FindMap(const char *mapname, char **foundmapnamep, mapsearchfreq_t **freqp, INT32 *freqcp) { - INT32 newmapnum = 0; - INT32 mapnum; - INT32 apromapnum = 0; + UINT16 newmapnum = 0; + UINT16 mapnum; + UINT16 apromapnum = 0; size_t mapnamelen; char *realmapname = NULL; @@ -6558,7 +6558,7 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) Z_Free(freq); } -INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) +UINT16 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) { INT32 newmapnum; diff --git a/src/g_game.h b/src/g_game.h index 003f89fbf..0635ccfea 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -38,18 +38,18 @@ extern boolean playeringame[MAXPLAYERS]; extern tic_t levelstarttic; // for modding? -extern INT16 prevmap, nextmap; +extern UINT16 prevmap, nextmap; // see also G_MapNumber typedef enum { - NEXTMAP_RESERVED = INT16_MAX, // so nextmap+1 doesn't roll over -- remove when gamemap is made 0-indexed - NEXTMAP_TITLE = INT16_MAX-1, - NEXTMAP_EVALUATION = INT16_MAX-2, - NEXTMAP_CREDITS = INT16_MAX-3, - NEXTMAP_CEREMONY = INT16_MAX-4, - NEXTMAP_VOTING = INT16_MAX-5, - NEXTMAP_INVALID = INT16_MAX-6, // Always last + 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; @@ -77,8 +77,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 INT16 kartmap2native[NEXTMAP_SPECIAL], nativemap2kart[NEXTMAP_SPECIAL]; -extern INT16 nextexnum; +extern UINT16 kartmap2native[NEXTMAP_SPECIAL], nativemap2kart[NEXTMAP_SPECIAL]; +extern UINT16 nextexnum; extern INT32 gameovertics; extern UINT8 ammoremovaltics; @@ -130,11 +130,11 @@ void weaponPrefChange4(void); #define MAXPLMOVE (50) -const char *G_BuildMapName(INT32 map); -INT32 G_MapNumber(const char *mapname); -INT32 G_LevelTitleToMapNum(const char * leveltitle); -INT16 G_KartMapToNative(INT16 mapnum); -INT16 G_NativeMapToKart(INT16 mapnum); +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); void G_ResetAnglePrediction(player_t *player); void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); @@ -189,9 +189,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, INT32 map, boolean resetplayer, +void G_InitNew(UINT8 pencoremode, UINT16 map, boolean resetplayer, boolean skipprecutscene); -char *G_BuildMapTitle(INT32 mapnum); +char *G_BuildMapTitle(UINT16 mapnum); struct searchdim { @@ -209,12 +209,12 @@ struct mapsearchfreq_t UINT8 total;/* total hits */ }; -INT32 G_FindMap(const char *query, char **foundmapnamep, +UINT16 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. */ -INT32 G_FindMapByNameOrCode(const char *query, char **foundmapnamep); +UINT16 G_FindMapByNameOrCode(const char *query, char **foundmapnamep); // XMOD spawning mapthing_t *G_FindTeamStart(INT32 playernum); @@ -226,7 +226,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, INT32 map, INT32 pickedchar, +void G_DeferedInitNew(boolean pencoremode, UINT16 map, INT32 pickedchar, UINT8 ssplayers, boolean FLS); void G_DoLoadLevel(boolean resetplayer); @@ -235,11 +235,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, INT16 mapoverride); +void G_LoadGame(UINT32 slot, UINT16 mapoverride); void G_SaveGameData(void); -void G_SaveGame(UINT32 slot, INT16 mapnum); +void G_SaveGame(UINT32 slot, UINT16 mapnum); void G_SaveGameOver(UINT32 slot, boolean modifylives); @@ -250,7 +250,7 @@ void G_UpdateGametypeSelections(void); INT32 G_GetGametypeByName(const char *gametypestr); INT32 G_GuessGametypeByTOL(UINT32 tol); -boolean G_IsSpecialStage(INT32 mapnum); +boolean G_IsSpecialStage(UINT16 mapnum); boolean G_GametypeUsesLives(void); boolean G_GametypeHasTeams(void); boolean G_GametypeHasSpectators(void); @@ -381,7 +381,7 @@ 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(INT16 map); +tic_t G_GetBestTime(UINT16 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); @@ -398,7 +398,7 @@ UINT32 G_TOLFlag(INT32 pgametype); INT16 G_GetFirstMapOfGametype(UINT8 pgametype); INT16 G_RandMap(UINT32 tolflags, INT16 pprevmap, UINT8 ignorebuffer, UINT8 maphell, INT16 *extbuffer); -void G_AddMapToBuffer(INT16 map); +void G_AddMapToBuffer(UINT16 map); typedef struct { diff --git a/src/k_kart.c b/src/k_kart.c index ecd2796dc..8071c1efb 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(INT16 mapNum) +UINT8 K_RaceLapCount(UINT16 mapNum) { if (!(gametypes[gametype]->rules & GTR_CIRCUIT)) { diff --git a/src/k_kart.h b/src/k_kart.h index b9e91772b..272222d5a 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -228,7 +228,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(INT16 mapNum); +UINT8 K_RaceLapCount(UINT16 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 cc30f2c64..78ac9d208 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -440,11 +440,11 @@ static int lib_pGetColorAfter(lua_State *L) static int lib_gMapNumber(lua_State *L) { const char *arg = luaL_checkstring(L, 1); - INT32 map; + UINT16 map; map = G_MapNumber(arg); - if (map == INT32_MAX) + if (map == NEXTMAP_INVALID) return 0; @@ -3347,7 +3347,7 @@ static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) static int lib_gBuildMapName(lua_State *L) { - INT32 map = Lcheckmapnumber(L, 1, "G_BuildMapName"); + UINT16 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) { - INT32 map = Lcheckmapnumber(L, 1, "G_BuildMapTitle"); + UINT16 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); - INT32 map; + UINT16 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); - INT32 map; + UINT16 map; char *realname; map = G_FindMapByNameOrCode(query, &realname); lua_pushnumber(L, map); @@ -3542,7 +3542,7 @@ static int lib_gExitLevel(lua_State *L) static int lib_gIsSpecialStage(lua_State *L) { - INT32 mapnum = Lcheckmapnumber(L, 1, "G_IsSpecialStage"); + UINT16 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 8fb09244a..153b548e1 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) { - INT16 mapnum; + UINT16 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) { - INT16 mapnum; + UINT16 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 83e7cb643..3454d2bcd 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -403,7 +403,7 @@ UINT8 M_SecretUnlocked(INT32 type) #undef CHADYES } -UINT8 M_MapLocked(INT32 mapnum) +UINT8 M_MapLocked(UINT16 mapnum) { #ifdef DEVELOP @@ -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(INT32 mapnum) +emblem_t *M_GetLevelEmblems(UINT16 mapnum) { - static INT32 map = -1; + static UINT16 map = -1; static INT32 i = -1; if (mapnum >= 0) diff --git a/src/m_cond.h b/src/m_cond.h index 087eae676..2c8d27d0b 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -170,11 +170,11 @@ UINT8 M_CheckLevelEmblems(void); // Checking unlockable status UINT8 M_AnySecretUnlocked(void); UINT8 M_SecretUnlocked(INT32 type); -UINT8 M_MapLocked(INT32 mapnum); +UINT8 M_MapLocked(UINT16 mapnum); INT32 M_CountEmblems(void); // Emblem shit -emblem_t *M_GetLevelEmblems(INT32 mapnum); +emblem_t *M_GetLevelEmblems(UINT16 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 865b25002..2a9f3bb7a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -201,7 +201,7 @@ int M_GetWaitingMode(void); typedef struct { - INT16 mapnum; + UINT16 mapnum; char mapname[MAXMAPNAME]; UINT8 color; boolean available; @@ -637,10 +637,10 @@ INT32 HU_GetHighlightColor(void) return highlightflags; } -fixed_t M_GetMapThumbnail(INT16 mapnum, patch_t **out) +fixed_t M_GetMapThumbnail(UINT16 mapnum, patch_t **out) { patch_t *patch = NULL; - if (mapnum == -1) + if (mapnum == NEXTMAP_INVALID) patch = randomlvl; else if (mapnum >= 0 && mapnum < nummapheaders && mapheaderinfo[mapnum]) patch = mapheaderinfo[mapnum]->thumbnailPic; @@ -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(INT32 mapnum, INT32 x, INT32 y) +static void M_DrawMapEmblems(UINT16 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: { - INT32 mapnum = G_MapNumber(item->patch); + UINT16 mapnum = G_MapNumber(item->patch); scale = M_GetMapThumbnail(mapnum < nummapheaders ? mapnum : -1, &p)/4; break; } @@ -3040,7 +3040,7 @@ static INT32 M_GetLevelListTOL(void) } } -static boolean M_LevelAvailableOnPlatter(INT32 mapnum) +static boolean M_LevelAvailableOnPlatter(UINT16 mapnum) { // don't care (void)mapnum; @@ -3052,7 +3052,7 @@ static boolean M_LevelAvailableOnPlatter(INT32 mapnum) // // Determines whether to show a given map in the various level-select lists. // -static boolean M_CanShowLevelOnPlatter(INT32 mapnum) +static boolean M_CanShowLevelOnPlatter(UINT16 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++]; - INT16 mapnum = cup->cachedlevels[j]; + UINT16 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++) { - INT32 mapnum = sortedmaps[i]; + UINT16 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(INT32 mapnum) +boolean M_CanShowLevelInList(UINT16 mapnum) { return M_CanShowLevelOnPlatter(mapnum) && M_LevelAvailableOnPlatter(mapnum); } @@ -6483,7 +6483,6 @@ INT32 MR_GrandPrixTemp(INT32 choice) INT32 MR_StartGrandPrix(INT32 choice) { cupheader_t *gpcup; - INT32 levelNum; (void)choice; diff --git a/src/m_menu.h b/src/m_menu.h index e7a6cb825..da24c74e9 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(INT32 mapnum); +boolean M_CanShowLevelInList(UINT16 mapnum); typedef enum { @@ -450,7 +450,7 @@ void M_RefreshPauseMenu(void); INT32 HU_GetHighlightColor(void); -fixed_t M_GetMapThumbnail(INT16 mapnum, patch_t **out); +fixed_t M_GetMapThumbnail(UINT16 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 1ad790058..9c96bcca8 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, INT16 mapnum) +static inline void P_ArchiveMisc(savebuffer_t *save, UINT16 mapnum) { TracyCZone(__zone, true); @@ -4007,20 +4007,20 @@ static inline void P_ArchiveMisc(savebuffer_t *save, INT16 mapnum) if (gamecomplete) mapnum |= 8192; - WRITEINT16(save->p, mapnum); + WRITEUINT16(save->p, mapnum); WRITEUINT16(save->p, emeralds+357); WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder)); TracyCZoneEnd(__zone); } -static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride) +static inline void P_UnArchiveSPGame(savebuffer_t *save, UINT16 mapoverride) { TracyCZone(__zone, true); char testname[sizeof(timeattackfolder)]; - gamemap = READINT16(save->p); + gamemap = READUINT16(save->p); if (mapoverride != 0) { @@ -4568,7 +4568,7 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(savebuffer_t *save) return ret; } -void P_SaveGame(savebuffer_t *save, INT16 mapnum) +void P_SaveGame(savebuffer_t *save, UINT16 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, INT16 mapoverride) +boolean P_LoadGame(savebuffer_t *save, UINT16 mapoverride) { if (gamestate == GS_INTERMISSION) Y_EndIntermission(); diff --git a/src/p_saveg.h b/src/p_saveg.h index de0527dbe..ca4c6907b 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -27,9 +27,9 @@ extern "C" { // Persistent storage/archiving. // These are the load / save game routines. -void P_SaveGame(savebuffer_t *save, INT16 mapnum); +void P_SaveGame(savebuffer_t *save, UINT16 mapnum); void P_SaveNetGame(savebuffer_t *save, boolean resending); -boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride); +boolean P_LoadGame(savebuffer_t *save, UINT16 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 79dbbf410..868cb1407 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(INT16 i) +void P_SetDemoFlickies(UINT16 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(INT16 i) * * \param i The header to clear flickies for */ -void P_DeleteFlickies(INT16 i) +void P_DeleteFlickies(UINT16 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(INT16 i) +void P_AllocMapHeader(UINT16 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; -INT16 wadnamemap = 0; // gamemap based +UINT16 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 e09f467fa..7f0626dba 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -98,7 +98,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 INT16 wadnamemap; +extern UINT16 wadnamemap; #define WADNAMECHECK(name) (!strncmp(name, "WADNAME", 7)) // WARNING: The following functions should be grouped as follows: @@ -130,10 +130,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(INT16 i); +void P_AllocMapHeader(UINT16 i); -void P_SetDemoFlickies(INT16 i); -void P_DeleteFlickies(INT16 i); +void P_SetDemoFlickies(UINT16 i); +void P_DeleteFlickies(UINT16 i); // Needed for NiGHTS void P_ReloadRings(void); diff --git a/src/p_user.c b/src/p_user.c index dd57bc695..c4956d4f1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -310,7 +310,7 @@ boolean P_PlayerMoving(INT32 pnum) // UINT8 P_GetNextEmerald(void) { - INT16 mapnum = gamemap-1; + UINT16 mapnum = gamemap-1; if (mapnum > nummapheaders || !mapheaderinfo[mapnum]) return 0; diff --git a/src/y_inter.c b/src/y_inter.c index be1d7fe17..469119c84 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; - INT16 mapnum; + UINT16 mapnum; fixed_t picwidth = 160; // CEP: scale by screen hypotenuse for extra voting rows @@ -1551,7 +1551,7 @@ void Y_VoteDrawer(void) if (i == rowval) { str = "RANDOM"; - mapnum = -1; + mapnum = NEXTMAP_INVALID; } else {