/* ==================== CL_Init ==================== */ void CL_Init( void ) { qboolean loaded; Q_memset( &cls, 0, sizeof( cls ) ); if( Host_IsDedicated() ) return; // nothing running on the client Con_Init(); CL_InitLocal(); R_Init(); // init renderer S_Init(); // init sound // unreliable buffer. unsed for unreliable commands and voice stream BF_Init( &cls.datagram, "cls.datagram", cls.datagram_buf, sizeof( cls.datagram_buf )); IN_TouchInit(); #if defined (__ANDROID__) { char clientlib[256]; Q_snprintf( clientlib, sizeof(clientlib), "%s/" CLIENTDLL, getenv("XASH3D_GAMELIBDIR")); loaded = CL_LoadProgs( clientlib ); if( !loaded ) { Q_snprintf( clientlib, sizeof(clientlib), "%s/" CLIENTDLL, getenv("XASH3D_ENGLIBDIR")); loaded = CL_LoadProgs( clientlib ); } } #else { char clientlib[256]; Com_ResetLibraryError(); if( Sys_GetParmFromCmdLine( "-clientlib", clientlib ) ) loaded = CL_LoadProgs( clientlib ); else loaded = CL_LoadProgs( va( "%s/%s" , GI->dll_path, SI.clientlib )); if( !loaded ) { loaded = CL_LoadProgs( CLIENTDLL ); } } #endif if( loaded ) { cls.initialized = true; cls.keybind_changed = false; cl.maxclients = 1; // allow to drawing player in menu cls.olddemonum = -1; cls.demonum = -1; } else Sys_Warn("Could not load client library:\n%s", Com_GetLibraryError()); }
/* ================== SCR_Init ================== */ void SCR_Init( void ) { if( scr_init ) return; MsgDev( D_NOTE, "SCR_Init()\n" ); scr_centertime = Cvar_Get( "scr_centertime", "2.5", 0, "centerprint hold time" ); cl_levelshot_name = Cvar_Get( "cl_levelshot_name", "*black", 0, "contains path to current levelshot" ); cl_allow_levelshots = Cvar_Get( "allow_levelshots", "0", CVAR_ARCHIVE, "allow engine to use indivdual levelshots instead of 'loading' image" ); scr_loading = Cvar_Get( "scr_loading", "0", 0, "loading bar progress" ); scr_download = Cvar_Get( "scr_download", "0", 0, "downloading bar progress" ); cl_testlights = Cvar_Get( "cl_testlights", "0", 0, "test dynamic lights" ); cl_envshot_size = Cvar_Get( "cl_envshot_size", "256", CVAR_ARCHIVE, "envshot size of cube side" ); scr_dark = Cvar_Get( "v_dark", "0", 0, "starts level from dark screen" ); scr_viewsize = Cvar_Get( "viewsize", "120", CVAR_ARCHIVE, "screen size" ); // register our commands Cmd_AddCommand( "timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" ); Cmd_AddCommand( "skyname", CL_SetSky_f, "set new skybox by basename" ); Cmd_AddCommand( "viewpos", SCR_Viewpos_f, "prints current player origin" ); Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" ); Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" ); Com_ResetLibraryError(); if( host.state != HOST_RESTART && !UI_LoadProgs( )) { Sys_Warn( "can't initialize menu library:\n%s", Com_GetLibraryError() ); // this is not fatal for us // console still can't be toggled in-game without extra cmd-line switch if( !host.developer ) host.developer = 1; // we need console, because menu is missing } SCR_LoadCreditsFont (); SCR_InstallParticlePalette (); SCR_RegisterTextures (); SCR_InitCinematic(); CL_InitNetgraph(); SCR_VidInit(); if( host.state != HOST_RESTART ) { if( host.developer && Sys_CheckParm( "-toconsole" )) Cbuf_AddText( "toggleconsole\n" ); else UI_SetActiveMenu( true ); } scr_init = true; }
/* =============== CL_ChangeGame This is experiment. Use with precaution =============== */ qboolean CL_ChangeGame( const char *gamefolder, qboolean bReset ) { if( Host_IsDedicated() ) return false; if( Q_stricmp( host.gamefolder, gamefolder )) { kbutton_t *mlook, *jlook; qboolean mlook_active = false, jlook_active = false; string mapname, maptitle; int maxEntities; mlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_mlook" ); jlook = (kbutton_t *)clgame.dllFuncs.KB_Find( "in_jlook" ); if( mlook && ( mlook->state & 1 )) mlook_active = true; if( jlook && ( jlook->state & 1 )) jlook_active = true; // so reload all images (remote connect) Mod_ClearAll( true ); R_ShutdownImages(); FS_LoadGameInfo( (bReset) ? host.gamefolder : gamefolder ); R_InitImages(); // save parms maxEntities = clgame.maxEntities; Q_strncpy( mapname, clgame.mapname, MAX_STRING ); Q_strncpy( maptitle, clgame.maptitle, MAX_STRING ); Com_ResetLibraryError(); if( !CL_LoadProgs( va( "%s/%s", GI->dll_path, GI->client_lib))) Sys_Warn( "Can't initialize client library\n%s", Com_GetLibraryError() ); // restore parms clgame.maxEntities = maxEntities; Q_strncpy( clgame.mapname, mapname, MAX_STRING ); Q_strncpy( clgame.maptitle, maptitle, MAX_STRING ); // invalidate fonts so we can reloading them again Q_memset( &cls.creditsFont, 0, sizeof( cls.creditsFont )); SCR_InstallParticlePalette(); SCR_LoadCreditsFont(); Con_InvalidateFonts(); SCR_RegisterTextures (); CL_FreeEdicts (); SCR_VidInit (); if( cls.key_dest == key_game ) // restore mouse state clgame.dllFuncs.IN_ActivateMouse(); // restore mlook state if( mlook_active ) Cmd_ExecuteString( "+mlook\n", src_command ); if( jlook_active ) Cmd_ExecuteString( "+jlook\n", src_command ); return true; } return false; }
/* ================ VGui_Startup Load vgui_support library and call VGui_Startup ================ */ void VGui_Startup( int width, int height ) { static qboolean failed = false; if( failed ) return; if(!vgui.initialized) { void (*F) ( vguiapi_t * ); char vguiloader[256]; char vguilib[256]; Com_ResetLibraryError(); // hack: load vgui with correct path first if specified. // it will be reused while resolving vgui support and client deps if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) ) { if( Q_strstr( vguilib, ".dll") ) Q_strncpy( vguiloader, "vgui_support.dll", 256 ); else Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 ); if( !Com_LoadLibrary( vguilib, false ) ) MsgDev( D_WARN, "VGUI preloading failed. Default library will be used!\n"); } if( !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) ) Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 ); lib = Com_LoadLibrary( vguiloader, false ); if(!lib) MsgDev( D_ERROR, "Failed to load vgui_support library: %s", Com_GetLibraryError() ); else { F = Com_GetProcAddress( lib, "InitAPI" ); if( F ) { F( &vgui ); vgui.initialized = true; VGUI_InitCursors(); } else MsgDev( D_ERROR, "Failed to find vgui_support library entry point!\n" ); } } // vgui may crash if it cannot find font if( width <= 320 ) width = 320; else if( width <= 400 ) width = 400; else if( width <= 512 ) width = 512; else if( width <= 640 ) width = 640; else if( width <= 800 ) width = 800; else if( width <= 1024 ) width = 1024; else if( width <= 1152 ) width = 1152; else if( width <= 1280 ) width = 1280; else //if( width <= 1600 ) width = 1600; if( vgui.initialized ) { //host.mouse_visible = true; vgui.Startup( width, height ); } else failed = true; }