/* * CL_InitInputDynvars */ void CL_InitInputDynvars( void ) { Dynvar_Create( "m_filterBufferSize", true, CL_MouseFilterBufferSizeGet_f, CL_MouseFilterBufferSizeSet_f ); Dynvar_Create( "m_filterBufferDecay", true, CL_MouseFilterBufferDecayGet_f, CL_MouseFilterBufferDecaySet_f ); // we could simply call Dynvar_SetValue(m_filterBufferSize, "5") here, but then the user would get a warning in the console if m_filter was != M_FILTER_EXTRAPOLATE buf_size = DEFAULT_BUF_SIZE; buf_x = (float *) Mem_ZoneMalloc( sizeof( float ) * buf_size ); buf_y = (float *) Mem_ZoneMalloc( sizeof( float ) * buf_size ); memset( buf_x, 0, sizeof( float ) * buf_size ); memset( buf_y, 0, sizeof( float ) * buf_size ); }
/* * Sys_InitTimeDynvar */ void Sys_InitTimeDynvar( void ) { QueryPerformanceFrequency( (LARGE_INTEGER *) &hwtimer_freq ); hwtimer_var = Dynvar_Create( "sys_hwtimer", 1, Sys_GetHwTimer_f, Sys_SetHwTimer_f ); assert( hwtimer_var ); Dynvar_AddListener( hwtimer_var, Sys_SynchronizeTimers_f ); Dynvar_SetValue( hwtimer_var, "0" ); }
/* * Sys_InitDynvars */ void Sys_InitDynvars( void ) { char *dummyStr; dynvar_t *affinity_var; affinity_var = Dynvar_Create( "sys_affinity", true, Sys_GetAffinity_f, Sys_SetAffinity_f ); assert( affinity_var ); Dynvar_GetValue( affinity_var, (void **)&dummyStr ); assert( dummyStr ); Dynvar_SetValue( affinity_var, dummyStr ); Sys_InitTimeDynvar(); }
/* * Key_Init */ void Key_Init( void ) { int i; assert( !key_initialized ); // // init ascii characters in console mode // for( i = 32; i < 128; i++ ) consolekeys[i] = qtrue; consolekeys[K_ENTER] = qtrue; consolekeys[KP_ENTER] = qtrue; consolekeys[K_TAB] = qtrue; consolekeys[K_LEFTARROW] = qtrue; consolekeys[KP_LEFTARROW] = qtrue; consolekeys[K_RIGHTARROW] = qtrue; consolekeys[KP_RIGHTARROW] = qtrue; consolekeys[K_UPARROW] = qtrue; consolekeys[KP_UPARROW] = qtrue; consolekeys[K_DOWNARROW] = qtrue; consolekeys[KP_DOWNARROW] = qtrue; consolekeys[K_BACKSPACE] = qtrue; consolekeys[K_HOME] = qtrue; consolekeys[KP_HOME] = qtrue; consolekeys[K_END] = qtrue; consolekeys[KP_END] = qtrue; consolekeys[K_PGUP] = qtrue; consolekeys[KP_PGUP] = qtrue; consolekeys[K_PGDN] = qtrue; consolekeys[KP_PGDN] = qtrue; consolekeys[K_LSHIFT] = qtrue; consolekeys[K_RSHIFT] = qtrue; consolekeys[K_INS] = qtrue; consolekeys[K_DEL] = qtrue; consolekeys[KP_INS] = qtrue; consolekeys[KP_DEL] = qtrue; consolekeys[KP_SLASH] = qtrue; consolekeys[KP_PLUS] = qtrue; consolekeys[KP_MINUS] = qtrue; consolekeys[KP_5] = qtrue; consolekeys[K_WIN] = qtrue; // consolekeys[K_LWIN] = qtrue; // consolekeys[K_RWIN] = qtrue; consolekeys[K_MENU] = qtrue; consolekeys[K_LCTRL] = qtrue; // wsw : pb : ctrl in console for ctrl-v consolekeys[K_RCTRL] = qtrue; consolekeys[K_LALT] = qtrue; consolekeys[K_RALT] = qtrue; consolekeys['`'] = qfalse; consolekeys['~'] = qfalse; // wsw : pb : support mwheel in console consolekeys[K_MWHEELDOWN] = qtrue; consolekeys[K_MWHEELUP] = qtrue; menubound[K_ESCAPE] = qtrue; // Vic: allow to bind F1-F12 from the menu // for (i=0 ; i<12 ; i++) // menubound[K_F1+i] = qtrue; // // register our functions // Cmd_AddCommand( "bind", Key_Bind_f ); Cmd_AddCommand( "unbind", Key_Unbind_f ); Cmd_AddCommand( "unbindall", Key_Unbindall ); Cmd_AddCommand( "bindlist", Key_Bindlist_f ); // wsw : aiwa : create dynvar for alternative color escape character key_colorEscape = Dynvar_Create( "key_colorEscape", qtrue, Key_GetColorEscape_f, Key_SetColorEscape_f ); in_debug = Cvar_Get( "in_debug", "0", 0 ); key_initialized = qtrue; }
/* * Qcommon_Init */ void Qcommon_Init( int argc, char **argv ) { if( setjmp( abortframe ) ) Sys_Error( "Error during initialization: %s", com_errormsg ); QThreads_Init(); com_print_mutex = QMutex_Create(); // initialize memory manager Memory_Init(); // prepare enough of the subsystems to handle // cvar and command buffer management COM_InitArgv( argc, argv ); Cbuf_Init(); // initialize cmd/cvar/dynvar tries Cmd_PreInit(); Cvar_PreInit(); Dynvar_PreInit(); // create basic commands and cvars Cmd_Init(); Cvar_Init(); Dynvar_Init(); dynvars_initialized = qtrue; wswcurl_init(); Key_Init(); // we need to add the early commands twice, because // a basepath or cdpath needs to be set before execing // config files, but we want other parms to override // the settings of the config files Cbuf_AddEarlyCommands( qfalse ); Cbuf_Execute(); // wsw : aiwa : create dynvars (needs to be completed before .cfg scripts are executed) Dynvar_Create( "sys_uptime", qtrue, Com_Sys_Uptime_f, DYNVAR_READONLY ); Dynvar_Create( "frametick", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); Dynvar_Create( "quit", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); Dynvar_Create( "irc_connected", qfalse, Irc_GetConnected_f, Irc_SetConnected_f ); Sys_InitDynvars(); CL_InitDynvars(); #ifdef TV_SERVER_ONLY tv_server = Cvar_Get( "tv_server", "1", CVAR_NOSET ); Cvar_ForceSet( "tv_server", "1" ); #else tv_server = Cvar_Get( "tv_server", "0", CVAR_NOSET ); #endif #ifdef DEDICATED_ONLY dedicated = Cvar_Get( "dedicated", "1", CVAR_NOSET ); Cvar_ForceSet( "dedicated", "1" ); #else dedicated = Cvar_Get( "dedicated", "0", CVAR_NOSET ); #endif #ifdef MATCHMAKER mm_server = Cvar_Get( "mm_server", "1", CVAR_READONLY ); Cvar_ForceSet( "mm_server", "1" ); #else mm_server = Cvar_Get( "mm_server", "0", CVAR_READONLY ); #endif FS_Init(); Cbuf_AddText( "exec default.cfg\n" ); if( !dedicated->integer ) { Cbuf_AddText( "exec config.cfg\n" ); Cbuf_AddText( "exec autoexec.cfg\n" ); } else if( mm_server->integer ) { Cbuf_AddText( "exec mmaker_autoexec.cfg\n" ); } else if( tv_server->integer ) { Cbuf_AddText( "exec tvserver_autoexec.cfg\n" ); } else { Cbuf_AddText( "exec dedicated_autoexec.cfg\n" ); } Cbuf_AddEarlyCommands( qtrue ); Cbuf_Execute(); // // init commands and vars // Memory_InitCommands(); Qcommon_InitCommands(); host_speeds = Cvar_Get( "host_speeds", "0", 0 ); log_stats = Cvar_Get( "log_stats", "0", 0 ); developer = Cvar_Get( "developer", "0", 0 ); timescale = Cvar_Get( "timescale", "1.0", CVAR_CHEAT ); fixedtime = Cvar_Get( "fixedtime", "0", CVAR_CHEAT ); if( tv_server->integer ) logconsole = Cvar_Get( "logconsole", "tvconsole.log", CVAR_ARCHIVE ); else if( dedicated->integer ) logconsole = Cvar_Get( "logconsole", "wswconsole.log", CVAR_ARCHIVE ); else logconsole = Cvar_Get( "logconsole", "", CVAR_ARCHIVE ); logconsole_append = Cvar_Get( "logconsole_append", "1", CVAR_ARCHIVE ); logconsole_flush = Cvar_Get( "logconsole_flush", "0", CVAR_ARCHIVE ); logconsole_timestamp = Cvar_Get( "logconsole_timestamp", "0", CVAR_ARCHIVE ); com_showtrace = Cvar_Get( "com_showtrace", "0", 0 ); com_introPlayed3 = Cvar_Get( "com_introPlayed3", "0", CVAR_ARCHIVE ); Cvar_Get( "irc_server", "irc.quakenet.org", CVAR_ARCHIVE ); Cvar_Get( "irc_port", "6667", CVAR_ARCHIVE ); Cvar_Get( "irc_nick", APPLICATION "Player", CVAR_ARCHIVE ); Cvar_Get( "irc_user", APPLICATION "User", CVAR_ARCHIVE ); Cvar_Get( "irc_password", "", CVAR_ARCHIVE ); Cvar_Get( "gamename", APPLICATION, CVAR_READONLY ); versioncvar = Cvar_Get( "version", APP_VERSION_STR " " CPUSTRING " " __DATE__ " " BUILDSTRING, CVAR_SERVERINFO|CVAR_READONLY ); revisioncvar = Cvar_Get( "revision", SVN_RevString(), CVAR_READONLY ); Sys_Init(); NET_Init(); Netchan_Init(); CM_Init(); Steam_LoadLibrary(); Com_ScriptModule_Init(); MM_Init(); SV_Init(); CL_Init(); SCR_EndLoadingPlaque(); if( !dedicated->integer ) { Cbuf_AddText( "exec stuffcmds.cfg\n" ); } else if( mm_server->integer ) { Cbuf_AddText( "exec mmaker_stuffcmds.cfg\n" ); } else if( tv_server->integer ) { Cbuf_AddText( "exec tvserver_stuffcmds.cfg\n" ); } else { Cbuf_AddText( "exec dedicated_stuffcmds.cfg\n" ); } // add + commands from command line if( !Cbuf_AddLateCommands() ) { // if the user didn't give any commands, run default action if( !dedicated->integer ) { // only play the introduction sequence once if( !com_introPlayed3->integer ) { Cvar_ForceSet( com_introPlayed3->name, "1" ); #if !defined(__MACOSX__) && !defined(__ANDROID__) Cbuf_AddText( "cinematic intro.roq\n" ); #endif } } } else { // the user asked for something explicit // so drop the loading plaque SCR_EndLoadingPlaque(); } Com_Printf( "\n====== %s Initialized ======\n", APPLICATION ); Cbuf_Execute(); }
/* ================== SCR_UpdateScreen This is called every frame, and can also be called explicitly to flush text to the screen. ================== */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } for( i = 0; i < numframes; i++ ) { R_BeginFrame( separation[i], scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_DrawConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( SCR_GetCinematicTime() > 0 ) { SCR_DrawCinematic(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_DrawConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_DrawConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); R_EndFrame(); } }
/* * SCR_UpdateScreen * * This is called every frame, and can also be called explicitly to flush * text to the screen. */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; qboolean scr_cinematic; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet Con_CheckResize(); SCR_CheckSystemFontsModified(); /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } // avoid redrawing fullscreen cinematics unless damaged by console drawing scr_cinematic = cls.state == CA_CINEMATIC ? qtrue : qfalse; // if( scr_cinematic && !cl.cin.redraw && !scr_con_current && !scr_con_previous ) { // return; // } if( cls.cgameActive && cls.state < CA_LOADING ) { // this is when we've finished loading cgame media and are waiting // for the first valid snapshot to arrive. keep the loading screen untouched return; } for( i = 0; i < numframes; i++ ) { re.BeginFrame( separation[i], scr_cinematic || scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_UpdateConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( scr_cinematic ) { SCR_DrawCinematic(); SCR_DrawConsole(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue, qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_GETTING_TICKET || cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_UpdateConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_UpdateConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse, qtrue ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); re.EndFrame(); } }
/* * SCR_UpdateScreen * * This is called every frame, and can also be called explicitly to flush * text to the screen. */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; bool cinematic; bool forcevsync, forceclear; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", false, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized || !re.ScreenEnabled() ) return; // not ready yet Con_CheckResize(); SCR_CheckSystemFontsModified(); /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } cinematic = cls.state == CA_CINEMATIC ? true : false; forcevsync = cinematic; forceclear = cinematic; for( i = 0; i < numframes; i++ ) { re.BeginFrame( separation[i], forceclear, forcevsync ); if( scr_draw_loading == 2 ) { // loading plaque over APP_STARTUP_COLOR screen scr_draw_loading = 0; CL_UIModule_UpdateConnectScreen( true ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( cinematic ) { SCR_DrawCinematic(); SCR_DrawConsole(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( true, true ); SCR_DrawConsole(); } else if( cls.state == CA_GETTING_TICKET || cls.state == CA_CONNECTING || cls.state == CA_HANDSHAKE ) { CL_UIModule_UpdateConnectScreen( true ); } else if( cls.state == CA_CONNECTED ) { if( cls.cgameActive ) { CL_UIModule_UpdateConnectScreen( false ); SCR_RenderView( separation[i] ); } else { CL_UIModule_UpdateConnectScreen( true ); } } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( false, true ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); re.EndFrame(); } }