mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 11:25:42 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
void ScriptMgr::OnInstall(Vehicle* veh)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
{
|
||||
@@ -33,7 +33,7 @@ void ScriptMgr::OnInstall(Vehicle* veh)
|
||||
void ScriptMgr::OnUninstall(Vehicle* veh)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
{
|
||||
@@ -44,7 +44,7 @@ void ScriptMgr::OnUninstall(Vehicle* veh)
|
||||
void ScriptMgr::OnReset(Vehicle* veh)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
{
|
||||
@@ -55,7 +55,7 @@ void ScriptMgr::OnReset(Vehicle* veh)
|
||||
void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
ASSERT(accessory);
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
@@ -67,7 +67,7 @@ void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
|
||||
void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
ASSERT(passenger);
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
@@ -79,7 +79,7 @@ void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
|
||||
void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger)
|
||||
{
|
||||
ASSERT(veh);
|
||||
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
|
||||
ASSERT(veh->GetBase()->IsCreature());
|
||||
ASSERT(passenger);
|
||||
|
||||
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
|
||||
|
||||
Reference in New Issue
Block a user