From 2fa14abf42ab4a094405b5407b39faaf018d9072 Mon Sep 17 00:00:00 2001 From: n0n4m3 Date: Sat, 26 Dec 2009 11:38:30 +0100 Subject: [PATCH] Move some grid object functions into one parent class --HG-- branch : trunk --- src/game/Corpse.h | 5 +---- src/game/Creature.h | 5 +---- src/game/DynamicObject.h | 5 +---- src/game/GameObject.h | 6 +----- src/game/Object.h | 9 +++++++++ src/game/Player.h | 4 +--- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/game/Corpse.h b/src/game/Corpse.h index e0374a0347..e9088e17b8 100644 --- a/src/game/Corpse.h +++ b/src/game/Corpse.h @@ -48,7 +48,7 @@ enum CorpseFlags CORPSE_FLAG_LOOTABLE = 0x20 }; -class Corpse : public WorldObject +class Corpse : public WorldObject, public GridObject { public: explicit Corpse( CorpseType type = CORPSE_BONES ); @@ -88,10 +88,7 @@ class Corpse : public WorldObject void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId,receiver); } void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); } - GridReference &GetGridRef() { return m_gridRef; } private: - GridReference m_gridRef; - CorpseType m_type; time_t m_time; GridPair m_grid; // gride for corpse position for fast search diff --git a/src/game/Creature.h b/src/game/Creature.h index 6470af4bb7..b3e3a8a455 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -397,7 +397,7 @@ typedef std::map CreatureSpellCooldowns; #define MAX_VENDOR_ITEMS 150 // Limitation in 3.x.x item count in SMSG_LIST_INVENTORY -class TRINITY_DLL_SPEC Creature : public Unit +class TRINITY_DLL_SPEC Creature : public Unit, public GridObject { public: @@ -607,7 +607,6 @@ class TRINITY_DLL_SPEC Creature : public Unit bool hasQuest(uint32 quest_id) const; bool hasInvolvedQuest(uint32 quest_id) const; - GridReference &GetGridRef() { return m_gridRef; } bool isRegeneratingHealth() { return m_regenHealth; } virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; } virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const @@ -711,8 +710,6 @@ class TRINITY_DLL_SPEC Creature : public Unit //Formation var CreatureGroup *m_formation; - - GridReference m_gridRef; }; class AssistDelayEvent : public BasicEvent diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 89b227e64f..11cf030a6c 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -26,7 +26,7 @@ class Unit; struct SpellEntry; -class DynamicObject : public WorldObject +class DynamicObject : public WorldObject, public GridObject { public: typedef std::set AffectedSet; @@ -58,7 +58,6 @@ class DynamicObject : public WorldObject void Whisper(int32 textId,uint64 receiver) { MonsterWhisper(textId,receiver); } void YellToZone(int32 textId, uint32 language, uint64 TargetGuid) { MonsterYellToZone(textId,language,TargetGuid); } - GridReference &GetGridRef() { return m_gridRef; } protected: uint32 m_spellId; uint32 m_effMask; @@ -66,7 +65,5 @@ class DynamicObject : public WorldObject uint32 m_updateTimer; float m_radius; AffectedSet m_affected; - private: - GridReference m_gridRef; }; #endif diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 358af95a9b..8d378d5a96 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -581,7 +581,7 @@ class Unit; // 5 sec for bobber catch #define FISHING_BOBBER_READY_TIME 5 -class TRINITY_DLL_SPEC GameObject : public WorldObject +class TRINITY_DLL_SPEC GameObject : public WorldObject, public GridObject { public: explicit GameObject(); @@ -722,8 +722,6 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject GameObject* LookupFishingHoleAround(float range); - GridReference &GetGridRef() { return m_gridRef; } - void CastSpell(Unit *target, uint32 spell); void SendCustomAnim(); bool IsInRange(float x, float y, float z, float radius) const; @@ -759,7 +757,5 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject uint16 m_LootMode; // bitmask, default DEFAULT_LOOT_MODE, determines what loot will be lootable private: void SwitchDoorOrButton(bool activate, bool alternative = false); - - GridReference m_gridRef; }; #endif diff --git a/src/game/Object.h b/src/game/Object.h index 93cf0d40e8..684e542335 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -448,6 +448,15 @@ class WorldLocation : public Position uint32 m_mapId; }; +template +class GridObject +{ + public: + GridReference &GetGridRef() { return m_gridRef; } + protected: + GridReference m_gridRef; +}; + class TRINITY_DLL_SPEC WorldObject : public Object, public WorldLocation { public: diff --git a/src/game/Player.h b/src/game/Player.h index db6e72b576..cdc19d4740 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -960,7 +960,7 @@ struct BGData bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; } }; -class TRINITY_DLL_SPEC Player : public Unit +class TRINITY_DLL_SPEC Player : public Unit, public GridObject { friend class WorldSession; friend void Item::AddToUpdateQueueOf(Player *player); @@ -2238,7 +2238,6 @@ class TRINITY_DLL_SPEC Player : public Unit uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); } void SetOriginalGroup(Group *group, int8 subgroup = -1); - GridReference &GetGridRef() { return m_gridRef; } MapReference &GetMapRef() { return m_mapRef; } // Set map to player and add reference @@ -2531,7 +2530,6 @@ Spell * m_spellModTakingSpell; m_DelayedOperations |= operation; } - GridReference m_gridRef; MapReference m_mapRef; void UpdateCharmedAI();