Fix some errors and add some comments. Also, actnum is not an INT32.

This commit is contained in:
sphere 2020-04-30 17:12:52 +02:00
parent 69c11a8220
commit 0287c6956e
7 changed files with 15 additions and 17 deletions

View File

@ -1690,7 +1690,7 @@ static void CL_LoadReceivedSavegame(void)
// load a base level // load a base level
if (P_LoadNetGame()) 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)); CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap));
if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, "")) if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, ""))
{ {

View File

@ -4629,7 +4629,7 @@ char *G_BuildMapTitle(INT32 mapnum)
{ {
size_t len = 1; size_t len = 1;
const char *zonetext = NULL; const char *zonetext = NULL;
const INT32 actnum = mapheaderinfo[mapnum-1]->actnum; const UINT8 actnum = mapheaderinfo[mapnum-1]->actnum;
len += strlen(mapheaderinfo[mapnum-1]->lvlttl); len += strlen(mapheaderinfo[mapnum-1]->lvlttl);
if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE)) if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE))

View File

@ -5186,7 +5186,7 @@ static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick)
{ {
if (M_CanShowLevelOnPlatter(mapnum, gt)) 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 headingisname = (fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[mapnum]->lvlttl));
const boolean wide = (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON); const boolean wide = (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON);

View File

@ -1383,7 +1383,7 @@ void ST_drawTitleCard(void)
{ {
if (!splitscreen) 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); V_DrawMappedPatch(ttlnumxpos + (V_LevelActNumWidth(actnum)/4) + ttlscroll, 104 - ttlscroll, 0, actpat, colormap);
else else
V_DrawMappedPatch(ttlnumxpos + ttlscroll, 104 - ttlscroll, 0, actpat, colormap); V_DrawMappedPatch(ttlnumxpos + ttlscroll, 104 - ttlscroll, 0, actpat, colormap);

View File

@ -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 // Draw an act number for a level title
void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num) void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num)
{ {
if (num < 0 || num > 99) if (num > 99)
return; // not supported return; // not supported
while (num > 0) 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]); V_DrawScaledPatch(x + (V_LevelActNumWidth(num) - V_LevelActNumWidth(num%10)), y, flags, ttlnum[num%10]);
else else
V_DrawScaledPatch(x, y, flags, ttlnum[num]); V_DrawScaledPatch(x, y, flags, ttlnum[num]);
@ -3345,19 +3345,17 @@ INT32 V_LevelNameHeight(const char *string)
} }
// For ST_drawTitleCard // For ST_drawTitleCard
// Returns the width of the act num patch // Returns the width of the act num patch(es)
INT32 V_LevelActNumWidth(UINT8 num) INT16 V_LevelActNumWidth(UINT8 num)
{ {
SHORT result = 0; INT16 result = 0;
if (num > 99)
return 0; // not a valid number
if (num == 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; num = num/10;
} }

View File

@ -238,12 +238,12 @@ void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option
// Draw tall nums, used for menu, HUD, intermission // Draw tall nums, used for menu, HUD, intermission
void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); 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_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 // Find string width from lt_font chars
INT32 V_LevelNameWidth(const char *string); INT32 V_LevelNameWidth(const char *string);
INT32 V_LevelNameHeight(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); void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
INT32 V_CreditStringWidth(const char *string); INT32 V_CreditStringWidth(const char *string);

View File

@ -73,7 +73,7 @@ typedef union
UINT32 score, total; // fake score, total UINT32 score, total; // fake score, total
UINT32 tics; // time UINT32 tics; // time
INT32 actnum; // act number being displayed UINT8 actnum; // act number being displayed
patch_t *ptotal; // TOTAL patch_t *ptotal; // TOTAL
UINT8 gotlife; // Number of extra lives obtained UINT8 gotlife; // Number of extra lives obtained
} coop; } coop;