Skip to content

Commit bc0d60b

Browse files
kphoenix137StephenCWills
authored andcommitted
Add Player hasNoMana helper
1 parent 7e8173e commit bc0d60b

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

Source/engine/render/scrollrt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ void DrawAndBlit()
17911791
DrawFlaskValues(out, { mainPanel.position.x + 134, mainPanel.position.y + 28 }, MyPlayer->_pHitPoints >> 6, MyPlayer->_pMaxHP >> 6);
17921792
if (*GetOptions().Gameplay.showManaValues)
17931793
DrawFlaskValues(out, { mainPanel.position.x + mainPanel.size.width - 138, mainPanel.position.y + 28 },
1794-
(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || (MyPlayer->_pMana >> 6) <= 0) ? 0 : MyPlayer->_pMana >> 6,
1794+
(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || MyPlayer->hasNoMana()) ? 0 : MyPlayer->_pMana >> 6,
17951795
HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : MyPlayer->_pMaxMana >> 6);
17961796
if (*GetOptions().Gameplay.floatingInfoBox)
17971797
DrawFloatingInfoBox(out);

Source/missiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4207,7 +4207,7 @@ static void DeleteMissiles()
42074207
void ProcessManaShield()
42084208
{
42094209
Player &myPlayer = *MyPlayer;
4210-
if (myPlayer.pManaShield && myPlayer._pMana <= 0) {
4210+
if (myPlayer.pManaShield && myPlayer.hasNoMana()) {
42114211
myPlayer.pManaShield = false;
42124212
NetSendCmd(true, CMD_REMSHIELD);
42134213
}

Source/monster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4008,7 +4008,7 @@ void PrepDoEnding()
40084008
if (gbIsMultiplayer) {
40094009
if (player.hasNoLife())
40104010
player._pHitPoints = 64;
4011-
if (player._pMana >> 6 == 0)
4011+
if (player.hasNoMana())
40124012
player._pMana = 64;
40134013
}
40144014
}

Source/objects.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,7 @@ void OperateShrineCostOfWisdom(Player &player, SpellID spellId, diablo_message m
25332533
player._pMana -= t;
25342534
player._pMaxMana -= t;
25352535
player._pMaxManaBase -= t;
2536-
if (player._pMana >> 6 <= 0) {
2536+
if (player.hasNoMana()) {
25372537
player._pMana = v1;
25382538
player._pManaBase = 0;
25392539
}

Source/panels/charpanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ PanelEntry panelEntries[] = {
188188
{ N_("Mana"), { LeftColumnLabelX, 312 }, 45, LeftColumnLabelWidth,
189189
[]() { return StyledText { GetMaxManaColor(), StrCat(HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) ? 0 : InspectPlayer->_pMaxMana >> 6) }; } },
190190
{ "", { 135, 312 }, 45, 0,
191-
[]() { return StyledText { (InspectPlayer->_pMana != InspectPlayer->_pMaxMana ? UiFlags::ColorRed : GetMaxManaColor()), StrCat((HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || (InspectPlayer->_pMana >> 6) <= 0) ? 0 : InspectPlayer->_pMana >> 6) }; } },
191+
[]() { return StyledText { (InspectPlayer->_pMana != InspectPlayer->_pMaxMana ? UiFlags::ColorRed : GetMaxManaColor()), StrCat((HasAnyOf(InspectPlayer->_pIFlags, ItemSpecialEffect::NoMana) || InspectPlayer->hasNoMana()) ? 0 : InspectPlayer->_pMana >> 6) }; } },
192192

193193
{ N_("Resist magic"), { RightColumnLabelX, 256 }, 57, RightColumnLabelWidth,
194194
[]() { return GetResistInfo(InspectPlayer->_pMagResist); } },

Source/player.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,11 @@ struct Player {
905905
{
906906
return leveltype == DTYPE_TOWN ? false : _pHitPoints >> 6 <= 0;
907907
}
908+
909+
bool hasNoMana() const
910+
{
911+
return _pMana >> 6 <= 0;
912+
}
908913
};
909914

910915
extern DVL_API_FOR_TEST uint8_t MyPlayerId;

0 commit comments

Comments
 (0)