2019-10-25 17:07:14 +00:00
/*
* * gamecvars . cpp
* *
* * most of the game CVARs from the frontend consolidated to only have one instance
* *
* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* * Copyright 2019 Christoph Oelckers
* * All rights reserved .
* *
* * Redistribution and use in source and binary forms , with or without
* * modification , are permitted provided that the following conditions
* * are met :
* *
* * 1. Redistributions of source code must retain the above copyright
* * notice , this list of conditions and the following disclaimer .
* * 2. Redistributions in binary form must reproduce the above copyright
* * notice , this list of conditions and the following disclaimer in the
* * documentation and / or other materials provided with the distribution .
* * 3. The name of the author may not be used to endorse or promote products
* * derived from this software without specific prior written permission .
* *
* * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* * IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* * INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* * NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* * DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* * THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* * THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* *
* *
*/
2019-10-21 22:18:58 +00:00
# include "c_cvars.h"
# include "common.h"
2019-10-22 21:31:46 +00:00
# include "baselayer.h"
# include "gameconfigfile.h"
2019-10-26 07:22:49 +00:00
# include "gamecontrol.h"
2019-10-27 08:38:55 +00:00
# include "m_argv.h"
2019-10-27 12:40:24 +00:00
# include "rts.h"
2019-11-10 10:42:25 +00:00
# include "stats.h"
2020-04-12 06:07:48 +00:00
# include "raze_music.h"
2019-12-02 23:57:03 +00:00
# include "c_dispatch.h"
# include "gstrings.h"
2019-12-08 23:33:14 +00:00
# include "quotemgr.h"
2019-10-21 22:18:58 +00:00
2020-04-11 22:04:02 +00:00
# define CVAR_FRONTEND_BLOOD 0
# define CVAR_FRONTEND_DUKELIKE 0
2019-10-21 22:52:07 +00:00
/* Notes
RedNukem has this for the toggle autorun command . Todo : Check what this is supposed to accomplish . The implementation makes no sense at all .
( ! RRRA | | ( ! g_player [ myconnectindex ] . ps - > on_motorcycle & & ! g_player [ myconnectindex ] . ps - > on_boat ) ) )
*/
2019-10-21 22:18:58 +00:00
CVARD ( Bool , cl_crosshair , true , CVAR_ARCHIVE , " enable/disable crosshair " ) ;
2019-10-21 22:58:51 +00:00
CVARD ( Bool , cl_automsg , false , CVAR_ARCHIVE , " enable/disable automatically sending messages to all players " ) // Not implemented for Blood
2019-12-08 23:33:14 +00:00
CVARD ( Bool , cl_autorun , true , CVAR_ARCHIVE , " enable/disable autorun " )
2019-10-21 22:52:07 +00:00
CVARD ( Bool , cl_runmode , true , CVAR_ARCHIVE , " enable/disable modernized run key operation " )
2019-12-05 00:08:35 +00:00
bool G_CheckAutorun ( bool button )
{
if ( cl_runmode ) return button | | cl_autorun ;
else return button ^ ! ! cl_autorun ;
}
2019-10-21 22:58:51 +00:00
CVARD ( Bool , cl_autosave , true , CVAR_ARCHIVE , " enable/disable autosaves " ) // Not implemented for Blood (but looks like the other games never check it either.)
CVARD ( Bool , cl_autosavedeletion , true , CVAR_ARCHIVE , " enable/disable automatic deletion of autosaves " ) // Not implemented for Blood
CVARD ( Int , cl_maxautosaves , 8 , CVAR_ARCHIVE , " number of autosaves to keep before deleting the oldest " ) // Not implemented for Blood
2019-10-21 23:00:22 +00:00
CVARD ( Int , cl_cheatmask , ~ 0 , CVAR_ARCHIVE , " configure what cheats show in the cheats menu " )
CVARD ( Bool , cl_obituaries , true , CVAR_ARCHIVE , " enable/disable multiplayer death messages " ) // Not implemented for Blood
CVARD ( Bool , cl_democams , true , CVAR_ARCHIVE , " enable/disable demo playback cameras " ) // Not implemented for Blood
2019-10-27 16:55:14 +00:00
CVARD ( Bool , cl_idplayers , true , CVAR_ARCHIVE , " enable/disable name display when aiming at opponents " )
2019-10-21 23:00:22 +00:00
CVARD ( Bool , cl_weaponsway , true , CVAR_ARCHIVE , " enable/disable player weapon swaying " ) // Not implemented for Blood
2019-10-21 22:18:58 +00:00
2019-10-22 00:15:24 +00:00
// Todo: Consolidate these to be consistent across games?
2019-10-22 22:30:51 +00:00
CVARD ( Bool , cl_viewbob , true , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " enable/disable player head bobbing " ) // Not implemented for Blood
CVARD ( Bool , cl_viewhbob , true , CVAR_ARCHIVE | CVAR_FRONTEND_BLOOD , " enable/disable view horizontal bobbing " ) // Only implemented in Blood
CVARD ( Bool , cl_viewvbob , true , CVAR_ARCHIVE | CVAR_FRONTEND_BLOOD , " enable/disable view vertical bobbing " ) // Only implemented in Blood
2019-10-22 00:15:24 +00:00
CVARD ( Bool , cl_interpolate , true , CVAR_ARCHIVE , " enable/disable view interpolation " ) // only implemented in Blood
CVARD ( Bool , cl_slopetilting , false , CVAR_ARCHIVE , " enable/disable slope tilting " ) // only implemented in Blood
2019-10-27 12:48:03 +00:00
CVARD ( Int , cl_showweapon , 1 , CVAR_ARCHIVE , " enable/disable show weapons " ) // only implemented in Blood
2020-05-22 23:26:51 +00:00
CVARD ( Bool , cl_sointerpolation , true , CVAR_ARCHIVE , " enable/disable sector object interpolation " ) // only implemented in SW
2019-10-22 15:47:24 +00:00
CUSTOM_CVARD ( Int , cl_crosshairscale , 50 , CVAR_ARCHIVE , " changes the size of the crosshair " )
{
if ( self < 1 ) self = 1 ;
else if ( self > 100 ) self = 100 ;
}
2019-10-22 15:00:22 +00:00
2019-10-22 00:15:24 +00:00
2019-10-22 15:47:24 +00:00
CUSTOM_CVARD ( Int , cl_autoaim , 1 , CVAR_ARCHIVE | CVAR_USERINFO , " enable/disable weapon autoaim " )
2019-10-21 22:18:58 +00:00
{
2019-12-18 18:17:37 +00:00
if ( self < 0 | | self > ( ( g_gameType & GAMEFLAG_BLOOD ) ? 2 : 3 ) ) self = 1 ; // The Shadow Warrior backend only has a bool for this.
2019-10-21 22:18:58 +00:00
} ;
2019-10-22 15:47:24 +00:00
CUSTOM_CVARD ( Int , cl_weaponswitch , 3 , CVAR_ARCHIVE | CVAR_USERINFO , " enable/disable auto weapon switching " )
2019-10-22 00:31:14 +00:00
{
if ( self < 0 ) self = 0 ;
2020-02-12 21:46:18 +00:00
if ( self > 1 & & ( g_gameType & GAMEFLAG_SW ) ) self = 1 ;
2019-12-18 18:17:37 +00:00
if ( self > 3 & & ( g_gameType & GAMEFLAG_BLOOD ) ) self = 3 ;
2019-10-22 00:31:14 +00:00
if ( self > 7 ) self = 7 ;
}
2019-10-21 23:00:22 +00:00
CUSTOM_CVARD ( Int , cl_autovote , 0 , CVAR_ARCHIVE , " enable/disable automatic voting " )
{
if ( self < 0 | | self > 2 ) self = 0 ;
}
2020-01-26 21:22:41 +00:00
2019-10-22 00:01:05 +00:00
// Demos
2019-10-21 23:06:02 +00:00
CVARD_NAMED ( Bool , demorec_seeds , demorec_seeds_cvar , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable recording of random seed for later sync checking " )
CVARD_NAMED ( Bool , demorec_diffs , demorec_diffs_cvar , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable diff recording in demos " )
CVARD_NAMED ( Bool , demorec_force , demorec_force_cvar , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable forced demo recording " )
CVARD_NAMED ( Int , demorec_difftics , demorec_difftics_cvar , 60 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " sets game tic interval after which a diff is recorded " )
CVARD ( Bool , demoplay_diffs , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable application of diffs in demo playback " )
CVARD ( Bool , demoplay_showsync , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable display of sync status " )
2019-10-22 00:01:05 +00:00
// Sound
2019-12-07 20:39:17 +00:00
CUSTOM_CVARD ( Bool , snd_ambience , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL , " enables/disables ambient sounds " ) // Not implemented for Blood
2019-12-07 19:48:16 +00:00
{
gi - > SetAmbience ( self ) ;
}
2019-10-22 00:01:05 +00:00
CVARD ( Bool , snd_enabled , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enables/disables sound effects " )
CVARD ( Bool , snd_tryformats , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enables/disables automatic discovery of replacement sounds and music in .flac and .ogg formats " )
CVARD ( Bool , snd_doppler , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable 3d sound " )
CVARD ( Bool , mus_restartonload , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " restart the music when loading a saved game with the same map or not " ) // only implemented for Blood - todo: generalize
2019-12-26 12:04:29 +00:00
CVARD ( Bool , mus_redbook , true , CVAR_ARCHIVE , " enables/disables redbook audio " )
2019-10-22 00:01:05 +00:00
CUSTOM_CVARD ( Int , snd_fxvolume , 255 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " controls volume for sound effects " )
{
if ( self < 0 ) self = 0 ;
if ( self > 255 ) self = 255 ;
}
CUSTOM_CVARD ( Int , snd_mixrate , 44100 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " sound mixing rate " )
{
if ( self < 11025 ) self = 11025 ;
else if ( self > 48000 ) self = 48000 ;
}
2020-01-28 20:31:48 +00:00
CUSTOM_CVARD ( Int , snd_speech , 1 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enables/disables player speech " )
2019-10-22 00:01:05 +00:00
{
2019-10-22 21:31:46 +00:00
if ( self < 0 ) self = 0 ;
2020-01-28 20:31:48 +00:00
else if ( self > 1 ) self = 1 ;
2019-10-22 00:01:05 +00:00
}
2019-10-24 18:28:46 +00:00
2019-10-22 21:31:46 +00:00
// HUD
2019-10-25 17:07:14 +00:00
// This was particularly messy. EDuke and Rednukem had no consistent setting for this but a complex combination of 4 CVARs and lots of mod flags controlling the HUD layout
2019-10-22 22:30:51 +00:00
// NBlood had this differently with an inverted scale of 0-7 with 0 having no HUD.
2019-10-25 17:07:14 +00:00
// For consistency all frontends now use the same scale, with 0 being the smallest and 11 being the largest, which get converted to the internal settings by the set_hud_layout callback.
2020-01-22 12:53:26 +00:00
int hud_size_max = 11 ; // 11 is for Duke Nukem and its offspring games.
2019-10-22 22:30:51 +00:00
CUSTOM_CVARD ( Int , hud_size , 9 , CVAR_ARCHIVE | CVAR_NOINITCALL , " Defines the HUD size and style " )
2019-10-22 21:31:46 +00:00
{
if ( self < 0 ) self = 0 ;
2020-01-22 12:53:26 +00:00
else if ( self > hud_size_max ) self = hud_size_max ;
2019-10-22 21:31:46 +00:00
else
{
if ( gi - > validate_hud ( self ) )
gi - > set_hud_layout ( self ) ;
else
2020-04-11 21:45:45 +00:00
Printf ( " Hud size %d not available \n " , * self ) ;
2019-10-22 21:31:46 +00:00
}
}
2019-10-22 22:30:51 +00:00
CUSTOM_CVARD ( Int , hud_scale , 100 , CVAR_ARCHIVE | CVAR_NOINITCALL , " changes the hud scale " )
2019-10-22 21:31:46 +00:00
{
2020-02-13 23:56:23 +00:00
if ( self < 35 ) self = 35 ;
2019-10-22 21:31:46 +00:00
else if ( self > 100 ) self = 100 ;
2020-03-22 09:20:59 +00:00
else gi - > set_hud_scale ( self ) ;
2019-10-22 21:31:46 +00:00
}
// This is to allow flattening the overly complicated HUD configuration to one single value and keep the complexity safely inside the HUD code.
bool G_ChangeHudLayout ( int direction )
{
2019-10-22 22:30:51 +00:00
if ( direction < 0 & & hud_size > 0 )
2019-10-22 21:31:46 +00:00
{
2019-10-22 22:30:51 +00:00
int layout = hud_size - 1 ;
2019-10-22 21:31:46 +00:00
while ( ! gi - > validate_hud ( layout ) & & layout > = 0 ) layout - - ;
2019-12-04 23:54:55 +00:00
if ( layout > = 0 & & layout < hud_size & & gi - > validate_hud ( layout ) )
2019-10-22 21:31:46 +00:00
{
2019-10-22 22:30:51 +00:00
hud_size = layout ;
2019-10-22 21:31:46 +00:00
return true ;
}
}
2019-12-07 20:39:17 +00:00
else if ( direction > 0 & & hud_size < 11 )
2019-10-22 21:31:46 +00:00
{
2019-10-22 22:30:51 +00:00
int layout = hud_size + 1 ;
2019-10-22 21:31:46 +00:00
while ( ! gi - > validate_hud ( layout ) & & layout < = 11 ) layout + + ;
2019-12-04 23:54:55 +00:00
if ( layout < = 11 & & layout > hud_size & & gi - > validate_hud ( layout ) )
2019-10-22 21:31:46 +00:00
{
2019-10-22 22:30:51 +00:00
hud_size = layout ;
2019-10-22 21:31:46 +00:00
return true ;
}
}
return false ;
}
int hud_statusbarrange ; // will be set by the game's configuration setup.
2019-10-22 21:43:16 +00:00
CUSTOM_CVARD ( Int , hud_custom , 0 , CVAR_ARCHIVE | CVAR_NOINITCALL , " change the custom hud " ) // this has no backing implementation, it seems to be solely for scripted HUDs.
2019-10-22 21:31:46 +00:00
{
if ( self < 0 ) self = 0 ;
2020-02-09 17:42:14 +00:00
else if ( self > 0 & & self > = hud_statusbarrange ) self = hud_statusbarrange - 1 ;
2019-10-22 21:31:46 +00:00
}
2019-10-22 22:20:27 +00:00
CVARD ( Bool , hud_stats , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable level statistics display " )
CVARD ( Bool , hud_showmapname , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable map name display on load " )
2019-10-23 23:30:33 +00:00
CVARD ( Bool , hud_position , false , CVAR_ARCHIVE , " aligns the status bar to the bottom/top " )
CVARD ( Bool , hud_bgstretch , false , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " enable/disable background image stretching in wide resolutions " )
CVARD ( Int , hud_messagetime , 120 , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " length of time to display multiplayer chat messages " )
2019-12-04 00:38:51 +00:00
CUSTOM_CVARD ( Int , hud_messages , 1 , CVAR_ARCHIVE , " enable/disable showing messages " )
{
if ( self < 0 | | self > 2 ) self = 1 ;
}
2019-12-08 23:33:14 +00:00
// This cannot be done with the 'toggle' CCMD because it needs to control itself when to output the message
2019-12-02 23:57:03 +00:00
CCMD ( togglemessages )
{
if ( hud_messages )
{
2019-12-08 23:33:14 +00:00
gi - > PrintMessage ( PRINT_MEDIUM , " %s \n " , quoteMgr . GetQuote ( 24 ) ) ;
2019-12-02 23:57:03 +00:00
hud_messages = false ;
}
else
{
hud_messages = true ;
2019-12-08 23:33:14 +00:00
gi - > PrintMessage ( PRINT_MEDIUM , " %s \n " , quoteMgr . GetQuote ( 23 ) ) ;
2019-12-02 23:57:03 +00:00
}
}
2019-10-27 15:53:00 +00:00
//{
//Blood::gGameMessageMgr.SetState(self); // this is for terminaing an active message. Cannot be done like this because CVARs are global.
//}
2019-10-23 23:30:33 +00:00
CVARD_NAMED ( Int , hud_numbertile , althud_numbertile , 2930 , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " first tile in alt hud number set " )
CVARD_NAMED ( Int , hud_numberpal , althud_numberpal , 0 , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " pal for alt hud numbers " )
CVARD_NAMED ( Int , hud_shadows , althud_shadows , true , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " enable/disable althud shadows " )
CVARD_NAMED ( Int , hud_flashing , althud_flashing , true , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " enable/disable althud flashing " )
CVARD ( Bool , hud_glowingquotes , true , CVAR_ARCHIVE , " enable/disable \" glowing \" quote text " )
CUSTOM_CVARD ( Int , hud_textscale , 200 , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " sets multiplayer chat message size " )
{
if ( self < 100 ) self = 100 ;
else if ( self > 400 ) self = 400 ;
}
CUSTOM_CVARD ( Int , hud_weaponscale , 100 , CVAR_ARCHIVE | CVAR_FRONTEND_DUKELIKE , " changes the weapon scale " )
{
if ( self < 30 ) self = 30 ;
else if ( self > 100 ) self = 100 ;
}
CUSTOM_CVARD ( Int , r_fov , 90 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " change the field of view " )
2019-10-22 22:20:27 +00:00
{
if ( self < 60 ) self = 60 ;
2019-10-26 11:16:32 +00:00
else if ( self > 140 ) self = 140 ;
2019-10-22 22:20:27 +00:00
}
2019-10-22 21:31:46 +00:00
2019-10-22 22:30:51 +00:00
CVARD ( Bool , r_horizcenter , false , CVAR_ARCHIVE | CVAR_FRONTEND_BLOOD , " enable/disable centered horizon line " ) // only present in Blood, maybe add to others?
2019-12-05 00:08:35 +00:00
CVARD ( Bool , in_mousemode , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " toggles vertical mouse view " )
CVAR ( Bool , silentmouseaimtoggle , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG )
CCMD ( togglemouseaim )
2019-10-22 23:30:43 +00:00
{
2019-12-05 00:08:35 +00:00
in_mousemode = ! in_mousemode ;
if ( ! silentmouseaimtoggle )
{
gi - > DoPrintMessage ( PRINT_MEDIUM , in_mousemode ? GStrings ( " TXT_MOUSEAIMON " ) : GStrings ( " TXT_MOUSEAIMOFF " ) ) ;
}
2019-10-22 23:30:43 +00:00
}
2019-10-22 22:59:01 +00:00
CVARD ( Bool , in_mouseflip , false , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " invert vertical mouse movement " )
2019-10-22 22:55:48 +00:00
2019-10-22 22:59:01 +00:00
CUSTOM_CVARD ( Int , in_mousebias , 0 , CVAR_GLOBALCONFIG | CVAR_ARCHIVE , " emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time " )
2019-10-22 22:55:48 +00:00
{
if ( self < 0 ) self = 0 ;
else if ( self > 32 ) self = 32 ;
}
2019-11-10 14:15:14 +00:00
CVARD ( Bool , in_mousesmoothing , false , CVAR_GLOBALCONFIG | CVAR_ARCHIVE , " enable/disable mouse input smoothing " )
2019-10-22 22:59:01 +00:00
2019-12-03 19:49:56 +00:00
CUSTOM_CVARD ( Float , in_mousesensitivity , 1 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " changes the mouse sensitivity " )
2019-10-23 15:21:14 +00:00
{
if ( self < 0 ) self = 0 ;
2019-12-03 19:49:56 +00:00
else if ( self > 6 ) self = 6 ;
2019-11-09 18:15:03 +00:00
}
2019-12-03 19:49:56 +00:00
CUSTOM_CVARD ( Float , in_mousescalex , 1 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " changes the mouse sensitivity " )
2019-11-09 18:15:03 +00:00
{
2019-12-03 19:49:56 +00:00
if ( self < - 4 ) self = 4 ;
else if ( self > 4 ) self = 4 ;
2019-11-09 18:15:03 +00:00
}
2019-12-03 19:49:56 +00:00
CUSTOM_CVARD ( Float , in_mousescaley , 1 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " changes the mouse sensitivity " )
2019-11-09 18:15:03 +00:00
{
2019-12-03 19:49:56 +00:00
if ( self < - 4 ) self = 4 ;
else if ( self > 4 ) self = 4 ;
2019-10-23 15:21:14 +00:00
}
2019-10-22 23:04:07 +00:00
CUSTOM_CVARD ( Int , r_drawweapon , 1 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable weapon drawing " )
{
if ( self < 0 | | self > 2 ) self = 1 ;
}
2019-11-10 10:42:25 +00:00
ADD_STAT ( fps )
{
return gi - > statFPS ( ) ;
}
2019-12-23 19:55:12 +00:00
ADD_STAT ( coord )
{
return gi - > GetCoordString ( ) ;
}
2019-10-22 23:04:07 +00:00
CUSTOM_CVARD ( Int , r_showfps , 0 , 0 , " show the frame rate counter " )
{
if ( self < 0 | | self > 3 ) self = 1 ;
2019-11-10 10:42:25 +00:00
FStat : : EnableStat ( " fps " , self ! = 0 ) ;
2019-10-22 23:04:07 +00:00
}
2019-10-21 22:18:58 +00:00
2019-10-22 23:04:07 +00:00
CUSTOM_CVARD ( Int , r_showfpsperiod , 0 , 0 , " time in seconds before averaging min and max stats for r_showfps 2+ " )
{
if ( self < 0 | | self > 5 ) self = 1 ;
}
2019-10-22 22:59:01 +00:00
2019-10-22 23:30:43 +00:00
float r_ambientlightrecip ;
2019-10-21 22:18:58 +00:00
2019-10-22 23:30:43 +00:00
CUSTOM_CVARD ( Float , r_ambientlight , 1.0 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " sets the global map light level " )
{
if ( self < 0.1f ) self = 0.1f ;
else if ( self > 10.f ) self = 10.f ;
else r_ambientlightrecip = 1.f / self ;
}
2019-10-21 22:18:58 +00:00
2019-11-05 19:25:57 +00:00
CVARD ( Bool , r_shadows , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable sprite and model shadows " )
2019-10-21 22:18:58 +00:00
2019-10-22 23:30:43 +00:00
// Gross hack stuff. Only settable from the command line
CVARD ( Bool , r_rotatespritenowidescreen , false , CVAR_NOSET , " pass bit 1024 to all CON rotatesprite calls " )
2019-10-23 12:39:33 +00:00
CVARD ( Bool , r_precache , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " enable/disable the pre-level caching routine " )
2019-10-23 15:07:29 +00:00
CUSTOM_CVARD ( Int , r_maxfps , 200 , CVAR_ARCHIVE | CVAR_GLOBALCONFIG , " limit the frame rate " )
2019-10-23 12:39:33 +00:00
{
2019-10-23 15:07:29 +00:00
if ( self < 0 ) self = 0 ;
else if ( self > 0 & & self < 30 ) self = 30 ;
2019-10-23 12:39:33 +00:00
else if ( self > 1000 ) self = 1000 ;
}
2019-10-21 22:18:58 +00:00
2019-10-23 15:07:29 +00:00
int G_FPSLimit ( void )
{
if ( r_maxfps < = 0 )
return 1 ;
auto frameDelay = timerGetFreqU64 ( ) / ( double ) r_maxfps ;
static double nextPageDelay ;
static uint64_t lastFrameTicks ;
nextPageDelay = clamp ( nextPageDelay , 0.0 , frameDelay ) ;
uint64_t const frameTicks = timerGetTicksU64 ( ) ;
uint64_t const elapsedTime = frameTicks - lastFrameTicks ;
double const dElapsedTime = elapsedTime ;
if ( dElapsedTime > = nextPageDelay )
{
if ( dElapsedTime < = nextPageDelay + frameDelay )
nextPageDelay + = frameDelay - dElapsedTime ;
lastFrameTicks = frameTicks ;
return 1 ;
}
return 0 ;
}
2019-10-23 16:36:48 +00:00
CUSTOM_CVARD ( String , wchoice , " 3457860291 " , CVAR_ARCHIVE | CVAR_NOINITCALL | CVAR_FRONTEND_DUKELIKE , " sets weapon autoselection order " )
2019-10-23 15:21:14 +00:00
{
char dest [ 11 ] ;
2019-10-23 16:36:48 +00:00
char const * c = self ;
2019-10-23 15:21:14 +00:00
if ( * c )
{
int j = 0 ;
while ( * c & & j < 10 )
{
dest [ j ] = * c - ' 0 ' ;
c + + ;
j + + ;
}
while ( j < 10 )
{
if ( j = = 9 )
dest [ 9 ] = 1 ;
else
dest [ j ] = 2 ;
j + + ;
}
2020-04-11 21:45:45 +00:00
// if (!gi->SetWeaponChoice(dest)) Printf("Weapon ordering not supported\n");
2019-10-23 15:21:14 +00:00
}
else
{
2020-04-11 21:45:45 +00:00
Printf ( " Using default weapon orders. \n " ) ;
2019-10-23 15:21:14 +00:00
self = " 3457860291 " ;
}
2019-10-23 16:36:48 +00:00
}
2019-10-23 15:21:14 +00:00
2019-10-23 15:07:29 +00:00
2019-10-23 19:11:37 +00:00
CVARD ( Bool , r_voxels , true , CVAR_ARCHIVE , " enable/disable automatic sprite->voxel rendering " )
2019-10-21 22:18:58 +00:00
2019-10-27 08:38:55 +00:00
//==========================================================================
//
// Global setup that formerly wasn't CVARs but merely global stuff saved in the config.
//
//==========================================================================
CVAR ( Bool , displaysetup , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG )
bool gNoAutoLoad ; // for overrides from the def files
CVAR ( Bool , noautoload , true , CVAR_ARCHIVE | CVAR_GLOBALCONFIG )
bool G_AllowAutoload ( )
{
if ( noautoload | | gNoAutoLoad | | Args - > CheckParm ( " -noautoload " ) ) return false ;
return true ;
}
2020-04-11 22:04:02 +00:00
// color code format is as follows:
// ^## sets a color, where ## is the palette number
// ^S# sets a shade, range is 0-7 equiv to shades 0-14
// ^O resets formatting to defaults
static const char * OSD_StripColors ( char * outBuf , const char * inBuf )
{
const char * ptr = outBuf ;
while ( * inBuf )
{
if ( * inBuf = = ' ^ ' )
{
if ( isdigit ( * ( inBuf + 1 ) ) )
{
inBuf + = 2 + ! ! isdigit ( * ( inBuf + 2 ) ) ;
continue ;
}
else if ( ( toupper ( * ( inBuf + 1 ) ) = = ' O ' ) )
{
inBuf + = 2 ;
continue ;
}
else if ( ( toupper ( * ( inBuf + 1 ) ) = = ' S ' ) & & isdigit ( * ( inBuf + 2 ) ) )
{
inBuf + = 3 ;
continue ;
}
}
* ( outBuf + + ) = * ( inBuf + + ) ;
}
* outBuf = ' \0 ' ;
return ptr ;
}
2019-10-27 12:40:24 +00:00
CVAR ( Bool , adult_lockout , false , CVAR_ARCHIVE )
CUSTOM_CVAR ( String , playername , " Player " , CVAR_ARCHIVE | CVAR_USERINFO )
2019-10-27 08:38:55 +00:00
{
2019-10-27 12:40:24 +00:00
TArray < char > buffer ( strlen ( self ) + 1 , 1 ) ;
OSD_StripColors ( buffer . Data ( ) , self ) ;
if ( buffer . Size ( ) < strlen ( self ) )
{
self = buffer . Data ( ) ;
}
2019-10-27 13:09:56 +00:00
//Net_SendClientInfo(); This is in the client code. Todo.
2019-10-27 08:38:55 +00:00
}
2019-11-09 18:15:03 +00:00
2019-10-27 12:40:24 +00:00
CUSTOM_CVAR ( String , rtsname , " " , CVAR_ARCHIVE | CVAR_USERINFO )
{
RTS_Init ( self ) ;
}
2019-10-27 08:38:55 +00:00
2019-11-02 00:30:21 +00:00
CVAR ( String , usermapfolder , " " , CVAR_ARCHIVE ) ;
2019-10-27 08:38:55 +00:00
2019-12-04 00:38:51 +00:00
CUSTOM_CVAR ( Int , playercolor , 0 , CVAR_ARCHIVE | CVAR_USERINFO )
{
if ( self < 0 | | self > 10 ) self = 0 ;
else ; // gi->UpdatePlayerColor(); // this part is game specific
}
CUSTOM_CVAR ( Int , playerteam , 0 , CVAR_USERINFO ) // this one is transient and won't be saved.
{
if ( self < 0 | | self > 3 ) self = 0 ;
else ; // gi->UpdatePlayerTeam(); // this part is game specific
}
2019-12-05 18:52:46 +00:00
// Will only become useful if the obituary system gets overhauled and for localization
2019-12-04 00:38:51 +00:00
CUSTOM_CVAR ( Int , playergender , 0 , CVAR_USERINFO | CVAR_ARCHIVE )
{
if ( self < 0 | | self > 3 ) self = 0 ;
}
2019-11-09 18:15:03 +00:00
2020-01-26 21:22:41 +00:00
2019-11-09 18:15:03 +00:00
// Internal settings for demo recording and the multiplayer menu. These won't get saved and only are CVARs so that the menu code can use them.
2020-01-08 00:00:57 +00:00
CVAR ( Int , m_recstat , false , CVAR_NOSET )
2019-11-09 18:15:03 +00:00
CVAR ( Int , m_coop , 0 , CVAR_NOSET )
CVAR ( Int , m_ffire , 1 , CVAR_NOSET )
2019-12-04 00:38:51 +00:00
CVAR ( Int , m_monsters , 1 , CVAR_NOSET )
2019-11-09 18:15:03 +00:00
CVAR ( Int , m_marker , 1 , CVAR_NOSET )
CVAR ( Int , m_level_number , 0 , CVAR_NOSET )
2019-12-04 00:38:51 +00:00
CVAR ( Int , m_episode_number , 0 , CVAR_NOSET )
2019-11-09 18:15:03 +00:00
CVAR ( Int , m_noexits , 0 , CVAR_NOSET )
2019-12-04 00:38:51 +00:00
CVAR ( String , m_server , " localhost " , CVAR_NOSET )
CVAR ( String , m_netport , " 19014 " , CVAR_NOSET )
2019-11-09 18:15:03 +00:00
2019-10-23 19:11:37 +00:00
#if 0
2019-10-22 21:31:46 +00:00
/*
2019-10-22 22:20:27 +00:00
// Currently unavailable due to dependency on an obsolete OpenGL feature
{ " deliriumblur " , " enable/disable delirium blur effect(polymost) " , ( void * ) & gDeliriumBlur , CVAR_BOOL , 0 , 1 } ,
2019-10-22 22:59:01 +00:00
// This one gets changed at run time by the game code, so making it persistent does not work
2019-10-22 23:04:07 +00:00
// This option is not really useful anymore
{ " r_camrefreshdelay " , " minimum delay between security camera sprite updates, 120 = 1 second " , ( void * ) & ud . camera_time , CVAR_INT , 1 , 240 } ,
2019-10-23 15:21:14 +00:00
// This requires a different approach, because it got used like a CCMD, not a CVAR.
{ " skill " , " changes the game skill setting " , ( void * ) & ud . m_player_skill , CVAR_INT | CVAR_FUNCPTR | CVAR_NOSAVE /*|CVAR_NOMULTI*/ , 0 , 5 } ,
2019-10-23 16:58:34 +00:00
// just as a reminder:
/*
else if ( ! Bstrcasecmp ( parm - > name , " vid_gamma " ) )
{
}
else if ( ! Bstrcasecmp ( parm - > name , " vid_brightness " ) | | ! Bstrcasecmp ( parm - > name , " vid_contrast " ) )
{
}
*/
2019-10-23 19:11:37 +00:00
2019-10-21 22:18:58 +00:00
# endif