aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-11-12 16:39:24 +0100
committerShauren <shauren.trinity@gmail.com>2024-11-12 16:39:24 +0100
commit4e551741cf893a96bee66c063d4e028df7a11adf (patch)
treeb1e31bfe60bf36931b00cb5f6eb620bdf39ba531
parentaf4dcc93ed04c4f2219c14821b25cb9efeb7e781 (diff)
Core/Misc: Fix some GCC warnings
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp16
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp4
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp42
-rw-r--r--src/server/game/Spells/Spell.cpp3
4 files changed, 24 insertions, 41 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index b44b7454f65..4b3e2d55026 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -1853,21 +1853,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
case SMART_ACTION_SET_UNIT_FIELD_BYTES_1:
{
for (WorldObject* target : targets)
- if (IsUnit(target))
+ if (Unit* unitTarget = target->ToUnit())
{
switch (e.action.setunitByte.type)
{
case 0:
- target->ToUnit()->SetStandState(UnitStandStateType(e.action.setunitByte.byte1));
+ unitTarget->SetStandState(UnitStandStateType(e.action.setunitByte.byte1));
break;
case 1:
// pet talent points
break;
case 2:
- target->ToUnit()->SetVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
+ unitTarget->SetVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
break;
case 3:
- target->ToUnit()->SetAnimTier(AnimTier(e.action.setunitByte.byte1));
+ unitTarget->SetAnimTier(AnimTier(e.action.setunitByte.byte1));
break;
}
}
@@ -1876,21 +1876,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
case SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1:
{
for (WorldObject* target : targets)
- if (IsUnit(target))
+ if (Unit* unitTarget = target->ToUnit())
{
switch (e.action.setunitByte.type)
{
case 0:
- target->ToUnit()->SetStandState(UNIT_STAND_STATE_STAND);
+ unitTarget->SetStandState(UNIT_STAND_STATE_STAND);
break;
case 1:
// pet talent points
break;
case 2:
- target->ToUnit()->RemoveVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
+ unitTarget->RemoveVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
break;
case 3:
- target->ToUnit()->SetAnimTier(AnimTier::Ground);
+ unitTarget->SetAnimTier(AnimTier::Ground);
break;
}
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 03376801b3e..f64dc9306f2 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9507,11 +9507,13 @@ void Unit::UpdateAllDamagePctDoneMods()
float Unit::GetTotalStatValue(Stats stat) const
{
+ float createStat = GetCreateStat(stat); // retrieved early to workaround a GCC false positive warning about out of bounds array access (conversion to UnitMods confuses it)
+
UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + AsUnderlyingType(stat));
// value = ((base_value * base_pct) + total_value) * total_pct
float value = CalculatePct(GetFlatModifierValue(unitMod, BASE_VALUE), std::max(GetFlatModifierValue(unitMod, BASE_PCT_EXCLUDE_CREATE), -100.0f));
- value += GetCreateStat(stat);
+ value += createStat;
value *= GetPctModifierValue(unitMod, BASE_PCT);
value += GetFlatModifierValue(unitMod, TOTAL_VALUE);
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 14b3e40b3ed..db893f4b379 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -1644,14 +1644,14 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
return;
Unit* target = aurApp->GetTarget();
- Player* playerTarget = target->ToPlayer();
InvisibilityType type = InvisibilityType(GetMiscValue());
if (apply)
{
// apply glow vision
- if (playerTarget && type == INVISIBILITY_GENERAL)
- playerTarget->AddAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
+ if (type == INVISIBILITY_GENERAL)
+ if (Player* playerTarget = target->ToPlayer())
+ playerTarget->AddAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
target->m_invisibility.AddFlag(type);
target->m_invisibility.AddValue(type, GetAmount());
@@ -1660,39 +1660,19 @@ void AuraEffect::HandleModInvisibility(AuraApplication const* aurApp, uint8 mode
}
else
{
- if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
+ if (!target->HasAuraTypeWithMiscvalue(SPELL_AURA_MOD_INVISIBILITY, type))
{
- // if not have different invisibility auras.
- // always remove glow vision
- if (Player * playerTarget = target->ToPlayer())
- playerTarget->RemoveAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
+ // if not have invisibility auras of type INVISIBILITY_GENERAL
+ // remove glow vision
+ if (type == INVISIBILITY_GENERAL)
+ if (Player* playerTarget = target->ToPlayer())
+ playerTarget->RemoveAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
target->m_invisibility.DelFlag(type);
-
- target->RemoveVisFlag(UNIT_VIS_FLAGS_INVISIBLE);
}
- else
- {
- bool found = false;
- Unit::AuraEffectList const& invisAuras = target->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY);
- for (Unit::AuraEffectList::const_iterator i = invisAuras.begin(); i != invisAuras.end(); ++i)
- {
- if (GetMiscValue() == (*i)->GetMiscValue())
- {
- found = true;
- break;
- }
- }
- if (!found)
- {
- // if not have invisibility auras of type INVISIBILITY_GENERAL
- // remove glow vision
- if (playerTarget && type == INVISIBILITY_GENERAL)
- playerTarget->RemoveAuraVision(PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
- target->m_invisibility.DelFlag(type);
- }
- }
+ if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
+ target->RemoveVisFlag(UNIT_VIS_FLAGS_INVISIBLE);
target->m_invisibility.AddValue(type, -GetAmount());
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9ce04c387e4..c6bf17beb35 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -4369,7 +4369,8 @@ void Spell::update(uint32 difftime)
m_caster->SendMessageToSet(empowerSetStage.Write(), true);
m_empower->CompletedStages = completedStages;
- m_caster->ToUnit()->SetSpellEmpowerStage(completedStages);
+ if (Unit* unitCaster = m_caster->ToUnit())
+ unitCaster->SetSpellEmpowerStage(completedStages);
CallScriptEmpowerStageCompletedHandlers(completedStages);
}