Commit 183e6f5e authored by nanahira's avatar nanahira

ref

parents 710a55c9 3ecfeece
......@@ -93,7 +93,6 @@ extern bool exit_on_return;
extern bool auto_watch_mode;
extern bool open_file;
extern wchar_t open_file_name[256];
extern wchar_t open_file_name_with_category[256];
extern bool bot_mode;
#endif
......@@ -12,7 +12,6 @@ bool exit_on_return = false;
bool auto_watch_mode = false;
bool open_file = false;
wchar_t open_file_name[256] = L"";
wchar_t open_file_name_with_category[256] = L"";
bool bot_mode = false;
void ClickButton(irr::gui::IGUIElement* btn) {
......@@ -131,11 +130,14 @@ int main(int argc, char* argv[]) {
exit_on_return = !keep_on_return;
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
if(deckCategorySpecified && wcslen(ygo::mainGame->gameConf.lastcategory)) {
swprintf(open_file_name_with_category, 256, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, open_file_name);
if(deckCategorySpecified) {
#ifdef WIN32
myswprintf(open_file_name, L"%ls\\%ls", ygo::mainGame->gameConf.lastcategory, wargv[i]);
#else
myswprintf(open_file_name, L"%ls/%ls", ygo::mainGame->gameConf.lastcategory, wargv[i]);
#endif
} else {
wcscpy(open_file_name_with_category, open_file_name);
wcscpy(open_file_name, wargv[i]);
}
}
ClickButton(ygo::mainGame->btnDeckEdit);
......
......@@ -403,14 +403,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case BUTTON_DECK_EDIT: {
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(open_file && deckManager.LoadDeck(open_file_name_with_category)) {
if(open_file && deckManager.LoadDeck(open_file_name)) {
#ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\');
#else
wchar_t *dash = wcsrchr(open_file_name, L'/');
#endif
wchar_t *dot = wcsrchr(open_file_name, L'.');
if(dash && dot) {
if(dash && dot && !mywcsncasecmp(dot, L".ydk", 4)) { // full path
wchar_t deck_name[256];
wcsncpy(deck_name, dash + 1, dot - dash - 1);
deck_name[dot - dash - 1] = L'\0';
......@@ -420,7 +420,17 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnManageDeck->setEnabled(false);
mainGame->cbDBCategory->setEnabled(false);
mainGame->cbDBDecks->setEnabled(false);
} else {
} else if(dash) { // has category
wchar_t deck_name[256];
wcsncpy(deck_name, dash + 1, 256);
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), deck_name)) {
wcscpy(mainGame->gameConf.lastdeck, deck_name);
mainGame->cbDBDecks->setSelected(i);
break;
}
}
} else { // only deck name
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) {
wcscpy(mainGame->gameConf.lastdeck, open_file_name);
......
......@@ -228,7 +228,7 @@ bool Replay::CheckReplay(const wchar_t* name) {
ReplayHeader rheader;
size_t count = fread(&rheader, sizeof(ReplayHeader), 1, rfp);
fclose(rfp);
return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u;
return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0u && (rheader.version < 0x1353u || (rheader.flag & REPLAY_UNIFORM));
}
bool Replay::DeleteReplay(const wchar_t* name) {
wchar_t fname[256];
......
This diff is collapsed.
Subproject commit 76cf3f7441e5cd285da297a70b8d277fc99167f2
Subproject commit 17ad8099eb8821050bea00af3fd74eb0fd90cc39
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