Use strlen for all of the valid zone title/act num checks

This commit is contained in:
TehRealSalt 2018-06-05 17:28:46 -04:00
parent 23d83423cc
commit 4fd88293ff
7 changed files with 32 additions and 32 deletions

View file

@ -1637,14 +1637,14 @@ static void CL_LoadReceivedSavegame(void)
if (P_LoadNetGame()) if (P_LoadNetGame())
{ {
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 (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0)
{ {
CONS_Printf(": %s", mapheaderinfo[gamemap-1]->lvlttl); CONS_Printf(": %s", mapheaderinfo[gamemap-1]->lvlttl);
if (strcmp(mapheaderinfo[gamemap-1]->zonttl, "")) if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0)
CONS_Printf(" %s", mapheaderinfo[gamemap-1]->zonttl); CONS_Printf(" %s", mapheaderinfo[gamemap-1]->zonttl);
else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
CONS_Printf(M_GetText(" ZONE")); CONS_Printf(M_GetText(" ZONE"));
if (strcmp(mapheaderinfo[gamemap-1]->actnum, "")) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
CONS_Printf(" %s", mapheaderinfo[gamemap-1]->actnum); CONS_Printf(" %s", mapheaderinfo[gamemap-1]->actnum);
} }
CONS_Printf("\"\n"); CONS_Printf("\"\n");

View file

@ -4523,16 +4523,16 @@ static void Command_Showmap_f(void)
{ {
if (gamestate == GS_LEVEL) if (gamestate == GS_LEVEL)
{ {
if (mapheaderinfo[gamemap-1]->zonttl) if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0)
{ {
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
CONS_Printf("%s (%d): %s %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum); CONS_Printf("%s (%d): %s %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum);
else else
CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl); CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl);
} }
else else
{ {
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum); CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum);
else else
CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl); CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl);

View file

@ -4097,7 +4097,7 @@ char *G_BuildMapTitle(INT32 mapnum)
const char *actnum = NULL; const char *actnum = NULL;
len += strlen(mapheaderinfo[mapnum-1]->lvlttl); len += strlen(mapheaderinfo[mapnum-1]->lvlttl);
if (strcmp(mapheaderinfo[mapnum-1]->zonttl, "")) if (strlen(mapheaderinfo[mapnum-1]->zonttl) > 0)
{ {
zonetext = M_GetText(mapheaderinfo[mapnum-1]->zonttl); zonetext = M_GetText(mapheaderinfo[mapnum-1]->zonttl);
len += strlen(zonetext) + 1; // ' ' + zonetext len += strlen(zonetext) + 1; // ' ' + zonetext
@ -4107,7 +4107,7 @@ char *G_BuildMapTitle(INT32 mapnum)
zonetext = M_GetText("ZONE"); zonetext = M_GetText("ZONE");
len += strlen(zonetext) + 1; // ' ' + zonetext len += strlen(zonetext) + 1; // ' ' + zonetext
} }
if (strcmp(mapheaderinfo[mapnum-1]->actnum, "")) if (strlen(mapheaderinfo[mapnum-1]->actnum) > 0)
{ {
actnum = M_GetText(mapheaderinfo[mapnum-1]->actnum); actnum = M_GetText(mapheaderinfo[mapnum-1]->actnum);
len += strlen(actnum) + 1; // ' ' + actnum len += strlen(actnum) + 1; // ' ' + actnum

View file

@ -3371,16 +3371,16 @@ static void M_DrawPauseMenu(void)
// Draw any and all emblems at the top. // Draw any and all emblems at the top.
M_DrawMapEmblems(gamemap, 272, 28); M_DrawMapEmblems(gamemap, 272, 28);
if (mapheaderinfo[gamemap-1]->zonttl) if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0)
{ {
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
V_DrawString(40, 28, V_YELLOWMAP, va("%s %s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum)); V_DrawString(40, 28, V_YELLOWMAP, va("%s %s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl, mapheaderinfo[gamemap-1]->actnum));
else else
V_DrawString(40, 28, V_YELLOWMAP, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl)); V_DrawString(40, 28, V_YELLOWMAP, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl));
} }
else else
{ {
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
V_DrawString(40, 28, V_YELLOWMAP, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum)); V_DrawString(40, 28, V_YELLOWMAP, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum));
else else
V_DrawString(40, 28, V_YELLOWMAP, mapheaderinfo[gamemap-1]->lvlttl); V_DrawString(40, 28, V_YELLOWMAP, mapheaderinfo[gamemap-1]->lvlttl);
@ -5347,16 +5347,16 @@ static void M_DrawStatsMaps(int location)
mnum = statsMapList[i]; mnum = statsMapList[i];
M_DrawMapEmblems(mnum+1, 292, y); M_DrawMapEmblems(mnum+1, 292, y);
if (mapheaderinfo[mnum]->zonttl) if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0)
{ {
if (mapheaderinfo[mnum]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
V_DrawString(20, y, V_YELLOWMAP, va("%s %s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->zonttl, mapheaderinfo[mnum]->actnum)); V_DrawString(20, y, V_YELLOWMAP, va("%s %s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->zonttl, mapheaderinfo[mnum]->actnum));
else else
V_DrawString(20, y, V_YELLOWMAP, va("%s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->zonttl)); V_DrawString(20, y, V_YELLOWMAP, va("%s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->zonttl));
} }
else else
{ {
if (mapheaderinfo[mnum]->actnum) if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0)
V_DrawString(20, y, V_YELLOWMAP, va("%s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->actnum)); V_DrawString(20, y, V_YELLOWMAP, va("%s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->actnum));
else else
V_DrawString(20, y, V_YELLOWMAP, mapheaderinfo[mnum]->lvlttl); V_DrawString(20, y, V_YELLOWMAP, mapheaderinfo[mnum]->lvlttl);

View file

@ -681,7 +681,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->lvlttl,
(strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart
((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"), ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"),
(mapheaderinfo[gamemap-1]->actnum) ? va(" %s",mapheaderinfo[gamemap-1]->actnum) : ""); (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->actnum) : "");
else else
snprintf(lvlttltext, 48, "Unknown"); snprintf(lvlttltext, 48, "Unknown");

View file

@ -2683,7 +2683,7 @@ boolean P_SetupLevel(boolean skipprecip)
mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->lvlttl,
(strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart
((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"), ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"),
(mapheaderinfo[gamemap-1]->actnum) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : "");
V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx);
I_UpdateNoVsync(); I_UpdateNoVsync();
} }

View file

@ -295,7 +295,7 @@ void Y_IntermissionDrawer(void)
V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1);
V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2); V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2);
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum); V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum);
//if (gottimebonus && endtic != -1) //if (gottimebonus && endtic != -1)
@ -1159,24 +1159,24 @@ void Y_StartIntermission(void)
if (strlen(skins[players[consoleplayer].skin].realname) > 13) if (strlen(skins[players[consoleplayer].skin].realname) > 13)
{ {
strcpy(data.coop.passed1, "YOU GOT"); strcpy(data.coop.passed1, "YOU GOT");
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "THROUGH ACT" : "THROUGH THE ACT"); strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "THROUGH ACT" : "THROUGH THE ACT");
} }
// long enough that "X GOT" won't fit so use "X PASSED THE ACT" // long enough that "X GOT" won't fit so use "X PASSED THE ACT"
else if (strlen(skins[players[consoleplayer].skin].realname) > 8) else if (strlen(skins[players[consoleplayer].skin].realname) > 8)
{ {
strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname); strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname);
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "PASSED ACT" : "PASSED THE ACT"); strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "PASSED ACT" : "PASSED THE ACT");
} }
// length is okay for normal use // length is okay for normal use
else else
{ {
snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s GOT", snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s GOT",
skins[players[consoleplayer].skin].realname); skins[players[consoleplayer].skin].realname);
strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "THROUGH ACT" : "THROUGH THE ACT"); strcpy(data.coop.passed2, (strlen(mapheaderinfo[prevmap]->actnum) > 0) ? "THROUGH ACT" : "THROUGH THE ACT");
} }
// set X positions // set X positions
if (mapheaderinfo[gamemap-1]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
{ {
data.coop.passedx1 = 62 + (176 - V_LevelNameWidth(data.coop.passed1))/2; data.coop.passedx1 = 62 + (176 - V_LevelNameWidth(data.coop.passed1))/2;
data.coop.passedx2 = 62 + (176 - V_LevelNameWidth(data.coop.passed2))/2; data.coop.passedx2 = 62 + (176 - V_LevelNameWidth(data.coop.passed2))/2;
@ -1317,9 +1317,9 @@ void Y_StartIntermission(void)
Y_CalculateMatchWinners(); Y_CalculateMatchWinners();
// set up the levelstring // set up the levelstring
if (mapheaderinfo[prevmap]->zonttl) if (strlen(mapheaderinfo[prevmap]->zonttl) > 0)
{ {
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.match.levelstring, snprintf(data.match.levelstring,
sizeof data.match.levelstring, sizeof data.match.levelstring,
"%.32s %.32s * %s *", "%.32s %.32s * %s *",
@ -1332,7 +1332,7 @@ void Y_StartIntermission(void)
} }
else else
{ {
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.match.levelstring, snprintf(data.match.levelstring,
sizeof data.match.levelstring, sizeof data.match.levelstring,
"%.32s * %s *", "%.32s * %s *",
@ -1380,9 +1380,9 @@ void Y_StartIntermission(void)
Y_CalculateTournamentPoints(); Y_CalculateTournamentPoints();
// set up the levelstring // set up the levelstring
if (mapheaderinfo[prevmap]->zonttl) if (strlen(mapheaderinfo[prevmap]->zonttl) > 0)
{ {
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.match.levelstring, snprintf(data.match.levelstring,
sizeof data.match.levelstring, sizeof data.match.levelstring,
"%.32s %.32s * %s *", "%.32s %.32s * %s *",
@ -1395,7 +1395,7 @@ void Y_StartIntermission(void)
} }
else else
{ {
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.match.levelstring, snprintf(data.match.levelstring,
sizeof data.match.levelstring, sizeof data.match.levelstring,
"%.32s * %s *", "%.32s * %s *",
@ -1425,7 +1425,7 @@ void Y_StartIntermission(void)
Y_CalculateMatchWinners(); Y_CalculateMatchWinners();
// set up the levelstring // set up the levelstring
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.match.levelstring, snprintf(data.match.levelstring,
sizeof data.match.levelstring, sizeof data.match.levelstring,
"%.32s * %s *", "%.32s * %s *",
@ -1461,7 +1461,7 @@ void Y_StartIntermission(void)
Y_CalculateCompetitionWinners(); Y_CalculateCompetitionWinners();
// set up the levelstring // set up the levelstring
if (mapheaderinfo[prevmap]->actnum) if (strlen(mapheaderinfo[prevmap]->actnum) > 0)
snprintf(data.competition.levelstring, snprintf(data.competition.levelstring,
sizeof data.competition.levelstring, sizeof data.competition.levelstring,
"%.32s * %s *", "%.32s * %s *",
@ -2554,9 +2554,9 @@ void Y_StartVote(void)
lumpnum_t lumpnum; lumpnum_t lumpnum;
// set up the str // set up the str
if (mapheaderinfo[votelevels[i]]->zonttl) if (strlen(mapheaderinfo[votelevels[i]]->zonttl) > 0)
{ {
if (mapheaderinfo[votelevels[i]]->actnum) if (strlen(mapheaderinfo[votelevels[i]]->actnum) > 0)
snprintf(levelinfo[i].str, snprintf(levelinfo[i].str,
sizeof levelinfo[i].str, sizeof levelinfo[i].str,
"%.32s %.32s %s", "%.32s %.32s %s",
@ -2569,7 +2569,7 @@ void Y_StartVote(void)
} }
else else
{ {
if (mapheaderinfo[votelevels[i]]->actnum) if (strlen(mapheaderinfo[votelevels[i]]->actnum) > 0)
snprintf(levelinfo[i].str, snprintf(levelinfo[i].str,
sizeof levelinfo[i].str, sizeof levelinfo[i].str,
"%.32s %s", "%.32s %s",