From 4fd88293ffd397f28fafe3e95c64d9ce230b29ae Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 5 Jun 2018 17:28:46 -0400 Subject: [PATCH] Use strlen for all of the valid zone title/act num checks --- src/d_clisrv.c | 6 +++--- src/d_netcmd.c | 6 +++--- src/g_game.c | 4 ++-- src/m_menu.c | 12 ++++++------ src/m_misc.c | 2 +- src/p_setup.c | 2 +- src/y_inter.c | 32 ++++++++++++++++---------------- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fd4b2d158..0d3b9141e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1637,14 +1637,14 @@ static void CL_LoadReceivedSavegame(void) if (P_LoadNetGame()) { 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); - if (strcmp(mapheaderinfo[gamemap-1]->zonttl, "")) + if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) CONS_Printf(" %s", mapheaderinfo[gamemap-1]->zonttl); else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) 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("\"\n"); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 276cc1d00..2f2657d71 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4523,16 +4523,16 @@ static void Command_Showmap_f(void) { 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); else CONS_Printf("%s (%d): %s %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl); } 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); else CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl); diff --git a/src/g_game.c b/src/g_game.c index 4f41d1176..8b1e658f4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4097,7 +4097,7 @@ char *G_BuildMapTitle(INT32 mapnum) const char *actnum = NULL; 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); len += strlen(zonetext) + 1; // ' ' + zonetext @@ -4107,7 +4107,7 @@ char *G_BuildMapTitle(INT32 mapnum) zonetext = M_GetText("ZONE"); 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); len += strlen(actnum) + 1; // ' ' + actnum diff --git a/src/m_menu.c b/src/m_menu.c index 4de30fa9c..879823102 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3371,16 +3371,16 @@ static void M_DrawPauseMenu(void) // Draw any and all emblems at the top. 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)); else V_DrawString(40, 28, V_YELLOWMAP, va("%s %s", mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->zonttl)); } 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)); else V_DrawString(40, 28, V_YELLOWMAP, mapheaderinfo[gamemap-1]->lvlttl); @@ -5347,16 +5347,16 @@ static void M_DrawStatsMaps(int location) mnum = statsMapList[i]; 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)); else V_DrawString(20, y, V_YELLOWMAP, va("%s %s", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->zonttl)); } 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)); else V_DrawString(20, y, V_YELLOWMAP, mapheaderinfo[mnum]->lvlttl); diff --git a/src/m_misc.c b/src/m_misc.c index 7ebf1ac35..5727067c8 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -681,7 +681,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png mapheaderinfo[gamemap-1]->lvlttl, (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart ((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 snprintf(lvlttltext, 48, "Unknown"); diff --git a/src/p_setup.c b/src/p_setup.c index e32d3b861..e57fad947 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2683,7 +2683,7 @@ boolean P_SetupLevel(boolean skipprecip) mapheaderinfo[gamemap-1]->lvlttl, (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart ((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); I_UpdateNoVsync(); } diff --git a/src/y_inter.c b/src/y_inter.c index 30b2a4715..cd56b346b 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -295,7 +295,7 @@ void Y_IntermissionDrawer(void) 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); - if (mapheaderinfo[gamemap-1]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum); //if (gottimebonus && endtic != -1) @@ -1159,24 +1159,24 @@ void Y_StartIntermission(void) if (strlen(skins[players[consoleplayer].skin].realname) > 13) { 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" else if (strlen(skins[players[consoleplayer].skin].realname) > 8) { 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 else { snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s GOT", 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 - if (mapheaderinfo[gamemap-1]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) { data.coop.passedx1 = 62 + (176 - V_LevelNameWidth(data.coop.passed1))/2; data.coop.passedx2 = 62 + (176 - V_LevelNameWidth(data.coop.passed2))/2; @@ -1317,9 +1317,9 @@ void Y_StartIntermission(void) Y_CalculateMatchWinners(); // 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, sizeof data.match.levelstring, "%.32s %.32s * %s *", @@ -1332,7 +1332,7 @@ void Y_StartIntermission(void) } else { - if (mapheaderinfo[prevmap]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) snprintf(data.match.levelstring, sizeof data.match.levelstring, "%.32s * %s *", @@ -1380,9 +1380,9 @@ void Y_StartIntermission(void) Y_CalculateTournamentPoints(); // 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, sizeof data.match.levelstring, "%.32s %.32s * %s *", @@ -1395,7 +1395,7 @@ void Y_StartIntermission(void) } else { - if (mapheaderinfo[prevmap]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) snprintf(data.match.levelstring, sizeof data.match.levelstring, "%.32s * %s *", @@ -1425,7 +1425,7 @@ void Y_StartIntermission(void) Y_CalculateMatchWinners(); // set up the levelstring - if (mapheaderinfo[prevmap]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) snprintf(data.match.levelstring, sizeof data.match.levelstring, "%.32s * %s *", @@ -1461,7 +1461,7 @@ void Y_StartIntermission(void) Y_CalculateCompetitionWinners(); // set up the levelstring - if (mapheaderinfo[prevmap]->actnum) + if (strlen(mapheaderinfo[prevmap]->actnum) > 0) snprintf(data.competition.levelstring, sizeof data.competition.levelstring, "%.32s * %s *", @@ -2554,9 +2554,9 @@ void Y_StartVote(void) lumpnum_t lumpnum; // 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, sizeof levelinfo[i].str, "%.32s %.32s %s", @@ -2569,7 +2569,7 @@ void Y_StartVote(void) } else { - if (mapheaderinfo[votelevels[i]]->actnum) + if (strlen(mapheaderinfo[votelevels[i]]->actnum) > 0) snprintf(levelinfo[i].str, sizeof levelinfo[i].str, "%.32s %s",