Skip to content

Commit

Permalink
rename u_mapinfo->g_umapinfo, cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin committed Dec 18, 2024
1 parent 3f41e8f commit bc83ba0
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 85 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
54 changes: 1 addition & 53 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/g_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
84 changes: 73 additions & 11 deletions src/u_mapinfo.c → src/g_umapinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@
//
//-----------------------------------------------------------------------------

#include "g_umapinfo.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

Expand Down Expand Up @@ -309,7 +308,7 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
{
if (!strcasecmp(SC_GetString(s), "clear"))
{
M_ClearEpisodes();
MN_ClearEpisodes();
}
else
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions src/u_mapinfo.h → src/g_umapinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//
//-----------------------------------------------------------------------------

#ifndef UMAPINFO_H
#define UMAPINFO_H
#ifndef G_UMAPINFO_H
#define G_UMAPINFO_H

#include "doomtype.h"

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/m_cheat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
9 changes: 5 additions & 4 deletions src/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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;

Expand All @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions src/mn_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/s_musinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit bc83ba0

Please sign in to comment.