diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2016-08-28 20:09:44 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2016-08-28 20:15:24 -0300 |
| commit | bd4bf0a73fa29701835176ce757e2fb498b39cdc (patch) | |
| tree | a3a0329aed5cb96e0003c783ca6e1b9a3fe4d3de /src/server/game/Entities | |
| parent | 8727048af67f6e416f82b4c8498d9c072069371f (diff) | |
Core/GameObject: migrated non-WDB fields to new gameobject_template_addon table
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 24 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 16 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 3 | ||||
| -rw-r--r-- | src/server/game/Entities/Transport/Transport.cpp | 9 |
4 files changed, 38 insertions, 14 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 6e538b935bf..d60ffaf1efe 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -235,8 +235,11 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u SetObjectScale(goinfo->size); - SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); - SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); + if (GameObjectTemplateAddon const* addon = GetTemplateAddon()) + { + SetUInt32Value(GAMEOBJECT_FACTION, addon->faction); + SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags); + } SetEntry(goinfo->entry); @@ -627,8 +630,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(); @@ -649,7 +653,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) @@ -676,6 +681,11 @@ void GameObject::Update(uint32 diff) sScriptMgr->OnGameObjectUpdate(this, diff); } +GameObjectTemplateAddon const* GameObject::GetTemplateAddon() const +{ + return sObjectMgr->GetGameObjectTemplateAddon(GetGOInfo()->entry); +} + void GameObject::Refresh() { // Do not refresh despawned GO from spellcast (GO's from spellcast are destroyed after despawn) @@ -700,7 +710,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 6e2d50120f8..1270d8f231a 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -43,10 +43,6 @@ struct GameObjectTemplate std::string IconName; std::string castBarCaption; std::string unk1; - uint32 mingold; - uint32 maxgold; - uint32 faction; - uint32 flags; float size; union // different GO types have different data field { @@ -564,8 +560,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; @@ -680,6 +687,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, Position const& pos, G3D::Quat const& rotation, 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; GameObjectData const* GetGOData() const { return m_goData; } GameObjectValue const* GetGOValue() const { return &m_goValue; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 9d750f1b6ac..0c75630ee51 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -8383,7 +8383,8 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) group->UpdateLooterGuid(go); } - loot->generateMoneyLoot(go->GetGOInfo()->mingold, go->GetGOInfo()->maxgold); + if (GameObjectTemplateAddon const* addon = go->GetTemplateAddon()) + loot->generateMoneyLoot(addon->mingold, addon->maxgold); if (loot_type == LOOT_FISHING) go->getFishLoot(loot, this); diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp index 0d97e120fff..991f1d06723 100644 --- a/src/server/game/Entities/Transport/Transport.cpp +++ b/src/server/game/Entities/Transport/Transport.cpp @@ -57,7 +57,6 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, Object::_Create(guidlow, 0, HighGuid::Mo_Transport); GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry); - if (!goinfo) { TC_LOG_ERROR("sql.sql", "Transport not created: entry in `gameobject_template` not found, guidlow: %u map: %u (X: %f Y: %f Z: %f) ang: %f", guidlow, mapid, x, y, z, ang); @@ -81,10 +80,14 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, _triggeredArrivalEvent = false; _triggeredDepartureEvent = false; + if (GameObjectTemplateAddon const* addon = GetTemplateAddon()) + { + SetFaction(addon->faction); + SetUInt32Value(GAMEOBJECT_FLAGS, addon->flags); + } + m_goValue.Transport.PathProgress = 0; SetObjectScale(goinfo->size); - SetFaction(goinfo->faction); - SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); SetPeriod(tInfo->pathTime); SetEntry(goinfo->entry); SetDisplayId(goinfo->displayId); |
