refactor(Core): Make more use of helpers. (#19835)

* Init.

* Reword.

* Update codestyle script.

Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Add gameobject type ID check, reorder checks.

* Add helper/codestyle check for unit type.

* `IsUnit()` -> `IsCreature()`

* Add `IsUnit()` method.

* Use type mask.

https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5
Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com>

* Replace instances of `isType` with `IsUnit`.

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
Benjamin Jackson
2024-09-03 13:41:31 -04:00
committed by GitHub
parent e3e4133e88
commit 1edac37ac3
165 changed files with 725 additions and 719 deletions

View File

@@ -136,7 +136,7 @@ class spell_the_flag_of_ownership : public SpellScript
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
if (!caster || !caster->IsPlayer())
return;
Player* target = GetHitPlayer();
if (!target)
@@ -155,7 +155,7 @@ class spell_the_flag_of_ownership : public SpellScript
{
for( std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); )
{
if ((*itr)->GetTypeId() != TYPEID_PLAYER || (*itr)->ToPlayer()->IsAlive())
if (!(*itr)->IsPlayer() || (*itr)->ToPlayer()->IsAlive())
{
targets.erase(itr);
itr = targets.begin();
@@ -1835,7 +1835,7 @@ class spell_gen_feign_death_all_flags : public AuraScript
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
@@ -1846,7 +1846,7 @@ class spell_gen_feign_death_all_flags : public AuraScript
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->InitializeReactState();
}
@@ -1870,7 +1870,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
@@ -1880,7 +1880,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->InitializeReactState();
}
@@ -1903,7 +1903,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript
target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->SetReactState(REACT_PASSIVE);
}
@@ -1913,7 +1913,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript
target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT);
if (target->GetTypeId() == TYPEID_UNIT)
if (target->IsCreature())
target->ToCreature()->InitializeReactState();
}
@@ -1944,7 +1944,7 @@ class spell_gen_teleporting : public SpellScript
void HandleScript(SpellEffIndex /* effIndex */)
{
Unit* target = GetHitUnit();
if (target->GetTypeId() != TYPEID_PLAYER)
if (!target->IsPlayer())
return;
// return from top
@@ -2504,7 +2504,7 @@ class spell_gen_vehicle_scaling_aura: public AuraScript
bool Load() override
{
return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->GetTypeId() == TYPEID_UNIT;
return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->IsCreature();
}
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
@@ -3729,7 +3729,7 @@ class spell_gen_despawn_self : public SpellScript
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_UNIT;
return GetCaster()->IsCreature();
}
void HandleDummy(SpellEffIndex effIndex)