diff options
| author | xinef1 <w.szyszko2@gmail.com> | 2017-02-20 20:27:08 +0100 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-02-20 16:27:08 -0300 |
| commit | ae9d01a3245c59a8a8d50516a79b79250337450d (patch) | |
| tree | d8cb2e521d7e15c130d21aad9d2225ba82b7998d /src/server/game/Entities/GameObject | |
| parent | 4eae29d421e1d7a28aaa50d401cbbf09c50bd476 (diff) | |
Store cached static data queries, instead of building them in every query opcode (#18637)
- Added config option to enable / disable cache
- Reinitialize data on reload command use
- Always send WDB fields in item query
Diffstat (limited to 'src/server/game/Entities/GameObject')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 50 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 5 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 3ef54a6187c..2fc2d44666b 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -33,6 +33,56 @@ #include "World.h" #include "Transport.h" +void GameObjectTemplate::InitializeQueryData() +{ + WorldPacket queryTemp; + for (uint8 loc = LOCALE_enUS; loc < TOTAL_LOCALES; ++loc) + { + queryTemp = BuildQueryData(static_cast<LocaleConstant>(loc)); + QueryData[loc] = queryTemp; + } +} + +WorldPacket GameObjectTemplate::BuildQueryData(LocaleConstant loc) const +{ + WorldPacket queryTemp(SMSG_GAMEOBJECT_QUERY_RESPONSE, 200); + + std::string locName = name; + std::string locIconName = IconName; + std::string locCastBarCaption = castBarCaption; + + if (GameObjectLocale const* gameObjectLocale = sObjectMgr->GetGameObjectLocale(entry)) + { + ObjectMgr::GetLocaleString(gameObjectLocale->Name, loc, locName); + ObjectMgr::GetLocaleString(gameObjectLocale->CastBarCaption, loc, locCastBarCaption); + } + + queryTemp << uint32(entry); + queryTemp << uint32(type); + queryTemp << uint32(displayId); + queryTemp << locName; + queryTemp << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 + queryTemp << locIconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword) + queryTemp << locCastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting") + queryTemp << unk1; // 2.0.3, string + queryTemp.append(raw.data, MAX_GAMEOBJECT_DATA); + queryTemp << float(size); // go size + + GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(entry); + if (items) + { + for (size_t i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) + queryTemp << (i < items->size() ? uint32((*items)[i]) : uint32(0)); + } + else + { + for (size_t i = 0; i < MAX_GAMEOBJECT_QUEST_ITEMS; ++i) + queryTemp << uint32(0); + } + + return queryTemp; +} + GameObject::GameObject() : WorldObject(false), MapObject(), m_model(nullptr), m_goValue(), m_AI(nullptr) { diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 549b51cbab6..b9160f3cc11 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -25,6 +25,7 @@ #include "Object.h" #include "LootMgr.h" #include "DatabaseEnv.h" +#include "WorldPacket.h" #include <G3D/Quat.h> class GameObjectAI; @@ -423,6 +424,7 @@ struct GameObjectTemplate std::string AIName; uint32 ScriptId; + WorldPacket QueryData[TOTAL_LOCALES]; // helpers bool IsDespawnAtAction() const @@ -559,6 +561,9 @@ struct GameObjectTemplate default: return 0; } } + + void InitializeQueryData(); + WorldPacket BuildQueryData(LocaleConstant loc) const; }; // From `gameobject_template_addon` |
