From d8cb2cdffb30c0654abbab5cd46c5b6098cf147a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 31 Mar 2013 18:22:27 -0700 Subject: [PATCH] Handle args on Windows in NativeInit() too. Now it's like everyone else, plus it works again. Bonus. Fixes #1134. --- UI/NativeApp.cpp | 4 ++-- Windows/EmuThread.cpp | 2 +- Windows/main.cpp | 47 +------------------------------------------ 3 files changed, 4 insertions(+), 49 deletions(-) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 909048b73..b8ffdba18 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -201,6 +201,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co config_filename = user_data_path + "/ppsspp.ini"; g_Config.Load(config_filename.c_str()); +#endif const char *fileToLog = 0; const char *stateToLoad = 0; @@ -252,6 +253,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co if (fileToLog != NULL) LogManager::GetInstance()->ChangeFileLog(fileToLog); +#ifndef _WIN32 if (g_Config.currentDirectory == "") { #if defined(ANDROID) g_Config.currentDirectory = external_directory; @@ -261,7 +263,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co g_Config.currentDirectory = getenv("HOME"); #endif } -#endif #if defined(ANDROID) // Maybe there should be an option to use internal memory instead, but I think @@ -283,7 +284,6 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co g_Config.flashDirectory = g_Config.memCardDirectory+"/flash/"; #endif -#ifndef _WIN32 for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index a3d958db0..f10fab8b9 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -55,7 +55,7 @@ DWORD TheThread(LPVOID x) { Host *oldHost = host; UpdateScreenScale(); - NativeInit(0, 0, memstick.c_str(), memstick.c_str(), "1234"); + NativeInit(__argc, (const char **)__argv, memstick.c_str(), memstick.c_str(), "1234"); Host *nativeHost = host; host = oldHost; diff --git a/Windows/main.cpp b/Windows/main.cpp index de49c4adb..945bd0fe1 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -58,9 +58,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin { Common::EnableCrashingOnCrashes(); - const char *fileToStart = NULL; - const char *fileToLog = NULL; - const char *stateToLoad = NULL; bool hideLog = true; #ifdef _DEBUG @@ -71,6 +68,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); + // The rest is handled in NativeInit(). for (int i = 1; i < __argc; ++i) { if (__argv[i][0] == '\0') @@ -80,14 +78,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin { switch (__argv[i][1]) { - case 'j': - g_Config.bJit = true; - g_Config.bSaveSettings = false; - break; - case 'i': - g_Config.bJit = false; - g_Config.bSaveSettings = false; - break; case 'l': hideLog = false; break; @@ -95,32 +85,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin g_Config.bAutoRun = false; g_Config.bSaveSettings = false; break; - case '-': - if (!strcmp(__argv[i], "--log") && i < __argc - 1) - fileToLog = __argv[++i]; - if (!strncmp(__argv[i], "--log=", strlen("--log=")) && strlen(__argv[i]) > strlen("--log=")) - fileToLog = __argv[i] + strlen("--log="); - if (!strcmp(__argv[i], "--state") && i < __argc - 1) - stateToLoad = __argv[++i]; - if (!strncmp(__argv[i], "--state=", strlen("--state=")) && strlen(__argv[i]) > strlen("--state=")) - stateToLoad = __argv[i] + strlen("--state="); - break; } } - else if (fileToStart == NULL) - { - fileToStart = __argv[i]; - if (!File::Exists(fileToStart)) - { - fprintf(stderr, "File not found: %s\n", fileToStart); - exit(1); - } - } - else - { - fprintf(stderr, "Can only boot one file"); - exit(1); - } } //Windows, API init stuff @@ -152,16 +118,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin MainWindow::UpdateMenus(); LogManager::Init(); - if (fileToLog != NULL) - LogManager::GetInstance()->ChangeFileLog(fileToLog); LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); - if (fileToStart != NULL) - { - MainWindow::SetPlaying(fileToStart); - MainWindow::Update(); - MainWindow::UpdateMenus(); - } // Emu thread is always running! EmuThread_Start(); @@ -172,9 +130,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin if (!hideLog) SetForegroundWindow(hwndMain); - if (fileToStart != NULL && stateToLoad != NULL) - SaveState::Load(stateToLoad); - //so.. we're at the message pump of the GUI thread MSG msg; while (GetMessage(&msg, NULL, 0, 0)) //while no quit