void TEST_Init (void) { Com_SetExceptionCallback(Test_InitError); com_aliasSysPool = Mem_CreatePool("Common: Alias system"); com_cmdSysPool = Mem_CreatePool("Common: Command system"); com_cmodelSysPool = Mem_CreatePool("Common: Collision model"); com_cvarSysPool = Mem_CreatePool("Common: Cvar system"); com_fileSysPool = Mem_CreatePool("Common: File system"); com_genericPool = Mem_CreatePool("Generic"); Mem_Init(); Cbuf_Init(); Cmd_Init(); Cvar_Init(); FS_InitFilesystem(qtrue); FS_AddGameDirectory("./unittest", qfalse); Swap_Init(); SV_Init(); NET_Init(); FS_ExecAutoexec(); OBJZERO(csi); Com_SetExceptionCallback(Test_RunError); http_timeout = Cvar_Get("noname", "", 0, NULL); http_proxy = Cvar_Get("noname", "", 0, NULL); }
/* ============ Cvar_GetLatchedVars Any variables with latched values will now be updated ============ */ void Cvar_GetLatchedVars (void) { cvar_t *var; for (var = cvar_vars ; var ; var = var->next) { if (!var->latched_string) continue; Z_Free (var->string); var->string = var->latched_string; var->latched_string = NULL; var->value = atof(var->string); if (!strcmp(var->name, "game")) { FS_SetGame(var->string); FS_ExecAutoexec (); } } }
void CL_Init(void) { if (dedicated->value) { return; /* nothing running on the client */ } /* all archived variables will now be loaded */ Con_Init(); S_Init(); SCR_Init(); VID_Init(); IN_Init(); V_Init(); net_message.data = net_message_buffer; net_message.maxsize = sizeof(net_message_buffer); M_Init(); cls.disable_screen = true; /* don't draw yet */ #ifdef CDA CDAudio_Init(); #endif CL_InitLocal(); FS_ExecAutoexec(); Cbuf_Execute(); Key_ReadConsoleHistory(); }
void CLQ2_Init() { cls.realtime = Sys_Milliseconds(); // // register our variables // clq2_footsteps = Cvar_Get( "cl_footsteps", "1", 0 ); clq2_noskins = Cvar_Get( "cl_noskins", "0", 0 ); clq2_predict = Cvar_Get( "cl_predict", "1", 0 ); clq2_showmiss = Cvar_Get( "clq2_showmiss", "0", 0 ); clq2_vwep = Cvar_Get( "cl_vwep", "1", CVAR_ARCHIVE ); cl_paused = Cvar_Get( "paused", "0", CVAR_CHEAT ); cl_timeout = Cvar_Get( "cl_timeout", "120", 0 ); clq2_maxfps = Cvar_Get( "cl_maxfps", "90", 0 ); Cvar_Get( "adr0", "", CVAR_ARCHIVE ); Cvar_Get( "adr1", "", CVAR_ARCHIVE ); Cvar_Get( "adr2", "", CVAR_ARCHIVE ); Cvar_Get( "adr3", "", CVAR_ARCHIVE ); Cvar_Get( "adr4", "", CVAR_ARCHIVE ); Cvar_Get( "adr5", "", CVAR_ARCHIVE ); Cvar_Get( "adr6", "", CVAR_ARCHIVE ); Cvar_Get( "adr7", "", CVAR_ARCHIVE ); Cvar_Get( "adr8", "", CVAR_ARCHIVE ); // // userinfo // Cvar_Get( "password", "", CVAR_USERINFO ); Cvar_Get( "spectator", "0", CVAR_USERINFO ); clq2_name = Cvar_Get( "name", "unnamed", CVAR_USERINFO | CVAR_ARCHIVE ); clq2_skin = Cvar_Get( "skin", "male/grunt", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get( "rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE ); // FIXME Cvar_Get( "msg", "1", CVAR_USERINFO | CVAR_ARCHIVE ); q2_hand = Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get( "fov", "90", CVAR_USERINFO | CVAR_ARCHIVE ); clq2_gender = Cvar_Get( "gender", "male", CVAR_USERINFO | CVAR_ARCHIVE ); clq2_gender_auto = Cvar_Get( "gender_auto", "1", CVAR_ARCHIVE ); clq2_gender->modified = false; // clear this so we know when user sets it manually // // register our commands // Cmd_AddCommand( "pingservers", CLQ2_PingServers_f ); Cmd_AddCommand( "record", CLQ2_Record_f ); Cmd_AddCommand( "stop", CLQ2_Stop_f ); Cmd_AddCommand( "connect", CLQ2_Connect_f ); Cmd_AddCommand( "reconnect", CLQ2_Reconnect_f ); Cmd_AddCommand( "pause", CLQ2_Pause_f ); Cmd_AddCommand( "changing", CLQ2_Changing_f ); Cmd_AddCommand( "skins", CLQ2_Skins_f ); Cmd_AddCommand( "userinfo", CLQ2_Userinfo_f ); Cmd_AddCommand( "precache", CLQ2_Precache_f ); Cmd_AddCommand( "download", CLQ2_Download_f ); Cmd_AddCommand( "snd_restart", CLQ2_Snd_Restart_f ); Cmd_AddCommand( "vid_restart", VID_Restart_f ); // // forward to server commands // // the only thing this does is allow command completion // to work -- all unknown commands are automatically // forwarded to the server Cmd_AddCommand( "wave", NULL ); Cmd_AddCommand( "inven", NULL ); Cmd_AddCommand( "kill", NULL ); Cmd_AddCommand( "use", NULL ); Cmd_AddCommand( "drop", NULL ); Cmd_AddCommand( "say", NULL ); Cmd_AddCommand( "say_team", NULL ); Cmd_AddCommand( "info", NULL ); Cmd_AddCommand( "prog", NULL ); Cmd_AddCommand( "give", NULL ); Cmd_AddCommand( "god", NULL ); Cmd_AddCommand( "notarget", NULL ); Cmd_AddCommand( "noclip", NULL ); Cmd_AddCommand( "invuse", NULL ); Cmd_AddCommand( "invprev", NULL ); Cmd_AddCommand( "invnext", NULL ); Cmd_AddCommand( "invdrop", NULL ); Cmd_AddCommand( "weapnext", NULL ); Cmd_AddCommand( "weapprev", NULL ); cls.disable_screen = true; // don't draw yet FS_ExecAutoexec(); Cbuf_Execute(); }
/* ============ Cvar_Set2 ============ */ cvar_t *Cvar_Set2 (char *var_name, char *value, qboolean force) { cvar_t *var; var = Cvar_FindVar (var_name); if (!var) { // create it return Cvar_Get (var_name, value, 0); } if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO)) { if (!Cvar_InfoValidate (value)) { Com_Printf("invalid info cvar value\n"); return var; } } if (!force) { if (var->flags & CVAR_NOSET) { Com_Printf ("%s is write protected.\n", var_name); return var; } if (var->flags & CVAR_LATCH) { if (var->latched_string) { if (strcmp(value, var->latched_string) == 0) return var; Z_Free (var->latched_string); } else { if (strcmp(value, var->string) == 0) return var; } if (Com_ServerState()) { Com_Printf ("%s will be changed for next game.\n", var_name); var->latched_string = CopyString(value); } else { var->string = CopyString(value); var->value = atof (var->string); if (!strcmp(var->name, "game")) { FS_SetGame(var->string); FS_ExecAutoexec (); } } return var; } } else { if (var->latched_string) { Z_Free (var->latched_string); var->latched_string = NULL; } } if (!strcmp(value, var->string)) return var; // not changed var->modified = true; if (var->flags & CVAR_USERINFO) userinfo_modified = true; // transmit at next oportunity Z_Free (var->string); // free the old value string var->string = CopyString(value); var->value = atof (var->string); return var; }
/** * @brief Init function * @sa Com_ParseScripts * @sa Qcommon_Shutdown * @sa Sys_Init * @sa CL_Init */ void Qcommon_Init (int argc, char** argv) { logfile_active = nullptr; developer = nullptr; Sys_InitSignals(); /* random seed */ Com_SetRandomSeed(time(nullptr)); com_aliasSysPool = Mem_CreatePool("Common: Alias system for commands and enums"); com_cmdSysPool = Mem_CreatePool("Common: Command system"); com_cmodelSysPool = Mem_CreatePool("Common: Collision model"); com_cvarSysPool = Mem_CreatePool("Common: Cvar system"); com_fileSysPool = Mem_CreatePool("Common: File system"); com_genericPool = Mem_CreatePool("Generic"); com_networkPool = Mem_CreatePool("Network"); try { OBJZERO(csi); /* prepare enough of the subsystems to handle * cvar and command buffer management */ Com_InitArgv(argc, argv); Swap_Init(); Cbuf_Init(); Cmd_Init(); Cvar_Init(); uploadcrashdump = Cvar_Get("uploadcrashdump", "1", 0, "upload crashdumps to the developers"); Key_Init(); /* we need to add the early commands twice, because * a basedir needs to be set before executing * config files, but we want other parms to override * the settings of the config files */ Cbuf_AddEarlyCommands(false); Cbuf_Execute(); FS_InitFilesystem(true); Cbuf_AddText("exec default.cfg\n"); #ifdef DEDICATED_ONLY Cbuf_AddText("exec dedconfig.cfg\n"); #else Cbuf_AddText("exec config.cfg\n"); #endif Cbuf_AddEarlyCommands(true); Cbuf_Execute(); Com_SetRenderModified(false); Com_SetUserinfoModified(false); /* init commands and vars */ Cmd_AddCommand("saveconfig", Com_WriteConfig_f, "Write the configuration to file"); Cmd_AddCommand("gametypelist", Com_GameTypeList_f, "List all available multiplayer game types"); #ifdef DEBUG Cmd_AddCommand("debug_help", Com_DebugHelp_f, "Show some debugging help"); Cmd_AddCommand("debug_error", Com_DebugError_f, "Just throw a fatal error to test error shutdown procedures"); #endif Cmd_AddCommand("setdeveloper", Com_DeveloperSet_f, "Set the developer cvar to only get the debug output you want"); developer = Cvar_Get("developer", "0", 0, "Activate developer output to logfile and gameconsole"); #ifdef DEBUG logfile_active = Cvar_Get("logfile", "2", 0, "0 = deactivate logfile, 1 = write normal logfile, 2 = flush on every new line, 3 = always append to existing file"); #else logfile_active = Cvar_Get("logfile", "1", 0, "0 = deactivate logfile, 1 = write normal logfile, 2 = flush on every new line, 3 = always append to existing file"); #endif sv_gametype = Cvar_Get("sv_gametype", "fight1on1", CVAR_ARCHIVE | CVAR_SERVERINFO, "Sets the multiplayer gametype - see gametypelist command for a list of all gametypes"); http_proxy = Cvar_Get("http_proxy", "", CVAR_ARCHIVE, "Use this proxy for http transfers"); http_timeout = Cvar_Get("http_timeout", "3", CVAR_ARCHIVE, "Http connection and read timeout"); port = Cvar_Get("port", DOUBLEQUOTE(PORT_SERVER), CVAR_NOSET); masterserver_url = Cvar_Get("masterserver_url", MASTER_SERVER, CVAR_ARCHIVE, "URL of UFO:AI masterserver"); #ifdef DEDICATED_ONLY sv_dedicated = Cvar_Get("sv_dedicated", "1", CVAR_SERVERINFO | CVAR_NOSET, "Is this a dedicated server?"); /* don't allow to override this from commandline of config */ Cvar_ForceSet("sv_dedicated", "1"); #else sv_dedicated = Cvar_Get("sv_dedicated", "0", CVAR_SERVERINFO | CVAR_NOSET, "Is this a dedicated server?"); /* set this to false for client - otherwise Qcommon_Frame would set the initial values to multiplayer */ sv_gametype->modified = false; s_language = Cvar_Get("s_language", "", CVAR_ARCHIVE, "Game language - full language string e.g. en_EN.UTF-8"); s_language->modified = false; cl_maxfps = Cvar_Get("cl_maxfps", "50", CVAR_ARCHIVE); Cvar_SetCheckFunction("cl_maxfps", Com_CvarCheckMaxFPS); #endif // 5 is an i7 with a medium gfx-card // 3 dual core with 2 GB // 2 EeePc with 1 GB // 1 smartphone const char* hwclassVal = "5"; #ifdef __ANDROID__ /** get the hardware class of the machine we are running on. */ hwclassVal = "1"; #endif hwclass = Cvar_Get("hwclass", hwclassVal, 0, "Defines the hardware class of this machine. 1 is the lowest, 5 is the highest."); const char* s = va("UFO: Alien Invasion %s %s %s %s", UFO_VERSION, CPUSTRING, __DATE__, BUILDSTRING); Cvar_Get("version", s, CVAR_NOSET, "Full version string"); Cvar_Get("ver", UFO_VERSION, CVAR_SERVERINFO | CVAR_NOSET, "Version number"); if (sv_dedicated->integer) Cmd_AddCommand("quit", Com_Quit, "Quits the game"); Mem_Init(); Sys_Init(); NET_Init(); #ifndef NO_HTTP curl_global_init(CURL_GLOBAL_NOTHING); Com_Printf("%s initialized.\n", curl_version()); #endif SV_Init(); /* e.g. init the client hunk that is used in script parsing */ CL_Init(); Com_ParseScripts(sv_dedicated->integer); #ifndef DEDICATED_ONLY Cbuf_AddText("exec keys.cfg\n"); #endif if (!sv_dedicated->integer) Cbuf_AddText("init\n"); else Cbuf_AddText("dedicated_start\n"); Cbuf_Execute(); FS_ExecAutoexec(); /* add + commands from command line * if the user didn't give any commands, run default action */ if (Cbuf_AddLateCommands()) { /* the user asked for something explicit * so drop the loading plaque */ SCR_EndLoadingPlaque(); } const cvar_t* com_pipefile = Cvar_Get("com_pipefile", "", CVAR_ARCHIVE, "Filename of the pipe that is used to send commands to the game"); if (com_pipefile->string[0] != '\0') { FS_CreateOpenPipeFile(com_pipefile->string, &pipefile); } CL_InitAfter(); /* Check memory integrity */ Mem_CheckGlobalIntegrity(); #ifndef DEDICATED_ONLY if (!sv_dedicated->integer) { Schedule_Timer(cl_maxfps, &CL_Frame, nullptr, nullptr); Schedule_Timer(Cvar_Get("cl_slowfreq", "10", 0, nullptr), &CL_SlowFrame, nullptr, nullptr); /* now hide the console */ Sys_ShowConsole(false); } #endif Schedule_Timer(Cvar_Get("sv_freq", "10", CVAR_NOSET, nullptr), &SV_Frame, nullptr, nullptr); /** @todo This line wants to be removed */ Schedule_Timer(Cvar_Get("cbuf_freq", "10", 0, nullptr), &Cbuf_Execute_timer, nullptr, nullptr); Com_Printf("====== UFO Initialized ======\n"); Com_Printf("=============================\n"); } catch (comDrop_t const&) { Sys_Error("Error during initialization"); } }