Commit d3bea35f authored by nanahira's avatar nanahira

Merge branch 'master' into server

parents a3d4c6c1 0ca05198
Pipeline #5517 passed with stages
in 2 minutes and 40 seconds
...@@ -97,6 +97,7 @@ extern bool exit_on_return; ...@@ -97,6 +97,7 @@ extern bool exit_on_return;
extern bool auto_watch_mode; extern bool auto_watch_mode;
extern bool open_file; extern bool open_file;
extern wchar_t open_file_name[256]; extern wchar_t open_file_name[256];
extern wchar_t open_file_name_with_category[256];
extern bool bot_mode; extern bool bot_mode;
#endif #endif
...@@ -13,6 +13,7 @@ bool exit_on_return = false; ...@@ -13,6 +13,7 @@ bool exit_on_return = false;
bool auto_watch_mode = false; bool auto_watch_mode = false;
bool open_file = false; bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
wchar_t open_file_name_with_category[256] = L"";
bool bot_mode = false; bool bot_mode = false;
void ClickButton(irr::gui::IGUIElement* btn) { void ClickButton(irr::gui::IGUIElement* btn) {
...@@ -144,6 +145,7 @@ int main(int argc, char* argv[]) { ...@@ -144,6 +145,7 @@ int main(int argc, char* argv[]) {
#endif //_WIN32 #endif //_WIN32
bool keep_on_return = false; bool keep_on_return = false;
bool deckCategorySpecified = false;
for(int i = 1; i < wargc; ++i) { for(int i = 1; i < wargc; ++i) {
if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') { if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') {
ygo::dataManager.LoadDB(&wargv[i][2]); ygo::dataManager.LoadDB(&wargv[i][2]);
...@@ -180,9 +182,16 @@ int main(int argc, char* argv[]) { ...@@ -180,9 +182,16 @@ int main(int argc, char* argv[]) {
keep_on_return = true; keep_on_return = true;
} else if(!wcscmp(wargv[i], L"--auto-watch")) { // Auto watch mode } else if(!wcscmp(wargv[i], L"--auto-watch")) { // Auto watch mode
auto_watch_mode = true; auto_watch_mode = true;
} else if(!wcscmp(wargv[i], L"--deck-category")) {
++i;
if(i < wargc) {
deckCategorySpecified = true;
wcscpy(ygo::mainGame->gameConf.lastcategory, wargv[i]);
}
} else if(!wcscmp(wargv[i], L"-d")) { // Deck } else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i; ++i;
ygo::mainGame->gameConf.lastcategory[0] = 0; if(!deckCategorySpecified)
ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]); wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue; continue;
...@@ -191,6 +200,11 @@ int main(int argc, char* argv[]) { ...@@ -191,6 +200,11 @@ int main(int argc, char* argv[]) {
if(i < wargc) { if(i < wargc) {
open_file = true; open_file = true;
wcscpy(open_file_name, wargv[i]); wcscpy(open_file_name, wargv[i]);
if(deckCategorySpecified) {
swprintf(open_file_name_with_category, 256, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, open_file_name);
} else {
wcscpy(open_file_name_with_category, open_file_name);
}
} }
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
break; break;
......
...@@ -313,7 +313,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -313,7 +313,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int extra = replay.ReadInt32(); int extra = replay.ReadInt32();
for(int j = 0; j < extra; ++j) for(int j = 0; j < extra; ++j)
tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32())); tmp_deck.extra.push_back(dataManager.GetCodePointer(replay.ReadInt32()));
myswprintf(filename, L"./deck/%ls %ls.ydk", ex_filename, namebuf[i]); FileSystem::SafeFileName(namebuf[i]);
myswprintf(filename, L"deck/%ls-%d %ls.ydk", ex_filename, i + 1, namebuf[i]);
deckManager.SaveDeck(tmp_deck, filename); deckManager.SaveDeck(tmp_deck, filename);
} }
mainGame->stACMessage->setText(dataManager.GetSysString(1335)); mainGame->stACMessage->setText(dataManager.GetSysString(1335));
...@@ -402,7 +403,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -402,7 +403,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_DECK_EDIT: { case BUTTON_DECK_EDIT: {
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(open_file && deckManager.LoadDeck(open_file_name)) { if(open_file && deckManager.LoadDeck(open_file_name_with_category)) {
#ifdef WIN32 #ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\'); wchar_t *dash = wcsrchr(open_file_name, L'\\');
#else #else
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
class FileSystem { class FileSystem {
public: public:
static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"<>:\"/\\|?*")) != NULL)
*wfile++ = '_';
}
static bool IsFileExists(const wchar_t* wfile) { static bool IsFileExists(const wchar_t* wfile) {
DWORD attr = GetFileAttributesW(wfile); DWORD attr = GetFileAttributesW(wfile);
return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY); return attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY);
...@@ -112,6 +117,11 @@ public: ...@@ -112,6 +117,11 @@ public:
class FileSystem { class FileSystem {
public: public:
static void SafeFileName(wchar_t* wfile) {
while((wfile = wcspbrk(wfile, L"/")) != NULL)
*wfile++ = '_';
}
static bool IsFileExists(const char* file) { static bool IsFileExists(const char* file) {
struct stat fileStat; struct stat fileStat;
return (stat(file, &fileStat) == 0) && !S_ISDIR(fileStat.st_mode); return (stat(file, &fileStat) == 0) && !S_ISDIR(fileStat.st_mode);
......
Subproject commit ffaa1d435ea6175f3ec055db3dbc14c3de9cf38b Subproject commit 3b8c69d81b0969e5df2853cb75b8985e4a65780f
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