diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/game/DataStores/DB2HotfixGenerator.cpp | 23 | ||||
| -rw-r--r-- | src/server/game/DataStores/DB2HotfixGenerator.h | 34 | ||||
| -rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 6 | 
3 files changed, 37 insertions, 26 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<class T> -void DB2HotfixGenerator<T>::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<T*>(entry)); -        ++_count; +    TC_LOG_ERROR("db2.hotfix", "Hotfix specified for %s row id %u which does not exist", storageName.c_str(), recordId); +} -        if (notifyClient) -            sDB2Manager.InsertNewHotfix(_storage.GetTableHash(), id); -    } +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 <initializer_list> -template<class T> -class DB2Storage; +class TC_GAME_API DB2HotfixGeneratorBase +{ +public: +    static void LogMissingRecord(std::string const& storageName, uint32 recordId); +    static void AddClientHotfix(uint32 tableHash, uint32 recordId); +};  template<class T> -class DB2HotfixGenerator +class DB2HotfixGenerator : private DB2HotfixGeneratorBase  {  public:      explicit DB2HotfixGenerator(DB2Storage<T>& 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<T*>(entry)); +            ++_count; + +            if (notifyClient) +                DB2HotfixGeneratorBase::AddClientHotfix(_storage.GetTableHash(), id); +        } +    } +      DB2Storage<T>& _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<typename T> -class DB2HotfixGenerator; +class DB2HotfixGeneratorBase;  TC_GAME_API extern DB2Storage<AchievementEntry>                     sAchievementStore;  TC_GAME_API extern DB2Storage<AnimKitEntry>                         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<typename T> -    friend class DB2HotfixGenerator; +    friend class DB2HotfixGeneratorBase;      void InsertNewHotfix(uint32 tableHash, uint32 recordId);      uint32 _maxHotfixId = 0;  };  | 
