Commit b2996052 authored by DailyShana's avatar DailyShana

fix and unify

parent f74786b3
......@@ -57,84 +57,83 @@ int main(int argc, char* argv[]) {
return 0;
#ifdef _WIN32
wchar_t** wargv;
int wargc;
LPWSTR commandLine = GetCommandLineW();
wargv = CommandLineToArgvW(commandLine, &wargc);
wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
#else
wchar_t wargv[argc][256];
for(int i = 1; i < argc; ++i) {
int wargc = argc;
wchar_t (*wargv)[256] = new wchar_t[wargc][256];
for(int i = 0; i < argc; ++i) {
BufferIO::DecodeUTF8(argv[i], wargv[i]);
}
#endif //_WIN32
bool keep_on_return = false;
for(int i = 1; i < argc; ++i) {
if(argv[i][0] == '-' && argv[i][1] == 'e' && argv[i][2] != '\0') {
for(int i = 1; i < wargc; ++i) {
if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') {
char param[128];
BufferIO::EncodeUTF8(&wargv[i][2], param);
ygo::dataManager.LoadDB(param);
continue;
}
if(!strcmp(argv[i], "-e")) { // extra database
if(!wcscmp(wargv[i], L"-e")) { // extra database
++i;
if(i < argc) {
if(i < wargc) {
char param[128];
BufferIO::EncodeUTF8(wargv[i], param);
ygo::dataManager.LoadDB(param);
}
continue;
} else if(!strcmp(argv[i], "-n")) { // nickName
} else if(!wcscmp(wargv[i], L"-n")) { // nickName
++i;
if(i < argc)
if(i < wargc)
ygo::mainGame->ebNickName->setText(wargv[i]);
continue;
} else if(!strcmp(argv[i], "-h")) { // Host address
} else if(!wcscmp(wargv[i], L"-h")) { // Host address
++i;
if(i < argc)
if(i < wargc)
ygo::mainGame->ebJoinHost->setText(wargv[i]);
continue;
} else if(!strcmp(argv[i], "-p")) { // host Port
} else if(!wcscmp(wargv[i], L"-p")) { // host Port
++i;
if(i < argc)
if(i < wargc)
ygo::mainGame->ebJoinPort->setText(wargv[i]);
continue;
} else if(!strcmp(argv[i], "-w")) { // host passWord
} else if(!wcscmp(wargv[i], L"-w")) { // host passWord
++i;
if(i < argc)
if(i < wargc)
ygo::mainGame->ebJoinPass->setText(wargv[i]);
continue;
} else if(!strcmp(argv[i], "-k")) { // Keep on return
} else if(!wcscmp(wargv[i], L"-k")) { // Keep on return
exit_on_return = false;
keep_on_return = true;
} else if(!strcmp(argv[i], "-d")) { // Deck
} else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i;
if(i + 1 < argc) { // select deck
if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue;
} else { // open deck
exit_on_return = !keep_on_return;
if(i < argc) {
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
}
ClickButton(ygo::mainGame->btnDeckEdit);
break;
}
} else if(!strcmp(argv[i], "-c")) { // Create host
} else if(!wcscmp(wargv[i], L"-c")) { // Create host
exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnHostConfirm);
break;
} else if(!strcmp(argv[i], "-j")) { // Join host
} else if(!wcscmp(wargv[i], L"-j")) { // Join host
exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(argv[i], "-r")) { // Replay
} else if(!wcscmp(wargv[i], L"-r")) { // Replay
exit_on_return = !keep_on_return;
++i;
if(i < argc) {
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
}
......@@ -142,10 +141,10 @@ int main(int argc, char* argv[]) {
if(open_file)
ClickButton(ygo::mainGame->btnLoadReplay);
break;
} else if(!strcmp(argv[i], "-s")) { // Single
} else if(!wcscmp(wargv[i], L"-s")) { // Single
exit_on_return = !keep_on_return;
++i;
if(i < argc) {
if(i < wargc) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
}
......@@ -153,16 +152,16 @@ int main(int argc, char* argv[]) {
if(open_file)
ClickButton(ygo::mainGame->btnLoadSinglePlay);
break;
} else if(argc == 2 && strlen(argv[1]) >= 4) {
char* pstrext = argv[1] + strlen(argv[1]) - 4;
if(!mystrncasecmp(pstrext, ".ydk", 4)) {
} else if(wargc == 2 && wcslen(wargv[1]) >= 4) {
wchar_t* pstrext = wargv[1] + wcslen(wargv[1]) - 4;
if(!mywcsncasecmp(pstrext, L".ydk", 4)) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnDeckEdit);
break;
}
if(!mystrncasecmp(pstrext, ".yrp", 4)) {
if(!mywcsncasecmp(pstrext, L".yrp", 4)) {
open_file = true;
wcscpy(open_file_name, wargv[i]);
exit_on_return = !keep_on_return;
......@@ -174,6 +173,8 @@ int main(int argc, char* argv[]) {
}
#ifdef _WIN32
LocalFree(wargv);
#else
delete[] wargv;
#endif
ygo::mainGame->MainLoop();
#ifdef _WIN32
......
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