mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7552] Move client version dependend DBC code to src/game.
This commit is contained in:
parent
02d05a2339
commit
c4d4bb5620
35 changed files with 214 additions and 252 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "Database/DBCEnums.h"
|
#include "DBCEnums.h"
|
||||||
#include "GameEventMgr.h"
|
#include "GameEventMgr.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "Guild.h"
|
#include "Guild.h"
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Policies/Singleton.h"
|
#include "Policies/Singleton.h"
|
||||||
#include "Database/DBCEnums.h"
|
|
||||||
#include "Database/DBCStores.h"
|
|
||||||
#include "Database/DatabaseEnv.h"
|
#include "Database/DatabaseEnv.h"
|
||||||
|
#include "DBCEnums.h"
|
||||||
|
#include "DBCStores.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Database/DatabaseEnv.h"
|
#include "Database/DatabaseEnv.h"
|
||||||
#include "Database/DBCStores.h"
|
|
||||||
#include "Database/SQLStorage.h"
|
#include "Database/SQLStorage.h"
|
||||||
|
#include "DBCStores.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
|
||||||
#include "AccountMgr.h"
|
#include "AccountMgr.h"
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DBCStores.h"
|
#include "DBCStores.h"
|
||||||
//#include "DataStore.h"
|
|
||||||
#include "Policies/SingletonImp.h"
|
#include "Policies/SingletonImp.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
|
||||||
#include "DBCfmt.cpp"
|
#include "DBCfmt.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
@ -160,7 +159,7 @@ template<class T>
|
||||||
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, const std::string& dbc_path, const std::string& filename)
|
inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, const std::string& dbc_path, const std::string& filename)
|
||||||
{
|
{
|
||||||
// compatibility format and C++ structure sizes
|
// compatibility format and C++ structure sizes
|
||||||
assert(DBCFile::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFile::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));
|
assert(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));
|
||||||
|
|
||||||
std::string dbc_filename = dbc_path + filename;
|
std::string dbc_filename = dbc_path + filename;
|
||||||
if(storage.Load(dbc_filename.c_str()))
|
if(storage.Load(dbc_filename.c_str()))
|
||||||
|
|
@ -16,12 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DBCSTORES_H
|
#ifndef MANGOS_DBCSTORES_H
|
||||||
#define DBCSTORES_H
|
#define MANGOS_DBCSTORES_H
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
//#include "DataStore.h"
|
#include "Database/DBCStore.h"
|
||||||
#include "dbcfile.h"
|
|
||||||
#include "DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
@ -59,77 +58,6 @@ uint32 GetTalentInspectBitPosInTab(uint32 talentId);
|
||||||
uint32 GetTalentTabInspectBitSize(uint32 talentTabId);
|
uint32 GetTalentTabInspectBitSize(uint32 talentTabId);
|
||||||
uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls);
|
uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls);
|
||||||
|
|
||||||
template<class T>
|
|
||||||
class DBCStorage
|
|
||||||
{
|
|
||||||
typedef std::list<char*> StringPoolList;
|
|
||||||
public:
|
|
||||||
explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { }
|
|
||||||
~DBCStorage() { Clear(); }
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
bool Load(char const* fn)
|
|
||||||
{
|
|
||||||
DBCFile dbc;
|
|
||||||
// Check if load was sucessful, only then continue
|
|
||||||
if(!dbc.Load(fn, fmt))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
fieldCount = dbc.GetCols();
|
|
||||||
m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable);
|
|
||||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
|
||||||
|
|
||||||
// error in dbc file at loading if NULL
|
|
||||||
return indexTable!=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LoadStringsFrom(char const* fn)
|
|
||||||
{
|
|
||||||
// DBC must be already loaded using Load
|
|
||||||
if(!indexTable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
DBCFile dbc;
|
|
||||||
// Check if load was successful, only then continue
|
|
||||||
if(!dbc.Load(fn, fmt))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear()
|
|
||||||
{
|
|
||||||
if (!indexTable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
delete[] ((char*)indexTable);
|
|
||||||
indexTable = NULL;
|
|
||||||
delete[] ((char*)m_dataTable);
|
|
||||||
m_dataTable = NULL;
|
|
||||||
|
|
||||||
while(!m_stringPoolList.empty())
|
|
||||||
{
|
|
||||||
delete[] m_stringPoolList.front();
|
|
||||||
m_stringPoolList.pop_front();
|
|
||||||
}
|
|
||||||
nCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32 nCount;
|
|
||||||
uint32 fieldCount;
|
|
||||||
char const* fmt;
|
|
||||||
T** indexTable;
|
|
||||||
T* m_dataTable;
|
|
||||||
StringPoolList m_stringPoolList;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern DBCStorage <AchievementEntry> sAchievementStore;
|
extern DBCStorage <AchievementEntry> sAchievementStore;
|
||||||
extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore;
|
extern DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore;
|
||||||
extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions
|
extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DBCSTRUCTURE_H
|
#ifndef MANGOS_DBCSTRUCTURE_H
|
||||||
#define DBCSTRUCTURE_H
|
#define MANGOS_DBCSTRUCTURE_H
|
||||||
|
|
||||||
#include "DBCEnums.h"
|
#include "DBCEnums.h"
|
||||||
#include "Platform/Define.h"
|
#include "Platform/Define.h"
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef MANGOS_DBCSFRM_H
|
||||||
|
#define MANGOS_DBCSFRM_H
|
||||||
|
|
||||||
const char Achievementfmt[]="niixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxxi";
|
const char Achievementfmt[]="niixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxxi";
|
||||||
const char AchievementCriteriafmt[]="niiiiiiiixxxxxxxxxxxxxxxxxiixix";
|
const char AchievementCriteriafmt[]="niiiiiiiixxxxxxxxxxxxxxxxxiixix";
|
||||||
const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx";
|
const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx";
|
||||||
|
|
@ -97,3 +100,5 @@ const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiii
|
||||||
const char WorldMapAreaEntryfmt[]="xinxffffix";
|
const char WorldMapAreaEntryfmt[]="xinxffffix";
|
||||||
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
|
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
|
||||||
const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
|
const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "HostilRefManager.h"
|
#include "HostilRefManager.h"
|
||||||
#include "ThreatManager.h"
|
#include "ThreatManager.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "Database/DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
|
|
||||||
HostilRefManager::~HostilRefManager()
|
HostilRefManager::~HostilRefManager()
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "UpdateMask.h"
|
#include "UpdateMask.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
|
|
||||||
void MailItem::deleteItem( bool inDB )
|
void MailItem::deleteItem( bool inDB )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,11 @@ libmangosgame_a_SOURCES = \
|
||||||
CreatureAISelector.h \
|
CreatureAISelector.h \
|
||||||
Creature.cpp \
|
Creature.cpp \
|
||||||
Creature.h \
|
Creature.h \
|
||||||
|
DBCEnums.h \
|
||||||
|
DBCfmt.h \
|
||||||
|
DBCStores.cpp \
|
||||||
|
DBCStores.h \
|
||||||
|
DBCStructure.h \
|
||||||
debugcmds.cpp \
|
debugcmds.cpp \
|
||||||
DestinationHolder.cpp \
|
DestinationHolder.cpp \
|
||||||
DestinationHolder.h \
|
DestinationHolder.h \
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "zthread/Lockable.h"
|
#include "zthread/Lockable.h"
|
||||||
#include "zthread/Mutex.h"
|
#include "zthread/Mutex.h"
|
||||||
#include "zthread/FairReadWriteLock.h"
|
#include "zthread/FairReadWriteLock.h"
|
||||||
#include "Database/DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include "GridDefines.h"
|
#include "GridDefines.h"
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Pet.h"
|
#include "Pet.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "Spell.h"
|
#include "Spell.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ReputationMgr.h"
|
#include "ReputationMgr.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
#include "Database/DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
enum FactionFlags
|
enum FactionFlags
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "SpellAuraDefines.h"
|
#include "SpellAuraDefines.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Spell.h"
|
#include "Spell.h"
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
// For more high level function for sSpellStore data
|
// For more high level function for sSpellStore data
|
||||||
|
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
#include "Database/DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include "Database/SQLStorage.h"
|
#include "Database/SQLStorage.h"
|
||||||
|
|
||||||
#include "Utilities/UnorderedMap.h"
|
#include "Utilities/UnorderedMap.h"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#include "TotemAI.h"
|
#include "TotemAI.h"
|
||||||
#include "Totem.h"
|
#include "Totem.h"
|
||||||
#include "Creature.h"
|
#include "Creature.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "Path.h"
|
#include "Path.h"
|
||||||
|
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
|
||||||
void MapManager::LoadTransports()
|
void MapManager::LoadTransports()
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
#include "FollowerRefManager.h"
|
#include "FollowerRefManager.h"
|
||||||
#include "Utilities/EventProcessor.h"
|
#include "Utilities/EventProcessor.h"
|
||||||
#include "MotionMaster.h"
|
#include "MotionMaster.h"
|
||||||
#include "Database/DBCStructure.h"
|
#include "DBCStructure.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
enum SpellInterruptFlags
|
enum SpellInterruptFlags
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Database/DBCStores.h"
|
#include "DBCStores.h"
|
||||||
#include "LootMgr.h"
|
#include "LootMgr.h"
|
||||||
#include "ItemEnchantmentMgr.h"
|
#include "ItemEnchantmentMgr.h"
|
||||||
#include "MapManager.h"
|
#include "MapManager.h"
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,15 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "dbcfile.h"
|
#include "DBCFileLoader.h"
|
||||||
|
|
||||||
DBCFile::DBCFile()
|
DBCFileLoader::DBCFileLoader()
|
||||||
{
|
{
|
||||||
data = NULL;
|
data = NULL;
|
||||||
fieldsOffset = NULL;
|
fieldsOffset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DBCFile::Load(const char *filename, const char *fmt)
|
bool DBCFileLoader::Load(const char *filename, const char *fmt)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32 header;
|
uint32 header;
|
||||||
|
|
@ -89,7 +89,7 @@ bool DBCFile::Load(const char *filename, const char *fmt)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBCFile::~DBCFile()
|
DBCFileLoader::~DBCFileLoader()
|
||||||
{
|
{
|
||||||
if(data)
|
if(data)
|
||||||
delete [] data;
|
delete [] data;
|
||||||
|
|
@ -97,13 +97,13 @@ DBCFile::~DBCFile()
|
||||||
delete [] fieldsOffset;
|
delete [] fieldsOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBCFile::Record DBCFile::getRecord(size_t id)
|
DBCFileLoader::Record DBCFileLoader::getRecord(size_t id)
|
||||||
{
|
{
|
||||||
assert(data);
|
assert(data);
|
||||||
return Record(*this, data + id*recordSize);
|
return Record(*this, data + id*recordSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 DBCFile::GetFormatRecordSize(const char * format,int32* index_pos)
|
uint32 DBCFileLoader::GetFormatRecordSize(const char * format,int32* index_pos)
|
||||||
{
|
{
|
||||||
uint32 recordsize = 0;
|
uint32 recordsize = 0;
|
||||||
int32 i = -1;
|
int32 i = -1;
|
||||||
|
|
@ -135,7 +135,7 @@ uint32 DBCFile::GetFormatRecordSize(const char * format,int32* index_pos)
|
||||||
return recordsize;
|
return recordsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* DBCFile::AutoProduceData(const char* format, uint32& records, char**& indexTable)
|
char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**& indexTable)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
format STRING, NA, FLOAT,NA,INT <=>
|
format STRING, NA, FLOAT,NA,INT <=>
|
||||||
|
|
@ -218,7 +218,7 @@ char* DBCFile::AutoProduceData(const char* format, uint32& records, char**& inde
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* DBCFile::AutoProduceStrings(const char* format, char* dataTable)
|
char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable)
|
||||||
{
|
{
|
||||||
if(strlen(format)!=fieldCount)
|
if(strlen(format)!=fieldCount)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DBCFILE_H
|
#ifndef DBC_FILE_LOADER_H
|
||||||
#define DBCFILE_H
|
#define DBC_FILE_LOADER_H
|
||||||
#include "Platform/Define.h"
|
#include "Platform/Define.h"
|
||||||
#include "Utilities/ByteConverter.h"
|
#include "Utilities/ByteConverter.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
@ -35,11 +35,11 @@ enum
|
||||||
FT_LOGIC='l' //Logical (boolean)
|
FT_LOGIC='l' //Logical (boolean)
|
||||||
};
|
};
|
||||||
|
|
||||||
class DBCFile
|
class DBCFileLoader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DBCFile();
|
DBCFileLoader();
|
||||||
~DBCFile();
|
~DBCFileLoader();
|
||||||
|
|
||||||
bool Load(const char *filename, const char *fmt);
|
bool Load(const char *filename, const char *fmt);
|
||||||
|
|
||||||
|
|
@ -75,11 +75,11 @@ class DBCFile
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Record(DBCFile &file_, unsigned char *offset_): offset(offset_), file(file_) {}
|
Record(DBCFileLoader &file_, unsigned char *offset_): offset(offset_), file(file_) {}
|
||||||
unsigned char *offset;
|
unsigned char *offset;
|
||||||
DBCFile &file;
|
DBCFileLoader &file;
|
||||||
|
|
||||||
friend class DBCFile;
|
friend class DBCFileLoader;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
94
src/shared/Database/DBCStore.h
Normal file
94
src/shared/Database/DBCStore.h
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DBCSTORE_H
|
||||||
|
#define DBCSTORE_H
|
||||||
|
|
||||||
|
#include "DBCFileLoader.h"
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class DBCStorage
|
||||||
|
{
|
||||||
|
typedef std::list<char*> StringPoolList;
|
||||||
|
public:
|
||||||
|
explicit DBCStorage(const char *f) : nCount(0), fieldCount(0), fmt(f), indexTable(NULL), m_dataTable(NULL) { }
|
||||||
|
~DBCStorage() { Clear(); }
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
|
bool Load(char const* fn)
|
||||||
|
{
|
||||||
|
DBCFileLoader dbc;
|
||||||
|
// Check if load was sucessful, only then continue
|
||||||
|
if(!dbc.Load(fn, fmt))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fieldCount = dbc.GetCols();
|
||||||
|
m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable);
|
||||||
|
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
||||||
|
|
||||||
|
// error in dbc file at loading if NULL
|
||||||
|
return indexTable!=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadStringsFrom(char const* fn)
|
||||||
|
{
|
||||||
|
// DBC must be already loaded using Load
|
||||||
|
if(!indexTable)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DBCFileLoader dbc;
|
||||||
|
// Check if load was successful, only then continue
|
||||||
|
if(!dbc.Load(fn, fmt))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
if (!indexTable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
delete[] ((char*)indexTable);
|
||||||
|
indexTable = NULL;
|
||||||
|
delete[] ((char*)m_dataTable);
|
||||||
|
m_dataTable = NULL;
|
||||||
|
|
||||||
|
while(!m_stringPoolList.empty())
|
||||||
|
{
|
||||||
|
delete[] m_stringPoolList.front();
|
||||||
|
m_stringPoolList.pop_front();
|
||||||
|
}
|
||||||
|
nCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 nCount;
|
||||||
|
uint32 fieldCount;
|
||||||
|
char const* fmt;
|
||||||
|
T** indexTable;
|
||||||
|
T* m_dataTable;
|
||||||
|
StringPoolList m_stringPoolList;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
|
|
||||||
#include "Database/DBCStores.h"
|
|
||||||
#include "Database/Field.h"
|
#include "Database/Field.h"
|
||||||
#include "Database/QueryResult.h"
|
#include "Database/QueryResult.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,9 @@ AM_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(sr
|
||||||
noinst_LIBRARIES = libmangosdatabase.a
|
noinst_LIBRARIES = libmangosdatabase.a
|
||||||
|
|
||||||
libmangosdatabase_a_SOURCES = \
|
libmangosdatabase_a_SOURCES = \
|
||||||
DBCStores.cpp \
|
DBCFileLoader.cpp \
|
||||||
DBCStores.h \
|
DBCFileLoader.h \
|
||||||
DBCStructure.h \
|
DBCStore.h \
|
||||||
DBCfmt.cpp \
|
|
||||||
Database.cpp \
|
Database.cpp \
|
||||||
Database.h \
|
Database.h \
|
||||||
DatabaseEnv.h \
|
DatabaseEnv.h \
|
||||||
|
|
@ -59,6 +58,4 @@ libmangosdatabase_a_SOURCES = \
|
||||||
SqlDelayThread.cpp \
|
SqlDelayThread.cpp \
|
||||||
SqlDelayThread.h \
|
SqlDelayThread.h \
|
||||||
SqlOperations.cpp \
|
SqlOperations.cpp \
|
||||||
SqlOperations.h \
|
SqlOperations.h
|
||||||
dbcfile.cpp \
|
|
||||||
dbcfile.h
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "dbcfile.h"
|
#include "DBCFileLoader.h"
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
template<class S, class D>
|
template<class S, class D>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7551"
|
#define REVISION_NR "7552"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
|
|
@ -798,6 +798,21 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Server">
|
Name="Server">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCEnums.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCfmt.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStructure.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\game\GlobalEvents.cpp">
|
RelativePath="..\..\src\game\GlobalEvents.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
||||||
|
|
@ -198,37 +198,13 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="DataStores">
|
Name="DataStores">
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\DBCEnums.h">
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.cpp">
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.h">
|
RelativePath="..\..\src\shared\Database\DBCStore.h">
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCfmt.cpp">
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32">
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.cpp">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStructure.h">
|
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
|
||||||
|
|
@ -1238,6 +1238,26 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Server"
|
Name="Server"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCEnums.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCfmt.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStructure.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\game\GlobalEvents.cpp"
|
RelativePath="..\..\src\game\GlobalEvents.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -440,63 +440,15 @@
|
||||||
Name="DataStores"
|
Name="DataStores"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\DBCEnums.h"
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.cpp"
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.h"
|
RelativePath="..\..\src\shared\Database\DBCStore.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCfmt.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|x64"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|x64"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStructure.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
|
||||||
|
|
@ -1240,6 +1240,26 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Server"
|
Name="Server"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCEnums.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCfmt.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStores.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\src\game\DBCStructure.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\game\GlobalEvents.cpp"
|
RelativePath="..\..\src\game\GlobalEvents.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -444,63 +444,15 @@
|
||||||
Name="DataStores"
|
Name="DataStores"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\DBCEnums.h"
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.cpp"
|
RelativePath="..\..\src\shared\Database\DBCFileLoader.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\shared\Database\dbcfile.h"
|
RelativePath="..\..\src\shared\Database\DBCStore.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCfmt.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|x64"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|x64"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
ObjectFile="$(IntDir)/$(InputName)1.obj"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStores.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\src\shared\Database\DBCStructure.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue