aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-06 19:46:20 +0200
committerTreeston <treeston.mmoc@gmail.com>2020-08-06 19:46:33 +0200
commit629908172fb5ac2f515f9474cdf6aba1b331958b (patch)
tree65d38abd779bfaa770aed6bb55db099260ff6431 /src
parent02a018ea1394452896ecdd87c98df5fc8655046d (diff)
Core/Object: Deduplicate some checks
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Object/Object.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 24ae1450df5..a95289937fd 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -158,38 +158,38 @@ class TC_GAME_API Object
void ForceValuesUpdateAtIndex(uint32);
inline bool IsPlayer() const { return GetTypeId() == TYPEID_PLAYER; }
- static Player* ToPlayer(Object* o) { if (o && o->GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(o); else return nullptr; }
- static Player const* ToPlayer(Object const* o) { if (o && o->GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player const*>(o); else return nullptr; }
+ static Player* ToPlayer(Object* o) { if (o && o->IsPlayer()) return reinterpret_cast<Player*>(o); else return nullptr; }
+ static Player const* ToPlayer(Object const* o) { if (o && o->IsPlayer()) return reinterpret_cast<Player const*>(o); else return nullptr; }
Player* ToPlayer() { return ToPlayer(this); }
Player const* ToPlayer() const { return ToPlayer(this); }
inline bool IsCreature() const { return GetTypeId() == TYPEID_UNIT; }
- static Creature* ToCreature(Object* o) { if (o && o->GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(o); else return nullptr; }
- static Creature const* ToCreature(Object const* o) { if (o && o->GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(o); else return nullptr; }
+ static Creature* ToCreature(Object* o) { if (o && o->IsCreature()) return reinterpret_cast<Creature*>(o); else return nullptr; }
+ static Creature const* ToCreature(Object const* o) { if (o && o->IsCreature()) return reinterpret_cast<Creature const*>(o); else return nullptr; }
Creature* ToCreature() { return ToCreature(this); }
Creature const* ToCreature() const { return ToCreature(this); }
inline bool IsUnit() const { return isType(TYPEMASK_UNIT); }
- static Unit* ToUnit(Object* o) { if (o && o->isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit*>(o); else return nullptr; }
- static Unit const* ToUnit(Object const* o) { if (o && o->isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit const*>(o); else return nullptr; }
+ static Unit* ToUnit(Object* o) { if (o && o->IsUnit()) return reinterpret_cast<Unit*>(o); else return nullptr; }
+ static Unit const* ToUnit(Object const* o) { if (o && o->IsUnit()) return reinterpret_cast<Unit const*>(o); else return nullptr; }
Unit* ToUnit() { return ToUnit(this); }
Unit const* ToUnit() const { return ToUnit(this); }
inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; }
- static GameObject* ToGameObject(Object* o) { if (o && o->GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(o); else return nullptr; }
- static GameObject const* ToGameObject(Object const* o) { if (o && o->GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject const*>(o); else return nullptr; }
+ static GameObject* ToGameObject(Object* o) { if (o && o->IsGameObject()) return reinterpret_cast<GameObject*>(o); else return nullptr; }
+ static GameObject const* ToGameObject(Object const* o) { if (o && o->IsGameObject()) return reinterpret_cast<GameObject const*>(o); else return nullptr; }
GameObject* ToGameObject() { return ToGameObject(this); }
GameObject const* ToGameObject() const { return ToGameObject(this); }
inline bool IsCorpse() const { return GetTypeId() == TYPEID_CORPSE; }
- static Corpse* ToCorpse(Object* o) { if (o && o->GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(o); else return nullptr; }
- static Corpse const* ToCorpse(Object const* o) { if (o && o->GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse const*>(o); else return nullptr; }
+ static Corpse* ToCorpse(Object* o) { if (o && o->IsCorpse()) return reinterpret_cast<Corpse*>(o); else return nullptr; }
+ static Corpse const* ToCorpse(Object const* o) { if (o && o->IsCorpse()) return reinterpret_cast<Corpse const*>(o); else return nullptr; }
Corpse* ToCorpse() { return ToCorpse(this); }
Corpse const* ToCorpse() const { return ToCorpse(this); }
inline bool IsDynObject() const { return GetTypeId() == TYPEID_DYNAMICOBJECT; }
- static DynamicObject* ToDynObject(Object* o) { if (o && o->GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject*>(o); else return nullptr; }
- static DynamicObject const* ToDynObject(Object const* o) { if (o && o->GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject const*>(o); else return nullptr; }
+ static DynamicObject* ToDynObject(Object* o) { if (o && o->IsDynObject()) return reinterpret_cast<DynamicObject*>(o); else return nullptr; }
+ static DynamicObject const* ToDynObject(Object const* o) { if (o && o->IsDynObject()) return reinterpret_cast<DynamicObject const*>(o); else return nullptr; }
DynamicObject* ToDynObject() { return ToDynObject(this); }
DynamicObject const* ToDynObject() const { return ToDynObject(this); }