Build fix

This commit is contained in:
Shauren
2018-01-09 22:43:37 +01:00
parent 208ae9e69f
commit b3baa7f4bc
3 changed files with 39 additions and 28 deletions

View File

@@ -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;
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);
}

View File

@@ -18,13 +18,18 @@
#ifndef DB2HotfixGenerator_h__
#define DB2HotfixGenerator_h__
#include "Define.h"
#include "DB2Store.h"
#include <initializer_list>
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 DB2Storage;
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;

View File

@@ -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;
};