From bc83ba069e82217ffa0ea4348ff0afa5eadc68ca Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Wed, 18 Dec 2024 16:20:43 +0700 Subject: [PATCH] rename u_mapinfo->g_umapinfo, cosmetic changes --- src/CMakeLists.txt | 2 +- src/d_main.c | 4 +- src/f_finale.c | 2 +- src/g_game.c | 54 +------------------- src/g_game.h | 2 - src/{u_mapinfo.c => g_umapinfo.c} | 84 +++++++++++++++++++++++++++---- src/{u_mapinfo.h => g_umapinfo.h} | 10 ++-- src/m_cheat.c | 2 +- src/mn_menu.c | 9 ++-- src/mn_menu.h | 3 ++ src/p_enemy.c | 2 +- src/s_musinfo.c | 2 +- src/s_sound.c | 2 +- src/st_widgets.c | 2 +- src/wi_stuff.c | 4 +- 15 files changed, 99 insertions(+), 85 deletions(-) rename src/{u_mapinfo.c => g_umapinfo.c} (92%) rename src/{u_mapinfo.h => g_umapinfo.h} (89%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fdc73e46..dcd5548b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,7 @@ set(WOOF_SOURCES g_game.c g_game.h g_input.c g_input.h g_nextweapon.c g_nextweapon.h + g_umapinfo.c g_umapinfo.h hu_command.c hu_command.h hu_coordinates.c hu_coordinates.h hu_crosshair.c hu_crosshair.h @@ -137,7 +138,6 @@ set(WOOF_SOURCES st_widgets.c st_widgets.h statdump.c statdump.h tables.c tables.h - u_mapinfo.c u_mapinfo.h v_flextran.c v_flextran.h v_fmt.c v_fmt.h v_trans.c v_trans.h diff --git a/src/d_main.c b/src/d_main.c index 9600eaf3d..f11e34f34 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -80,7 +80,7 @@ #include "st_stuff.h" #include "st_widgets.h" #include "statdump.h" -#include "u_mapinfo.h" +#include "g_umapinfo.h" #include "v_fmt.h" #include "v_video.h" #include "w_wad.h" @@ -2373,7 +2373,7 @@ void D_DoomMain(void) if (!M_ParmExists("-nomapinfo")) { - W_ProcessInWads("UMAPINFO", U_ParseMapInfo, PROCESS_IWAD | PROCESS_PWAD); + W_ProcessInWads("UMAPINFO", G_ParseMapInfo, PROCESS_IWAD | PROCESS_PWAD); } G_ParseCompDatabase(); diff --git a/src/f_finale.c b/src/f_finale.c index e3356774b..9c817ccad 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -27,6 +27,7 @@ #include "doomstat.h" #include "doomtype.h" #include "g_game.h" +#include "g_umapinfo.h" #include "info.h" #include "m_misc.h" // [FG] M_StringDuplicate() #include "m_swap.h" @@ -36,7 +37,6 @@ #include "sounds.h" #include "st_sbardef.h" #include "st_stuff.h" -#include "u_mapinfo.h" #include "v_fmt.h" #include "v_video.h" #include "w_wad.h" diff --git a/src/g_game.c b/src/g_game.c index fb2b51ff6..919093510 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -42,6 +42,7 @@ #include "f_finale.h" #include "g_game.h" #include "g_nextweapon.h" +#include "g_umapinfo.h" #include "hu_command.h" #include "hu_obituary.h" #include "i_gamepad.h" @@ -88,7 +89,6 @@ #include "st_widgets.h" #include "statdump.h" // [FG] StatCopy() #include "tables.h" -#include "u_mapinfo.h" #include "v_video.h" #include "version.h" #include "w_wad.h" @@ -3849,58 +3849,6 @@ void G_SetFastParms(int fast_pending) } } -mapentry_t *G_LookupMapinfo(int episode, int map) -{ - char lumpname[9] = {0}; - M_StringCopy(lumpname, MapName(episode, map), sizeof(lumpname)); - - mapentry_t *entry; - array_foreach(entry, umapinfo) - { - if (!strcasecmp(lumpname, entry->mapname)) - return entry; - } - - return NULL; -} - -// Check if the given map name can be expressed as a gameepisode/gamemap pair -// and be reconstructed from it. -int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap) -{ - char lumpname[9], mapuname[9]; - int epi = -1, map = -1; - - if (strlen(mapname) > 8) - return 0; - strncpy(mapuname, mapname, 8); - mapuname[8] = 0; - M_StringToUpper(mapuname); - - if (gamemode != commercial) - { - if (sscanf(mapuname, "E%dM%d", &epi, &map) != 2) - return 0; - strcpy(lumpname, MapName(epi, map)); - } - else - { - if (sscanf(mapuname, "MAP%d", &map) != 1) - return 0; - strcpy(lumpname, MapName(epi = 1, map)); - } - - if (epi > 4) - EpiCustom = true; - - if (pEpi) - *pEpi = epi; - if (pMap) - *pMap = map; - - return !strcmp(mapuname, lumpname); -} - // // G_InitNew // Can be called by the startup code or the menu task, diff --git a/src/g_game.h b/src/g_game.h index af163f9c7..adec0daaa 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -75,8 +75,6 @@ byte *G_WriteOptions(byte *demo_p); // killough 3/1/98 void G_PlayerReborn(int player); void G_DoVictory(void); -int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap); - void G_EnableWarp(boolean warp); void G_SetTimeScale(void); diff --git a/src/u_mapinfo.c b/src/g_umapinfo.c similarity index 92% rename from src/u_mapinfo.c rename to src/g_umapinfo.c index 38196f72f..7dc3fb7ff 100644 --- a/src/u_mapinfo.c +++ b/src/g_umapinfo.c @@ -18,25 +18,24 @@ // //----------------------------------------------------------------------------- +#include "g_umapinfo.h" + +#include #include #include #include "doomdef.h" #include "doomstat.h" #include "doomtype.h" +#include "g_game.h" #include "m_array.h" #include "m_misc.h" #include "m_scanner.h" -#include "u_mapinfo.h" +#include "mn_menu.h" #include "w_wad.h" #include "z_zone.h" -void M_AddEpisode(const char *map, const char *gfx, const char *txt, char key); -void M_ClearEpisodes(void); - -int G_ValidateMapName(const char *mapname, int *pEpi, int *pMap); - -mapentry_t *umapinfo = NULL, *umapdef = NULL; +mapentry_t *umapinfo = NULL; static level_t *secretlevels; @@ -309,7 +308,7 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape) { if (!strcasecmp(SC_GetString(s), "clear")) { - M_ClearEpisodes(); + MN_ClearEpisodes(); } else { @@ -335,7 +334,7 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape) } } - M_AddEpisode(mape->mapname, lumpname, alttext, key); + MN_AddEpisode(mape->mapname, lumpname, alttext, key); if (alttext) { @@ -538,7 +537,7 @@ static void ParseMapEntry(scanner_t *s, mapentry_t *entry) } } -void U_ParseMapInfo(int lumpnum) +void G_ParseMapInfo(int lumpnum) { scanner_t *s = SC_Open("UMAPINFO", W_CacheLumpNum(lumpnum, PU_CACHE), W_LumpLength(lumpnum)); @@ -605,12 +604,75 @@ void U_ParseMapInfo(int lumpnum) SC_Close(s); } +mapentry_t *G_LookupMapinfo(int episode, int map) +{ + char lumpname[9] = {0}; + M_StringCopy(lumpname, MapName(episode, map), sizeof(lumpname)); + + mapentry_t *entry; + array_foreach(entry, umapinfo) + { + if (!strcasecmp(lumpname, entry->mapname)) + { + return entry; + } + } + + return NULL; +} + +// Check if the given map name can be expressed as a gameepisode/gamemap pair +// and be reconstructed from it. + +boolean G_ValidateMapName(const char *mapname, int *episode, int *map) +{ + if (strlen(mapname) > 8) + { + return false; + } + + char lumpname[9], mapuname[9]; + int e = -1, m = -1; + + M_StringCopy(mapuname, mapname, 8); + mapuname[8] = 0; + M_StringToUpper(mapuname); + + if (gamemode != commercial) + { + if (sscanf(mapuname, "E%dM%d", &e, &m) != 2) + { + return 0; + } + strcpy(lumpname, MapName(e, m)); + } + else + { + if (sscanf(mapuname, "MAP%d", &m) != 1) + { + return 0; + } + strcpy(lumpname, MapName(e = 1, m)); + } + + if (episode) + { + *episode = e; + } + if (map) + { + *map = m; + } + + return !strcmp(mapuname, lumpname); +} + boolean U_CheckField(char *str) { return str && str[0] && strcmp(str, "-"); } -boolean U_IsSecretMap(int episode, int map) +boolean G_IsSecretMap(int episode, int map) { level_t *level; array_foreach(level, secretlevels) diff --git a/src/u_mapinfo.h b/src/g_umapinfo.h similarity index 89% rename from src/u_mapinfo.h rename to src/g_umapinfo.h index 1dea7a4b9..80db1b3dc 100644 --- a/src/u_mapinfo.h +++ b/src/g_umapinfo.h @@ -18,8 +18,8 @@ // //----------------------------------------------------------------------------- -#ifndef UMAPINFO_H -#define UMAPINFO_H +#ifndef G_UMAPINFO_H +#define G_UMAPINFO_H #include "doomtype.h" @@ -62,10 +62,12 @@ extern boolean EpiCustom; mapentry_t *G_LookupMapinfo(int episode, int map); +boolean G_ValidateMapName(const char *mapname, int *episode, int *map); + boolean U_CheckField(char *str); -void U_ParseMapInfo(int lumpnum); +void G_ParseMapInfo(int lumpnum); -boolean U_IsSecretMap(int episode, int map); +boolean G_IsSecretMap(int episode, int map); #endif diff --git a/src/m_cheat.c b/src/m_cheat.c index 50c345b5b..458ac5cd0 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -30,6 +30,7 @@ #include "doomdef.h" #include "doomstat.h" #include "g_game.h" +#include "g_umapinfo.h" #include "info.h" #include "m_cheat.h" #include "m_array.h" @@ -51,7 +52,6 @@ #include "sounds.h" #include "st_widgets.h" #include "tables.h" -#include "u_mapinfo.h" #include "w_wad.h" #include "ws_stuff.h" diff --git a/src/mn_menu.c b/src/mn_menu.c index bf52372d3..5f2a305ee 100644 --- a/src/mn_menu.c +++ b/src/mn_menu.c @@ -37,6 +37,7 @@ #include "doomtype.h" #include "dstrings.h" #include "g_game.h" +#include "g_umapinfo.h" #include "i_input.h" #include "i_printf.h" #include "i_system.h" @@ -59,7 +60,6 @@ #include "st_sbardef.h" #include "st_stuff.h" #include "st_widgets.h" -#include "u_mapinfo.h" #include "v_fmt.h" #include "v_video.h" #include "w_wad.h" @@ -517,13 +517,13 @@ static short EpiMenuEpi[MAX_EPISODES] = {1, 2, 3, 4, -1, -1, -1, -1, -1, -1}; // static int epiChoice; -void M_ClearEpisodes(void) +void MN_ClearEpisodes(void) { EpiDef.numitems = 0; NewDef.prevMenu = &MainDef; } -void M_AddEpisode(const char *map, const char *gfx, const char *txt, char key) +void MN_AddEpisode(const char *map, const char *gfx, const char *txt, char key) { int epi, mapnum; @@ -540,7 +540,8 @@ void M_AddEpisode(const char *map, const char *gfx, const char *txt, char key) if (EpiDef.numitems == 8) { - I_Printf(VB_WARNING, "M_AddEpisode: UMAPINFO spec limit of 8 episodes exceeded!"); + I_Printf(VB_WARNING, + "MN_AddEpisode: UMAPINFO spec limit of 8 episodes exceeded!"); } else if (EpiDef.numitems >= MAX_EPISODES) { diff --git a/src/mn_menu.h b/src/mn_menu.h index a873565e4..a702ba672 100644 --- a/src/mn_menu.h +++ b/src/mn_menu.h @@ -57,6 +57,9 @@ void M_Init(void); void MN_StartControlPanel(void); +void MN_AddEpisode(const char *map, const char *gfx, const char *txt, char key); +void MN_ClearEpisodes(void); + void MN_ForcedLoadAutoSave(const char *msg); void MN_ForcedLoadGame(const char *msg); // killough 5/15/98: forced loadgames void MN_Trans(void); // killough 11/98: reset translucency diff --git a/src/p_enemy.c b/src/p_enemy.c index 4cce3840c..31e1fed46 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -29,6 +29,7 @@ #include "doomstat.h" #include "doomtype.h" #include "g_game.h" +#include "g_umapinfo.h" #include "hu_obituary.h" #include "i_printf.h" #include "i_system.h" @@ -53,7 +54,6 @@ #include "s_sound.h" #include "sounds.h" #include "tables.h" -#include "u_mapinfo.h" #include "z_zone.h" static mobj_t *current_actor; diff --git a/src/s_musinfo.c b/src/s_musinfo.c index a76592ab4..01cdcacd5 100644 --- a/src/s_musinfo.c +++ b/src/s_musinfo.c @@ -23,7 +23,7 @@ #include "s_musinfo.h" #include "doomtype.h" -#include "g_game.h" +#include "g_umapinfo.h" #include "i_printf.h" #include "p_mobj.h" #include "s_sound.h" diff --git a/src/s_sound.c b/src/s_sound.c index 369b23ead..dc858124d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -24,6 +24,7 @@ #include "doomdef.h" #include "doomstat.h" +#include "g_umapinfo.h" #include "i_printf.h" #include "i_rumble.h" #include "i_sound.h" @@ -36,7 +37,6 @@ #include "s_sound.h" #include "s_trakinfo.h" #include "sounds.h" -#include "u_mapinfo.h" #include "w_wad.h" #include "z_zone.h" diff --git a/src/st_widgets.c b/src/st_widgets.c index 39cc63524..63ff70455 100644 --- a/src/st_widgets.c +++ b/src/st_widgets.c @@ -24,6 +24,7 @@ #include "doomstat.h" #include "doomtype.h" #include "dstrings.h" +#include "g_umapinfo.h" #include "hu_command.h" #include "hu_coordinates.h" #include "hu_obituary.h" @@ -41,7 +42,6 @@ #include "sounds.h" #include "st_sbardef.h" #include "st_stuff.h" -#include "u_mapinfo.h" #include "v_video.h" boolean show_messages; diff --git a/src/wi_stuff.c b/src/wi_stuff.c index 7a7c89907..7ebba97eb 100644 --- a/src/wi_stuff.c +++ b/src/wi_stuff.c @@ -26,6 +26,7 @@ #include "doomdef.h" #include "doomstat.h" #include "doomtype.h" +#include "g_umapinfo.h" #include "g_game.h" #include "i_printf.h" #include "m_misc.h" @@ -37,7 +38,6 @@ #include "st_sbardef.h" #include "st_stuff.h" #include "sounds.h" -#include "u_mapinfo.h" #include "v_fmt.h" #include "v_video.h" #include "w_wad.h" @@ -464,7 +464,7 @@ static boolean CheckConditions(interlevelcond_t *conditions, break; case AnimCondition_MapNotSecret: - conditionsmet &= !U_IsSecretMap(episode, map); + conditionsmet &= !G_IsSecretMap(episode, map); break; case AnimCondition_SecretVisited: