/* ================= main ================= */ int main(int argc, char **argv) { char commandLine[MAX_STRING_CHARS] = { 0 }; Sys_PlatformInit(); // Set the initial time base Sys_Milliseconds(); #ifdef __APPLE__ // This is passed if we are launched by double-clicking if (argc >= 2 && Q_strncmp(argv[1], "-psn", 4) == 0) { argc = 1; } #endif Sys_ParseArgs(argc, argv); #if defined(__APPLE__) && !defined(DEDICATED) // argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS // But on OS X we want to pretend the binary path is the .app's parent // So that way the base folder is right next to the .app allowing { char parentdir[1024]; CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); if (!url) { Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024)) { Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath"); Sys_Exit(1); } Sys_SetBinaryPath(parentdir); CFRelease(url); CFRelease(url2); } #else Sys_SetBinaryPath(Sys_Dirname(argv[0])); #endif Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default // Concatenate the command line for passing to Com_Init Sys_BuildCommandLine(argc, argv, commandLine, sizeof(commandLine)); Com_Init(commandLine); NET_Init(); Sys_SetUpConsoleAndSignals(); Sys_GameLoop(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char commandLine[MAX_STRING_CHARS] = { 0 }; char cwd[MAX_OSPATH]; // should never get a previous instance in Win32 if (hPrevInstance) { return EXIT_FAILURE; } #ifdef EXCEPTION_HANDLER WinSetExceptionVersion(Q3_VERSION); #endif g_wv.hInstance = hInstance; #if 1 commandLine[0] = '\0'; Sys_ParseArgs(__argc, __argv); Sys_BuildCommandLine(__argc, __argv, commandLine, sizeof(commandLine)); #else Q_strncpyz(commandLine, lpCmdLine, sizeof(commandLine)); #endif #ifndef DEDICATED Sys_SetProcessProperties(); //show the splash screen Sys_Splash(qtrue); #endif #ifdef USE_WINDOWS_CONSOLE // done before Com/Sys_Init since we need this for error output Sys_CreateConsole(); #endif #ifdef DEDICATED Sys_ShowConsoleWindow(1, qtrue); #endif // no abort/retry/fail errors SetErrorMode(SEM_FAILCRITICALERRORS); // get the initial time base Sys_Milliseconds(); Com_Init(commandLine); NET_Init(); Sys_Splash(qfalse); _getcwd(cwd, sizeof(cwd)); Com_Printf("Working directory: %s\n", cwd); // hide the early console since we've reached the point where we // have a working graphics subsystems #ifndef LEGACY_DEBUG if (!com_dedicated->integer && !com_viewlog->integer) { Sys_ShowConsoleWindow(0, qfalse); } #endif // main game loop Sys_GameLoop(); // never gets here return EXIT_SUCCESS; }
/** * @brief SDL_main * @param[in] argc * @param[in] argv * @return */ int main(int argc, char **argv) { char commandLine[MAX_STRING_CHARS] = { 0 }; Sys_PlatformInit(); // Set the initial time base Sys_Milliseconds(); #ifdef __APPLE__ // This is passed if we are launched by double-clicking if (argc >= 2 && Q_strncmp(argv[1], "-psn", 4) == 0) { argc = 1; } #endif Sys_ParseArgs(argc, argv); #if defined(__APPLE__) && !defined(DEDICATED) // argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS // But on OS X we want to pretend the binary path is the .app's parent // So that way the base folder is right next to the .app allowing { char parentdir[1024]; CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); if (!url) { Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath"); Sys_Exit(EXIT_FAILURE); } CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024)) { Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath"); Sys_Exit(EXIT_FAILURE); } Sys_SetBinaryPath(parentdir); CFRelease(url); CFRelease(url2); } #else Sys_SetBinaryPath(Sys_Dirname(argv[0])); #endif Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default // Concatenate the command line for passing to Com_Init Sys_BuildCommandLine(argc, argv, commandLine, sizeof(commandLine)); Com_Init(commandLine); NET_Init(); Sys_SetUpConsoleAndSignals(); #ifdef _WIN32 #ifndef DEDICATED if (com_viewlog->integer) { Sys_ShowConsoleWindow(1, qfalse); } #endif Sys_Splash(qfalse); { char cwd[MAX_OSPATH]; _getcwd(cwd, sizeof(cwd)); Com_Printf("Working directory: %s\n", cwd); } // hide the early console since we've reached the point where we // have a working graphics subsystems #ifndef LEGACY_DEBUG if (!com_dedicated->integer && !com_viewlog->integer) { Sys_ShowConsoleWindow(0, qfalse); } #endif #endif Sys_GameLoop(); return EXIT_SUCCESS; }