diff options
author | Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> | 2024-09-03 13:41:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 14:41:31 -0300 |
commit | 1edac37ac37dfbfdc5f4d1ba36140dc077f06236 (patch) | |
tree | 3fcc7413a65a54e9e9508388a1b2991484c14d4f /src/server/game/Scripting/MapScripts.cpp | |
parent | e3e4133e883f13a880a7281b66488ee529cf392e (diff) |
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>
Diffstat (limited to 'src/server/game/Scripting/MapScripts.cpp')
-rw-r--r-- | src/server/game/Scripting/MapScripts.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index fe945d7195..ebf2d3daa2 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -157,7 +157,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s Unit* unit = nullptr; if (!obj) LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target"); - else if (!obj->isType(TYPEMASK_UNIT)) + else if (!obj->IsUnit()) LOG_ERROR("maps.script", "{} {} object is not unit (TypeId: {}, Entry: {}, GUID: {}), skipping.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString()); else @@ -236,7 +236,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script LOG_ERROR("maps.script", "{} door guid is not specified.", scriptInfo->GetDebugInfo()); else if (!source) LOG_ERROR("maps.script", "{} source object is nullptr.", scriptInfo->GetDebugInfo()); - else if (!source->isType(TYPEMASK_UNIT)) + else if (!source->IsUnit()) LOG_ERROR("maps.script", "{} source object is not unit ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString()); else { @@ -510,7 +510,7 @@ void Map::ScriptsProcess() Player* player = target->ToPlayer(); if (player) { - if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) + if (!source->IsCreature() && !source->IsGameObject() && !source->IsPlayer()) { LOG_ERROR("maps.script", "{} source is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString()); break; @@ -522,7 +522,7 @@ void Map::ScriptsProcess() player = source->ToPlayer(); if (player) { - if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsCreature() && !target->IsGameObject() && !target->IsPlayer()) { LOG_ERROR("maps.script", "{} target is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString()); break; @@ -538,7 +538,7 @@ void Map::ScriptsProcess() } // quest id and flags checked at script loading - if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) && + if ((!worldObject->IsCreature() || ((Unit*)worldObject)->IsAlive()) && (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance)))) player->GroupEventHappens(step.script->QuestExplored.QuestID, worldObject); else @@ -641,7 +641,7 @@ void Map::ScriptsProcess() break; } - if (target->GetTypeId() != TYPEID_GAMEOBJECT) + if (!target->IsGameObject()) { LOG_ERROR("maps.script", "{} target object is not gameobject ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString()); break; @@ -697,13 +697,13 @@ void Map::ScriptsProcess() break; } - if (!uSource || !uSource->isType(TYPEMASK_UNIT)) + if (!uSource || !uSource->IsUnit()) { LOG_ERROR("maps.script", "{} no source unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID); break; } - if (!uTarget || !uTarget->isType(TYPEMASK_UNIT)) + if (!uTarget || !uTarget->IsUnit()) { LOG_ERROR("maps.script", "{} no target unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID); break; |