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

@@ -587,7 +587,7 @@ bool Map::AddToMap(T* obj, bool checkTransport)
obj->AddToWorld();
if (checkTransport)
if (!(obj->GetTypeId() == TYPEID_GAMEOBJECT && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d
if (!(obj->IsGameObject() && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d
if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj))
transport->AddPassenger(obj, true);
@@ -602,7 +602,7 @@ bool Map::AddToMap(T* obj, bool checkTransport)
// Xinef: little hack for vehicles, accessories have to be added after visibility update so they wont fall off the vehicle, moved from Creature::AIM_Initialize
// Initialize vehicle, this is done only for summoned npcs, DB creatures are handled by grid loaders
if (obj->GetTypeId() == TYPEID_UNIT)
if (obj->IsCreature())
if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
vehicle->Reset();
return true;
@@ -2662,8 +2662,8 @@ void Map::AddObjectToSwitchList(WorldObject* obj, bool on)
{
ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
// i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses
// the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases
if (obj->GetTypeId() != TYPEID_UNIT && obj->GetTypeId() != TYPEID_GAMEOBJECT)
// the contained objects only if IsCreature() , so we can return in all other cases
if (!obj->IsCreature() && !obj->IsGameObject())
return;
std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);