Core/Misc: Fix some GCC warnings

This commit is contained in:
Shauren
2024-11-12 16:39:24 +01:00
parent af4dcc93ed
commit 4e551741cf
4 changed files with 25 additions and 42 deletions
@@ -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;
}
}
+3 -1
View File
@@ -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);
@@ -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,40 +1660,20 @@ 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);
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)
// 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->m_invisibility.DelFlag(type);
}
if (!target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
target->RemoveVisFlag(UNIT_VIS_FLAGS_INVISIBLE);
target->m_invisibility.AddValue(type, -GetAmount());
}
+2 -1
View File
@@ -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);
}