Skip to content

Commit

Permalink
umapinfo: finale handling improvements, cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin committed Dec 18, 2024
1 parent bc83ba0 commit 04b44da
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 212 deletions.
298 changes: 189 additions & 109 deletions src/f_finale.c

Large diffs are not rendered by default.

50 changes: 28 additions & 22 deletions src/g_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ int G_GotoNextLevel(int *pEpi, int *pMap)
next = gamemapinfo->nextsecret;
else if (gamemapinfo->nextmap[0])
next = gamemapinfo->nextmap;
else if (U_CheckField(gamemapinfo->endpic))
else if (gamemapinfo->flags & MapInfo_EndGame)
{
epsd = 1;
map = 1;
Expand Down Expand Up @@ -1693,9 +1693,9 @@ static void G_DoCompleted(void)
const char *next = NULL;
boolean intermission = false;

if (U_CheckField(gamemapinfo->endpic))
if (gamemapinfo->flags & MapInfo_EndGame)
{
if (gamemapinfo->nointermission)
if (gamemapinfo->flags & MapInfo_NoIntermission)
{
gameaction = ga_victory;
return;
Expand Down Expand Up @@ -3313,25 +3313,31 @@ void G_WorldDone(void)

if (gamemapinfo)
{
if (gamemapinfo->intertextsecret && secretexit)
{
if (U_CheckField(gamemapinfo->intertextsecret)) // if the intermission was not cleared
F_StartFinale();
return;
}
else if (gamemapinfo->intertext && !secretexit)
{
if (U_CheckField(gamemapinfo->intertext)) // if the intermission was not cleared
F_StartFinale();
return;
}
else if (U_CheckField(gamemapinfo->endpic) && !secretexit)
{
// game ends without a status screen.
gameaction = ga_victory;
return;
}
// if nothing applied, use the defaults.
if (secretexit)
{
if (gamemapinfo->intertextsecret
&& !(gamemapinfo->flags & MapInfo_InterTextSecretClear))
{
F_StartFinale();
return;
}
}
else
{
if (gamemapinfo->intertext
&& !(gamemapinfo->flags & MapInfo_InterTextClear))
{
F_StartFinale();
return;
}
else if (gamemapinfo->flags & MapInfo_EndGame)
{
// game ends without a status screen.
gameaction = ga_victory;
return;
}
}
// if nothing applied, use the defaults.
}

if (gamemode == commercial)
Expand Down
104 changes: 65 additions & 39 deletions src/g_umapinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,6 @@ static char *ParseMultiString(scanner_t *s)
{
char *build = NULL;

if (SC_CheckToken(s, TK_Identifier))
{
if (!strcasecmp(SC_GetString(s), "clear"))
{
// this was explicitly deleted to override the default.
return strdup("-");
}
else
{
SC_Error(s, "Either 'clear' or string constant expected");
}
}

do
{
SC_MustGetToken(s, TK_StringConst);
Expand Down Expand Up @@ -284,7 +271,7 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
{
if (!strcasecmp(SC_GetString(s), "clear"))
{
ReplaceString(&mape->label, "-");
mape->flags |= MapInfo_LabelClear;
}
else
{
Expand All @@ -293,6 +280,7 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
}
else
{
mape->flags &= ~MapInfo_LabelClear;
SC_MustGetToken(s, TK_StringConst);
ReplaceString(&mape->label, SC_GetString(s));
}
Expand Down Expand Up @@ -374,42 +362,46 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
}
else if (!strcasecmp(prop, "endpic"))
{
mape->flags |= MapInfo_EndGamePicture;
ParseLumpName(s, mape->endpic);
}
else if (!strcasecmp(prop, "endcast"))
{
SC_MustGetToken(s, TK_BoolConst);
if (SC_GetBoolean(s))
{
strcpy(mape->endpic, "$CAST");
mape->flags |= MapInfo_EndGameCast;
}
else
{
strcpy(mape->endpic, "-");
mape->flags &= ~MapInfo_EndGameCast;
mape->flags |= MapInfo_EndGameClear;
}
}
else if (!strcasecmp(prop, "endbunny"))
{
SC_MustGetToken(s, TK_BoolConst);
if (SC_GetBoolean(s))
{
strcpy(mape->endpic, "$BUNNY");
mape->flags |= MapInfo_EndGameBunny;
}
else
{
strcpy(mape->endpic, "-");
mape->flags &= ~MapInfo_EndGameBunny;
mape->flags |= MapInfo_EndGameClear;
}
}
else if (!strcasecmp(prop, "endgame"))
{
SC_MustGetToken(s, TK_BoolConst);
if (SC_GetBoolean(s))
{
strcpy(mape->endpic, "!");
mape->flags |= MapInfo_EndGameStandard;
}
else
{
strcpy(mape->endpic, "-");
mape->flags &= ~MapInfo_EndGameStandard;
mape->flags |= MapInfo_EndGameClear;
}
}
else if (!strcasecmp(prop, "exitpic"))
Expand All @@ -431,7 +423,14 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
else if (!strcasecmp(prop, "nointermission"))
{
SC_MustGetToken(s, TK_BoolConst);
mape->nointermission = SC_GetBoolean(s);
if (SC_GetBoolean(s))
{
mape->flags |= MapInfo_NoIntermission;
}
else
{
mape->flags &= ~MapInfo_NoIntermission;
}
}
else if (!strcasecmp(prop, "partime"))
{
Expand All @@ -440,21 +439,49 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
}
else if (!strcasecmp(prop, "intertext"))
{
char *text = ParseMultiString(s);
if (mape->intertext)
if (SC_CheckToken(s, TK_Identifier))
{
if (!strcasecmp(SC_GetString(s), "clear"))
{
mape->flags |= MapInfo_InterTextClear;
}
else
{
SC_Error(s, "Either 'clear' or string constant expected");
}
}
else
{
free(mape->intertext);
mape->flags &= ~MapInfo_InterTextClear;
if (mape->intertext)
{
free(mape->intertext);
}
mape->intertext = ParseMultiString(s);
}
mape->intertext = text;
}
else if (!strcasecmp(prop, "intertextsecret"))
{
char *text = ParseMultiString(s);
if (mape->intertextsecret)
if (SC_CheckToken(s, TK_Identifier))
{
if (!strcasecmp(SC_GetString(s), "clear"))
{
mape->flags |= MapInfo_InterTextSecretClear;
}
else
{
SC_Error(s, "Either 'clear' or string constant expected");
}
}
else
{
free(mape->intertextsecret);
mape->flags &= ~MapInfo_InterTextSecretClear;
if (mape->intertextsecret)
{
free(mape->intertextsecret);
}
mape->intertextsecret = ParseMultiString(s);
}
mape->intertextsecret = text;
}
else if (!strcasecmp(prop, "interbackdrop"))
{
Expand All @@ -469,11 +496,12 @@ static void ParseStandardProperty(scanner_t *s, mapentry_t *mape)
SC_MustGetToken(s, TK_Identifier);
if (!strcasecmp(SC_GetString(s), "clear"))
{
mape->flags |= MapInfo_BossActionClear;
array_free(mape->bossactions);
mape->nobossactions = true; // mark level free of boss actions
}
else
{
mape->flags &= ~MapInfo_BossActionClear;
int type, special, tag;
for (type = 0; arrlen(actor_names); ++type)
{
Expand Down Expand Up @@ -549,30 +577,33 @@ void G_ParseMapInfo(int lumpnum)
// Set default level progression here to simplify the checks elsewhere.
// Doing this lets us skip all normal code for this if nothing has been
// defined.
if (parsed.endpic[0] && (strcmp(parsed.endpic, "-") != 0))
if (parsed.flags & MapInfo_EndGame)
{
parsed.nextmap[0] = 0;
}
else if (!parsed.nextmap[0] && !parsed.endpic[0])
else if (!parsed.nextmap[0] && !(parsed.flags & MapInfo_EndGameClear))
{
if (!strcasecmp(parsed.mapname, "MAP30"))
{
strcpy(parsed.endpic, "$CAST");
parsed.flags |= MapInfo_EndGameCast;
}
else if (!strcasecmp(parsed.mapname, "E1M8"))
{
parsed.flags |= MapInfo_EndGamePicture;
strcpy(parsed.endpic, gamemode == retail ? "CREDIT" : "HELP2");
}
else if (!strcasecmp(parsed.mapname, "E2M8"))
{
parsed.flags |= MapInfo_EndGamePicture;
strcpy(parsed.endpic, "VICTORY2");
}
else if (!strcasecmp(parsed.mapname, "E3M8"))
{
strcpy(parsed.endpic, "$BUNNY");
parsed.flags |= MapInfo_EndGameBunny;
}
else if (!strcasecmp(parsed.mapname, "E4M8"))
{
parsed.flags |= MapInfo_EndGamePicture;
strcpy(parsed.endpic, "ENDPIC");
}
else
Expand Down Expand Up @@ -667,11 +698,6 @@ boolean G_ValidateMapName(const char *mapname, int *episode, int *map)
return !strcmp(mapuname, lumpname);
}

boolean U_CheckField(char *str)
{
return str && str[0] && strcmp(str, "-");
}

boolean G_IsSecretMap(int episode, int map)
{
level_t *level;
Expand Down
24 changes: 20 additions & 4 deletions src/g_umapinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@

#include "doomtype.h"

typedef enum
{
MapInfo_LabelClear = (1u << 0),

MapInfo_EndGamePicture = (1u << 2),
MapInfo_EndGameStandard = (1u << 3),
MapInfo_EndGameCast = (1u << 4),
MapInfo_EndGameBunny = (1u << 5),
MapInfo_EndGame = (MapInfo_EndGamePicture | MapInfo_EndGameStandard
| MapInfo_EndGameCast | MapInfo_EndGameBunny),
MapInfo_EndGameClear = (1u << 6),

MapInfo_NoIntermission = (1u << 7),
MapInfo_InterTextClear = (1u << 8),
MapInfo_InterTextSecretClear = (1u << 9),

MapInfo_BossActionClear = (1u << 10)
} mapinfo_flags_t;

typedef struct
{
int type;
Expand Down Expand Up @@ -51,9 +70,8 @@ typedef struct mapentry_s
char interbackdrop[9];
char intermusic[9];
int partime;
boolean nointermission;
bossaction_t *bossactions;
boolean nobossactions;
mapinfo_flags_t flags;
} mapentry_t;

extern mapentry_t *umapinfo;
Expand All @@ -64,8 +82,6 @@ mapentry_t *G_LookupMapinfo(int episode, int map);

boolean G_ValidateMapName(const char *mapname, int *episode, int *map);

boolean U_CheckField(char *str);

void G_ParseMapInfo(int lumpnum);

boolean G_IsSecretMap(int episode, int map);
Expand Down
2 changes: 1 addition & 1 deletion src/mn_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ static void SetDefaultSaveName(char *name, const char *append)
char *maplump = MapName(gameepisode, gamemap);
int maplumpnum = W_CheckNumForName(maplump);

if (gamemapinfo && U_CheckField(gamemapinfo->label))
if (gamemapinfo && gamemapinfo->label)
{
maplump = gamemapinfo->label;
}
Expand Down
Loading

0 comments on commit 04b44da

Please sign in to comment.