Commit 9b6f503d authored by nanahira's avatar nanahira

Merge branch 'develop' into server-develop

parents c8e0b04e cbf0ad54
Pipeline #37753 passed with stages
in 8 minutes and 58 seconds
...@@ -103,12 +103,16 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -103,12 +103,16 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
else else
ret = ReadDB(pDB); ret = ReadDB(pDB);
sqlite3_close(pDB); sqlite3_close(pDB);
return ret;
#else #else
#ifdef _WIN32 #ifdef _WIN32
auto reader = FileSystem->createAndOpenFile(wfile); auto reader = FileSystem->createAndOpenFile(wfile);
#else #else
auto reader = FileSystem->createAndOpenFile(file); auto reader = FileSystem->createAndOpenFile(file);
#endif #endif
return LoadDB(reader);
}
bool DataManager::LoadDB(irr::io::IReadFile* reader) {
if(reader == nullptr) if(reader == nullptr)
return false; return false;
spmemvfs_db_t db; spmemvfs_db_t db;
...@@ -120,14 +124,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -120,14 +124,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
reader->drop(); reader->drop();
(mem->data)[mem->total] = '\0'; (mem->data)[mem->total] = '\0';
bool ret{}; bool ret{};
if (spmemvfs_open_db(&db, file, mem) != SQLITE_OK) if (spmemvfs_open_db(&db, "temp.db", mem) != SQLITE_OK)
ret = Error(db.handle); ret = Error(db.handle);
else else
ret = ReadDB(db.handle); ret = ReadDB(db.handle);
spmemvfs_close_db(&db); spmemvfs_close_db(&db);
spmemvfs_env_fini(); spmemvfs_env_fini();
#endif //YGOPRO_SERVER_MODE
return ret; return ret;
#endif //SERVER_ZIP_SUPPORT
} }
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
bool DataManager::LoadStrings(const char* file) { bool DataManager::LoadStrings(const char* file) {
......
...@@ -45,6 +45,9 @@ public: ...@@ -45,6 +45,9 @@ public:
DataManager(); DataManager();
bool ReadDB(sqlite3* pDB); bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile); bool LoadDB(const wchar_t* wfile);
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
bool LoadDB(irr::io::IReadFile* reader);
#endif
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
bool LoadStrings(const char* file); bool LoadStrings(const char* file);
bool LoadStrings(irr::io::IReadFile* reader); bool LoadStrings(irr::io::IReadFile* reader);
......
...@@ -551,10 +551,7 @@ bool Game::Initialize() { ...@@ -551,10 +551,7 @@ bool Game::Initialize() {
chkLFlist->setChecked(gameConf.use_lflist); chkLFlist->setChecked(gameConf.use_lflist);
cbLFlist = env->addComboBox(irr::core::rect<irr::s32>(posX + 115, posY, posX + 250, posY + 25), tabSystem, COMBOBOX_LFLIST); cbLFlist = env->addComboBox(irr::core::rect<irr::s32>(posX + 115, posY, posX + 250, posY + 25), tabSystem, COMBOBOX_LFLIST);
cbLFlist->setMaxSelectionRows(6); cbLFlist->setMaxSelectionRows(6);
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i) RefreshLFList();
cbLFlist->addItem(deckManager._lfList[i].listName.c_str());
cbLFlist->setEnabled(gameConf.use_lflist);
cbLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbLFlist->getItemCount() - 1);
posY += 30; posY += 30;
chkEnableSound = env->addCheckBox(gameConf.enable_sound, irr::core::rect<irr::s32>(posX, posY, posX + 120, posY + 25), tabSystem, CHECKBOX_ENABLE_SOUND, dataManager.GetSysString(1279)); chkEnableSound = env->addCheckBox(gameConf.enable_sound, irr::core::rect<irr::s32>(posX, posY, posX + 120, posY + 25), tabSystem, CHECKBOX_ENABLE_SOUND, dataManager.GetSysString(1279));
chkEnableSound->setChecked(gameConf.enable_sound); chkEnableSound->setChecked(gameConf.enable_sound);
...@@ -1287,6 +1284,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW ...@@ -1287,6 +1284,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW
} }
#endif //YGOPRO_SERVER_MODE #endif //YGOPRO_SERVER_MODE
void Game::LoadExpansions(const wchar_t* expansions_path) { void Game::LoadExpansions(const wchar_t* expansions_path) {
bool lflist_changed = false;
FileSystem::TraversalDir(expansions_path, [&](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(expansions_path, [&](const wchar_t* name, bool isdir) {
if (isdir) if (isdir)
return; return;
...@@ -1297,9 +1295,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1297,9 +1295,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
return; return;
} }
if (IsExtension(name, L".conf")) { if (IsExtension(name, L".conf")) {
if(!std::wcscmp(name, L"lflist.conf")) if(!std::wcscmp(name, L"lflist.conf")) {
deckManager.LoadLFListSingle(fpath, true); deckManager.LoadLFListSingle(fpath, true);
else { lflist_changed = true;
} else {
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
char upath[1024]; char upath[1024];
BufferIO::EncodeUTF8(fpath, upath); BufferIO::EncodeUTF8(fpath, upath);
...@@ -1323,7 +1322,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1323,7 +1322,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}); });
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE) #if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
for(irr::u32 i = 0; i < DataManager::FileSystem->getFileArchiveCount(); ++i) { for(irr::u32 i = 0; i < DataManager::FileSystem->getFileArchiveCount(); ++i) {
auto archive = DataManager::FileSystem->getFileArchive(i)->getFileList(); auto archiveObj = DataManager::FileSystem->getFileArchive(i);
auto archive = archiveObj->getFileList();
for(irr::u32 j = 0; j < archive->getFileCount(); ++j) { for(irr::u32 j = 0; j < archive->getFileCount(); ++j) {
#ifdef _WIN32 #ifdef _WIN32
const wchar_t* fname = archive->getFullFileName(j).c_str(); const wchar_t* fname = archive->getFullFileName(j).c_str();
...@@ -1332,24 +1332,27 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1332,24 +1332,27 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
const char* uname = archive->getFullFileName(j).c_str(); const char* uname = archive->getFullFileName(j).c_str();
BufferIO::DecodeUTF8(uname, fname); BufferIO::DecodeUTF8(uname, fname);
#endif #endif
auto createReader = [&]() {
#ifdef _WIN32
return archiveObj->createAndOpenFile(fname);
#else
return archiveObj->createAndOpenFile(uname);
#endif
};
if (IsExtension(fname, L".cdb")) { if (IsExtension(fname, L".cdb")) {
dataManager.LoadDB(fname); dataManager.LoadDB(createReader());
continue; continue;
} }
if (IsExtension(fname, L".conf")) { if (IsExtension(fname, L".conf")) {
#ifdef _WIN32 auto reader = createReader();
auto reader = DataManager::FileSystem->createAndOpenFile(fname); if(!std::wcscmp(fname, L"lflist.conf")) {
#else
auto reader = DataManager::FileSystem->createAndOpenFile(uname);
#endif
if(!std::wcscmp(fname, L"lflist.conf"))
deckManager.LoadLFListSingle(reader, true); deckManager.LoadLFListSingle(reader, true);
else lflist_changed = true;
#ifdef YGOPRO_SERVER_MODE } else {
{} #ifndef YGOPRO_SERVER_MODE
#else
dataManager.LoadStrings(reader); dataManager.LoadStrings(reader);
#endif #endif
}
continue; continue;
} }
#ifndef YGOPRO_SERVER_MODE #ifndef YGOPRO_SERVER_MODE
...@@ -1361,6 +1364,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1361,6 +1364,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
} }
} }
#endif //SERVER_ZIP_SUPPORT #endif //SERVER_ZIP_SUPPORT
#ifndef YGOPRO_SERVER_MODE
if(lflist_changed)
RefreshLFList();
#endif
} }
void Game::LoadExpansionsAll() { void Game::LoadExpansionsAll() {
#ifdef SERVER_PRO2_SUPPORT #ifdef SERVER_PRO2_SUPPORT
...@@ -1504,6 +1511,13 @@ void Game::RefreshLocales() { ...@@ -1504,6 +1511,13 @@ void Game::RefreshLocales() {
} }
} }
} }
void Game::RefreshLFList() {
cbLFlist->clear();
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbLFlist->addItem(deckManager._lfList[i].listName.c_str());
cbLFlist->setEnabled(gameConf.use_lflist);
cbLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbLFlist->getItemCount() - 1);
}
void Game::RefreshBot() { void Game::RefreshBot() {
if(!gameConf.enable_bot_mode) if(!gameConf.enable_bot_mode)
return; return;
......
...@@ -217,6 +217,7 @@ public: ...@@ -217,6 +217,7 @@ public:
void RefreshSingleplay(); void RefreshSingleplay();
void RefreshBot(); void RefreshBot();
void RefreshLocales(); void RefreshLocales();
void RefreshLFList();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv); void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color); void DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color);
void DrawBackGround(); void DrawBackGround();
......
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