/** * @brief Initializes the global arguments list and dispatches to an underlying * implementation, if provided. Should be called shortly after program * execution begins. */ void Com_Init(int32_t argc, char *argv[]) { quetoo.argc = argc; quetoo.argv = argv; // options that any Com_* implementation can use for (int32_t i = 1; i < Com_Argc(); i++) { // if we specified debug mode, quickly set it to all here // so that early systems prior to init can write stuff out if (!g_strcmp0(Com_Argv(i), "-debug") || !g_strcmp0(Com_Argv(i), "+debug")) { Com_SetDebug("all"); continue; } if (!g_strcmp0(Com_Argv(i), "-log") || !g_strcmp0(Com_Argv(i), "+log")) { Com_InitLog(); continue; } } if (quetoo.Init) { quetoo.Init(); } }
/** * @brief */ static void Debug_f(void) { if (Cmd_Argc() == 1) { Com_Print("Set or toggle debug categories.\nUsage: debug [category] ..\n"); Com_Print("Categories:\n"); const char *categories[] = { "ai", "cgame", "client", "collision", "console", "filesystem", "game", "net", "pmove_client", "pmove_server", "renderer", "server", "sound", }; Com_Print(" none\n"); for (size_t i = 0; i < lengthof(categories); i++) { int32_t color = CON_COLOR_WHITE; switch (1 << i) { case DEBUG_AI: case DEBUG_GAME: case DEBUG_SERVER: color = CON_COLOR_CYAN; break; case DEBUG_CGAME: case DEBUG_CLIENT: case DEBUG_RENDERER: case DEBUG_SOUND: color = CON_COLOR_MAGENTA; break; case DEBUG_COLLISION: case DEBUG_CONSOLE: case DEBUG_FILESYSTEM: case DEBUG_NET: color = CON_COLOR_YELLOW; break; case DEBUG_PMOVE_CLIENT: case DEBUG_PMOVE_SERVER: color = CON_COLOR_BLUE; break; default: break; } Com_Print(" ^%d%s^7\n", color, categories[i]); } Com_Print(" ^2all^7\n"); Com_Print(" ^1breakpoint^7\n"); return; } Com_SetDebug(Cmd_Args()); Com_Print("Debug mask: %s\n", Com_GetDebug()); }
/** * @brief */ static void Init(void) { SDL_Init(SDL_INIT_TIMER); Mem_Init(); Cmd_Init(); Cvar_Init(); verbose = Cvar_Add("verbose", "0", 0, "Print verbose debugging information"); dedicated = Cvar_Add("dedicated", "0", CVAR_NO_SET, "Run a dedicated server"); if (strstr(Sys_ExecutablePath(), "-dedicated")) { Cvar_ForceSet("dedicated", "1"); } if (dedicated->value) { Cvar_ForceSet("threads", "0"); } game = Cvar_Add("game", DEFAULT_GAME, CVAR_LATCH | CVAR_SERVER_INFO, "The game module name"); game->modified = g_strcmp0(game->string, DEFAULT_GAME); threads = Cvar_Add("threads", "0", CVAR_ARCHIVE, "Specifies the number of threads to create"); threads->modified = false; time_demo = Cvar_Add("time_demo", "0", CVAR_LO_ONLY, "Benchmark and stress test"); time_scale = Cvar_Add("time_scale", "1.0", CVAR_LO_ONLY, "Controls time lapse"); const char *s = va("Quetoo %s %s %s", VERSION, __DATE__, BUILD_HOST); Cvar_Add("version", s, CVAR_SERVER_INFO | CVAR_NO_SET, NULL); quetoo.Debug = Debug; quetoo.Error = Error; quetoo.Print = Print; quetoo.Verbose = Verbose; quetoo.Warn = Warn; Fs_Init(true); Thread_Init(threads->integer); Con_Init(); Cmd_Add("mem_stats", MemStats_f, CMD_SYSTEM, "Print memory stats"); Cmd_Add("debug", Debug_f, CMD_SYSTEM, "Control debugging output"); Cmd_Add("quit", Quit_f, CMD_SYSTEM, "Quit Quetoo"); Netchan_Init(); Sv_Init(); Cl_Init(); Com_Print("Quetoo %s %s %s initialized\n", VERSION, __DATE__, BUILD_HOST); // reset debug value since Cbuf may change it from Com's "all" init Com_SetDebug("0"); // execute any +commands specified on the command line Cbuf_InsertFromDefer(); Cbuf_Execute(); // dedicated server, nothing specified, use Edge if (dedicated->value && !Com_WasInit(QUETOO_SERVER)) { Cbuf_AddText("map edge\n"); Cbuf_Execute(); } }