Skip to content

Commit

Permalink
fix entering check in WI_initAnimatedBack, reformat (#2097)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfomin authored Dec 20, 2024
1 parent 5b1851e commit bf71e8c
Showing 1 changed file with 124 additions and 98 deletions.
222 changes: 124 additions & 98 deletions src/wi_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,19 +696,30 @@ static boolean SetupMusic(boolean enteringcondition)
//
void WI_slamBackground(void)
{
char name[32];

if (state != StatCount && enterpic)
strcpy(name, enterpic);
else if (exitpic)
strcpy(name, exitpic);
// with UMAPINFO it is possible that wbs->epsd > 3
else if (gamemode == commercial || wbs->epsd >= 3)
strcpy(name, "INTERPIC");
else
M_snprintf(name, sizeof(name), "WIMAP%d", wbs->epsd);
const char *name;

char lump[9] = {0};

if (state != StatCount && enterpic)
{
name = enterpic;
}
else if (exitpic)
{
name = exitpic;
}
// with UMAPINFO it is possible that wbs->epsd > 3
else if (gamemode == commercial || wbs->epsd >= 3)
{
name = "INTERPIC";
}
else
{
M_snprintf(lump, sizeof(lump), "WIMAP%d", wbs->epsd);
name = lump;
}

V_DrawPatchFullScreen(V_CachePatchName(name, PU_CACHE));
V_DrawPatchFullScreen(V_CachePatchName(name, PU_CACHE));
}

// ====================================================================
Expand Down Expand Up @@ -738,47 +749,45 @@ static void WI_DrawString(int y, const char* str)
//
static void WI_drawLF(void)
{
int y = WI_TITLEY;
int y = WI_TITLEY;

// The level defines a new name but no texture for the name.
if (wbs->lastmapinfo && wbs->lastmapinfo->levelname && wbs->lastmapinfo->levelpic[0] == 0)
{
WI_DrawString(y, wbs->lastmapinfo->levelname);

y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);
const mapentry_t *mapinfo = wbs->lastmapinfo;

if (wbs->lastmapinfo->author)
// The level defines a new name but no texture for the name.
if (mapinfo && mapinfo->levelname && !mapinfo->levelpic[0])
{
WI_DrawString(y, wbs->lastmapinfo->author);
WI_DrawString(y, mapinfo->levelname);

y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);

y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);
if (mapinfo->author)
{
WI_DrawString(y, mapinfo->author);

y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);
}
}
}
else if (wbs->lastmapinfo && wbs->lastmapinfo->levelpic[0])
{
patch_t* lpic = V_CachePatchName(wbs->lastmapinfo->levelpic, PU_CACHE);
else if (mapinfo && mapinfo->levelpic[0])
{
patch_t *patch = V_CachePatchName(mapinfo->levelpic, PU_CACHE);

V_DrawPatch((SCREENWIDTH - SHORT(lpic->width))/2,
y, lpic);
V_DrawPatch((SCREENWIDTH - SHORT(patch->width)) / 2, y, patch);

y += (5 * SHORT(lpic->height)) / 4;
}
else
// [FG] prevent crashes for levels without name graphics
if (wbs->last >= 0 && wbs->last < num_lnames && lnames[wbs->last] != NULL )
{
// draw <LevelName>
V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2,
y, lnames[wbs->last]);
y += (5 * SHORT(patch->height)) / 4;
}
// [FG] prevent crashes for levels without name graphics
else if (wbs->last >= 0 && wbs->last < num_lnames && lnames[wbs->last])
{
// draw <LevelName>
V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width)) / 2, y,
lnames[wbs->last]);

// draw "Finished!"
y += (5*SHORT(lnames[wbs->last]->height))/4;
}

V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2,
y, finished);
}
// draw "Finished!"
y += (5 * SHORT(lnames[wbs->last]->height)) / 4;
}

V_DrawPatch((SCREENWIDTH - SHORT(finished->width)) / 2, y, finished);
}

// ====================================================================
// WI_drawEL
Expand All @@ -788,49 +797,53 @@ static void WI_drawLF(void)
//
static void WI_drawEL(void)
{
int y = WI_TITLEY;
int y = WI_TITLEY;

// draw "Entering"
V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2,
y, entering);
// draw "Entering"
V_DrawPatch((SCREENWIDTH - SHORT(entering->width)) / 2, y, entering);

// The level defines a new name but no texture for the name
if (wbs->nextmapinfo && wbs->nextmapinfo->levelname && wbs->nextmapinfo->levelpic[0] == 0)
{
y += (5 * SHORT(entering->height)) / 4;
const mapentry_t *mapinfo = wbs->nextmapinfo;

WI_DrawString(y, wbs->nextmapinfo->levelname);

if (wbs->nextmapinfo->author)
// The level defines a new name but no texture for the name
if (mapinfo && mapinfo->levelname && !mapinfo->levelpic[0])
{
y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);
y += (5 * SHORT(entering->height)) / 4;

WI_DrawString(y, mapinfo->levelname);

WI_DrawString(y, wbs->nextmapinfo->author);
if (mapinfo->author)
{
y += (5 * SHORT(hu_font['A' - HU_FONTSTART]->height) / 4);

WI_DrawString(y, mapinfo->author);
}
}
}
else if (wbs->nextmapinfo && wbs->nextmapinfo->levelpic[0])
{
patch_t* lpic = V_CachePatchName(wbs->nextmapinfo->levelpic, PU_CACHE);
else if (mapinfo && mapinfo->levelpic[0])
{
patch_t *patch = V_CachePatchName(mapinfo->levelpic, PU_CACHE);

if (SHORT(lpic->height) < SCREENHEIGHT)
y += (5 * SHORT(lpic->height)) / 4;
if (SHORT(patch->height) < SCREENHEIGHT)
{
y += (5 * SHORT(patch->height)) / 4;
}

V_DrawPatch((SCREENWIDTH - SHORT(lpic->width))/2, y, lpic);
}
// [FG] prevent crashes for levels without name graphics
else if (wbs->next >= 0 && wbs->next < num_lnames && lnames[wbs->next] != NULL)
{
// draw level
// haleyjd: corrected to use height of entering, not map name
if (SHORT(lnames[wbs->next]->height) < SCREENHEIGHT)
y += (5 * SHORT(entering->height)) / 4;
V_DrawPatch((SCREENWIDTH - SHORT(patch->width)) / 2, y, patch);
}
// [FG] prevent crashes for levels without name graphics
else if (wbs->next >= 0 && wbs->next < num_lnames && lnames[wbs->next])
{
// draw level
// haleyjd: corrected to use height of entering, not map name
if (SHORT(lnames[wbs->next]->height) < SCREENHEIGHT)
{
y += (5 * SHORT(entering->height)) / 4;
}

V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2,
y, lnames[wbs->next]);
}
V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width)) / 2, y,
lnames[wbs->next]);
}
}


// ====================================================================
// WI_drawOnLnode
// Purpose: Draw patches at a location based on episode/map
Expand Down Expand Up @@ -900,9 +913,13 @@ static void WI_initAnimatedBack(boolean firstcall)
}

if (exitpic)
return;
if (enterpic && entering)
return;
{
return;
}
if (enterpic && state != StatCount)
{
return;
}

if (gamemode == commercial) // no animation for DOOM2
return;
Expand Down Expand Up @@ -951,9 +968,13 @@ static void WI_updateAnimatedBack(void)
}

if (exitpic)
return;
{
return;
}
if (enterpic && state != StatCount)
return;
{
return;
}

if (gamemode == commercial)
return;
Expand Down Expand Up @@ -1018,9 +1039,13 @@ static void WI_drawAnimatedBack(void)
}

if (exitpic)
return;
{
return;
}
if (enterpic && state != StatCount)
return;
{
return;
}

if (gamemode==commercial) //jff 4/25/98 Someone forgot commercial an enum
return;
Expand Down Expand Up @@ -1310,22 +1335,23 @@ static void WI_initShowNextLoc(void)

if (gamemapinfo)
{
if (gamemapinfo->flags & MapInfo_EndGame)
{
G_WorldDone();
return;
}
state = ShowNextLoc;
if (gamemapinfo->flags & MapInfo_EndGame)
{
G_WorldDone();
return;
}

// episode change
if (wbs->epsd != wbs->nextep)
{
void WI_loadData(void);
state = ShowNextLoc;

wbs->epsd = wbs->nextep;
wbs->last = wbs->next - 1;
WI_loadData();
}
// episode change
if (wbs->epsd != wbs->nextep)
{
void WI_loadData(void);

wbs->epsd = wbs->nextep;
wbs->last = wbs->next - 1;
WI_loadData();
}
}

state = ShowNextLoc;
Expand Down Expand Up @@ -1366,7 +1392,7 @@ static void WI_drawShowNextLoc(void)

if (gamemapinfo && gamemapinfo->flags & MapInfo_EndGame)
{
return;
return;
}

WI_slamBackground();
Expand Down

0 comments on commit bf71e8c

Please sign in to comment.