From 0287c6956e03ed8a5e690b4aea1a0b53086127d2 Mon Sep 17 00:00:00 2001 From: sphere Date: Thu, 30 Apr 2020 17:12:52 +0200 Subject: [PATCH] Fix some errors and add some comments. Also, actnum is not an INT32. --- src/d_clisrv.c | 2 +- src/g_game.c | 2 +- src/m_menu.c | 2 +- src/st_stuff.c | 2 +- src/v_video.c | 18 ++++++++---------- src/v_video.h | 4 ++-- src/y_inter.c | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 43321d92d..ed0b8e528 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1690,7 +1690,7 @@ static void CL_LoadReceivedSavegame(void) // load a base level if (P_LoadNetGame()) { - const INT32 actnum = mapheaderinfo[gamemap-1]->actnum; + const UINT8 actnum = mapheaderinfo[gamemap-1]->actnum; CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)); if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, "")) { diff --git a/src/g_game.c b/src/g_game.c index 92d71fbae..5bcf9f580 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4629,7 +4629,7 @@ char *G_BuildMapTitle(INT32 mapnum) { size_t len = 1; const char *zonetext = NULL; - const INT32 actnum = mapheaderinfo[mapnum-1]->actnum; + const UINT8 actnum = mapheaderinfo[mapnum-1]->actnum; len += strlen(mapheaderinfo[mapnum-1]->lvlttl); if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE)) diff --git a/src/m_menu.c b/src/m_menu.c index 2977b432f..c221571c8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5186,7 +5186,7 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) { if (M_CanShowLevelOnPlatter(mapnum, gt)) { - const INT32 actnum = mapheaderinfo[mapnum]->actnum; + const UINT8 actnum = mapheaderinfo[mapnum]->actnum; const boolean headingisname = (fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[mapnum]->lvlttl)); const boolean wide = (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON); diff --git a/src/st_stuff.c b/src/st_stuff.c index 26f2c1774..9d819b147 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1383,7 +1383,7 @@ void ST_drawTitleCard(void) { if (!splitscreen) { - if (actnum > 9) + if (actnum > 9) // slightly offset the act diamond for two-digit act numbers V_DrawMappedPatch(ttlnumxpos + (V_LevelActNumWidth(actnum)/4) + ttlscroll, 104 - ttlscroll, 0, actpat, colormap); else V_DrawMappedPatch(ttlnumxpos + ttlscroll, 104 - ttlscroll, 0, actpat, colormap); diff --git a/src/v_video.c b/src/v_video.c index e8d121f9a..e17df995b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2954,12 +2954,12 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) // Draw an act number for a level title void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num) { - if (num < 0 || num > 99) + if (num > 99) return; // not supported while (num > 0) { - if (num > 9) + if (num > 9) // if there are two digits, draw second digit first V_DrawScaledPatch(x + (V_LevelActNumWidth(num) - V_LevelActNumWidth(num%10)), y, flags, ttlnum[num%10]); else V_DrawScaledPatch(x, y, flags, ttlnum[num]); @@ -3345,19 +3345,17 @@ INT32 V_LevelNameHeight(const char *string) } // For ST_drawTitleCard -// Returns the width of the act num patch -INT32 V_LevelActNumWidth(UINT8 num) +// Returns the width of the act num patch(es) +INT16 V_LevelActNumWidth(UINT8 num) { - SHORT result = 0; - if (num > 99) - return 0; // not a valid number + INT16 result = 0; if (num == 0) - return SHORT(ttlnum[num]->width); + result = ttlnum[num]->width; - while (num > 0) + while (num > 0 && num <= 99) { - result = result + SHORT(ttlnum[num%10]->width); + result = result + ttlnum[num%10]->width; num = num/10; } diff --git a/src/v_video.h b/src/v_video.h index ed623a57f..664fa8995 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -238,12 +238,12 @@ void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option // Draw tall nums, used for menu, HUD, intermission void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits); -void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, INT32 num); +void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num); // Find string width from lt_font chars INT32 V_LevelNameWidth(const char *string); INT32 V_LevelNameHeight(const char *string); -INT32 V_LevelActNumWidth(INT32 num); // act number width +INT16 V_LevelActNumWidth(UINT8 num); // act number width void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string); INT32 V_CreditStringWidth(const char *string); diff --git a/src/y_inter.c b/src/y_inter.c index f1764a816..a2628832f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -73,7 +73,7 @@ typedef union UINT32 score, total; // fake score, total UINT32 tics; // time - INT32 actnum; // act number being displayed + UINT8 actnum; // act number being displayed patch_t *ptotal; // TOTAL UINT8 gotlife; // Number of extra lives obtained } coop;