[7552] Move client version dependend DBC code to src/game.

This commit is contained in:
VladimirMangos 2009-03-26 23:35:28 +03:00
parent 02d05a2339
commit c4d4bb5620
35 changed files with 214 additions and 252 deletions

View file

@ -20,7 +20,7 @@
#include "Common.h"
#include "Player.h"
#include "WorldPacket.h"
#include "Database/DBCEnums.h"
#include "DBCEnums.h"
#include "GameEventMgr.h"
#include "ObjectMgr.h"
#include "Guild.h"

View file

@ -20,9 +20,9 @@
#include "Common.h"
#include "Policies/Singleton.h"
#include "Database/DBCEnums.h"
#include "Database/DBCStores.h"
#include "Database/DatabaseEnv.h"
#include "DBCEnums.h"
#include "DBCStores.h"
#include <map>
#include <string>

View file

@ -18,8 +18,8 @@
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Database/DBCStores.h"
#include "Database/SQLStorage.h"
#include "DBCStores.h"
#include "ProgressBar.h"
#include "AccountMgr.h"

View file

@ -17,12 +17,11 @@
*/
#include "DBCStores.h"
//#include "DataStore.h"
#include "Policies/SingletonImp.h"
#include "Log.h"
#include "ProgressBar.h"
#include "DBCfmt.cpp"
#include "DBCfmt.h"
#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)
{
// 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;
if(storage.Load(dbc_filename.c_str()))

View file

@ -16,12 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DBCSTORES_H
#define DBCSTORES_H
#ifndef MANGOS_DBCSTORES_H
#define MANGOS_DBCSTORES_H
#include "Common.h"
//#include "DataStore.h"
#include "dbcfile.h"
#include "Database/DBCStore.h"
#include "DBCStructure.h"
#include <list>
@ -59,77 +58,6 @@ uint32 GetTalentInspectBitPosInTab(uint32 talentId);
uint32 GetTalentTabInspectBitSize(uint32 talentTabId);
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 <AchievementCriteriaEntry> sAchievementCriteriaStore;
extern DBCStorage <AreaTableEntry> sAreaStore;// recommend access using functions

View file

@ -16,8 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DBCSTRUCTURE_H
#define DBCSTRUCTURE_H
#ifndef MANGOS_DBCSTRUCTURE_H
#define MANGOS_DBCSTRUCTURE_H
#include "DBCEnums.h"
#include "Platform/Define.h"

View file

@ -16,6 +16,9 @@
* 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 AchievementCriteriafmt[]="niiiiiiiixxxxxxxxxxxxxxxxxiixix";
const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx";
@ -97,3 +100,5 @@ const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiii
const char WorldMapAreaEntryfmt[]="xinxffffix";
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
#endif

View file

@ -19,7 +19,7 @@
#include "HostilRefManager.h"
#include "ThreatManager.h"
#include "Unit.h"
#include "Database/DBCStructure.h"
#include "DBCStructure.h"
#include "SpellMgr.h"
HostilRefManager::~HostilRefManager()

View file

@ -27,7 +27,7 @@
#include "UpdateMask.h"
#include "Unit.h"
#include "Language.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
void MailItem::deleteItem( bool inDB )
{

View file

@ -97,6 +97,11 @@ libmangosgame_a_SOURCES = \
CreatureAISelector.h \
Creature.cpp \
Creature.h \
DBCEnums.h \
DBCfmt.h \
DBCStores.cpp \
DBCStores.h \
DBCStructure.h \
debugcmds.cpp \
DestinationHolder.cpp \
DestinationHolder.h \

View file

@ -24,7 +24,7 @@
#include "zthread/Lockable.h"
#include "zthread/Mutex.h"
#include "zthread/FairReadWriteLock.h"
#include "Database/DBCStructure.h"
#include "DBCStructure.h"
#include "GridDefines.h"
#include "Cell.h"
#include "Object.h"

View file

@ -20,7 +20,7 @@
#include "Errors.h"
#include "Pet.h"
#include "Player.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "Spell.h"
#include "ObjectAccessor.h"
#include "SpellMgr.h"

View file

@ -17,7 +17,7 @@
*/
#include "ReputationMgr.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "Player.h"
#include "WorldPacket.h"

View file

@ -21,7 +21,7 @@
#include "Common.h"
#include "SharedDefines.h"
#include "Database/DBCStructure.h"
#include "DBCStructure.h"
#include <map>
enum FactionFlags

View file

@ -17,7 +17,7 @@
*/
#include "Common.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "ObjectMgr.h"

View file

@ -20,7 +20,7 @@
#include "ObjectMgr.h"
#include "SpellAuraDefines.h"
#include "ProgressBar.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "World.h"
#include "Chat.h"
#include "Spell.h"

View file

@ -23,7 +23,7 @@
// For more high level function for sSpellStore data
#include "SharedDefines.h"
#include "Database/DBCStructure.h"
#include "DBCStructure.h"
#include "Database/SQLStorage.h"
#include "Utilities/UnorderedMap.h"

View file

@ -19,7 +19,7 @@
#include "TotemAI.h"
#include "Totem.h"
#include "Creature.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "ObjectAccessor.h"
#include "SpellMgr.h"

View file

@ -24,7 +24,7 @@
#include "Path.h"
#include "WorldPacket.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "ProgressBar.h"
void MapManager::LoadTransports()

View file

@ -31,7 +31,7 @@
#include "FollowerRefManager.h"
#include "Utilities/EventProcessor.h"
#include "MotionMaster.h"
#include "Database/DBCStructure.h"
#include "DBCStructure.h"
#include <list>
enum SpellInterruptFlags

View file

@ -40,7 +40,7 @@
#include "ObjectMgr.h"
#include "SpellMgr.h"
#include "Chat.h"
#include "Database/DBCStores.h"
#include "DBCStores.h"
#include "LootMgr.h"
#include "ItemEnchantmentMgr.h"
#include "MapManager.h"

View file

@ -20,15 +20,15 @@
#include <stdlib.h>
#include <string.h>
#include "dbcfile.h"
#include "DBCFileLoader.h"
DBCFile::DBCFile()
DBCFileLoader::DBCFileLoader()
{
data = NULL;
fieldsOffset = NULL;
}
bool DBCFile::Load(const char *filename, const char *fmt)
bool DBCFileLoader::Load(const char *filename, const char *fmt)
{
uint32 header;
@ -89,7 +89,7 @@ bool DBCFile::Load(const char *filename, const char *fmt)
return true;
}
DBCFile::~DBCFile()
DBCFileLoader::~DBCFileLoader()
{
if(data)
delete [] data;
@ -97,13 +97,13 @@ DBCFile::~DBCFile()
delete [] fieldsOffset;
}
DBCFile::Record DBCFile::getRecord(size_t id)
DBCFileLoader::Record DBCFileLoader::getRecord(size_t id)
{
assert(data);
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;
int32 i = -1;
@ -135,7 +135,7 @@ uint32 DBCFile::GetFormatRecordSize(const char * format,int32* index_pos)
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 <=>
@ -218,7 +218,7 @@ char* DBCFile::AutoProduceData(const char* format, uint32& records, char**& inde
return dataTable;
}
char* DBCFile::AutoProduceStrings(const char* format, char* dataTable)
char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable)
{
if(strlen(format)!=fieldCount)
return NULL;

View file

@ -16,8 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DBCFILE_H
#define DBCFILE_H
#ifndef DBC_FILE_LOADER_H
#define DBC_FILE_LOADER_H
#include "Platform/Define.h"
#include "Utilities/ByteConverter.h"
#include <cassert>
@ -35,11 +35,11 @@ enum
FT_LOGIC='l' //Logical (boolean)
};
class DBCFile
class DBCFileLoader
{
public:
DBCFile();
~DBCFile();
DBCFileLoader();
~DBCFileLoader();
bool Load(const char *filename, const char *fmt);
@ -75,11 +75,11 @@ class DBCFile
}
private:
Record(DBCFile &file_, unsigned char *offset_): offset(offset_), file(file_) {}
Record(DBCFileLoader &file_, unsigned char *offset_): offset(offset_), file(file_) {}
unsigned char *offset;
DBCFile &file;
DBCFileLoader &file;
friend class DBCFile;
friend class DBCFileLoader;
};

View 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

View file

@ -23,7 +23,6 @@
#include "Log.h"
#include "Errors.h"
#include "Database/DBCStores.h"
#include "Database/Field.h"
#include "Database/QueryResult.h"

View file

@ -27,10 +27,9 @@ AM_CPPFLAGS = $(MANGOS_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir) -I$(sr
noinst_LIBRARIES = libmangosdatabase.a
libmangosdatabase_a_SOURCES = \
DBCStores.cpp \
DBCStores.h \
DBCStructure.h \
DBCfmt.cpp \
DBCFileLoader.cpp \
DBCFileLoader.h \
DBCStore.h \
Database.cpp \
Database.h \
DatabaseEnv.h \
@ -59,6 +58,4 @@ libmangosdatabase_a_SOURCES = \
SqlDelayThread.cpp \
SqlDelayThread.h \
SqlOperations.cpp \
SqlOperations.h \
dbcfile.cpp \
dbcfile.h
SqlOperations.h

View file

@ -18,7 +18,7 @@
#include "ProgressBar.h"
#include "Log.h"
#include "dbcfile.h"
#include "DBCFileLoader.h"
template<class T>
template<class S, class D>

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7551"
#define REVISION_NR "7552"
#endif // __REVISION_NR_H__

View file

@ -798,6 +798,21 @@
</Filter>
<Filter
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
RelativePath="..\..\src\game\GlobalEvents.cpp">
</File>

View file

@ -198,37 +198,13 @@
<Filter
Name="DataStores">
<File
RelativePath="..\..\src\shared\Database\DBCEnums.h">
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp">
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.cpp">
RelativePath="..\..\src\shared\Database\DBCFileLoader.h">
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.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">
RelativePath="..\..\src\shared\Database\DBCStore.h">
</File>
</Filter>
</Filter>

View file

@ -1238,6 +1238,26 @@
<Filter
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
RelativePath="..\..\src\game\GlobalEvents.cpp"
>

View file

@ -440,63 +440,15 @@
Name="DataStores"
>
<File
RelativePath="..\..\src\shared\Database\DBCEnums.h"
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp"
>
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.cpp"
RelativePath="..\..\src\shared\Database\DBCFileLoader.h"
>
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.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"
RelativePath="..\..\src\shared\Database\DBCStore.h"
>
</File>
</Filter>

View file

@ -1240,6 +1240,26 @@
<Filter
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
RelativePath="..\..\src\game\GlobalEvents.cpp"
>

View file

@ -444,63 +444,15 @@
Name="DataStores"
>
<File
RelativePath="..\..\src\shared\Database\DBCEnums.h"
RelativePath="..\..\src\shared\Database\DBCFileLoader.cpp"
>
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.cpp"
RelativePath="..\..\src\shared\Database\DBCFileLoader.h"
>
</File>
<File
RelativePath="..\..\src\shared\Database\dbcfile.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"
RelativePath="..\..\src\shared\Database\DBCStore.h"
>
</File>
</Filter>