Skip to content

Commit

Permalink
Minor refactoring of mapinfo code
Browse files Browse the repository at this point in the history
Untested. More to come...
  • Loading branch information
bradharding committed Sep 1, 2023
1 parent 3746ba2 commit 1dc991b
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 177 deletions.
15 changes: 7 additions & 8 deletions src/c_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -4020,7 +4020,7 @@ static bool map_cmd_func1(char *cmd, char *parms)
M_StringCopy(wadname, leafname(lumpinfo[i]->wadfile->path), sizeof(wadname));
replaced = (W_CheckMultipleLumps(mapcmdlump) > 1 && !chex && !FREEDOOM);
pwad = (lumpinfo[i]->wadfile->type == PWAD);
M_StringCopy(mapinfoname, P_GetMapName((mapcmdepisode - 1) * 10 + mapcmdmap), sizeof(mapinfoname));
M_StringCopy(mapinfoname, P_GetMapName(mapcmdepisode, mapcmdmap), sizeof(mapinfoname));

switch (gamemission)
{
Expand Down Expand Up @@ -4237,7 +4237,7 @@ static void maplist_cmd_func2(char *cmd, char *parms)
M_StringCopy(wadname, leafname(lumpinfo[i]->wadfile->path), sizeof(wadname));
replaced = (W_CheckMultipleLumps(lump) > 1 && !chex && !FREEDOOM);
pwad = (lumpinfo[i]->wadfile->type == PWAD);
M_StringCopy(mapinfoname, P_GetMapName(--ep * 10 + (--map) + 1), sizeof(mapinfoname));
M_StringCopy(mapinfoname, P_GetMapName(--ep, --map), sizeof(mapinfoname));

switch (gamemission)
{
Expand Down Expand Up @@ -4591,13 +4591,12 @@ static void mapstats_cmd_func2(char *cmd, char *parms)
/* 59 */ { JR, "", "", "", "" }
};

const int i = (gamemission == doom ? gameepisode * 10 : 0) + gamemap;
const char *author = P_GetMapAuthor(i);
const char *author = P_GetMapAuthor(gameepisode, gamemap);

if (*author)
C_TabbedOutput(tabs, "Author\t%s", author);
else if (canmodify && *authors[i][gamemission])
C_TabbedOutput(tabs, "Author\t%s", authors[i][gamemission]);
else if (canmodify && *authors[gameepisode][gamemission])
C_TabbedOutput(tabs, "Author\t%s", authors[gameepisode][gamemission]);
else if (REKKR)
C_TabbedOutput(tabs, "Author\tMatthew Little");
}
Expand Down Expand Up @@ -4859,8 +4858,8 @@ static void mapstats_cmd_func2(char *cmd, char *parms)
{
int lumps;
char namebuf[9];
const char *musicartist = P_GetMapMusicComposer((gameepisode - 1) * 10 + gamemap);
const char *musictitle = P_GetMapMusicTitle((gameepisode - 1) * 10 + gamemap);
const char *musicartist = P_GetMapMusicComposer(gameepisode, gamemap);
const char *musictitle = P_GetMapMusicTitle(gameepisode, gamemap);
const Mix_MusicType musictype = Mix_GetMusicType(NULL);

temp = uppercase(mus_playing->name1);
Expand Down
20 changes: 10 additions & 10 deletions src/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ static void F_ConsoleFinaleText(void)
//
void F_StartFinale(void)
{
char *intertext = P_GetInterText(gamemap);
char *intersecret = P_GetInterSecretText(gamemap);
char *intertext = P_GetInterText(gameepisode, gamemap);
char *intersecret = P_GetInterSecretText(gameepisode, gamemap);

viewactive = false;
automapactive = false;
Expand All @@ -121,8 +121,8 @@ void F_StartFinale(void)

if (*intertext || (*intersecret && secretexit))
{
char *interbackdrop = P_GetInterBackrop(gamemap);
int mus = P_GetInterMusic(gamemap);
char *interbackdrop = P_GetInterBackrop(gameepisode, gamemap);
int mus = P_GetInterMusic(gameepisode, gamemap);

if (!secretexit)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ void F_StartFinale(void)
else
S_ChangeMusic((gamemode == commercial ? mus_read_m : mus_victor), true, false, false);
}
else if (P_GetMapEndCast(gamemap))
else if (P_GetMapEndCast(gameepisode, gamemap))
{
gameaction = ga_nothing;
gamestate = GS_FINALE;
Expand Down Expand Up @@ -307,16 +307,16 @@ void F_Ticker(void)
if (finalecount > FixedMul((fixed_t)strlen(finaletext) * FRACUNIT, TextSpeed()) + (midstage ? NEWTEXTWAIT : TEXTWAIT)
|| (midstage && acceleratestage))
{
if (P_GetMapEndCast(gamemap))
if (P_GetMapEndCast(gameepisode, gamemap))
F_StartCast();
else if (P_GetMapEndBunny(gamemap))
else if (P_GetMapEndBunny(gameepisode, gamemap))
{
finalecount = 0;
finalestage = F_STAGE_ARTSCREEN;
wipegamestate = GS_NONE;
S_StartMusic(mus_bunny);
}
else if (P_GetMapEndGame(gamemap))
else if (P_GetMapEndGame(gameepisode, gamemap))
{
finalecount = 0;
finalestage = F_STAGE_ARTSCREEN;
Expand Down Expand Up @@ -988,7 +988,7 @@ static void F_BunnyScroll(void)
//
static void F_ArtScreenDrawer(void)
{
const int lumpnum = P_GetMapEndPic(gamemap);
const int lumpnum = P_GetMapEndPic(gameepisode, gamemap);

if (lumpnum > 0)
{
Expand All @@ -997,7 +997,7 @@ static void F_ArtScreenDrawer(void)
else
V_DrawPatch(0, 0, 0, W_CacheLumpNum(lumpnum));
}
else if (P_GetMapEndBunny(gamemap) || gameepisode == 3)
else if (P_GetMapEndBunny(gameepisode, gamemap) || gameepisode == 3)
F_BunnyScroll();
else
{
Expand Down
25 changes: 12 additions & 13 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,8 @@ static void G_ResetPlayer(void)
//
void G_DoLoadLevel(void)
{
int ep;
const int map = (gameepisode - 1) * 10 + gamemap;
bool resetplayer;
int ep;
bool resetplayer;

HU_DrawDisk();

Expand Down Expand Up @@ -622,8 +621,10 @@ void G_DoLoadLevel(void)

freeze = false;

ep = (gamemode == commercial ? (gamemission == pack_nerve ? 2 : 1) : gameepisode);

// [BH] Reset player's health, armor, weapons and ammo on pistol start
if ((resetplayer = (pistolstart || P_GetMapPistolStart(map))))
if ((resetplayer = (pistolstart || P_GetMapPistolStart(ep, gamemap))))
G_ResetPlayer();

if (viewplayer->cheats & CF_CHOPPERS)
Expand Down Expand Up @@ -653,13 +654,12 @@ void G_DoLoadLevel(void)
// died.
P_FreeSecNodeList();

ep = (gamemode == commercial ? (gamemission == pack_nerve ? 2 : 1) : gameepisode);
P_MapName(ep, gamemap);

P_SetupLevel(ep, gamemap);

// [BH] Reset player's health, armor, weapons and ammo on pistol start
if (resetplayer && map != 1)
if (resetplayer && gamemap != 1)
{
if (M_StringCompare(playername, playername_default))
C_Warning(0, "You now have 100%% health, no armor, and only a pistol with 50 bullets.");
Expand Down Expand Up @@ -1253,7 +1253,7 @@ void G_SecretExitLevel(void)

int G_GetParTime(void)
{
const int par = P_GetMapPar((gameepisode - 1) * 10 + gamemap);
const int par = P_GetMapPar(gameepisode, gamemap);

if (par)
return par;
Expand All @@ -1278,9 +1278,8 @@ int G_GetParTime(void)

static void G_DoCompleted(void)
{
const int map = (gameepisode - 1) * 10 + gamemap;
const int nextmap = P_GetMapNext(map);
const int secretnextmap = P_GetMapSecretNext(map);
const int nextmap = P_GetMapNext(gameepisode, gamemap);
const int secretnextmap = P_GetMapSecretNext(gameepisode, gamemap);

P_LookForFriends();

Expand Down Expand Up @@ -1448,8 +1447,8 @@ static void G_DoCompleted(void)
//
void G_WorldDone(void)
{
const char *intertext = P_GetInterText(gamemap);
const char *intersecrettext = P_GetInterSecretText(gamemap);
const char *intertext = P_GetInterText(gameepisode, gamemap);
const char *intersecrettext = P_GetInterSecretText(gameepisode, gamemap);

gameaction = ga_worlddone;

Expand All @@ -1462,7 +1461,7 @@ void G_WorldDone(void)
return;
}

if (P_GetMapEndCast(gamemap))
if (P_GetMapEndCast(gameepisode, gamemap))
{
F_StartFinale();
return;
Expand Down
9 changes: 4 additions & 5 deletions src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1958,9 +1958,8 @@ void A_Explode(mobj_t *actor, player_t *player, pspdef_t *psp)
//
void A_BossDeath(mobj_t *actor, player_t *player, pspdef_t *psp)
{
line_t junk = { 0 };
const int map = (gameepisode - 1) * 10 + gamemap;
int numbossactions = P_GetNumBossActions(map);
line_t junk = { 0 };
int numbossactions = P_GetNumBossActions(gameepisode, gamemap);

// numbossactions == 0 means to use the defaults.
// numbossactions == -1 means to do nothing.
Expand All @@ -1976,7 +1975,7 @@ void A_BossDeath(mobj_t *actor, player_t *player, pspdef_t *psp)
return; // no one left alive, so do not end game

for (i = 0; i < numbossactions; i++)
if (P_GetBossAction(map, i)->type == actor->type)
if (P_GetBossAction(gameepisode, gamemap, i)->type == actor->type)
break;

if (i >= numbossactions)
Expand All @@ -1994,7 +1993,7 @@ void A_BossDeath(mobj_t *actor, player_t *player, pspdef_t *psp)

for (i = 0; i < numbossactions; i++)
{
bossaction_t *bossaction = P_GetBossAction(map, i);
bossaction_t *bossaction = P_GetBossAction(gameepisode, gamemap, i);

if (bossaction->type == actor->type)
{
Expand Down
2 changes: 1 addition & 1 deletion src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool P_TeleportMove(mobj_t *thing, const fixed_t x, const fixed_t y, const fixed
const sector_t *newsec;
const fixed_t radius = thing->radius;

telefrag = (thing->player || boss || P_GetAllowMonsterTelefrags((gameepisode - 1) * 10 + gamemap));
telefrag = (thing->player || boss || P_GetAllowMonsterTelefrags(gameepisode, gamemap));

// kill anything occupying the position
tmthing = thing;
Expand Down
Loading

0 comments on commit 1dc991b

Please sign in to comment.