From 25eaeff0dbfc6ba1606e5cd19ff2fc0d25963978 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 2 Jan 2021 14:46:58 +1100 Subject: [PATCH] - Wrap all `g_gameType & GAMEFLAG_BLOOD` checks into `isBlood()` inline. --- source/core/automap.cpp | 2 +- source/core/console/c_notifybuffer.cpp | 12 ++++++------ source/core/gamecontrol.cpp | 4 ++-- source/core/gamecontrol.h | 5 +++++ source/core/gamecvars.cpp | 4 ++-- source/core/gameinput.cpp | 7 +++---- source/core/inputstate.cpp | 6 +++--- source/core/maploader.cpp | 2 +- source/core/menu/razemenu.cpp | 4 ++-- source/core/searchpaths.cpp | 2 +- source/core/statusbar2.cpp | 2 +- 11 files changed, 27 insertions(+), 23 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 6af087c20..e039094fe 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -90,7 +90,7 @@ CCMD(togglemap) { automapMode++; if (automapMode == am_count) automapMode = am_off; - if ((g_gameType & GAMEFLAG_BLOOD) && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled + if (isBlood() && automapMode == am_overlay) automapMode = am_full; // todo: investigate if this can be re-enabled } } diff --git a/source/core/console/c_notifybuffer.cpp b/source/core/console/c_notifybuffer.cpp index ee18ea666..9eacdfdb7 100644 --- a/source/core/console/c_notifybuffer.cpp +++ b/source/core/console/c_notifybuffer.cpp @@ -112,12 +112,12 @@ void FNotifyBuffer::DrawNative() bool center = g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_NAM | GAMEFLAG_WW2GI | GAMEFLAG_RRALL | GAMEFLAG_SW); bool pulse = g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_NAM | GAMEFLAG_WW2GI | GAMEFLAG_RRALL); - unsigned topline = g_gameType & GAMEFLAG_BLOOD ? 0 : Text.Size() - 1; + unsigned topline = isBlood() ? 0 : Text.Size() - 1; - FFont* font = g_gameType & GAMEFLAG_BLOOD ? SmallFont2 : SmallFont; + FFont* font = isBlood() ? SmallFont2 : SmallFont; - int line = (g_gameType & GAMEFLAG_BLOOD)? Top : (g_gameType & GAMEFLAG_SW) ? 40 : font->GetDisplacement(); - bool canskip = (g_gameType & GAMEFLAG_BLOOD); + int line = isBlood() ? Top : (g_gameType & GAMEFLAG_SW) ? 40 : font->GetDisplacement(); + bool canskip = isBlood(); double scale = 1 / (NotifyFontScale * con_notifyscale); int lineadv = font->GetHeight() / NotifyFontScale; @@ -131,7 +131,7 @@ void FNotifyBuffer::DrawNative() int j = notify.TimeOut - notify.Ticker; if (j > 0) { - double alpha = g_gameType & GAMEFLAG_BLOOD? ((j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1) : 1; + double alpha = isBlood() ? ((j < NOTIFYFADETIME) ? 1. * j / NOTIFYFADETIME : 1) : 1; if (pulse) { alpha *= 0.7 + 0.3 * sin(I_msTime() / 100.); @@ -169,7 +169,7 @@ static bool printNative() { // Blood originally uses its tiny font for the notify display which does not play along well with localization because it is too small, so for non-English switch to the text font. if (con_notify_advanced) return false; - if (!(g_gameType & GAMEFLAG_BLOOD)) return true; + if (!isBlood()) return true; auto p = GStrings["REQUIRED_CHARACTERS"]; if (p && *p) return false; return true; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index c034ff152..9d0596dcb 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -601,7 +601,7 @@ void SetDefaultStrings() gSkillNames[3] = "$Damn I'm Good"; } // Blood hard codes its skill names, so we have to define them manually. - if (g_gameType & GAMEFLAG_BLOOD) + if (isBlood()) { gSkillNames[0] = "$STILL KICKING"; gSkillNames[1] = "$PINK ON THE INSIDE"; @@ -839,7 +839,7 @@ int RunGame() if (usedgroups.Size() == 0) return 0; // Handle CVARs with game specific defaults here. - if (g_gameType & GAMEFLAG_BLOOD) + if (isBlood()) { mus_redbook.SetGenericRepDefault(false, CVAR_Bool); // Blood should default to CD Audio off - all other games must default to on. am_showlabel.SetGenericRepDefault(true, CVAR_Bool); diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 2c34f5ad5..2663ea3a3 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -202,6 +202,11 @@ inline bool isShareware() return g_gameType & GAMEFLAG_SHAREWARE; } +inline bool isBlood() +{ + return g_gameType & GAMEFLAG_BLOOD; +} + TArray GrpScan(); void S_PauseSound(bool notmusic, bool notsfx); void S_ResumeSound(bool notsfx); diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 7cf12416f..deb6408c0 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -87,14 +87,14 @@ CVARD(Bool, cl_exhumedoldturn, false, CVAR_ARCHIVE, "enable/disable legacy turni CUSTOM_CVARD(Int, cl_autoaim, 1, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable weapon autoaim") { - if (self < 0 || self > ((g_gameType & GAMEFLAG_BLOOD)? 2 : 3)) self = 1; // The Shadow Warrior backend only has a bool for this. + if (self < 0 || self > (isBlood() ? 2 : 3)) self = 1; // The Shadow Warrior backend only has a bool for this. }; CUSTOM_CVARD(Int, cl_weaponswitch, 3, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disable auto weapon switching") { if (self < 0) self = 0; if (self > 1 && (g_gameType & GAMEFLAG_SW)) self = 1; - if (self > 3 && (g_gameType & GAMEFLAG_BLOOD)) self = 3; + if (self > 3 && isBlood()) self = 3; if (self > 7) self = 7; } diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index a7717a0df..a84df7574 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -404,8 +404,7 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b if (aimmode && canslopetilt) // If the floor is sloped { // Get a point, 512 (64 for Blood) units ahead of player's position - bool const isBlood = g_gameType & GAMEFLAG_BLOOD; - int const shift = -(isBlood ? 8 : 5); + int const shift = -(isBlood() ? 8 : 5); int const x = pos.x + ang.bcos(shift); int const y = pos.y + ang.bsin(shift); int16_t tempsect = cursectnum; @@ -423,9 +422,9 @@ void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, b // closely (to avoid accidently looking straight out when // you're at the edge of a sector line) then adjust horizon // accordingly - if (cursectnum == tempsect || (!isBlood && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) + if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))) { - *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood ? 160 : 1408)))); + *horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? 160 : 1408)))); } } } diff --git a/source/core/inputstate.cpp b/source/core/inputstate.cpp index 5cc38d4ad..5fcbd5099 100644 --- a/source/core/inputstate.cpp +++ b/source/core/inputstate.cpp @@ -248,7 +248,7 @@ void SetupGameButtons() CCMD(slot) { // The max differs between games so we have to handle this here. - int max = (g_gameType & GAMEFLAG_PSEXHUMED) || (g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE)) == (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE) ? 7 : (g_gameType & GAMEFLAG_BLOOD) ? 12 : 10; + int max = (g_gameType & GAMEFLAG_PSEXHUMED) || (g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE)) == (GAMEFLAG_DUKE | GAMEFLAG_SHAREWARE) ? 7 : isBlood() ? 12 : 10; if (argv.argc() != 2) { Printf("slot : select a weapon from the given slot (1-%d)", max); @@ -278,7 +278,7 @@ CCMD(weapalt) CCMD(useitem) { - int max = (g_gameType & GAMEFLAG_PSEXHUMED)? 6 : (g_gameType & GAMEFLAG_SW)? 7 : (g_gameType & GAMEFLAG_BLOOD) ? 4 : 5; + int max = (g_gameType & GAMEFLAG_PSEXHUMED)? 6 : (g_gameType & GAMEFLAG_SW)? 7 : isBlood() ? 4 : 5; if (argv.argc() != 2) { Printf("useitem : activates an inventory item (1-%d)", max); @@ -437,7 +437,7 @@ void ApplyGlobalInput(InputPacket& input, ControlInfo* hidInput, bool const crou if (buttonMap.ButtonDown(gamefunc_Open)) { - if (g_gameType & GAMEFLAG_BLOOD) buttonMap.ClearButton(gamefunc_Open); + if (isBlood()) buttonMap.ClearButton(gamefunc_Open); input.actions |= SB_OPEN; } if (G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run))) diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 63a1187bc..4d455ca21 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -455,7 +455,7 @@ void loadMapBackup(const char* filename) vec3_t pos; int16_t scratch; - if (g_gameType & GAMEFLAG_BLOOD) + if (isBlood()) { qloadboard(filename, 0, &pos, &scratch, &scratch); } diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index afd960c60..c2fef52bb 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -347,7 +347,7 @@ CCMD(quickload) static DMenuItemBase* CreateCustomListMenuItemText(double x, double y, int height, int hotkey, const char* text, FFont* font, PalEntry color1, PalEntry color2, FName command, int param) { const char* classname = - (g_gameType & GAMEFLAG_BLOOD) ? "ListMenuItemBloodTextItem" : + isBlood() ? "ListMenuItemBloodTextItem" : (g_gameType & GAMEFLAG_SW) ? "ListMenuItemSWTextItem" : (g_gameType & GAMEFLAG_PSEXHUMED) ? "ListMenuItemExhumedTextItem" : "ListMenuItemDukeTextItem"; auto c = PClass::FindClass(classname); @@ -564,7 +564,7 @@ void SetDefaultMenuColors() gameinfo.mSliderColor = "Orange"; gameinfo.mSliderBackColor = "White"; - if (g_gameType & GAMEFLAG_BLOOD) + if (isBlood()) { OptionSettings.mFontColorHeader = CR_DARKGRAY; OptionSettings.mFontColorHighlight = CR_WHITE; diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index cb4a68bb5..60d73b7ae 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -884,7 +884,7 @@ TArray GrpScan() const char* G_DefaultDefFile(void) { - if (g_gameType & GAMEFLAG_BLOOD) + if (isBlood()) return "blood.def"; if (g_gameType & GAMEFLAG_DUKE) diff --git a/source/core/statusbar2.cpp b/source/core/statusbar2.cpp index d1c30664e..7ba06d80a 100644 --- a/source/core/statusbar2.cpp +++ b/source/core/statusbar2.cpp @@ -366,7 +366,7 @@ void drawMapTitle() double scale = (g_gameType & GAMEFLAG_RRALL)? 0.4 : (g_gameType & GAMEFLAG_SW)? 0.7 : 1.0; auto text = currentLevel->DisplayName(); double x = 160 - BigFont->StringWidth(text) * scale / 2.; - double y = (g_gameType & GAMEFLAG_BLOOD)? 50 : 100 - BigFont->GetHeight()/2.; + double y = isBlood() ? 50 : 100 - BigFont->GetHeight()/2.; bool shadow = true; if (shadow)