aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp18
-rw-r--r--src/server/game/DataStores/DB2Stores.h2
-rw-r--r--src/server/game/DataStores/DBCStores.cpp39
-rw-r--r--src/server/game/DataStores/DBCStores.h5
-rw-r--r--src/server/game/Maps/TransportMgr.h2
-rw-r--r--src/server/game/World/World.cpp8
6 files changed, 26 insertions, 48 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index 66321a1c6b1..cdc42dfadb6 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -134,7 +134,7 @@ typedef std::list<std::string> DB2StoreProblemList;
uint32 DB2FilesCount = 0;
template<class T>
-inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, DB2Manager::StorageMap& stores, DB2Storage<T>* storage, std::string const& db2_path)
+inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, DB2Manager::StorageMap& stores, DB2Storage<T>* storage, std::string const& db2Path, uint32 defaultLocale)
{
// compatibility format and C++ structure sizes
ASSERT(DB2FileLoader::GetFormatRecordSize(storage->GetFormat()) == sizeof(T),
@@ -143,17 +143,17 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
++DB2FilesCount;
- if (storage->Load(db2_path, uint32(sWorld->GetDefaultDbcLocale())))
+ if (storage->Load(db2Path + localeNames[defaultLocale] + '/', defaultLocale))
{
storage->LoadFromDB();
for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
{
- if (uint32(sWorld->GetDefaultDbcLocale()) == i)
+ if (defaultLocale == i)
continue;
if (availableDb2Locales & (1 << i))
- if (!storage->LoadStringsFrom((db2_path + localeNames[i] + '/'), i))
+ if (!storage->LoadStringsFrom((db2Path + localeNames[i] + '/'), i))
availableDb2Locales &= ~(1 << i); // mark as not available for speedup next checks
storage->LoadStringsFromDB(i);
@@ -162,7 +162,7 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
else
{
// sort problematic db2 to (1) non compatible and (2) nonexistent
- if (FILE* f = fopen((db2_path + storage->GetFileName()).c_str(), "rb"))
+ if (FILE* f = fopen((db2Path + storage->GetFileName()).c_str(), "rb"))
{
std::ostringstream stream;
stream << storage->GetFileName() << " exists, and has " << storage->GetFieldCount() << " field(s) (expected " << strlen(storage->GetFormat())
@@ -178,16 +178,16 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
stores[storage->GetHash()] = storage;
}
-void DB2Manager::LoadStores(std::string const& dataPath)
+void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale)
{
uint32 oldMSTime = getMSTime();
- std::string db2Path = GetDBCLocaleFolder(dataPath);
+ std::string db2Path = dataPath + "dbc/";
DB2StoreProblemList bad_db2_files;
uint32 availableDb2Locales = 0xFF;
-#define LOAD_DB2(store) LoadDB2(availableDb2Locales, bad_db2_files, _stores, &store, db2Path)
+#define LOAD_DB2(store) LoadDB2(availableDb2Locales, bad_db2_files, _stores, &store, db2Path, defaultLocale)
LOAD_DB2(sAreaGroupMemberStore);
LOAD_DB2(sAreaGroupStore);
@@ -501,7 +501,7 @@ void DB2Manager::LoadStores(std::string const& dataPath)
// error checks
if (bad_db2_files.size() >= DB2FilesCount)
{
- TC_LOG_ERROR("misc", "\nIncorrect DataDir value in worldserver.conf or ALL required *.db2 files (%d) not found by path: %sdb2", DB2FilesCount, dataPath.c_str());
+ TC_LOG_ERROR("misc", "\nIncorrect DataDir value in worldserver.conf or ALL required *.db2 files (%d) not found by path: %sdbc/%s/", DB2FilesCount, dataPath.c_str(), localeNames[defaultLocale]);
exit(1);
}
else if (!bad_db2_files.empty())
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 6ccf3933984..44d43a2981b 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -157,7 +157,7 @@ public:
return instance;
}
- void LoadStores(std::string const& dataPath);
+ void LoadStores(std::string const& dataPath, uint32 defaultLocale);
DB2StorageBase const* GetStorage(uint32 type) const;
void LoadHotfixData();
diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp
index 6dc364a412d..f576fc9d3b2 100644
--- a/src/server/game/DataStores/DBCStores.cpp
+++ b/src/server/game/DataStores/DBCStores.cpp
@@ -23,9 +23,7 @@
#include "DBCfmt.h"
#include "Timer.h"
#include "DB2Stores.h"
-#include "Config.h"
-#include <boost/filesystem.hpp>
#include <map>
typedef std::map<uint16, uint32> AreaFlagByAreaID;
@@ -168,7 +166,6 @@ SpellCategoryStore sSpellsByCategoryStore;
PetFamilySpellsStore sPetFamilySpellsStore;
SpellEffectScallingByEffectId sSpellEffectScallingByEffectId;
-
DBCStorage <SpellScalingEntry> sSpellScalingStore(SpellScalingEntryfmt);
DBCStorage <SpellTargetRestrictionsEntry> sSpellTargetRestrictionsStore(SpellTargetRestrictionsEntryfmt);
DBCStorage <SpellLevelsEntry> sSpellLevelsStore(SpellLevelsEntryfmt);
@@ -200,7 +197,7 @@ uint32 DBCFileCount = 0;
uint32 GameTableCount = 0;
template<class T>
-inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCStorage<T>& storage, std::string const& dbcPath, std::string const& filename, std::string const* customFormat = NULL, std::string const* customIndexName = NULL)
+inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCStorage<T>& storage, std::string const& dbcPath, std::string const& filename, uint32 defaultLocale, std::string const* customFormat = NULL, std::string const* customIndexName = NULL)
{
// compatibility format and C++ structure sizes
ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T),
@@ -208,7 +205,7 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt
filename.c_str(), DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), uint32(sizeof(T)));
++DBCFileCount;
- std::string dbcFilename = dbcPath + filename;
+ std::string dbcFilename = dbcPath + localeNames[defaultLocale] + '/' + filename;
SqlDbc * sql = NULL;
if (customFormat)
sql = new SqlDbc(&filename, customFormat, customIndexName, storage.GetFormat());
@@ -300,16 +297,16 @@ inline void LoadGameTable(StoreProblemList& errors, std::string const& tableName
}
}
-void LoadDBCStores(const std::string& dataPath)
+void LoadDBCStores(const std::string& dataPath, uint32 defaultLocale)
{
uint32 oldMSTime = getMSTime();
- std::string dbcPath = GetDBCLocaleFolder(dataPath);
+ std::string dbcPath = dataPath + "dbc/";
StoreProblemList bad_dbc_files;
uint32 availableDbcLocales = 0xFFFFFFFF;
-#define LOAD_DBC(store, file) LoadDBC(availableDbcLocales, bad_dbc_files, store, dbcPath, file)
+#define LOAD_DBC(store, file) LoadDBC(availableDbcLocales, bad_dbc_files, store, dbcPath, file, defaultLocale)
LOAD_DBC(sAchievementStore, "Achievement.dbc"/*, &CustomAchievementfmt, &CustomAchievementIndex*/);//20201
LOAD_DBC(sAnimKitStore, "AnimKit.dbc");//20201
@@ -503,7 +500,7 @@ void LoadDBCStores(const std::string& dataPath)
// error checks
if (bad_dbc_files.size() >= DBCFileCount)
{
- TC_LOG_ERROR("misc", "Incorrect DataDir value in worldserver.conf or ALL required *.dbc files (%d) not found by path: %sdbc", DBCFileCount, dataPath.c_str());
+ TC_LOG_ERROR("misc", "Incorrect DataDir value in worldserver.conf or ALL required *.dbc files (%d) not found by path: %sdbc/%s/", DBCFileCount, dataPath.c_str(), localeNames[defaultLocale]);
exit(1);
}
else if (!bad_dbc_files.empty())
@@ -530,11 +527,11 @@ void LoadDBCStores(const std::string& dataPath)
TC_LOG_INFO("server.loading", ">> Initialized %d DBC data stores in %u ms", DBCFileCount, GetMSTimeDiffToNow(oldMSTime));
}
-void LoadGameTables(const std::string& dataPath)
+void LoadGameTables(const std::string& dataPath, uint32 defaultLocale)
{
uint32 oldMSTime = getMSTime();
- std::string dbcPath = GetDBCLocaleFolder(dataPath);
+ std::string dbcPath = dataPath + "dbc/" + localeNames[defaultLocale] + '/';
StoreProblemList bad_dbc_files;
@@ -566,7 +563,7 @@ void LoadGameTables(const std::string& dataPath)
// error checks
if (bad_dbc_files.size() >= GameTableCount)
{
- TC_LOG_ERROR("misc", "Incorrect DataDir value in worldserver.conf or ALL required *.dbc GameTable files (%d) not found by path: %sdbc", DBCFileCount, dataPath.c_str());
+ TC_LOG_ERROR("misc", "Incorrect DataDir value in worldserver.conf or ALL required *.dbc GameTable files (%d) not found by path: %sdbc/%s/", DBCFileCount, dataPath.c_str(), localeNames[defaultLocale]);
exit(1);
}
else if (!bad_dbc_files.empty())
@@ -920,21 +917,3 @@ SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, u
return NULL;
}
-
-std::string GetDBCLocaleFolder(std::string const& dataPath)
-{
- using namespace boost::filesystem;
-
- const std::string dbcPath = dataPath + "dbc/";
- directory_iterator dir_iter(dbcPath);
- directory_iterator end_iter;
-
- const int locale = sConfigMgr->GetIntDefault("DBC.Locale", LOCALE_enUS);
- for(; dir_iter != end_iter; ++dir_iter)
- if (is_directory(*dir_iter) && GetLocaleByName((*dir_iter).path().filename().string()) == locale)
- // Return the full path appending detected locale folder
- return (*dir_iter).path().string() + "/";
-
- // Empty folder, or it has files but not subfolders (probably the DBC files).
- return dbcPath;
-}
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 041ce4f5013..b394bc9eb33 100644
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -226,8 +226,7 @@ extern DBCStorage <WMOAreaTableEntry> sWMOAreaTableStore;
//extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
-void LoadDBCStores(const std::string& dataPath);
-void LoadGameTables(const std::string& dataPath);
-std::string GetDBCLocaleFolder(std::string const& dataPath);
+void LoadDBCStores(const std::string& dataPath, uint32 defaultLocale);
+void LoadGameTables(const std::string& dataPath, uint32 defaultLocale);
#endif
diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h
index 2df1c9fb0ef..61d08908b78 100644
--- a/src/server/game/Maps/TransportMgr.h
+++ b/src/server/game/Maps/TransportMgr.h
@@ -99,7 +99,7 @@ typedef std::map<uint32, TransportAnimation> TransportAnimationContainer;
class TransportMgr
{
- friend void DB2Manager::LoadStores(std::string const&);
+ friend void DB2Manager::LoadStores(std::string const&, uint32);
public:
static TransportMgr* instance()
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 677c732b4e9..af1d7134663 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -419,7 +419,7 @@ void World::LoadConfigSettings(bool reload)
m_defaultDbcLocale = LocaleConstant(sConfigMgr->GetIntDefault("DBC.Locale", 0));
- if (m_defaultDbcLocale >= TOTAL_LOCALES)
+ if (m_defaultDbcLocale >= TOTAL_LOCALES || m_defaultDbcLocale < LOCALE_enUS)
{
TC_LOG_ERROR("server.loading", "Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", TOTAL_LOCALES);
m_defaultDbcLocale = LOCALE_enUS;
@@ -1459,15 +1459,15 @@ void World::SetInitialWorldSettings()
TC_LOG_INFO("server.loading", "Initialize data stores...");
///- Load DBCs
- LoadDBCStores(m_dataPath);
+ LoadDBCStores(m_dataPath, m_defaultDbcLocale);
///- Load DB2s
- sDB2Manager.LoadStores(m_dataPath);
+ sDB2Manager.LoadStores(m_dataPath, m_defaultDbcLocale);
TC_LOG_INFO("misc", "Loading hotfix info...");
sDB2Manager.LoadHotfixData();
///- Close hotfix database - it is only used during DB2 loading
HotfixDatabase.Close();
///- Load GameTables
- LoadGameTables(m_dataPath);
+ LoadGameTables(m_dataPath, m_defaultDbcLocale);
sSpellMgr->LoadPetFamilySpellsStore();