From b3baa7f4bc774756befa0aac634ba7630d2020b7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 9 Jan 2018 22:43:37 +0100 Subject: [PATCH] Build fix --- .../game/DataStores/DB2HotfixGenerator.cpp | 25 ++++--------- .../game/DataStores/DB2HotfixGenerator.h | 36 +++++++++++++++---- src/server/game/DataStores/DB2Stores.h | 6 ++-- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/server/game/DataStores/DB2HotfixGenerator.cpp b/src/server/game/DataStores/DB2HotfixGenerator.cpp index 4d3e18098ef..964b912aeb6 100644 --- a/src/server/game/DataStores/DB2HotfixGenerator.cpp +++ b/src/server/game/DataStores/DB2HotfixGenerator.cpp @@ -19,23 +19,12 @@ #include "DB2Stores.h" #include "Log.h" -template -void DB2HotfixGenerator::ApplyHotfix(uint32 const* begin, uint32 const* end, void(*fixer)(T*), bool notifyClient) +void DB2HotfixGeneratorBase::LogMissingRecord(std::string const& storageName, uint32 recordId) { - while (begin != end) - { - uint32 id = *begin++; - T const* entry = _storage.LookupEntry(id); - if (!entry) - { - TC_LOG_ERROR("db2.hotfix", "Hotfix specified for %s row which does not exist", _storage.GetFileName().c_str(), id); - continue; - } - - fixer(const_cast(entry)); - ++_count; - - if (notifyClient) - sDB2Manager.InsertNewHotfix(_storage.GetTableHash(), id); - } + TC_LOG_ERROR("db2.hotfix", "Hotfix specified for %s row id %u which does not exist", storageName.c_str(), recordId); +} + +void DB2HotfixGeneratorBase::AddClientHotfix(uint32 tableHash, uint32 recordId) +{ + sDB2Manager.InsertNewHotfix(tableHash, recordId); } diff --git a/src/server/game/DataStores/DB2HotfixGenerator.h b/src/server/game/DataStores/DB2HotfixGenerator.h index 06c986bf9b9..d8c32066421 100644 --- a/src/server/game/DataStores/DB2HotfixGenerator.h +++ b/src/server/game/DataStores/DB2HotfixGenerator.h @@ -18,13 +18,18 @@ #ifndef DB2HotfixGenerator_h__ #define DB2HotfixGenerator_h__ -#include "Define.h" +#include "DB2Store.h" +#include + +class TC_GAME_API DB2HotfixGeneratorBase +{ +public: + static void LogMissingRecord(std::string const& storageName, uint32 recordId); + static void AddClientHotfix(uint32 tableHash, uint32 recordId); +}; template -class DB2Storage; - -template -class DB2HotfixGenerator +class DB2HotfixGenerator : private DB2HotfixGeneratorBase { public: explicit DB2HotfixGenerator(DB2Storage& storage) : _storage(storage), _count(0) { } @@ -38,7 +43,26 @@ public: uint32 GetAppliedHotfixesCount() const { return _count; } private: - void ApplyHotfix(uint32 const* begin, uint32 const* end, void(*fixer)(T*), bool notifyClient); + void ApplyHotfix(uint32 const* begin, uint32 const* end, void(*fixer)(T*), bool notifyClient) + { + while (begin != end) + { + uint32 id = *begin++; + T const* entry = _storage.LookupEntry(id); + if (!entry) + { + DB2HotfixGeneratorBase::LogMissingRecord(_storage.GetFileName().c_str(), id); + continue; + } + + fixer(const_cast(entry)); + ++_count; + + if (notifyClient) + DB2HotfixGeneratorBase::AddClientHotfix(_storage.GetTableHash(), id); + } + } + DB2Storage& _storage; uint32 _count; diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 40d2a975660..d0e8112969f 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -32,8 +32,7 @@ #undef GetClassName #endif -template -class DB2HotfixGenerator; +class DB2HotfixGeneratorBase; TC_GAME_API extern DB2Storage sAchievementStore; TC_GAME_API extern DB2Storage sAnimKitStore; @@ -331,8 +330,7 @@ public: static void DeterminaAlternateMapPosition(uint32 mapId, float x, float y, float z, uint32* newMapId = nullptr, DBCPosition2D* newPos = nullptr); private: - template - friend class DB2HotfixGenerator; + friend class DB2HotfixGeneratorBase; void InsertNewHotfix(uint32 tableHash, uint32 recordId); uint32 _maxHotfixId = 0; };