diff --git a/src/game/Object/Object.h b/src/game/Object/Object.h index a9114af88..b93733c3f 100644 --- a/src/game/Object/Object.h +++ b/src/game/Object/Object.h @@ -80,6 +80,9 @@ class Map; class UpdateMask; class InstanceData; class TerrainInfo; +#ifdef ENABLE_ELUNA +class ElunaEventProcessor; +#endif /* ENABLE_ELUNA */ class TransportInfo; typedef UNORDERED_MAP UpdateDataMapType; @@ -221,6 +224,24 @@ class Object ObjectGuid const& GetGuidValue(uint16 index) const { return *reinterpret_cast(&GetUInt64Value(index)); } + Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast(this); else return NULL; } + Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast(this); else return NULL; } + + Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast(this); else return NULL; } + Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast(this); else return NULL; } + + Unit* ToUnit() { if (isType(TYPEMASK_UNIT)) return reinterpret_cast(this); else return NULL; } + Unit const* ToUnit() const { if (isType(TYPEMASK_UNIT)) return reinterpret_cast(this); else return NULL; } + + GameObject* ToGameObject() { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast(this); else return NULL; } + GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast(this); else return NULL; } + + Corpse* ToCorpse() { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast(this); else return NULL; } + Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast(this); else return NULL; } + + DynamicObject* ToDynObject() { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast(this); else return NULL; } + DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast(this); else return NULL; } + void SetInt32Value(uint16 index, int32 value); void SetUInt32Value(uint16 index, uint32 value); void SetUInt64Value(uint16 index, const uint64& value); @@ -624,6 +645,10 @@ class WorldObject : public Object virtual void StartGroupLoot(Group* /*group*/, uint32 /*timer*/) {} +#ifdef ENABLE_ELUNA + ElunaEventProcessor* elunaEvents; +#endif /* ENABLE_ELUNA */ + protected: explicit WorldObject(); diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index e480d8b77..0f6746567 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -10087,7 +10087,7 @@ Powers Unit::GetPowerTypeByIndex(uint32 index, uint32 classId) return Powers(sChrClassXPowerIndexStore[classId][index]); } -int32 Unit::GetPower(Powers power) const +uint32 Unit::GetPower(Powers power) const { if (power == POWER_HEALTH) return GetHealth(); @@ -10099,7 +10099,7 @@ int32 Unit::GetPower(Powers power) const return GetUInt32Value(UNIT_FIELD_POWER1 + powerIndex); } -int32 Unit::GetPowerByIndex(uint32 index) const +uint32 Unit::GetPowerByIndex(uint32 index) const { MANGOS_ASSERT(index < MAX_STORED_POWERS); diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index 11d91b548..cdbf87baa 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -1,4 +1,4 @@ -/** +/**Unit::GetPower * MaNGOS is a full featured server for World of Warcraft, supporting * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * @@ -1721,8 +1721,8 @@ class Unit : public WorldObject */ Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); } void setPowerType(Powers power); - int32 GetPower(Powers power) const; - int32 GetPowerByIndex(uint32 index) const; + uint32 GetPower(Powers power) const; + uint32 GetPowerByIndex(uint32 index) const; uint32 GetMaxPower(Powers power) const; uint32 GetMaxPowerByIndex(uint32 index) const; void SetPowerByIndex(uint32 power, int32 val);