Commit 2c9a0eee authored by mercury233's avatar mercury233 Committed by GitHub

update loading expansions (#2361)

parent fb23c232
......@@ -62,7 +62,11 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
cd.race = sqlite3_column_int(pStmt, 8);
cd.attribute = sqlite3_column_int(pStmt, 9);
cd.category = sqlite3_column_int(pStmt, 10);
_datas.insert(std::make_pair(cd.code, cd));
auto it = _datas.find(cd.code);
if(it != _datas.end())
it->second = cd;
else
_datas.insert(std::make_pair(cd.code, cd));
if(const char* text = (const char*)sqlite3_column_text(pStmt, 12)) {
BufferIO::DecodeUTF8(text, strBuffer);
cs.name = strBuffer;
......
......@@ -59,7 +59,6 @@ bool Game::Initialize() {
return false;
}
dataManager.FileSystem = device->getFileSystem();
LoadExpansions();
if(!dataManager.LoadDB(L"cards.cdb")) {
ErrorLog("Failed to load card database (cards.cdb)!");
return false;
......@@ -68,7 +67,7 @@ bool Game::Initialize() {
ErrorLog("Failed to load strings!");
return false;
}
dataManager.LoadStrings("./expansions/strings.conf");
LoadExpansions();
env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
if(!numFont) {
......@@ -1070,14 +1069,17 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth,
}
void Game::LoadExpansions() {
FileSystem::TraversalDir(L"./expansions", [](const wchar_t* name, bool isdir) {
wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name);
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".cdb", 4)) {
wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name);
dataManager.LoadDB(fpath);
}
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".conf", 5)) {
char upath[1024];
BufferIO::EncodeUTF8(fpath, upath);
dataManager.LoadStrings(upath);
}
if(!isdir && wcsrchr(name, '.') && (!mywcsncasecmp(wcsrchr(name, '.'), L".zip", 4) || !mywcsncasecmp(wcsrchr(name, '.'), L".ypk", 4))) {
wchar_t fpath[1024];
myswprintf(fpath, L"./expansions/%ls", name);
#ifdef _WIN32
dataManager.FileSystem->addFileArchive(fpath, true, false, EFAT_ZIP);
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment