- Wrap all g_gameType & GAMEFLAG_BLOOD checks into isBlood() inline.

This commit is contained in:
Mitchell Richters 2021-01-02 14:46:58 +11:00
parent 532d128afd
commit 25eaeff0db
11 changed files with 27 additions and 23 deletions

View file

@ -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
}
}

View file

@ -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;

View file

@ -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);

View file

@ -202,6 +202,11 @@ inline bool isShareware()
return g_gameType & GAMEFLAG_SHAREWARE;
}
inline bool isBlood()
{
return g_gameType & GAMEFLAG_BLOOD;
}
TArray<GrpEntry> GrpScan();
void S_PauseSound(bool notmusic, bool notsfx);
void S_ResumeSound(bool notsfx);

View file

@ -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;
}

View file

@ -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))));
}
}
}

View file

@ -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 <weaponslot>: 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 <itemnum>: 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)))

View file

@ -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);
}

View file

@ -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;

View file

@ -884,7 +884,7 @@ TArray<GrpEntry> GrpScan()
const char* G_DefaultDefFile(void)
{
if (g_gameType & GAMEFLAG_BLOOD)
if (isBlood())
return "blood.def";
if (g_gameType & GAMEFLAG_DUKE)

View file

@ -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)