void wswcurl_init( void ) { if( wswcurl_mempool ) { return; } wswcurl_mempool = Mem_AllocPool( NULL, "Curl" ); // HTTP proxy settings http_proxy = Cvar_Get( "http_proxy", "", CVAR_ARCHIVE ); http_proxyuserpwd = Cvar_Get( "http_proxyuserpwd", "", CVAR_ARCHIVE ); wswcurl_loadlib(); if( curlLibrary ) { qcurl_global_init( CURL_GLOBAL_ALL ); curldummy = qcurl_easy_init(); curlmulti = qcurl_multi_init(); } curldummy_mutex = QMutex_Create(); http_requests_mutex = QMutex_Create(); #ifdef USE_OPENSSL if( cryptoLibrary ) { int mutex_num; crypto_num_mutexes = qCRYPTO_num_locks(); crypto_mutexes = WMALLOC( crypto_num_mutexes * sizeof( *crypto_mutexes ) ); for( mutex_num = 0; mutex_num < crypto_num_mutexes; mutex_num++ ) crypto_mutexes[mutex_num] = QMutex_Create(); qCRYPTO_set_locking_callback( wswcurl_crypto_lockcallback ); } #endif }
static void SCR_InitFonts( void ) { cvar_t *con_fontSystemSmall = Cvar_Get( "con_fontSystemSmall", DEFAULT_FONT_SMALL, CVAR_ARCHIVE|CVAR_LATCH_VIDEO ); cvar_t *con_fontSystemMedium = Cvar_Get( "con_fontSystemMedium", DEFAULT_FONT_MEDIUM, CVAR_ARCHIVE|CVAR_LATCH_VIDEO ); cvar_t *con_fontSystemBig = Cvar_Get( "con_fontSystemBig", DEFAULT_FONT_BIG, CVAR_ARCHIVE|CVAR_LATCH_VIDEO ); fonts_mempool = Mem_AllocPool( NULL, "Fonts" ); // register system fonts cls.fontSystemSmall = SCR_RegisterFont( con_fontSystemSmall->string ); if( !cls.fontSystemSmall ) { cls.fontSystemSmall = SCR_RegisterFont( DEFAULT_FONT_SMALL ); if( !cls.fontSystemSmall ) Com_Error( ERR_FATAL, "Couldn't load default font \"%s\"", DEFAULT_FONT_SMALL ); } cls.fontSystemMedium = SCR_RegisterFont( con_fontSystemMedium->string ); if( !cls.fontSystemMedium ) cls.fontSystemMedium = SCR_RegisterFont( DEFAULT_FONT_MEDIUM ); cls.fontSystemBig = SCR_RegisterFont( con_fontSystemBig->string ); if( !cls.fontSystemBig ) cls.fontSystemBig = SCR_RegisterFont( DEFAULT_FONT_BIG ); }
void Com_ScriptModule_Init( void ) { angelwrap_import_t import; static const char *name = "angelwrap"; Com_ScriptModule_Shutdown(); //if( !com_angelscript->integer ) //{ // if( verbose ) // { // Com_Printf( "Not loading angel script module\n" ); // Com_Printf( "------------------------------------\n" ); // } // return; //} Com_Printf( "------- angel script initialization -------\n" ); com_scriptmodulepool = Mem_AllocPool( NULL, "Angel Script Module" ); import.Error = Com_ScriptModule_Error; import.Print = Com_ScriptModule_Print; import.Milliseconds = Sys_Milliseconds; import.Cvar_Get = Cvar_Get; import.Cvar_Set = Cvar_Set; import.Cvar_SetValue = Cvar_SetValue; import.Cvar_ForceSet = Cvar_ForceSet; import.Cvar_String = Cvar_String; import.Cvar_Value = Cvar_Value; import.Cmd_Argc = Cmd_Argc; import.Cmd_Argv = Cmd_Argv; import.Cmd_Args = Cmd_Args; import.Cmd_AddCommand = Cmd_AddCommand; import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteText = Cbuf_ExecuteText; import.Mem_Alloc = Com_ScriptModule_MemAlloc; import.Mem_Free = Com_ScriptModule_MemFree; import.Mem_AllocPool = Com_ScriptModule_MemAllocPool; import.Mem_FreePool = Com_ScriptModule_MemFreePool; import.Mem_EmptyPool = Com_ScriptModule_MemEmptyPool; // load the actual library if( !Com_ScriptModule_Load( name, &import ) ) { Mem_FreePool( &com_scriptmodulepool ); ae = NULL; return; } // check memory integrity Mem_CheckSentinelsGlobal(); Com_Printf( "------------------------------------\n" ); }
/* * Memory_Init */ void Memory_Init( void ) { assert( !memory_initialized ); zoneMemPool = Mem_AllocPool( NULL, "Zone" ); tempMemPool = Mem_AllocTempPool( "Temporary Memory" ); memory_initialized = qtrue; }
void wswcurl_init( void ) { wswcurl_mempool = Mem_AllocPool( NULL, "Curl" ); curldummy = curl_easy_init(); // HTTP proxy settings http_proxy = Cvar_Get( "http_proxy", "", CVAR_ARCHIVE ); http_proxyuserpwd = Cvar_Get( "http_proxyuserpwd", "", CVAR_ARCHIVE ); }
void wswcurl_init( void ) { wswcurl_mempool = Mem_AllocPool( NULL, "Curl" ); curldummy = curl_easy_init(); curlmulti = curl_multi_init(); http_requests_mutex = QMutex_Create(); // HTTP proxy settings http_proxy = Cvar_Get( "http_proxy", "", CVAR_ARCHIVE ); http_proxyuserpwd = Cvar_Get( "http_proxyuserpwd", "", CVAR_ARCHIVE ); }
void CL_MM_Init( void ) { if( cl_mm_initialized ) return; cl_mm_enabled = qfalse; cl_mm_loginState = LOGIN_STATE_NONE; cls.mm_session = 0; cl_mm_loginHandle = 0; cl_mm_loginState = LOGIN_STATE_NONE; cl_mm_loginTime = 0; cl_mm_loginRetries = 0; if( !cl_mm_mempool ) { cl_mm_errmsg = NULL; cl_mm_errmsg_size = 0; } if( !cl_mm_mempool ) cl_mm_mempool = Mem_AllocPool( NULL, "cl_mm" ); StatQuery_Init(); sq_api = StatQuery_GetAPI(); /* * create cvars */ cl_mm_session = Cvar_Get( "cl_mm_session", "0", CVAR_READONLY | CVAR_USERINFO ); cl_mm_autologin = Cvar_Get( "cl_mm_autologin", "0", CVAR_ARCHIVE ); // TODO: remove as cvar cl_mm_user = Cvar_Get( "cl_mm_user", "", CVAR_ARCHIVE ); /* * add commands */ Cmd_AddCommand( "mm_login", CL_MM_Login_f ); Cmd_AddCommand( "mm_logout", CL_MM_Logout_f ); Cvar_ForceSet( cl_mm_session->name, "0" ); /* * login */ if( cl_mm_autologin->integer ) CL_MM_Login( NULL, NULL ); cl_mm_initialized = qtrue; }
/* * CM_Init */ void CM_Init( void ) { assert( !cm_initialized ); cmap_mempool = Mem_AllocPool( NULL, "Collision Map" ); cm_noAreas = Cvar_Get( "cm_noAreas", "0", CVAR_CHEAT ); cm_noCurves = Cvar_Get( "cm_noCurves", "0", CVAR_CHEAT ); Cvar_Get( "cm_mapHeader", "", CVAR_READONLY ); Cvar_Get( "cm_mapVersion", "0", CVAR_READONLY ); cm_initialized = qtrue; }
/* * L10n_Init */ void L10n_Init( void ) { podomains_head = NULL; pomempool = Mem_AllocPool( NULL, "L10n" ); cl_lang = Cvar_Get( "lang", "", CVAR_USERINFO|CVAR_ARCHIVE #ifdef PUBLIC_BUILD | CVAR_LATCH_VIDEO #endif ); L10n_CheckUserLanguage(); }
void Sound_Init( void ) { // init pools host.soundpool = Mem_AllocPool( "SoundLib Pool" ); // install image formats (can be re-install later by Sound_Setup) switch( host.type ) { case HOST_NORMAL: sound.loadformats = load_game; sound.streamformat = stream_game; break; default: // all other instances not using soundlib or will be reinstalling later sound.loadformats = load_null; sound.streamformat = stream_null; break; } sound.tempbuffer = NULL; }
void StatQuery_Init( void ) { cJSON_Hooks hooks; if( sq_mempool == NULL ) { sq_mempool = Mem_AllocPool( NULL, "StatQuery" ); } // already initialized? if( sq_refcount++ > 0 ) { return; } // populate API structure sq_export.CreateQuery = StatQuery_CreateQuery; sq_export.DestroyQuery = StatQuery_DestroyQuery; sq_export.SetCallback = StatQuery_SetCallback; sq_export.Send = StatQuery_Send; sq_export.SetField = StatQuery_SetField; sq_export.GetRoot = StatQuery_GetRoot; sq_export.GetSection = StatQuery_GetSection; sq_export.GetNumber = StatQuery_GetNumber; sq_export.GetString = StatQuery_GetString; sq_export.GetArraySection = StatQuery_GetArraySection; sq_export.GetArrayNumber = StatQuery_GetArrayNumber; sq_export.GetArrayString = StatQuery_GetArrayString; sq_export.CreateSection = StatQuery_CreateSection; sq_export.CreateArray = StatQuery_CreateArray; sq_export.SetString = StatQuery_SetString; sq_export.SetNumber = StatQuery_SetNumber; sq_export.SetArrayString = StatQuery_SetArrayString; sq_export.SetArrayNumber = StatQuery_SetArrayNumber; sq_export.AddArrayString = StatQuery_AddArrayString; sq_export.AddArrayNumber = StatQuery_AddArrayNumber; sq_export.GetRawResponse = StatQuery_GetRawResponse; sq_export.GetTokenizedResponse = StatQuery_GetTokenizedResponse; sq_export.Poll = StatQuery_Poll; // init JSON hooks.malloc_fn = SQ_JSON_Alloc; hooks.free_fn = SQ_JSON_Free; cJSON_InitHooks( &hooks ); }
/* =============== Netchan_Init =============== */ void Netchan_Init( void ) { int port; // pick a port value that should be nice and random port = Com_RandomLong( 1, 65535 ); net_showpackets = Cvar_Get ("net_showpackets", "0", 0, "show network packets" ); net_chokeloopback = Cvar_Get( "net_chokeloop", "0", 0, "apply bandwidth choke to loopback packets" ); net_drawslider = Cvar_Get( "net_drawslider", "0", CVAR_ARCHIVE, "draw completion slider during signon" ); net_blocksize = Cvar_Get( "net_blocksize", "1024", 0, "network file fragmentation block size" ); net_showdrop = Cvar_Get( "net_showdrop", "0", 0, "show packets that are dropped" ); net_speeds = Cvar_Get( "net_speeds", "0", CVAR_ARCHIVE, "show network packets" ); net_qport = Cvar_Get( "net_qport", va( "%i", port ), CVAR_INIT, "current quake netport" ); net_mempool = Mem_AllocPool( "Network Pool" ); Huff_Init (); // initialize huffman compression BF_InitMasks (); // initialize bit-masks }
static void Irc_LoadLibrary( void ) { static irc_import_t import; dllfunc_t funcs[2]; GetIrcAPI_t GetIrcAPI_f; assert( !irc_libhandle ); import.Printf = Irc_Print; import.CL_GetKeyDest = CL_GetKeyDest; import.CL_GetClientState = CL_GetClientState; import.Key_DelegatePush = Key_DelegatePush; import.Key_DelegatePop = Key_DelegatePop; import.SCR_RegisterFont = SCR_RegisterFont; import.SCR_DrawString = SCR_DrawString; import.SCR_DrawStringWidth = SCR_DrawStringWidth; import.SCR_DrawRawChar = SCR_DrawRawChar; import.SCR_strHeight = SCR_FontHeight; import.SCR_strWidth = SCR_strWidth; import.SCR_StrlenForWidth = SCR_StrlenForWidth; import.SCR_GetScreenWidth = SCR_GetScreenWidth; import.SCR_GetScreenHeight = SCR_GetScreenHeight; import.R_RegisterPic = SCR_RegisterPic; import.R_DrawStretchPic = SCR_DrawStretchPic; import.Sys_Milliseconds = Sys_Milliseconds; import.Sys_Microseconds = Sys_Microseconds; import.Mem_AllocPool = Irc_MemAllocPool; import.Mem_Alloc = Irc_MemAlloc; import.Mem_Free = Irc_MemFree; import.Mem_FreePool = Irc_MemFreePool; import.Mem_EmptyPool = Irc_MemEmptyPool; import.Dynvar_Create = Dynvar_Create; import.Dynvar_Destroy = Dynvar_Destroy; import.Dynvar_Lookup = Dynvar_Lookup; import.Dynvar_GetName = Dynvar_GetName; import.Dynvar_GetValue = Dynvar_GetValue; import.Dynvar_SetValue = Dynvar_SetValue; import.Dynvar_CallListeners = Dynvar_CallListeners; import.Dynvar_AddListener = Dynvar_AddListener; import.Dynvar_RemoveListener = Dynvar_RemoveListener; import.DYNVAR_WRITEONLY = DYNVAR_WRITEONLY; import.DYNVAR_READONLY = DYNVAR_READONLY; import.Cvar_Get = Cvar_Get; import.Cvar_Set = Cvar_Set; import.Cvar_SetValue = Cvar_SetValue; import.Cvar_ForceSet = Cvar_ForceSet; import.Cvar_Integer = Cvar_Integer; import.Cvar_Value = Cvar_Value; import.Cvar_String = Cvar_String; import.Cmd_Argc = Cmd_Argc; import.Cmd_Argv = Cmd_Argv; import.Cmd_Args = Cmd_Args; import.Cmd_AddCommand = Cmd_AddCommand; import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteString = Cmd_ExecuteString; import.Com_BeginRedirect = Com_BeginRedirect; import.Com_EndRedirect = Com_EndRedirect; import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc; import.Cbuf_AddText = Cbuf_AddText; import.Trie_Create = Trie_Create; import.Trie_Destroy = Trie_Destroy; import.Trie_Clear = Trie_Clear; import.Trie_GetSize = Trie_GetSize; import.Trie_Insert = Trie_Insert; import.Trie_Remove = Trie_Remove; import.Trie_Replace = Trie_Replace; import.Trie_Find = Trie_Find; import.Trie_FindIf = Trie_FindIf; import.Trie_NoOfMatches = Trie_NoOfMatches; import.Trie_NoOfMatchesIf = Trie_NoOfMatchesIf; import.Trie_Dump = Trie_Dump; import.Trie_DumpIf = Trie_DumpIf; import.Trie_FreeDump = Trie_FreeDump; // load dynamic library Com_Printf( "Loading IRC module... " ); funcs[0].name = "GetIrcAPI"; funcs[0].funcPointer = (void **) &GetIrcAPI_f; funcs[1].name = NULL; irc_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/" LIB_PREFIX "irc_" ARCH LIB_SUFFIX, funcs ); if( irc_libhandle ) { // load succeeded int api_version; irc_export = GetIrcAPI_f( &import ); irc_pool = Mem_AllocPool( NULL, "IRC Module" ); api_version = irc_export->API(); if( api_version == IRC_API_VERSION ) { if( irc_export->Init() ) { dynvar_t *const quit = Dynvar_Lookup( "quit" ); if( quit ) Dynvar_AddListener( quit, Irc_Quit_f ); irc_initialized = true; Cmd_AddCommand( "irc_unload", Irc_UnloadLibrary ); Com_Printf( "Success.\n" ); } else { // initialization failed Mem_FreePool( &irc_pool ); Com_Printf( "Initialization failed.\n" ); Irc_UnloadLibrary(); } } else { // wrong version Mem_FreePool( &irc_pool ); Com_Printf( "Wrong version: %i, not %i.\n", api_version, IRC_API_VERSION ); Irc_UnloadLibrary(); } } else { Com_Printf( "Not found.\n" ); } Mem_DebugCheckSentinelsGlobal(); }
/* ================ FS_Init ================ */ void CFileSystem::Init() { mpLowLevelFileSystem->Init(); tStringList dirs; bool hasDefaultDir = false; int i; // Init memory fs_mempool = Mem_AllocPool( "FileSystem Pool" ); // add a path separator to the end of the basedir if it lacks one if( fs_basedir[0] && fs_basedir[Q_strlen(fs_basedir) - 1] != '/' && fs_basedir[Q_strlen(fs_basedir) - 1] != '\\' ) Q_strncat( fs_basedir, "/", sizeof( fs_basedir )); fs_searchpaths = NULL; mpConsole->AddCommand("fs_rescan", FS_Rescan_f, "rescan filesystem search pathes"); mpConsole->AddCommand("fs_path", FS_Path_f, "show filesystem search pathes"); mpConsole->AddCommand("fs_clearpaths", FS_ClearPaths_f, "clear filesystem search pathes"); // ignore commandlineoption "-game" for other stuff if( host.type == HOST_NORMAL || host.type == HOST_DEDICATED ) { stringlistinit( &dirs ); listdirectory( &dirs, "./" ); stringlistsort( &dirs ); SI.numgames = 0; if( !Sys_GetParmFromCmdLine( "-game", gs_basedir )) Q_strcpy( gs_basedir, SI.ModuleName ); // default dir if( FS_CheckNastyPath( gs_basedir, true )) { DevMsg( D_ERROR, "FS_Init: invalid game directory \"%s\"\n", gs_basedir ); Q_strcpy( gs_basedir, SI.ModuleName ); // default dir }; // validate directories for( i = 0; i < dirs.numstrings; i++ ) { if( !Q_stricmp( SI.ModuleName, dirs.strings[i] )) hasDefaultDir = true; if( !Q_stricmp( gs_basedir, dirs.strings[i] )) break; } if( i == dirs.numstrings ) { DevMsg( D_INFO, "FS_Init: game directory \"%s\" not exist\n", gs_basedir ); if(hasDefaultDir) Q_strncpy( gs_basedir, SI.ModuleName, sizeof( gs_basedir )); // default dir }; // build list of game directories here FS_AddGameDirectory( "./", 0 ); for( i = 0; i < dirs.numstrings; i++ ) { if(!mpLowLevelFileSystem->SysFolderExists( dirs.strings[i] ) || (!Q_stricmp( dirs.strings[i], ".." ) && !fs_ext_path )) continue; if( !SI.games[SI.numgames] ) SI.games[SI.numgames] = (gameinfo_t *)Mem_Alloc( fs_mempool, sizeof( gameinfo_t )); if( FS_ParseGameInfo( dirs.strings[i], SI.games[SI.numgames] )) SI.numgames++; // added }; stringlistfreecontents( &dirs ); }; MsgDev( D_NOTE, "FS_Init: done\n" ); };
/* * SV_Init * * Only called at plat.exe startup, not for each game */ void SV_Init( void ) { cvar_t *sv_pps; cvar_t *sv_fps; assert( !sv_initialized ); memset( &svc, 0, sizeof( svc ) ); SV_InitOperatorCommands(); sv_mempool = Mem_AllocPool( NULL, "Server" ); Cvar_Get( "sv_cheats", "0", CVAR_SERVERINFO | CVAR_LATCH ); Cvar_Get( "protocol", va( "%i", APP_PROTOCOL_VERSION ), CVAR_SERVERINFO | CVAR_NOSET ); sv_ip = Cvar_Get( "sv_ip", "", CVAR_ARCHIVE | CVAR_LATCH ); sv_port = Cvar_Get( "sv_port", va( "%i", PORT_SERVER ), CVAR_ARCHIVE | CVAR_LATCH ); sv_ip6 = Cvar_Get( "sv_ip6", "::", CVAR_ARCHIVE | CVAR_LATCH ); sv_port6 = Cvar_Get( "sv_port6", va( "%i", PORT_SERVER ), CVAR_ARCHIVE | CVAR_LATCH ); #ifdef TCP_SUPPORT sv_tcp = Cvar_Get( "sv_tcp", "1", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_LATCH ); #endif rcon_password = Cvar_Get( "rcon_password", "", 0 ); sv_hostname = Cvar_Get( "sv_hostname", APPLICATION " server", CVAR_SERVERINFO | CVAR_ARCHIVE ); sv_timeout = Cvar_Get( "sv_timeout", "125", 0 ); sv_zombietime = Cvar_Get( "sv_zombietime", "2", 0 ); sv_enforcetime = Cvar_Get( "sv_enforcetime", "1", 0 ); sv_showclamp = Cvar_Get( "sv_showclamp", "0", 0 ); sv_showRcon = Cvar_Get( "sv_showRcon", "1", 0 ); sv_showChallenge = Cvar_Get( "sv_showChallenge", "0", 0 ); sv_showInfoQueries = Cvar_Get( "sv_showInfoQueries", "0", 0 ); sv_highchars = Cvar_Get( "sv_highchars", "1", 0 ); sv_uploads_baseurl = Cvar_Get( "sv_uploads_baseurl", "", CVAR_ARCHIVE ); sv_uploads_demos_baseurl = Cvar_Get( "sv_uploads_demos_baseurl", "", CVAR_ARCHIVE ); if( dedicated->integer ) { sv_uploads = Cvar_Get( "sv_uploads", "1", CVAR_READONLY ); sv_uploads_from_server = Cvar_Get( "sv_uploads_from_server", "1", CVAR_READONLY ); sv_autoUpdate = Cvar_Get( "sv_autoUpdate", "1", CVAR_ARCHIVE ); sv_pure = Cvar_Get( "sv_pure", "1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO ); #ifdef PUBLIC_BUILD sv_public = Cvar_Get( "sv_public", "1", CVAR_ARCHIVE | CVAR_LATCH ); #else sv_public = Cvar_Get( "sv_public", "0", CVAR_ARCHIVE | CVAR_LATCH ); #endif } else { sv_uploads = Cvar_Get( "sv_uploads", "1", CVAR_ARCHIVE ); sv_uploads_from_server = Cvar_Get( "sv_uploads_from_server", "1", CVAR_ARCHIVE ); sv_autoUpdate = Cvar_Get( "sv_autoUpdate", "0", CVAR_READONLY ); sv_pure = Cvar_Get( "sv_pure", "0", CVAR_ARCHIVE | CVAR_LATCH | CVAR_SERVERINFO ); sv_public = Cvar_Get( "sv_public", "0", CVAR_ARCHIVE ); } sv_iplimit = Cvar_Get( "sv_iplimit", "3", CVAR_ARCHIVE ); sv_lastAutoUpdate = Cvar_Get( "sv_lastAutoUpdate", "0", CVAR_READONLY|CVAR_ARCHIVE ); sv_pure_forcemodulepk3 = Cvar_Get( "sv_pure_forcemodulepk3", "", CVAR_LATCH ); sv_defaultmap = Cvar_Get( "sv_defaultmap", "wdm1", CVAR_ARCHIVE ); sv_write_defaultmap = Cvar_Get( "sv_write_defaultmap", "0", CVAR_ARCHIVE ); sv_reconnectlimit = Cvar_Get( "sv_reconnectlimit", "3", CVAR_ARCHIVE ); sv_maxclients = Cvar_Get( "sv_maxclients", "8", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_LATCH ); sv_maxmvclients = Cvar_Get( "sv_maxmvclients", "4", CVAR_ARCHIVE | CVAR_SERVERINFO ); Cvar_Get( "sv_modmanifest", "", CVAR_READONLY ); Cvar_ForceSet( "sv_modmanifest", "" ); // fix invalid sv_maxclients values if( sv_maxclients->integer < 1 ) Cvar_FullSet( "sv_maxclients", "1", CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, qtrue ); else if( sv_maxclients->integer > MAX_CLIENTS ) Cvar_FullSet( "sv_maxclients", va( "%i", MAX_CLIENTS ), CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, qtrue ); sv_demodir = Cvar_Get( "sv_demodir", "", CVAR_NOSET ); if( sv_demodir->string[0] && Com_GlobMatch( "*[^0-9a-zA-Z_@]*", sv_demodir->string, qfalse ) ) { Com_Printf( "Invalid demo prefix string: %s\n", sv_demodir->string ); Cvar_ForceSet( "sv_demodir", "" ); } // wsw : jal : cap client's exceding server rules sv_maxrate = Cvar_Get( "sv_maxrate", "0", CVAR_DEVELOPER ); sv_compresspackets = Cvar_Get( "sv_compresspackets", "1", CVAR_DEVELOPER ); sv_skilllevel = Cvar_Get( "sv_skilllevel", "1", CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH ); if( sv_skilllevel->integer > 2 ) Cvar_ForceSet( "sv_skilllevel", "2" ); if( sv_skilllevel->integer < 0 ) Cvar_ForceSet( "sv_skilllevel", "0" ); sv_masterservers = Cvar_Get( "masterservers", DEFAULT_MASTER_SERVERS_IPS, CVAR_LATCH ); sv_debug_serverCmd = Cvar_Get( "sv_debug_serverCmd", "0", CVAR_ARCHIVE ); sv_MOTD = Cvar_Get( "sv_MOTD", "0", CVAR_ARCHIVE ); sv_MOTDFile = Cvar_Get( "sv_MOTDFile", "", CVAR_ARCHIVE ); sv_MOTDString = Cvar_Get( "sv_MOTDString", "", CVAR_ARCHIVE ); SV_MOTD_Update(); // this is a message holder for shared use MSG_Init( &tmpMessage, tmpMessageData, sizeof( tmpMessageData ) ); // init server updates ratio if( dedicated->integer ) sv_pps = Cvar_Get( "sv_pps", "20", CVAR_SERVERINFO|CVAR_NOSET ); else sv_pps = Cvar_Get( "sv_pps", "20", CVAR_SERVERINFO ); svc.snapFrameTime = (int)( 1000 / sv_pps->value ); if( svc.snapFrameTime > 200 ) { // too slow, also, netcode uses a byte Cvar_ForceSet( "sv_pps", "5" ); svc.snapFrameTime = 200; } else if( svc.snapFrameTime < 10 ) { // abusive Cvar_ForceSet( "sv_pps", "100" ); svc.snapFrameTime = 10; } sv_fps = Cvar_Get( "sv_fps", "62", CVAR_NOSET ); svc.gameFrameTime = (int)( 1000 / sv_fps->value ); if( svc.gameFrameTime > svc.snapFrameTime ) { // gamecode can never be slower than snaps svc.gameFrameTime = svc.snapFrameTime; Cvar_ForceSet( "sv_fps", sv_pps->dvalue ); } Com_Printf( "Game running at %i fps. Server transmit at %i pps\n", sv_fps->integer, sv_pps->integer ); //init the master servers list SV_InitMaster(); SV_MM_Init(); ML_Init(); sv_initialized = qtrue; }
/* * FTLIB_LoadLibrary */ void FTLIB_LoadLibrary( qboolean verbose ) { static ftlib_import_t import; dllfunc_t funcs[2]; void *( *GetFTLibAPI )(void *); assert( !ftlib_libhandle ); import.Print = &CL_FTLibModule_Print; import.Error = &CL_FTLibModule_Error; import.Cvar_Get = &Cvar_Get; import.Cvar_Set = &Cvar_Set; import.Cvar_SetValue = &Cvar_SetValue; import.Cvar_ForceSet = &Cvar_ForceSet; import.Cvar_String = &Cvar_String; import.Cvar_Value = &Cvar_Value; import.Cmd_Argc = &Cmd_Argc; import.Cmd_Argv = &Cmd_Argv; import.Cmd_Args = &Cmd_Args; import.Cmd_AddCommand = &Cmd_AddCommand; import.Cmd_RemoveCommand = &Cmd_RemoveCommand; import.Cmd_ExecuteText = &Cbuf_ExecuteText; import.Cmd_Execute = &Cbuf_Execute; import.Cmd_SetCompletionFunc = &Cmd_SetCompletionFunc; import.FS_FOpenFile = &FS_FOpenFile; import.FS_Read = &FS_Read; import.FS_Write = &FS_Write; import.FS_Print = &FS_Print; import.FS_Tell = &FS_Tell; import.FS_Seek = &FS_Seek; import.FS_Eof = &FS_Eof; import.FS_Flush = &FS_Flush; import.FS_FCloseFile = &FS_FCloseFile; import.FS_RemoveFile = &FS_RemoveFile; import.FS_GetFileList = &FS_GetFileList; import.FS_IsUrl = &FS_IsUrl; import.R_RegisterPic = &CL_FTLibModule_RegisterPic; import.R_RegisterRawPic = &CL_FTLibModule_RegisterRawPic; import.R_DrawStretchPic = &CL_FTLibModule_DrawStretchPic; import.R_SetScissorRegion = &CL_FTLibModule_SetScissorRegion; import.R_GetScissorRegion = &CL_FTLibModule_GetScissorRegion; import.Milliseconds = &Sys_Milliseconds; import.Microseconds = &Sys_Microseconds; import.Mem_AllocPool = &CL_FTLibModule_MemAllocPool; import.Mem_Alloc = &CL_FTLibModule_MemAlloc; import.Mem_Free = &CL_FTLibModule_MemFree; import.Mem_FreePool = &CL_FTLibModule_MemFreePool; import.Mem_EmptyPool = &CL_FTLibModule_MemEmptyPool; // load dynamic library ftlib_export = NULL; if( verbose ) { Com_Printf( "Loading Fonts module... " ); } funcs[0].name = "GetFTLibAPI"; funcs[0].funcPointer = ( void ** ) &GetFTLibAPI; funcs[1].name = NULL; ftlib_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/ftlib_" ARCH LIB_SUFFIX, funcs ); if( ftlib_libhandle ) { // load succeeded int api_version; ftlib_export = GetFTLibAPI( &import ); ftlib_mempool = Mem_AllocPool( NULL, "Fonts Library Module" ); api_version = ftlib_export->API(); if( api_version == FTLIB_API_VERSION ) { if( ftlib_export->Init( verbose ) ) { if( verbose ) { Com_Printf( "Success.\n" ); } } else { // initialization failed Mem_FreePool( &ftlib_mempool ); if( verbose ) { Com_Printf( "Initialization failed.\n" ); } FTLIB_UnloadLibrary( verbose ); } } else { // wrong version Mem_FreePool( &ftlib_mempool ); Com_Printf( "ftlib_LoadLibrary: wrong version: %i, not %i.\n", api_version, FTLIB_API_VERSION ); FTLIB_UnloadLibrary( verbose ); } } else { if( verbose ) { Com_Printf( "Not found.\n" ); } } Mem_CheckSentinelsGlobal(); }
/* * TV_Init * * Only called at plat.exe startup, not for each game */ void TV_Init( void ) { Com_Printf( "Initializing " APPLICATION " TV server\n" ); tv_mempool = Mem_AllocPool( NULL, "TV" ); TV_AddCommands(); Cvar_Get( "protocol", va( "%i", APP_PROTOCOL_VERSION ), CVAR_SERVERINFO | CVAR_NOSET ); Cvar_Get( "gamename", Cvar_String( "gamename" ), CVAR_SERVERINFO | CVAR_NOSET ); tv_password = Cvar_Get( "tv_password", "", 0 ); tv_ip = Cvar_Get( "tv_ip", "", CVAR_ARCHIVE | CVAR_NOSET ); tv_port = Cvar_Get( "tv_port", va( "%i", PORT_TV_SERVER ), CVAR_ARCHIVE | CVAR_NOSET ); tv_ip6 = Cvar_Get( "tv_ip6", "::", CVAR_ARCHIVE | CVAR_NOSET ); tv_port6 = Cvar_Get( "tv_port6", va( "%i", PORT_TV_SERVER ), CVAR_ARCHIVE | CVAR_NOSET ); #ifdef TCP_ALLOW_TVCONNECT tv_udp = Cvar_Get( "tv_udp", "1", CVAR_SERVERINFO | CVAR_NOSET ); tv_tcp = Cvar_Get( "tv_tcp", "1", CVAR_SERVERINFO | CVAR_NOSET ); #else tv_udp = Cvar_Get( "tv_udp", "1", CVAR_NOSET ); #endif #ifndef TCP_ALLOW_TVCONNECT Cvar_FullSet( "tv_tcp", "0", CVAR_READONLY, true ); #endif tv_reconnectlimit = Cvar_Get( "tv_reconnectlimit", "3", CVAR_ARCHIVE ); tv_timeout = Cvar_Get( "tv_timeout", "125", 0 ); tv_zombietime = Cvar_Get( "tv_zombietime", "2", 0 ); tv_name = Cvar_Get( "tv_name", APPLICATION "[TV]", CVAR_SERVERINFO | CVAR_ARCHIVE ); tv_compresspackets = Cvar_Get( "tv_compresspackets", "1", 0 ); tv_maxclients = Cvar_Get( "tv_maxclients", "32", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_NOSET ); tv_maxmvclients = Cvar_Get( "tv_maxmvclients", "4", CVAR_ARCHIVE | CVAR_SERVERINFO | CVAR_NOSET ); tv_public = Cvar_Get( "tv_public", "1", CVAR_ARCHIVE | CVAR_SERVERINFO ); tv_rcon_password = Cvar_Get( "tv_rcon_password", "", 0 ); tv_autorecord = Cvar_Get( "tv_autorecord", "", CVAR_ARCHIVE ); tv_lobbymusic = Cvar_Get( "tv_lobbymusic", "", CVAR_ARCHIVE ); tv_masterservers = Cvar_Get( "tv_masterservers", DEFAULT_MASTER_SERVERS_IPS, CVAR_LATCH ); tv_masterservers_steam = Cvar_Get( "tv_masterservers_steam", DEFAULT_MASTER_SERVERS_STEAM_IPS, CVAR_LATCH ); // flood control tv_floodprotection_messages = Cvar_Get( "tv_floodprotection_messages", "10", 0 ); tv_floodprotection_messages->modified = true; tv_floodprotection_seconds = Cvar_Get( "tv_floodprotection_seconds", "4", 0 ); tv_floodprotection_seconds->modified = true; tv_floodprotection_penalty = Cvar_Get( "tv_floodprotection_delay", "20", 0 ); tv_floodprotection_penalty->modified = true; if( tv_maxclients->integer < 0 ) Cvar_ForceSet( "tv_maxclients", "0" ); if( tv_maxclients->integer ) { tvs.clients = ( client_t * )Mem_Alloc( tv_mempool, sizeof( client_t ) * tv_maxclients->integer ); } else { tvs.clients = NULL; } tvs.lobby.spawncount = rand(); tvs.lobby.snapFrameTime = 100; // IPv4 if( !NET_StringToAddress( tv_ip->string, &tvs.address ) ) Com_Error( ERR_FATAL, "Couldn't understand address of tv_ip cvar: %s\n", NET_ErrorString() ); NET_SetAddressPort( &tvs.address, tv_port->integer ); if( tv_udp->integer ) { if( !NET_OpenSocket( &tvs.socket_udp, SOCKET_UDP, &tvs.address, true ) ) { Com_Printf( "Error: Couldn't open UDP socket: %s\n", NET_ErrorString() ); Cvar_ForceSet( tv_udp->name, "0" ); } } // IPv6 if( !NET_StringToAddress( tv_ip6->string, &tvs.addressIPv6 ) ) Com_Error( ERR_FATAL, "Couldn't understand address of tv_ip6 cvar: %s\n", NET_ErrorString() ); NET_SetAddressPort( &tvs.addressIPv6, tv_port6->integer ); if( tvs.addressIPv6.type != NA_NOTRANSMIT ) { if( !NET_OpenSocket( &tvs.socket_udp6, SOCKET_UDP, &tvs.addressIPv6, true ) ) { Com_Printf( "Error: Couldn't open UDP6 socket: %s\n", NET_ErrorString() ); } } #ifdef TCP_ALLOW_TVCONNECT if( tv_tcp->integer ) { bool err = true; if( !NET_OpenSocket( &tvs.socket_tcp, SOCKET_TCP, &tvs.address, true ) ) { Com_Printf( "Error: Couldn't open TCP socket: %s\n", NET_ErrorString() ); } else { NET_SetSocketNoDelay( &tvs.socket_tcp, 1 ); if( !NET_Listen( &tvs.socket_tcp ) ) { Com_Printf( "Error: Couldn't listen to TCP socket: %s\n", NET_ErrorString() ); } else { err = false; } } if( tvs.addressIPv6.type != NA_NOTRANSMIT ) { if( !NET_OpenSocket( &tvs.socket_tcp6, SOCKET_TCP, &tvs.addressIPv6, true ) ) { Com_Printf( "Error: Couldn't open TCP6 socket: %s\n", NET_ErrorString() ); } else { NET_SetSocketNoDelay( &tvs.socket_tcp6, 1 ); if( !NET_Listen( &tvs.socket_tcp6 ) ) { Com_Printf( "Error: Couldn't listen to TCP6 socket: %s\n", NET_ErrorString() ); } else { err = false; } } } if( err ) { Cvar_ForceSet( tv_tcp->name, "0" ); } } #endif TV_Downstream_InitMaster(); }
/* * CIN_LoadLibrary */ void CIN_LoadLibrary( bool verbose ) { static cin_import_t import; dllfunc_t funcs[2]; void *( *GetCinematicsAPI )(void *); assert( !cin_libhandle ); import.Print = &CL_CinModule_Print; import.Error = &CL_CinModule_Error; import.Cvar_Get = &Cvar_Get; import.Cvar_Set = &Cvar_Set; import.Cvar_SetValue = &Cvar_SetValue; import.Cvar_ForceSet = &Cvar_ForceSet; import.Cvar_String = &Cvar_String; import.Cvar_Value = &Cvar_Value; import.Cmd_Argc = &Cmd_Argc; import.Cmd_Argv = &Cmd_Argv; import.Cmd_Args = &Cmd_Args; import.Cmd_AddCommand = &Cmd_AddCommand; import.Cmd_RemoveCommand = &Cmd_RemoveCommand; import.Cmd_ExecuteText = &Cbuf_ExecuteText; import.Cmd_Execute = &Cbuf_Execute; import.Cmd_SetCompletionFunc = &Cmd_SetCompletionFunc; import.FS_FOpenFile = &FS_FOpenFile; import.FS_Read = &FS_Read; import.FS_Write = &FS_Write; import.FS_Print = &FS_Print; import.FS_Tell = &FS_Tell; import.FS_Seek = &FS_Seek; import.FS_Eof = &FS_Eof; import.FS_Flush = &FS_Flush; import.FS_FCloseFile = &FS_FCloseFile; import.FS_RemoveFile = &FS_RemoveFile; import.FS_GetFileList = &FS_GetFileList; import.FS_IsUrl = &FS_IsUrl; import.Milliseconds = &Sys_Milliseconds; import.Microseconds = &Sys_Microseconds; import.Mem_AllocPool = &CL_CinModule_MemAllocPool; import.Mem_Alloc = &CL_CinModule_MemAlloc; import.Mem_Free = &CL_CinModule_MemFree; import.Mem_FreePool = &CL_CinModule_MemFreePool; import.Mem_EmptyPool = &CL_CinModule_MemEmptyPool; // load dynamic library cin_export = NULL; if( verbose ) { Com_Printf( "Loading CIN module... " ); } funcs[0].name = "GetCinematicsAPI"; funcs[0].funcPointer = ( void ** ) &GetCinematicsAPI; funcs[1].name = NULL; cin_libhandle = Com_LoadLibrary( LIB_DIRECTORY "/" LIB_PREFIX "cin_" ARCH LIB_SUFFIX, funcs ); if( cin_libhandle ) { // load succeeded int api_version; cin_export = GetCinematicsAPI( &import ); cin_mempool = Mem_AllocPool( NULL, "CIN Module" ); api_version = cin_export->API(); if( api_version == CIN_API_VERSION ) { if( cin_export->Init( verbose ) ) { if( verbose ) { Com_Printf( "Success.\n" ); } } else { // initialization failed Mem_FreePool( &cin_mempool ); if( verbose ) { Com_Printf( "Initialization failed.\n" ); } CIN_UnloadLibrary( verbose ); } } else { // wrong version Mem_FreePool( &cin_mempool ); Com_Printf( "CIN_LoadLibrary: wrong version: %i, not %i.\n", api_version, CIN_API_VERSION ); CIN_UnloadLibrary( verbose ); } } else { if( verbose ) { Com_Printf( "Not found.\n" ); } } Mem_DebugCheckSentinelsGlobal(); }
/* ================= Host_InitCommon ================= */ void Host_InitCommon( const char* moduleName, const char* cmdLine, const char *progname, qboolean bChangeGame ) { char dev_level[4]; char szTemp[MAX_SYSPATH]; string szRootPath; #ifdef _WIN32 MEMORYSTATUS lpBuffer; lpBuffer.dwLength = sizeof( MEMORYSTATUS ); GlobalMemoryStatus( &lpBuffer ); #endif #ifndef __ANDROID__ if( !(SDL_GetBasePath()) ) Sys_Error( "couldn't determine current directory" ); Q_strncpy(host.rootdir, SDL_GetBasePath(), sizeof(host.rootdir)); if( host.rootdir[Q_strlen( host.rootdir ) - 1] == '/' ) host.rootdir[Q_strlen( host.rootdir ) - 1] = 0; #else Q_strncpy(host.rootdir, GAMEPATH, sizeof(host.rootdir)); #endif #ifdef _WIN32 host.oldFilter = SetUnhandledExceptionFilter( Sys_Crash ); host.hInst = GetModuleHandle( NULL ); #endif host.change_game = bChangeGame; host.state = HOST_INIT; // initialzation started host.developer = host.old_developer = 0; CRT_Init(); // init some CRT functions // some commands may turn engine into infinity loop, // e.g. xash.exe +game xash -game xash // so we clearing all cmd_args, but leave dbg states as well if( cmdLine ) Sys_ParseCommandLine( cmdLine ); #ifdef _WIN32 SetErrorMode( SEM_FAILCRITICALERRORS ); // no abort/retry/fail errors #endif host.mempool = Mem_AllocPool( "Zone Engine" ); if( Sys_CheckParm( "-console" )) host.developer = 1; if( Sys_CheckParm( "-dev" )) { if( Sys_GetParmFromCmdLine( "-dev", dev_level )) { if( Q_isdigit( dev_level )) host.developer = abs( Q_atoi( dev_level )); else host.developer++; // -dev == 1, -dev -console == 2 } else host.developer++; // -dev == 1, -dev -console == 2 } host.type = HOST_NORMAL; // predict state host.con_showalways = true; #ifdef PANDORA if( Sys_CheckParm( "-noshouldermb" )) noshouldermb = 1; #endif #ifdef __ANDROID__ if (chdir(host.rootdir) == 0) MsgDev(D_INFO,"%s is working directory now",host.rootdir); else MsgDev(D_ERROR,"%s is not exists",host.rootdir); #else // we can specified custom name, from Sys_NewInstance if( SDL_GetBasePath() && !host.change_game ) { Q_strncpy( szTemp, SDL_GetBasePath(), sizeof(szTemp) ); FS_FileBase( szTemp, SI.ModuleName ); } if(moduleName) Q_strncpy(SI.ModuleName, moduleName, sizeof(SI.ModuleName)); FS_ExtractFilePath( SI.ModuleName, szRootPath ); if( Q_stricmp( host.rootdir, szRootPath )) { Q_strncpy( host.rootdir, szRootPath, sizeof( host.rootdir )); #ifdef _WIN32 SetCurrentDirectory( host.rootdir ); #else chdir( host.rootdir ); #endif } #endif if( SI.ModuleName[0] == '#' ) host.type = HOST_DEDICATED; // determine host type if( progname[0] == '#' ) { Q_strncpy( SI.ModuleName, progname + 1, sizeof( SI.ModuleName )); host.type = HOST_DEDICATED; } else Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName )); if( host.type == HOST_DEDICATED ) { // check for duplicate dedicated server host.hMutex = SDL_CreateMutex( ); if( !host.hMutex ) { MSGBOX( "Dedicated server already running" ); Sys_Quit(); return; } Sys_MergeCommandLine( cmdLine ); SDL_DestroyMutex( host.hMutex ); host.hMutex = SDL_CreateSemaphore( 0 ); if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console } else { // don't show console as default if( host.developer < D_WARN ) host.con_showalways = false; } host.old_developer = host.developer; Con_CreateConsole(); // first text message into console or log MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" ); // startup cmds and cvars subsystem Cmd_Init(); Cvar_Init(); // share developer level across all dlls Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer ); Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" ); Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" ); Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" ); FS_Init(); Image_Init(); Sound_Init(); FS_LoadGameInfo( NULL ); Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder )); if( GI->secure ) { // clear all developer levels when game is protected Cvar_FullSet( "developer", "0", CVAR_INIT ); host.developer = host.old_developer = 0; host.con_showalways = false; } HPAK_Init(); IN_Init(); Key_Init(); }
/* * CL_SoundModule_Init */ void CL_SoundModule_Init( qboolean verbose ) { static const char *sound_modules[] = { "qf", "openal" }; static const int num_sound_modules = sizeof( sound_modules )/sizeof( sound_modules[0] ); sound_import_t import; if( !s_module ) s_module = Cvar_Get( "s_module", "1", CVAR_ARCHIVE|CVAR_LATCH_SOUND ); if( !s_module_fallback ) s_module_fallback = Cvar_Get( "s_module_fallback", "2", CVAR_LATCH_SOUND ); // unload anything we have now CL_SoundModule_Shutdown( verbose ); if( verbose ) Com_Printf( "------- sound initialization -------\n" ); Cvar_GetLatchedVars( CVAR_LATCH_SOUND ); if( s_module->integer < 0 || s_module->integer > num_sound_modules ) { Com_Printf( "Invalid value for s_module (%i), reseting to default\n", s_module->integer ); Cvar_ForceSet( "s_module", s_module->dvalue ); } if( s_module_fallback->integer < 0 || s_module_fallback->integer > num_sound_modules ) { Com_Printf( "Invalid value for s_module_fallback (%i), reseting to default\n", s_module_fallback->integer ); Cvar_ForceSet( "s_module_fallback", s_module_fallback->dvalue ); } if( !s_module->integer ) { if( verbose ) { Com_Printf( "Not loading a sound module\n" ); Com_Printf( "------------------------------------\n" ); } return; } cl_soundmodulepool = Mem_AllocPool( NULL, "Client Sound Module" ); import.Error = CL_SoundModule_Error; import.Print = CL_SoundModule_Print; import.Cvar_Get = Cvar_Get; import.Cvar_Set = Cvar_Set; import.Cvar_SetValue = Cvar_SetValue; import.Cvar_ForceSet = Cvar_ForceSet; import.Cvar_String = Cvar_String; import.Cvar_Value = Cvar_Value; import.Cmd_Argc = Cmd_Argc; import.Cmd_Argv = Cmd_Argv; import.Cmd_Args = Cmd_Args; import.Cmd_AddCommand = Cmd_AddCommand; import.Cmd_RemoveCommand = Cmd_RemoveCommand; import.Cmd_ExecuteText = Cbuf_ExecuteText; import.Cmd_Execute = Cbuf_Execute; import.Cmd_SetCompletionFunc = Cmd_SetCompletionFunc; import.FS_FOpenFile = FS_FOpenFile; import.FS_Read = FS_Read; import.FS_Write = FS_Write; import.FS_Print = FS_Print; import.FS_Tell = FS_Tell; import.FS_Seek = FS_Seek; import.FS_Eof = FS_Eof; import.FS_Flush = FS_Flush; import.FS_FCloseFile = FS_FCloseFile; import.FS_RemoveFile = FS_RemoveFile; import.FS_GetFileList = FS_GetFileList; import.FS_IsUrl = FS_IsUrl; import.Milliseconds = Sys_Milliseconds; import.PageInMemory = Com_PageInMemory; import.Mem_Alloc = CL_SoundModule_MemAlloc; import.Mem_Free = CL_SoundModule_MemFree; import.Mem_AllocPool = CL_SoundModule_MemAllocPool; import.Mem_FreePool = CL_SoundModule_MemFreePool; import.Mem_EmptyPool = CL_SoundModule_MemEmptyPool; import.GetEntitySpatilization = CL_GameModule_GetEntitySpatilization; import.LoadLibrary = Com_LoadLibrary; import.UnloadLibrary = Com_UnloadLibrary; if( !CL_SoundModule_Load( sound_modules[s_module->integer-1], &import, verbose ) ) { if( s_module->integer == s_module_fallback->integer || !CL_SoundModule_Load( sound_modules[s_module_fallback->integer-1], &import, verbose ) ) { if( verbose ) { Com_Printf( "Couldn't load a sound module\n" ); Com_Printf( "------------------------------------\n" ); } Mem_FreePool( &cl_soundmodulepool ); se = NULL; return; } Cvar_ForceSet( "s_module", va( "%i", s_module_fallback->integer ) ); } CL_SoundModule_SetAttenuationModel(); // check memory integrity Mem_CheckSentinelsGlobal(); if( verbose ) Com_Printf( "------------------------------------\n" ); }
/* ================= Host_InitCommon ================= */ void Host_InitCommon( int argc, const char** argv, const char *progname, qboolean bChangeGame ) { char dev_level[4]; char *baseDir; // some commands may turn engine into infinite loop, // e.g. xash.exe +game xash -game xash // so we clear all cmd_args, but leave dbg states as well Sys_ParseCommandLine( argc, argv ); host.enabledll = !Sys_CheckParm( "-nodll" ); host.shutdown_issued = false; host.crashed = false; #ifdef DLL_LOADER if( host.enabledll ) Setup_LDT_Keeper( ); // Must call before any thread creating #endif #if defined(XASH_SDL) && !(defined(PANDORA) || defined(RPI)) if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS )) { Sys_Error( "SDL_Init: %s", SDL_GetError() ); } #endif if( ( baseDir = getenv( "XASH3D_BASEDIR" ) ) ) { Q_strncpy( host.rootdir, baseDir, sizeof(host.rootdir) ); } else { #if defined(PANDORA) || defined(RPI) Q_strncpy( host.rootdir, ".", sizeof( host.rootdir ) ); #else #if defined(XASH_SDL) if( !( baseDir = SDL_GetBasePath() ) ) Sys_Error( "couldn't determine current directory: %s", SDL_GetError() ); Q_strncpy( host.rootdir, baseDir, sizeof( host.rootdir ) ); #else if( !getcwd( host.rootdir, sizeof(host.rootdir) ) ) host.rootdir[0] = 0; #endif #endif } if( host.rootdir[Q_strlen( host.rootdir ) - 1] == '/' ) host.rootdir[Q_strlen( host.rootdir ) - 1] = 0; if( !Sys_CheckParm( "-noch" ) ) { Sys_SetupCrashHandler(); } host.change_game = bChangeGame; host.state = HOST_INIT; // initialization started host.developer = host.old_developer = 0; host.textmode = false; host.mempool = Mem_AllocPool( "Zone Engine" ); if( Sys_CheckParm( "-console" )) host.developer = 1; if( Sys_CheckParm( "-dev" )) { if( Sys_GetParmFromCmdLine( "-dev", dev_level )) { if( Q_isdigit( dev_level )) host.developer = abs( Q_atoi( dev_level )); else host.developer++; // -dev == 1, -dev -console == 2 } else host.developer++; // -dev == 1, -dev -console == 2 } #ifdef XASH_DEDICATED host.type = HOST_DEDICATED; // predict state #else if( Sys_CheckParm("-dedicated") || progname[0] == '#' ) host.type = HOST_DEDICATED; else host.type = HOST_NORMAL; #endif host.con_showalways = true; host.mouse_visible = false; #ifdef XASH_SDL if( SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS )) { SDL_Init( SDL_INIT_TIMER ); host.type = HOST_DEDICATED; } #endif if ( SetCurrentDirectory( host.rootdir ) != 0) MsgDev( D_INFO, "%s is working directory now\n", host.rootdir ); else Sys_Error( "Changing working directory to %s failed.\n", host.rootdir ); // set default gamedir if( progname[0] == '#' ) progname++; Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName )); if( host.type == HOST_DEDICATED ) { Sys_MergeCommandLine( ); if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console } else { // don't show console as default if( host.developer < D_WARN ) host.con_showalways = false; } host.old_developer = host.developer; if( !Sys_CheckParm( "-nowcon" ) ) Con_CreateConsole(); // first text message into console or log MsgDev( D_NOTE, "Sys_LoadLibrary: Loading Engine Library - ok\n" ); // startup cmds and cvars subsystem Cmd_Init(); Cvar_Init(); // share developer level across all dlls Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer ); Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" ); Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" ); Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" ); Cmd_AddCommand( "userconfigd", Host_Userconfigd_f, "execute all scripts from userconfig.d" ); cmd_scripting = Cvar_Get( "cmd_scripting", "0", CVAR_ARCHIVE, "enable simple condition checking and variable operations" ); FS_Init(); Image_Init(); Sound_Init(); FS_LoadGameInfo( NULL ); Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder )); #if !(defined(PANDORA) || defined(RPI)) if( GI->secure ) { // clear all developer levels when game is protected Cvar_FullSet( "developer", "0", CVAR_INIT ); host.developer = host.old_developer = 0; host.con_showalways = false; } #endif HPAK_Init(); IN_Init(); Key_Init(); }
/* * R_InitSkinFiles */ void R_InitSkinFiles( void ) { r_skinsPool = Mem_AllocPool( NULL, "Skins" ); memset( r_skinfiles, 0, sizeof( r_skinfiles ) ); }