aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/GameObject
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2016-08-29 19:20:06 +0100
committerDDuarte <dnpd.dd@gmail.com>2016-08-29 19:20:06 +0100
commit8c625f0f89be959e8c73f5552fa8437e57499b89 (patch)
tree2f813f21b79e8fc75e0ada4d4d77b911bda94e26 /src/server/game/Entities/GameObject
parent8939b3b4ea69f904063ffd15a3b7fef771763170 (diff)
Core/GameObject: added possibilty for gameobjects to contain money loot.
Updates #14564 (cherry picked from commit b091415c03ffbfb5a7534d6b087101b15640fae7) Conflicts: src/server/game/Globals/ObjectMgr.cpp Core/GameObject: migrated non-WDB fields to new gameobject_template_addon table (cherry picked from commit bd4bf0a73fa29701835176ce757e2fb498b39cdc) Conflicts: src/server/game/Globals/ObjectMgr.cpp Core/GameObject: cache pointer to GameObjectTemplateAddon (cherry picked from commit 33102220e53731ca958b46e87abacdce07e3aa88) Conflicts: src/server/game/Entities/GameObject/GameObject.cpp Core/ObjectMgr: filter out bogus check This restores previous behaviour (cherry picked from commit 7028503e8f80dc5488ea9dbf33f595ef2044001d) Typo fix (cherry picked from commit fe3a0bf7e135cf8ba9035c4d3c271969d2915aaa)
Diffstat (limited to 'src/server/game/Entities/GameObject')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp21
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h15
2 files changed, 28 insertions, 8 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 56e4ca80c59..6d1cfe1f716 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -55,6 +55,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_cooldownTime = 0;
m_goInfo = NULL;
m_goData = NULL;
+ m_goTemplateAddon = nullptr;
m_spawnId = UI64LIT(0);
m_rotation = 0;
@@ -223,6 +224,7 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x,
Object::_Create(guid);
m_goInfo = goinfo;
+ m_goTemplateAddon = sObjectMgr->GetGameObjectTemplateAddon(name_id);
if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
{
@@ -237,8 +239,11 @@ bool GameObject::Create(uint32 name_id, Map* map, uint32 /*phaseMask*/, float x,
SetObjectScale(goinfo->size);
- SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
- SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
+ if (m_goTemplateAddon)
+ {
+ SetUInt32Value(GAMEOBJECT_FACTION, m_goTemplateAddon->faction);
+ SetUInt32Value(GAMEOBJECT_FLAGS, m_goTemplateAddon->flags);
+ }
SetEntry(goinfo->entry);
@@ -671,8 +676,9 @@ void GameObject::Update(uint32 diff)
SetGoState(GO_STATE_READY);
//any return here in case battleground traps
- if (GetGOInfo()->flags & GO_FLAG_NODESPAWN)
- return;
+ if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
+ if (addon->flags & GO_FLAG_NODESPAWN)
+ return;
}
loot.clear();
@@ -693,7 +699,8 @@ void GameObject::Update(uint32 diff)
{
SendObjectDeSpawnAnim(GetGUID());
//reset flags
- SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
+ if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
+ SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);
}
if (!m_respawnDelayTime)
@@ -744,7 +751,9 @@ void GameObject::Delete()
SendObjectDeSpawnAnim(GetGUID());
SetGoState(GO_STATE_READY);
- SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
+
+ if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
+ SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags);
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
if (poolid)
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index ae91170442c..3b3c8cadbfb 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -40,8 +40,6 @@ struct GameObjectTemplate
std::string IconName;
std::string castBarCaption;
std::string unk1;
- uint32 faction;
- uint32 flags;
float size;
int32 RequiredLevel;
union
@@ -812,8 +810,19 @@ struct GameObjectTemplate
}
};
+// From `gameobject_template_addon`
+struct GameObjectTemplateAddon
+{
+ uint32 entry;
+ uint32 faction;
+ uint32 flags;
+ uint32 mingold;
+ uint32 maxgold;
+};
+
// Benchmarked: Faster than std::map (insert/find)
typedef std::unordered_map<uint32, GameObjectTemplate> GameObjectTemplateContainer;
+typedef std::unordered_map<uint32, GameObjectTemplateAddon> GameObjectTemplateAddonContainer;
class OPvPCapturePoint;
struct TransportAnimation;
@@ -939,6 +948,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
bool Create(uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit = 0);
void Update(uint32 p_time) override;
GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
+ GameObjectTemplateAddon const* GetTemplateAddon() const { return m_goTemplateAddon; }
GameObjectData const* GetGOData() const { return m_goData; }
GameObjectValue const* GetGOValue() const { return &m_goValue; }
@@ -1158,6 +1168,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
ObjectGuid::LowType m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid
GameObjectTemplate const* m_goInfo;
+ GameObjectTemplateAddon const* m_goTemplateAddon;
GameObjectData const* m_goData;
GameObjectValue m_goValue;