aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2013-03-15 21:19:15 +0100
committerShauren <shauren.trinity@gmail.com>2013-03-15 21:19:15 +0100
commitdcdd9447fd9e07a9601134880356a3d53e43f919 (patch)
treebdcae5d19633c8e9ecf9f0a6ca34a48f9a8acbd0 /src
parente58e05d9d5da894447b81ded17c3b8fd9f4820a8 (diff)
Core/PacketIO: Allow playing all ingame movies
Closes #9434
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp23
-rw-r--r--src/server/game/DataStores/DB2Stores.h22
-rw-r--r--src/server/game/DataStores/DB2Structure.h8
-rw-r--r--src/server/game/DataStores/DB2fmt.h9
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp37
-rw-r--r--src/server/game/Globals/ObjectMgr.h7
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp17
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp46
-rw-r--r--src/server/game/Server/WorldSession.h1
-rw-r--r--src/server/game/World/World.cpp3
-rw-r--r--src/server/shared/DataStores/DB2Store.h59
11 files changed, 167 insertions, 65 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index dadcce42950..f4570a1c17e 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -16,23 +16,21 @@
*/
#include "DB2Stores.h"
-#include "Log.h"
-#include "SharedDefines.h"
-#include "SpellMgr.h"
#include "DB2fmt.h"
+#include "Common.h"
+#include "Log.h"
-#include <map>
-
-DB2Storage <ItemEntry> sItemStore(Itemfmt);
-DB2Storage <ItemCurrencyCostEntry> sItemCurrencyCostStore(ItemCurrencyCostfmt);
-DB2Storage <ItemExtendedCostEntry> sItemExtendedCostStore(ItemExtendedCostEntryfmt);
-DB2Storage <ItemSparseEntry> sItemSparseStore (ItemSparsefmt);
+DB2Storage<ItemEntry> sItemStore(Itemfmt);
+DB2Storage<ItemCurrencyCostEntry> sItemCurrencyCostStore(ItemCurrencyCostfmt);
+DB2Storage<ItemExtendedCostEntry> sItemExtendedCostStore(ItemExtendedCostEntryfmt);
+DB2Storage<ItemSparseEntry> sItemSparseStore(ItemSparsefmt);
+DB2Storage<KeyChainEntry> sKeyChainStore(KeyChainfmt);
typedef std::list<std::string> StoreProblemList1;
uint32 DB2FilesCount = 0;
-static bool LoadDB2_assert_print(uint32 fsize, uint32 rsize, const std::string& filename)
+static bool LoadDB2_assert_print(uint32 fsize, uint32 rsize, std::string const& filename)
{
sLog->outError(LOG_FILTER_GENERAL, "Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).", filename.c_str(), fsize, rsize);
@@ -51,7 +49,7 @@ struct LocalDB2Data
};
template<class T>
-inline void LoadDB2(StoreProblemList1& errlist, DB2Storage<T>& storage, const std::string& db2_path, const std::string& filename)
+inline void LoadDB2(StoreProblemList1& errlist, DB2Storage<T>& storage, std::string const& db2_path, std::string const& filename)
{
// compatibility format and C++ structure sizes
ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDB2_assert_print(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename));
@@ -74,7 +72,7 @@ inline void LoadDB2(StoreProblemList1& errlist, DB2Storage<T>& storage, const st
}
}
-void LoadDB2Stores(const std::string& dataPath)
+void LoadDB2Stores(std::string const& dataPath)
{
std::string db2Path = dataPath + "dbc/";
@@ -84,6 +82,7 @@ void LoadDB2Stores(const std::string& dataPath)
LoadDB2(bad_db2_files, sItemCurrencyCostStore, db2Path, "ItemCurrencyCost.db2");
LoadDB2(bad_db2_files, sItemSparseStore, db2Path, "Item-sparse.db2");
LoadDB2(bad_db2_files, sItemExtendedCostStore, db2Path, "ItemExtendedCost.db2");
+ LoadDB2(bad_db2_files, sKeyChainStore, db2Path, "KeyChain.db2");
// error checks
if (bad_db2_files.size() >= DB2FilesCount)
{
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 6cf719da70b..f57da14419c 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -18,17 +18,25 @@
#ifndef TRINITY_DB2STORES_H
#define TRINITY_DB2STORES_H
-#include "Common.h"
#include "DB2Store.h"
#include "DB2Structure.h"
+#include <string>
-#include <list>
+enum DB2Hash
+{
+ DB2_HASH_ITEM = 0x50238EC2,
+ DB2_HASH_ITEM_CURRENCY_COST = 0x6FE05AE9,
+ DB2_HASH_ITEM_EXTENDED_COST = 0xBB858355,
+ DB2_HASH_ITEM_SPARSE = 0x919BE54E,
+ DB2_HASH_KEYCHAIN = 0x6D8A2694,
+};
-extern DB2Storage <ItemEntry> sItemStore;
-extern DB2Storage <ItemCurrencyCostEntry> sItemCurrencyCostStore;
-extern DB2Storage <ItemExtendedCostEntry> sItemExtendedCostStore;
-extern DB2Storage <ItemSparseEntry> sItemSparseStore;
+extern DB2Storage<ItemEntry> sItemStore;
+extern DB2Storage<ItemCurrencyCostEntry> sItemCurrencyCostStore;
+extern DB2Storage<ItemExtendedCostEntry> sItemExtendedCostStore;
+extern DB2Storage<ItemSparseEntry> sItemSparseStore;
+extern DB2Storage<KeyChainEntry> sKeyChainStore;
-void LoadDB2Stores(const std::string& dataPath);
+void LoadDB2Stores(std::string const& dataPath);
#endif \ No newline at end of file
diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h
index a65136d7ccb..45b611180f4 100644
--- a/src/server/game/DataStores/DB2Structure.h
+++ b/src/server/game/DataStores/DB2Structure.h
@@ -148,6 +148,14 @@ struct ItemExtendedCostEntry
//uint32 Unknown[5]; // 26-30
};
+#define KEYCHAIN_SIZE 32
+
+struct KeyChainEntry
+{
+ uint32 Id;
+ uint8 Key[KEYCHAIN_SIZE];
+};
+
// GCC has alternative #pragma pack(N) syntax and old gcc version does not support pack(push, N), also any gcc version does not support it at some platform
#if defined(__GNUC__)
#pragma pack()
diff --git a/src/server/game/DataStores/DB2fmt.h b/src/server/game/DataStores/DB2fmt.h
index 3cc3a9b7693..e4b6801f36c 100644
--- a/src/server/game/DataStores/DB2fmt.h
+++ b/src/server/game/DataStores/DB2fmt.h
@@ -18,9 +18,10 @@
#ifndef TRINITY_DB2SFRM_H
#define TRINITY_DB2SFRM_H
-const char Itemfmt[]="niiiiiii";
-const char ItemCurrencyCostfmt[]="xn";
-const char ItemSparsefmt[]="niiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisssssiiiiiiiiiiiiiiiiiiiiiifiiifii";
-const char ItemExtendedCostEntryfmt[]="nxxiiiiiiiiiiiixiiiiiiiiiixxxxx";
+char const Itemfmt[]="niiiiiii";
+char const ItemCurrencyCostfmt[]="xn";
+char const ItemSparsefmt[]="niiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisssssiiiiiiiiiiiiiiiiiiiiiifiiifii";
+char const ItemExtendedCostEntryfmt[]="nxxiiiiiiiiiiiixiiiiiiiiiixxxxx";
+char const KeyChainfmt[]="nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
#endif
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 3b0cb8b736d..dfb84c23113 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -8737,7 +8737,7 @@ void ObjectMgr::LoadHotfixData()
HotfixInfo info;
info.Entry = fields[0].GetUInt32();
- info.Type = fields[1].GetUInt32();
+ info.Type = DB2Hash(fields[1].GetUInt32());
info.Timestamp = fields[2].GetUInt64();
_hotfixData.push_back(info);
@@ -8748,6 +8748,41 @@ void ObjectMgr::LoadHotfixData()
sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u hotfix info entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
+void ObjectMgr::LoadMissingKeyChains()
+{
+ uint32 oldMSTime = getMSTime();
+
+ QueryResult result = WorldDatabase.Query("SELECT keyId, k1, k2, k3, k4, k5, k6, k7, k8, "
+ "k9, k10, k11, k12, k13, k14, k15, k16, "
+ "k17, k18, k19, k20, k21, k22, k23, k24, "
+ "k25, k26, k27, k28, k29, k30, k31, k32 "
+ "FROM keychain_db2 ORDER BY keyId DESC");
+
+ if (!result)
+ {
+ sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 KeyChain entries. DB table `keychain_db2` is empty.");
+ return;
+ }
+
+ uint32 count = 0;
+
+ do
+ {
+ Field* fields = result->Fetch();
+ uint32 id = fields[0].GetUInt32();;
+
+ KeyChainEntry* kce = sKeyChainStore.CreateEntry(id, true);
+ kce->Id = id;
+ for (uint32 i = 0; i < KEYCHAIN_SIZE; ++i)
+ kce->Key[i] = fields[1 + i].GetUInt8();
+
+ ++count;
+ }
+ while (result->NextRow());
+
+ sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u KeyChain entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+}
+
void ObjectMgr::LoadFactionChangeSpells()
{
uint32 oldMSTime = getMSTime();
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 50d9baf292a..9987df7591f 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -43,6 +43,7 @@
#include "ConditionMgr.h"
#include <functional>
#include "PhaseMgr.h"
+#include "DB2Stores.h"
class Item;
class PhaseMgr;
@@ -640,7 +641,7 @@ typedef UNORDERED_MAP<uint32, DungeonEncounterList> DungeonEncounterContainer;
struct HotfixInfo
{
- uint32 Type;
+ DB2Hash Type;
uint32 Timestamp;
uint32 Entry;
};
@@ -1228,7 +1229,7 @@ class ObjectMgr
void LoadHotfixData();
HotfixData const& GetHotfixData() const { return _hotfixData; }
- time_t GetHotfixDate(uint32 entry, uint32 type) const
+ time_t GetHotfixDate(uint32 entry, DB2Hash type) const
{
time_t ret = 0;
for (HotfixData::const_iterator itr = _hotfixData.begin(); itr != _hotfixData.end(); ++itr)
@@ -1239,6 +1240,8 @@ class ObjectMgr
return ret ? ret : time(NULL);
}
+ void LoadMissingKeyChains();
+
private:
// first free id for selected id type
uint32 _auctionId;
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index 373c0d2a5e6..29af6fdc8f4 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -27,6 +27,7 @@
#include "UpdateData.h"
#include "ObjectAccessor.h"
#include "SpellInfo.h"
+#include "DB2Stores.h"
#include <vector>
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
@@ -284,16 +285,16 @@ void WorldSession::SendItemDb2Reply(uint32 entry)
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(entry);
if (!proto)
{
- data << uint32(-1); // entry
- data << uint32(DB2_REPLY_ITEM);
+ data << -int32(entry); // entry
+ data << uint32(DB2_HASH_ITEM);
data << uint32(time(NULL)); // hotfix date
data << uint32(0); // size of next block
return;
}
data << uint32(entry);
- data << uint32(DB2_REPLY_ITEM);
- data << uint32(sObjectMgr->GetHotfixDate(entry, DB2_REPLY_ITEM));
+ data << uint32(DB2_HASH_ITEM);
+ data << uint32(sObjectMgr->GetHotfixDate(entry, DB2_HASH_ITEM));
ByteBuffer buff;
buff << uint32(entry);
@@ -317,16 +318,16 @@ void WorldSession::SendItemSparseDb2Reply(uint32 entry)
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(entry);
if (!proto)
{
- data << uint32(-1); // entry
- data << uint32(DB2_REPLY_SPARSE);
+ data << -int32(entry); // entry
+ data << uint32(DB2_HASH_ITEM_SPARSE);
data << uint32(time(NULL)); // hotfix date
data << uint32(0); // size of next block
return;
}
data << uint32(entry);
- data << uint32(DB2_REPLY_SPARSE);
- data << uint32(sObjectMgr->GetHotfixDate(entry, DB2_REPLY_SPARSE));
+ data << uint32(DB2_HASH_ITEM_SPARSE);
+ data << uint32(sObjectMgr->GetHotfixDate(entry, DB2_HASH_ITEM_SPARSE));
ByteBuffer buff;
buff << uint32(entry);
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 94ef34e8dd7..a0a721c8971 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -55,6 +55,7 @@
#include "BattlegroundMgr.h"
#include "Battlefield.h"
#include "BattlefieldMgr.h"
+#include "DB2Stores.h"
void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData)
{
@@ -1894,22 +1895,61 @@ void WorldSession::HandleRequestHotfix(WorldPacket& recvPacket)
switch (type)
{
- case DB2_REPLY_ITEM:
+ case DB2_HASH_ITEM:
SendItemDb2Reply(entry);
break;
- case DB2_REPLY_SPARSE:
+ case DB2_HASH_ITEM_SPARSE:
SendItemSparseDb2Reply(entry);
break;
+ case DB2_HASH_KEYCHAIN:
+ SendKeyChainDb2Reply(entry);
+ break;
default:
- sLog->outError(LOG_FILTER_NETWORKIO, "CMSG_REQUEST_HOTFIX: Received unknown hotfix type: %u", type);
+ {
+ WorldPacket data(SMSG_DB_REPLY, 4 * 4);
+ data << -int32(entry);
+ data << uint32(type);
+ data << uint32(time(NULL));
+ data << uint32(0);
+ SendPacket(&data);
+
+ sLog->outError(LOG_FILTER_NETWORKIO, "CMSG_REQUEST_HOTFIX: Received unknown hotfix type: %u, entry %u", type, entry);
recvPacket.rfinish();
break;
+ }
}
}
delete[] guids;
}
+void WorldSession::SendKeyChainDb2Reply(uint32 entry)
+{
+ WorldPacket data(SMSG_DB_REPLY, 44);
+ KeyChainEntry const* keyChain = sKeyChainStore.LookupEntry(entry);
+ if (!keyChain)
+ {
+ data << -int32(entry); // entry
+ data << uint32(DB2_HASH_KEYCHAIN);
+ data << uint32(time(NULL)); // hotfix date
+ data << uint32(0); // size of next block
+ return;
+ }
+
+ data << uint32(entry);
+ data << uint32(DB2_HASH_KEYCHAIN);
+ data << uint32(sObjectMgr->GetHotfixDate(entry, DB2_HASH_KEYCHAIN));
+
+ ByteBuffer buff;
+ buff << uint32(entry);
+ buff.append(keyChain->Key, KEYCHAIN_SIZE);
+
+ data << uint32(buff.size());
+ data.append(buff);
+
+ SendPacket(&data);
+}
+
void WorldSession::HandleUpdateMissileTrajectory(WorldPacket& recvPacket)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_UPDATE_MISSILE_TRAJECTORY");
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index c4a918c227a..9680ac0d5e5 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -647,6 +647,7 @@ class WorldSession
void HandleAutoEquipItemOpcode(WorldPacket& recvPacket);
void SendItemDb2Reply(uint32 entry);
void SendItemSparseDb2Reply(uint32 entry);
+ void SendKeyChainDb2Reply(uint32 entry);
void HandleSellItemOpcode(WorldPacket& recvPacket);
void HandleBuyItemInSlotOpcode(WorldPacket& recvPacket);
void HandleBuyItemOpcode(WorldPacket& recvPacket);
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 018c5bc932a..c5d47dae56f 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1842,6 +1842,9 @@ void World::SetInitialWorldSettings()
sLog->outInfo(LOG_FILTER_GENERAL, "Loading hotfix info...");
sObjectMgr->LoadHotfixData();
+ sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Loading missing KeyChains...");
+ sObjectMgr->LoadMissingKeyChains();
+
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
sLog->outInfo(LOG_FILTER_WORLDSERVER, "World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000));
diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h
index 6ebca714fe6..c8f51bc96cb 100644
--- a/src/server/shared/DataStores/DB2Store.h
+++ b/src/server/shared/DataStores/DB2Store.h
@@ -34,37 +34,39 @@ class DB2Storage
typedef std::list<char*> StringPoolList;
typedef std::vector<T*> DataTableEx;
public:
- explicit DB2Storage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { }
+ explicit DB2Storage(char const* f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { }
~DB2Storage() { Clear(); }
- T const* LookupEntry(uint32 id) const { return (id>=nCount)?NULL:indexTable[id]; }
- uint32 GetNumRows() const { return nCount; }
+ T const* LookupEntry(uint32 id) const { return (id >= nCount) ? NULL : indexTable[id]; }
+ uint32 GetNumRows() const { return nCount; }
char const* GetFormat() const { return fmt; }
uint32 GetFieldCount() const { return fieldCount; }
- /// Copies the provided entry and stores it.
- void AddEntry(uint32 id, const T* entry)
+ /// Copies the provided entry and stores it.
+ T* CreateEntry(uint32 id, bool evenIfExists = false)
+ {
+ if (evenIfExists && LookupEntry(id))
+ return NULL;
+
+ if (id >= nCount)
{
- if (LookupEntry(id))
- return;
-
- if (id >= nCount)
- {
- // reallocate index table
- char** tmpIdxTable = new char*[id+1];
- memset(tmpIdxTable, 0, (id+1) * sizeof(char*));
- memcpy(tmpIdxTable, (char*)indexTable, nCount * sizeof(char*));
- delete[] ((char*)indexTable);
- nCount = id + 1;
- indexTable = (T**)tmpIdxTable;
- }
-
- T* entryDst = new T;
- memcpy((char*)entryDst, (char*)entry, sizeof(T));
- m_dataTableEx.push_back(entryDst);
- indexTable[id] = entryDst;
+ // reallocate index table
+ char** tmpIdxTable = new char*[id + 1];
+ memset(tmpIdxTable, 0, (id + 1) * sizeof(char*));
+ memcpy(tmpIdxTable, (char*)indexTable, nCount * sizeof(char*));
+ delete[] ((char*)indexTable);
+ nCount = id + 1;
+ indexTable = (T**)tmpIdxTable;
}
+ T* entryDst = new T;
+ m_dataTableEx.push_back(entryDst);
+ indexTable[id] = entryDst;
+ return entryDst;
+ }
+
+ void EraseEntry(uint32 id) { indexTable[id] = NULL; }
+
bool Load(char const* fn)
{
DB2FileLoader db2;
@@ -111,22 +113,23 @@ public:
delete[] ((char*)indexTable);
indexTable = NULL;
+
delete[] ((char*)m_dataTable);
m_dataTable = NULL;
- for (typename DataTableEx::const_iterator itr = m_dataTableEx.begin(); itr != m_dataTableEx.end(); ++itr)
- delete *itr;
- m_dataTableEx.clear();
+
+ for (typename DataTableEx::iterator itr = m_dataTableEx.begin(); itr != m_dataTableEx.end(); ++itr)
+ delete *itr;
+ m_dataTableEx.clear();
while (!m_stringPoolList.empty())
{
delete[] m_stringPoolList.front();
m_stringPoolList.pop_front();
}
+
nCount = 0;
}
- void EraseEntry(uint32 id) { indexTable[id] = NULL; }
-
private:
uint32 nCount;
uint32 fieldCount;