2004-08-23 00:15:46 +00:00
/*
Copyright ( C ) 1996 - 1997 Id Software , Inc .
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// cl.input.c -- builds an intended movement command to send to the server
# include "quakedef.h"
2005-02-28 07:16:19 +00:00
# ifdef _WIN32
# include "winquake.h" //fps indep stuff.
# endif
2005-03-10 03:55:18 +00:00
float in_sensitivityscale = 1 ;
2005-02-28 07:16:19 +00:00
2017-08-29 02:29:06 +00:00
# ifdef NQPROT
2018-12-06 04:55:35 +00:00
static cvar_t cl_movement = CVARD ( " cl_movement " , " 1 " , " Specifies whether to send movement sequence info over DPP7 protocols (other protocols are unaffected). Unlike cl_nopred, this can result in different serverside behaviour. " ) ;
2017-08-29 02:29:06 +00:00
# endif
2008-06-12 20:47:13 +00:00
2010-07-11 02:22:39 +00:00
cvar_t cl_nodelta = CVAR ( " cl_nodelta " , " 0 " ) ;
2004-08-23 00:15:46 +00:00
2021-07-17 15:10:01 +00:00
cvar_t cl_c2sdupe = CVARD ( " cl_c2sdupe " , " 0 " , " Send duplicate copies of packets to the server. This avoids extra latency caused by packetloss, but could also make the problem worse. " ) ;
2020-09-08 05:11:09 +00:00
cvar_t cl_c2spps = CVARD ( " cl_c2spps " , " 0 " , " Reduces outgoing packet rates by dropping up to a third of outgoing packets. " ) ;
cvar_t cl_c2sImpulseBackup = CVARD ( " cl_c2sImpulseBackup " , " 3 " , " Prevents the cl_c2spps setting from dropping redundant packets that contain impulses, in an attempt to keep impulses more reliable. " ) ;
2021-07-17 15:10:01 +00:00
static cvar_t cl_c2sMaxRedundancy = CVARD ( " cl_c2sMaxRedundancy " , " 5 " , " This is the maximum number of input frames to send in each input packet. Values greater than 1 provide redundancy and avoid prediction misses, though you might find cl_c2sdupe provides equivelent result and at lower latency. It is locked at 3 for vanilla quakeworld, and locked at 1 for vanilla netquake. " ) ;
2023-03-15 18:02:26 +00:00
cvar_t cl_netfps = CVARFD ( " cl_netfps " , " 150 " , CVAR_ARCHIVE , " Send up to this many packets to the server per second. The rate used is also limited by the server which usually forces a cap to this setting of 77. Low packet rates can result in extra extrapolation to try to hide the resulting latencies. " ) ;
2020-09-08 05:11:09 +00:00
cvar_t cl_queueimpulses = CVARD ( " cl_queueimpulses " , " 0 " , " Queues unsent impulses instead of replacing them. This avoids the need for extra wait commands (and the timing issues of such commands), but potentially increases latency and can cause scripts to be desynced with regard to buttons and impulses. " ) ;
cvar_t cl_smartjump = CVARD ( " cl_smartjump " , " 1 " , " Makes the jump button act as +moveup when in water. This is typically quieter and faster. " ) ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
cvar_t cl_iDrive = CVARFD ( " cl_iDrive " , " 1 " , CVAR_SEMICHEAT , " Effectively releases movement keys when the opposing key is pressed. This avoids dead-time when both keys are pressed. This can be emulated with various scripts, but that's messy. " ) ;
2014-03-30 08:55:06 +00:00
cvar_t cl_run = CVARD ( " cl_run " , " 0 " , " Enables autorun, inverting the state of the +speed key. " ) ;
2014-04-13 04:23:13 +00:00
cvar_t cl_fastaccel = CVARD ( " cl_fastaccel " , " 1 " , " Begin moving at full speed instantly, instead of waiting a frame or so. " ) ;
2014-06-21 17:58:17 +00:00
extern cvar_t cl_rollspeed ;
2019-01-13 16:51:50 +00:00
static cvar_t cl_sendchatstate = CVARD ( " cl_sendchatstate " , " 1 " , " Announce your chat state to the server in a privacy-violating kind of way. This allows other players to see your afk/at-console status. " ) ;
2004-08-23 00:15:46 +00:00
2010-07-11 02:22:39 +00:00
cvar_t cl_prydoncursor = CVAR ( " cl_prydoncursor " , " " ) ; //for dp protocol
cvar_t cl_instantrotate = CVARF ( " cl_instantrotate " , " 1 " , CVAR_SEMICHEAT ) ;
2021-05-09 13:02:49 +00:00
cvar_t in_xflip = CVAR ( " in_xflip " , " 0 " ) ;
cvar_t in_vraim = CVARD ( " in_vraim " , " 1 " , " When set to 1, the 'view' angle sent to the server is controlled by your vr headset instead of separately. This is for fallback behaviour and blocks mouse+joy+gamepad aiming. " ) ;
2005-08-03 23:14:59 +00:00
2010-07-11 02:22:39 +00:00
cvar_t prox_inmenu = CVAR ( " prox_inmenu " , " 0 " ) ;
2004-08-23 00:15:46 +00:00
2017-08-29 02:29:06 +00:00
usercmd_t cl_pendingcmd [ MAX_SPLITS ] ;
2005-05-26 12:55:34 +00:00
2010-08-14 00:15:07 +00:00
/*kinda a hack...*/
2016-07-21 19:27:59 +00:00
unsigned int con_splitmodifier ;
2015-03-03 00:14:43 +00:00
cvar_t cl_forceseat = CVARAD ( " in_forceseat " , " 0 " , " in_forcesplitclient " , " Overrides the device identifiers to control a specific client from any device. This can be used for debugging mods, where you only have one keyboard/mouse. " ) ;
2010-08-14 03:17:33 +00:00
int CL_TargettedSplit ( qboolean nowrap )
2010-08-14 00:15:07 +00:00
{
2010-08-14 03:17:33 +00:00
int mod ;
2015-06-24 17:59:57 +00:00
//explicitly targetted at some seat number from the server
2020-02-11 18:06:10 +00:00
if ( Cmd_ExecLevel > = RESTRICT_SERVER )
return Cmd_ExecLevel - RESTRICT_SERVER ;
2015-06-24 17:59:57 +00:00
//locally executed command.
2010-08-14 03:17:33 +00:00
if ( nowrap )
mod = MAX_SPLITS ;
else
mod = cl . splitclients ;
if ( mod < 1 )
2010-08-14 00:15:07 +00:00
return 0 ;
if ( con_splitmodifier > 0 )
2010-08-14 03:17:33 +00:00
return ( con_splitmodifier - 1 ) % mod ;
2015-03-03 00:14:43 +00:00
else if ( cl_forceseat . ival > 0 )
2016-07-12 00:40:13 +00:00
return ( cl_forceseat . ival - 1 ) % cl . splitclients ;
2010-08-14 00:15:07 +00:00
else
return 0 ;
}
void CL_Split_f ( void )
{
int tmp ;
char * c ;
c = Cmd_Argv ( 0 ) ;
tmp = con_splitmodifier ;
if ( * c = = ' + ' | | * c = = ' - ' )
{
2015-12-12 19:25:15 +00:00
con_splitmodifier = c [ 2 ] - ' 0 ' ;
2010-08-14 00:15:07 +00:00
Cmd_ExecuteString ( va ( " %c%s " , * c , Cmd_Args ( ) ) , Cmd_ExecLevel ) ;
}
else
{
2015-12-12 19:25:15 +00:00
con_splitmodifier = c [ 1 ] - ' 0 ' ;
2010-08-14 00:15:07 +00:00
Cmd_ExecuteString ( Cmd_Args ( ) , Cmd_ExecLevel ) ;
}
con_splitmodifier = tmp ;
}
2012-02-12 05:18:31 +00:00
void CL_SplitA_f ( void )
{
int tmp ;
char * c , * args ;
c = Cmd_Argv ( 0 ) ;
args = COM_Parse ( Cmd_Args ( ) ) ;
2013-03-12 22:44:00 +00:00
if ( ! args )
return ;
2012-02-12 05:18:31 +00:00
while ( * args = = ' ' | | * args = = ' \t ' )
args + + ;
tmp = con_splitmodifier ;
con_splitmodifier = atoi ( com_token ) ;
if ( * c = = ' + ' | | * c = = ' - ' )
Cmd_ExecuteString ( va ( " %c%s " , * c , args ) , Cmd_ExecLevel ) ;
else
Cmd_ExecuteString ( args , Cmd_ExecLevel ) ;
con_splitmodifier = tmp ;
}
2010-08-14 00:15:07 +00:00
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
KEY BUTTONS
Continuous button event tracking is complicated by the fact that two different
input sources ( say , mouse button 1 and the control key ) can both press the
same button , but the button should only be released when both of the
pressing key have been released .
When a key event issues a button command ( + forward , + attack , etc ) , it appends
its key number as a parameter to the command so it can be matched up with
the release .
state bit 0 is the current state of the key
state bit 1 is edge triggered on the up to down transition
state bit 2 is edge triggered on the down to up transition
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2017-12-09 21:22:46 +00:00
kbutton_t in_mlook , in_strafe , in_speed ;
static kbutton_t in_klook ;
static kbutton_t in_left , in_right , in_forward , in_back ;
static kbutton_t in_lookup , in_lookdown , in_moveleft , in_moveright ;
static kbutton_t in_use , in_jump , in_attack ;
static kbutton_t in_rollleft , in_rollright , in_up , in_down ;
2004-08-23 00:15:46 +00:00
2019-10-19 22:02:12 +00:00
static kbutton_t in_button [ 19 + 1 ] ;
2004-09-01 22:56:08 +00:00
2015-04-14 23:12:17 +00:00
# define IN_IMPULSECACHE 32
2017-12-09 21:22:46 +00:00
static int in_impulse [ MAX_SPLITS ] [ IN_IMPULSECACHE ] ;
static int in_nextimpulse [ MAX_SPLITS ] ;
static int in_impulsespending [ MAX_SPLITS ] ;
2020-07-21 07:58:54 +00:00
static void CL_QueueImpulse ( int pnum , int newimp )
{
if ( cl_queueimpulses . ival )
{
if ( in_impulsespending [ pnum ] > = IN_IMPULSECACHE )
{
Con_Printf ( " Too many impulses, ignoring %i \n " , newimp ) ;
return ;
}
in_impulse [ pnum ] [ ( in_nextimpulse [ pnum ] + in_impulsespending [ pnum ] ) % IN_IMPULSECACHE ] = newimp ;
in_impulsespending [ pnum ] + + ;
}
else
{
if ( in_impulsespending [ pnum ] )
Con_DPrintf ( " Too many impulses, forgetting %i \n " , in_impulse [ pnum ] [ ( in_nextimpulse [ pnum ] ) % IN_IMPULSECACHE ] ) ;
in_impulse [ pnum ] [ ( in_nextimpulse [ pnum ] ) % IN_IMPULSECACHE ] = newimp ;
in_impulsespending [ pnum ] = 1 ;
}
}
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
qboolean cursor_active ;
2004-08-23 00:15:46 +00:00
2010-08-14 00:15:07 +00:00
2018-12-06 04:55:35 +00:00
static qboolean KeyDown_Scan ( kbutton_t * b , kbutton_t * anti , int k )
2004-08-23 00:15:46 +00:00
{
2010-08-14 03:17:33 +00:00
int pnum = CL_TargettedSplit ( false ) ;
2004-08-23 00:15:46 +00:00
if ( k = = b - > down [ pnum ] [ 0 ] | | k = = b - > down [ pnum ] [ 1 ] )
2018-12-06 04:55:35 +00:00
return false ; // repeating key
2004-08-23 00:15:46 +00:00
if ( ! b - > down [ pnum ] [ 0 ] )
b - > down [ pnum ] [ 0 ] = k ;
else if ( ! b - > down [ pnum ] [ 1 ] )
b - > down [ pnum ] [ 1 ] = k ;
else
{
2018-04-09 18:01:15 +00:00
Con_DPrintf ( " Three keys down for a button! \n " ) ;
2018-12-06 04:55:35 +00:00
return false ;
2004-08-23 00:15:46 +00:00
}
if ( b - > state [ pnum ] & 1 )
2018-12-06 04:55:35 +00:00
return false ; // still down
2004-08-23 00:15:46 +00:00
b - > state [ pnum ] | = 1 + 2 ; // down + impulse down
2017-12-09 21:22:46 +00:00
if ( anti & & ( anti - > state [ pnum ] & 1 ) & & cl_iDrive . ival )
{ //anti-keys are the opposing key. so +forward can auto-release +back for slightly faster-responding keypresses.
b - > suppressed [ pnum ] = anti ;
anti - > suppressed [ pnum ] = NULL ;
anti - > state [ pnum ] & = ~ 1 ; // now up
anti - > state [ pnum ] | = 4 ; // impulse up
}
2018-12-06 04:55:35 +00:00
return true ;
2004-08-23 00:15:46 +00:00
}
2018-12-06 04:55:35 +00:00
static void KeyDown ( kbutton_t * b , kbutton_t * anti )
2004-08-23 00:15:46 +00:00
{
int k ;
char * c ;
c = Cmd_Argv ( 1 ) ;
if ( c [ 0 ] )
2017-06-21 01:24:25 +00:00
k = atoi ( c ) ;
2004-08-23 00:15:46 +00:00
else
2018-12-06 04:55:35 +00:00
k = - 1 ; // typed manually at the console for continuous down
KeyDown_Scan ( b , anti , k ) ;
}
static qboolean KeyUp_Scan ( kbutton_t * b , int k )
{
int pnum = CL_TargettedSplit ( false ) ;
if ( k < 0 )
2004-08-23 00:15:46 +00:00
{ // typed manually at the console, assume for unsticking, so clear all
2017-12-09 21:22:46 +00:00
b - > suppressed [ pnum ] = NULL ;
2004-08-23 00:15:46 +00:00
b - > down [ pnum ] [ 0 ] = b - > down [ pnum ] [ 1 ] = 0 ;
2018-12-06 04:55:35 +00:00
if ( b - > state [ pnum ] & ~ 4 )
{
b - > state [ pnum ] = 4 ; // impulse up
return true ;
}
return false ;
2004-08-23 00:15:46 +00:00
}
if ( b - > down [ pnum ] [ 0 ] = = k )
b - > down [ pnum ] [ 0 ] = 0 ;
else if ( b - > down [ pnum ] [ 1 ] = = k )
b - > down [ pnum ] [ 1 ] = 0 ;
else
2018-12-06 04:55:35 +00:00
return false ; // key up without coresponding down (menu pass through)
2004-08-23 00:15:46 +00:00
if ( b - > down [ pnum ] [ 0 ] | | b - > down [ pnum ] [ 1 ] )
2018-12-06 04:55:35 +00:00
return false ; // some other key is still holding it down
2004-08-23 00:15:46 +00:00
if ( ! ( b - > state [ pnum ] & 1 ) )
2018-12-06 04:55:35 +00:00
return false ; // still up (this should not happen)
2004-08-23 00:15:46 +00:00
b - > state [ pnum ] & = ~ 1 ; // now up
b - > state [ pnum ] | = 4 ; // impulse up
2017-12-09 21:22:46 +00:00
if ( b - > suppressed [ pnum ] )
{
if ( b - > suppressed [ pnum ] - > down [ pnum ] [ 0 ] | | b - > suppressed [ pnum ] - > down [ pnum ] [ 1 ] )
b - > suppressed [ pnum ] - > state [ pnum ] | = 1 + 2 ;
b - > suppressed [ pnum ] = NULL ;
}
2018-12-06 04:55:35 +00:00
return true ;
}
static qboolean KeyUp ( kbutton_t * b )
{
int k ;
char * c ;
c = Cmd_Argv ( 1 ) ;
if ( c [ 0 ] )
k = atoi ( c ) ;
else
k = - 1 ;
return KeyUp_Scan ( b , k ) ;
}
# ifdef QUAKESTATS
static cvar_t cl_weaponhide = CVARD ( " cl_weaponhide " , " 0 " , " HACK: Attempt to switch weapon to another in order to cheat your killer out of any possible weapon upgrades. \n 0: original behaviour \n 1: switch away when +attack/+fire is released \n 2: switch away only in deathmatch \n " ) ;
static cvar_t cl_weaponhide_preference = CVARAD ( " cl_weaponhide_preference " , " 2 1 " , " cl_weaponhide_axe " , " The weapon you would like to try to switch to when cl_weaponhide is active " ) ;
static cvar_t cl_weaponpreselect = CVARD ( " cl_weaponpreselect " , " 0 " , " HACK: Controls the interaction between the ^aweapon^a and ^a+attack^a commands (does not affect ^aimpulse^a). \n 0: weapon switch happens instantly \n 1: weapon switch happens on next attack \n 2: instant only when already firing, otherwise delayed \n 3: delay until new attack only in deathmatch 1 \n 4: delay until any attack only in deathmatch 1 " ) ;
static cvar_t cl_weaponforgetorder = CVARD ( " cl_weaponforgetorder " , " 0 " , " The 'weapon' command will lock in its weapon choice, instead of choosing a different weapon between select+fire. " ) ;
cvar_t r_viewpreselgun = CVARD ( " r_viewpreselgun " , " 0 " , " HACK: Display the preselected weaponmodel, instead of the current weaponmodel. " ) ;
2018-12-11 00:20:59 +00:00
static int preselectedweapons [ MAX_SPLITS ] ;
static int preselectedweapon [ MAX_SPLITS ] [ 32 ] ;
2022-06-19 15:18:08 +00:00
static kbutton_t in_wwheel ;
static float wwheeldir [ MAX_SPLITS ] [ 2 ] ;
static size_t wwheelsel [ MAX_SPLITS ] ;
static double wwheelseltime [ MAX_SPLITS ] ;
static struct weaponinfo_s {
char shortname [ 32 ] ; //must not look like an impulse.
int impulse ; //primary key...
int items_mask ;
int items_val ;
// int weapon_val; //unused...
int ammostat ;
int ammomin ;
char * icons [ 3 ] ; //unselected,selected,ammo
char * viewmodel ;
} * weaponinfo ;
static size_t weaponinfo_count ;
static int IN_NameToWeaponIdx ( const char * name )
{
size_t i ;
char * end ;
i = strtoul ( name , & end , 10 ) ;
if ( i & & ! end )
{ //select by impulse when they specified something numeric.
for ( i = 0 ; i < weaponinfo_count ; i + + )
{
if ( weaponinfo [ i ] . impulse = = i )
return i ;
}
}
else
{
for ( i = 0 ; i < weaponinfo_count ; i + + )
{
if ( ! strcmp ( name , weaponinfo [ i ] . shortname ) )
return i ;
}
}
return - 1 ;
}
static int IN_RegisterWeapon ( int impulse , const char * name , int items_mask , int items_val , int weapon_val , int ammostat , int ammomin , const char * viewmodel , const char * icon , const char * selicon , const char * ammoicon )
{
size_t i ;
char * end ;
if ( impulse < = 0 | | impulse > 255 )
return - 1 ; //no. just no...
if ( strtol ( name , & end , 10 ) ! = impulse )
{
if ( ! * end )
return - 1 ; //parsed as a number, which didn't match its impulse... don't break the impulse command.
}
//slots are unique/replaced by impulse
for ( i = 0 ; i < weaponinfo_count ; i + + )
{
if ( weaponinfo [ i ] . impulse = = impulse )
break ; //replace...
}
if ( i = = weaponinfo_count )
Z_ReallocElements ( ( void * * ) & weaponinfo , & weaponinfo_count , i + 1 , sizeof ( * weaponinfo ) ) ;
weaponinfo [ i ] . impulse = impulse ;
Q_strncpyz ( weaponinfo [ i ] . shortname , name , sizeof ( weaponinfo [ i ] . shortname ) ) ;
weaponinfo [ i ] . items_mask = items_mask ;
weaponinfo [ i ] . items_val = items_val ;
// weaponinfo[i].weapon_val; //unused...
weaponinfo [ i ] . ammostat = ammostat ;
weaponinfo [ i ] . ammomin = ammomin ;
# define Z_StrDupPtr2(v,s) do{Z_Free(*v),*(v) = (s&&*s)?strcpy(Z_Malloc(strlen(s)+1), s):NULL;}while(0)
Z_StrDupPtr2 ( & weaponinfo [ i ] . viewmodel , viewmodel ) ;
Z_StrDupPtr2 ( & weaponinfo [ i ] . icons [ 0 ] , icon ) ;
Z_StrDupPtr2 ( & weaponinfo [ i ] . icons [ 1 ] , selicon ) ;
Z_StrDupPtr2 ( & weaponinfo [ i ] . icons [ 2 ] , ammoicon ) ;
return i ;
}
static void IN_RegisterWeapon_Clear ( void )
{
while ( weaponinfo_count )
Z_Free ( weaponinfo [ - - weaponinfo_count ] . viewmodel ) ;
Z_Free ( weaponinfo ) ;
weaponinfo = NULL ;
}
void IN_RegisterWeapon_Reset ( void )
{
vfsfile_t * f ;
IN_RegisterWeapon_Clear ( ) ;
f = FS_OpenVFS ( " wwheel.txt " , " rb " , FS_GAME ) ;
if ( f )
{ //from the rerelease:
/*
slot N
{
impulse N
icon " gfx/weapons/ww_foo_1.lmp "
icon_sel " gfx/weapons/ww_foo_2.lmp "
ammoicon " FOO "
entvaroffs N
weaponnum N
}
*/
char line [ 1024 ] ;
char * v ;
for ( ; ; )
{
if ( ! VFS_GETS ( f , line , sizeof ( line ) ) )
break ;
v = COM_Parse ( line ) ;
if ( ! strcmp ( com_token , " slot " ) ) //slot N... just assume they're ordered.
{
//v = COM_Parse(line);
//slot = com_token
if ( ! VFS_GETS ( f , line , sizeof ( line ) ) )
break ;
v = COM_Parse ( line ) ;
if ( ! strcmp ( com_token , " { " ) )
{
int weaponbit = 0 ;
int impulse = 0 ;
int ammostat = - 1 ;
int ammocount = 0 ;
int field ;
char * icon = NULL ;
char * selicon = NULL ;
char * ammoicon = NULL ;
char * viewmodel = NULL ;
char * name = NULL ;
for ( ; ; )
{
if ( ! VFS_GETS ( f , line , sizeof ( line ) ) )
break ;
v = COM_Parse ( line ) ;
if ( ! strcmp ( com_token , " } " ) )
{ //end of this weapon.
IN_RegisterWeapon ( impulse , name ? name : va ( " %i " , impulse ) , weaponbit , weaponbit , weaponbit , ammostat , ammocount , viewmodel , icon , selicon , ammoicon ) ;
break ;
}
else if ( ! strcmp ( com_token , " impulse " ) )
{
v = COM_Parse ( v ) ;
impulse = atoi ( com_token ) ;
}
else if ( ! strcmp ( com_token , " weaponnum " ) )
{
v = COM_Parse ( v ) ;
weaponbit = atoi ( com_token ) ;
}
else if ( ! strcmp ( com_token , " icon " ) )
{
v = COM_Parse ( v ) ;
Z_StrDupPtr ( & icon , com_token ) ;
}
else if ( ! strcmp ( com_token , " icon_sel " ) )
{
v = COM_Parse ( v ) ;
Z_StrDupPtr ( & selicon , com_token ) ;
}
else if ( ! strcmp ( com_token , " ammoicon " ) )
{
v = COM_Parse ( v ) ;
if ( strchr ( com_token , ' . ' ) | | strchr ( com_token , ' / ' ) )
Z_StrDupPtr ( & ammoicon , com_token ) ;
else
Z_StrDupPtr ( & ammoicon , va ( " gfx/%s " , com_token ) ) ;
}
else if ( ! strcmp ( com_token , " entvaroffs " ) )
{ //this seems to be a host-only thing. the server can poke the qc's fields directly but other clients can't.
//remap known indexes to stats - this can only work for nq's system fields.
//note that rogue does some windowing thing so our client can only know either nails or lavanails, not both. either way those are NOT the normal stats and these weapons will appear to have infinite ammo as a result, sorry.
//they really should have used field names here, not numbers, but hey, not my spec... use our 'ammostat' instead for fancy mods.
v = COM_Parse ( v ) ;
field = atoi ( com_token ) ;
switch ( field )
{
case 216 : ammostat = STAT_SHELLS , ammocount = 1 ; break ;
case 220 : ammostat = STAT_NAILS , ammocount = 1 ; break ;
case 224 : ammostat = STAT_ROCKETS , ammocount = 1 ; break ;
case 228 : ammostat = STAT_CELLS , ammocount = 1 ; break ;
default : ammostat = - 1 , ammocount = 0 ; break ;
}
}
else if ( ! strcmp ( com_token , " ammostat " ) )
{ //non-qe
v = COM_Parse ( v ) ;
ammostat = atoi ( com_token ) ;
if ( ammocount < = 0 )
ammocount = 1 ;
}
else if ( ! strcmp ( com_token , " ammomin " ) )
{ //non-qe
v = COM_Parse ( v ) ;
ammocount = atoi ( com_token ) ;
}
else if ( ! strcmp ( com_token , " viewmodel " ) )
{ //non-qe, so preselect can show the correct model before its actually changed.
v = COM_Parse ( v ) ;
Z_StrDupPtr ( & viewmodel , com_token ) ;
}
else if ( ! strcmp ( com_token , " shortname " ) )
{ //non-qe, for `+fire nq`
v = COM_Parse ( v ) ;
Z_StrDupPtr ( & name , com_token ) ;
}
else if ( * com_token )
Con_Printf ( " Unexpected line in wwheel.txt: %s \n " , line ) ;
}
Z_Free ( icon ) ;
Z_Free ( selicon ) ;
Z_Free ( ammoicon ) ;
Z_Free ( viewmodel ) ;
Z_Free ( name ) ;
}
else
{
Con_Printf ( " missing block, found: %s \n " , line ) ;
break ;
}
}
else if ( * com_token )
Con_Printf ( " Unexpected line in wwheel.txt: %s \n " , line ) ;
}
VFS_CLOSE ( f ) ;
}
else
{
IN_RegisterWeapon ( 2 , " sg " , IT_SHOTGUN , IT_SHOTGUN , IT_SHOTGUN , STAT_SHELLS , 1 , " progs/v_shot.mdl " , NULL , NULL , " gfx/sb_shells " ) ;
IN_RegisterWeapon ( 3 , " ssg " , IT_SUPER_SHOTGUN , IT_SUPER_SHOTGUN , IT_SUPER_SHOTGUN , STAT_SHELLS , 1 , " progs/v_shot2.mdl " , NULL , NULL , " gfx/sb_shells " ) ;
IN_RegisterWeapon ( 4 , " ng " , IT_NAILGUN , IT_NAILGUN , IT_NAILGUN , STAT_NAILS , 1 , " progs/v_nail.mdl " , NULL , NULL , " gfx/sb_nails " ) ;
IN_RegisterWeapon ( 5 , " sng " , IT_SUPER_NAILGUN , IT_SUPER_NAILGUN , IT_SUPER_NAILGUN , STAT_NAILS , 1 , " progs/v_nail2.mdl " , NULL , NULL , " gfx/sb_nails " ) ;
IN_RegisterWeapon ( 6 , " gl " , IT_GRENADE_LAUNCHER , IT_GRENADE_LAUNCHER , IT_GRENADE_LAUNCHER , STAT_ROCKETS , 1 , " progs/v_rock.mdl " , NULL , NULL , " gfx/sb_rocket " ) ;
IN_RegisterWeapon ( 7 , " rl " , IT_ROCKET_LAUNCHER , IT_ROCKET_LAUNCHER , IT_ROCKET_LAUNCHER , STAT_ROCKETS , 1 , " progs/v_rock2.mdl " , NULL , NULL , " gfx/sb_rocket " ) ;
IN_RegisterWeapon ( 8 , " lg " , IT_LIGHTNING , IT_LIGHTNING , IT_LIGHTNING , STAT_CELLS , 1 , " progs/v_light.mdl " , NULL , NULL , " gfx/sb_cells " ) ;
IN_RegisterWeapon ( 1 , " axe " , IT_AXE , IT_AXE , IT_AXE , - 1 , 0 , " progs/v_axe.mdl " , NULL , NULL , NULL ) ;
}
}
static void IN_RegisterWeapon_f ( void )
{
if ( Cmd_Argc ( ) < = 2 )
{
const char * arg = Cmd_Argv ( 1 ) ;
if ( ! strcmp ( arg , " clear " ) )
IN_RegisterWeapon_Clear ( ) ;
else if ( ! strcmp ( arg , " reset " ) | | ! strcmp ( arg , " quake " ) ) //'quake' for compat with dp.
IN_RegisterWeapon_Reset ( ) ;
else
Con_Printf ( " Unknown arg %s \n " , Cmd_Argv ( 1 ) ) ;
}
else
{
IN_RegisterWeapon ( atoi ( Cmd_Argv ( 2 ) ) , //impulse
Cmd_Argv ( 1 ) , //name
atoi ( Cmd_Argv ( 3 ) ) , //itemsmask
atoi ( Cmd_Argv ( 3 ) ) , //itemsval
atoi ( Cmd_Argv ( 4 ) ) , //weaponval
atoi ( Cmd_Argv ( 5 ) ) , //ammostat
atoi ( Cmd_Argv ( 6 ) ) , //ammomin
Cmd_Argv ( 7 ) , //viewmodel
Cmd_Argv ( 8 ) , //weaponicon
Cmd_Argv ( 9 ) , //weaponicon_sel
Cmd_Argv ( 10 ) ) ; //ammoicon
}
}
2018-12-11 00:20:59 +00:00
2018-12-06 04:55:35 +00:00
//hacks, because we have to guess what the mod is doing. we'll probably get it wrong, which sucks.
2022-06-19 15:18:08 +00:00
static qboolean IN_HaveWeapon_Idx ( int pnum , size_t widx )
2018-12-06 04:55:35 +00:00
{
2022-06-19 15:18:08 +00:00
if ( widx < weaponinfo_count )
if ( ( cl . playerview [ pnum ] . stats [ STAT_ITEMS ] & weaponinfo [ widx ] . items_mask ) = = weaponinfo [ widx ] . items_val ) //we have the weapon
if ( weaponinfo [ widx ] . ammostat < 0 | | cl . playerview [ pnum ] . stats [ weaponinfo [ widx ] . ammostat ] > = weaponinfo [ widx ] . ammomin ) //and we have enough ammo for it too.
return true ;
return false ;
}
static qboolean IN_HaveWeapon ( int pnum , int impulse )
{
size_t widx ;
for ( widx = 0 ; widx < weaponinfo_count ; widx + + )
2018-12-06 04:55:35 +00:00
{
2022-06-19 15:18:08 +00:00
if ( weaponinfo [ widx ] . impulse = = impulse )
return IN_HaveWeapon_Idx ( pnum , widx ) ;
2018-12-06 04:55:35 +00:00
}
2022-06-19 15:18:08 +00:00
return false ; //we don't really know about it, but assume we can't because false negatives are better than false positives here.
}
static qboolean IN_HaveWeapon_Name ( int pnum , char * name , int * impulse )
{
int widx = IN_NameToWeaponIdx ( name ) ;
if ( widx < 0 )
return false ;
if ( ! IN_HaveWeapon_Idx ( pnum , widx ) )
return false ;
* impulse = weaponinfo [ widx ] . impulse ;
return true ;
2018-12-06 04:55:35 +00:00
}
static int IN_BestWeapon_Pre ( unsigned int pnum ) ;
//if we're using weapon preselection, then we probably also want to show which weapon will be selected, instead of showing the shotgun the whole time.
//this of course requires more hacks.
const char * IN_GetPreselectedViewmodelName ( unsigned int pnum )
{
if ( r_viewpreselgun . ival & & cl_weaponpreselect . ival & & pnum < countof ( preselectedweapons ) & & preselectedweapons [ pnum ] )
{
int best = IN_BestWeapon_Pre ( pnum ) ;
2022-06-19 15:18:08 +00:00
size_t widx ;
for ( widx = 0 ; widx < weaponinfo_count ; widx + + )
{
if ( weaponinfo [ widx ] . impulse = = best )
return weaponinfo [ widx ] . viewmodel ;
}
2018-12-06 04:55:35 +00:00
}
return NULL ;
}
2022-06-19 15:18:08 +00:00
2018-12-06 04:55:35 +00:00
static int IN_BestWeapon_Args ( unsigned int pnum , int firstarg , int argcount )
2022-06-19 15:18:08 +00:00
{ //returns impulses.
2018-12-06 04:55:35 +00:00
int i , imp ;
unsigned int best = 0 ;
for ( i = firstarg + argcount ; - - i > = firstarg ; )
{
2022-06-19 15:18:08 +00:00
if ( IN_HaveWeapon_Name ( pnum , Cmd_Argv ( i ) , & imp ) )
2018-12-06 04:55:35 +00:00
best = imp ;
}
return best ;
}
static int IN_BestWeapon_Pre ( unsigned int pnum )
{
int i , imp ;
unsigned int best = 0 ;
for ( i = preselectedweapons [ pnum ] ; i - - > 0 ; )
{
imp = preselectedweapon [ pnum ] [ i ] ;
if ( IN_HaveWeapon ( pnum , imp ) )
best = imp ;
}
return best ;
}
static void IN_DoPostSelect ( void )
{
2022-06-19 15:18:08 +00:00
int pnum = CL_TargettedSplit ( false ) ;
2018-12-06 04:55:35 +00:00
if ( cl_weaponpreselect . ival )
{
int best = IN_BestWeapon_Pre ( pnum ) ;
if ( best )
2020-07-21 07:58:54 +00:00
CL_QueueImpulse ( pnum , best ) ;
2018-12-06 04:55:35 +00:00
}
2022-06-19 15:18:08 +00:00
if ( in_wwheel . state [ pnum ] & 1 )
{
in_wwheel . state [ pnum ] = 0 ;
pnum = CL_TargettedSplit ( false ) ;
if ( wwheelsel [ pnum ] < weaponinfo_count )
CL_QueueImpulse ( pnum , weaponinfo [ wwheelsel [ pnum ] ] . impulse ) ;
}
2018-12-06 04:55:35 +00:00
}
//The weapon command autoselects a prioritised weapon like multi-arg impulse does.
//however, it potentially makes the switch only on the next +attack.
2019-08-19 16:15:31 +00:00
void IN_Weapon ( void )
2018-12-06 04:55:35 +00:00
{
int newimp ;
int pnum = CL_TargettedSplit ( false ) ;
int mode , best , i ;
2022-06-19 15:18:08 +00:00
preselectedweapons [ pnum ] = 0 ;
2018-12-06 04:55:35 +00:00
for ( i = 1 ; i < Cmd_Argc ( ) & & i < = countof ( preselectedweapon [ pnum ] ) ; i + + )
2022-06-19 15:18:08 +00:00
{
best = IN_NameToWeaponIdx ( Cmd_Argv ( i ) ) ;
if ( best > = 0 )
best = weaponinfo [ best ] . impulse ; //a known weapon
else
best = atoi ( Cmd_Argv ( i ) ) ; //fall back
if ( best > 0 )
preselectedweapon [ pnum ] [ preselectedweapons [ pnum ] + + ] = best ;
}
2018-12-06 04:55:35 +00:00
best = IN_BestWeapon_Pre ( pnum ) ;
if ( best )
{
newimp = best ;
if ( cl_weaponforgetorder . ival )
{ //make sure the +attack sticks with the selected weapon.
preselectedweapon [ pnum ] [ 0 ] = best ;
preselectedweapons [ pnum ] = 1 ;
}
}
else
return ; //no new weapon...
mode = cl_weaponpreselect . ival ;
if ( mode = = 3 )
mode = ( cl . deathmatch = = 1 ) ? 1 : 0 ;
else if ( mode = = 4 )
mode = ( cl . deathmatch = = 1 ) ? 2 : 0 ;
if ( mode = = 1 )
return ; //don't change yet.
if ( mode = = 2 & & ! ( in_attack . state [ pnum ] & 3 ) )
return ; //2 changes instantly only when already firing.
2020-07-21 07:58:54 +00:00
CL_QueueImpulse ( pnum , newimp ) ;
2004-08-23 00:15:46 +00:00
}
2018-12-06 04:55:35 +00:00
//+fire 8 7 [keycode]
//does impulse 8 or 7 (according to held weapons) along with a +attack
2019-08-19 16:15:31 +00:00
void IN_FireDown ( void )
2018-12-06 04:55:35 +00:00
{
int pnum = CL_TargettedSplit ( false ) ;
int k ;
int impulse ;
impulse = Cmd_Argc ( ) - 1 ;
k = atoi ( Cmd_Argv ( impulse ) ) ;
if ( k > = 32 )
impulse - - ; //scancode, don't treat that arg as a weapon number
else
k = - 1 ;
impulse = IN_BestWeapon_Args ( pnum , 1 , impulse ) ;
if ( impulse )
2020-07-21 07:58:54 +00:00
CL_QueueImpulse ( pnum , impulse ) ;
2018-12-06 04:55:35 +00:00
else
IN_DoPostSelect ( ) ;
KeyDown_Scan ( & in_attack , NULL , k ) ;
}
static void IN_DoWeaponHide ( void )
{
if ( cl_weaponhide . ival & & ! ( cl_weaponhide . ival = = 2 & & cl . deathmatch = = 1 ) )
{
int impulse , best = 0 ;
int pnum = CL_TargettedSplit ( false ) ;
char tok [ 64 ] ;
char * l = cl_weaponhide_preference . string ;
if ( ! strcmp ( l , " 0 " ) ) l = " 2 " ; //for compat with ezquake's cl_weaponhide_axe cvar.
while ( l & & * l )
{
l = COM_ParseOut ( l , tok , sizeof ( tok ) ) ;
2022-06-19 15:18:08 +00:00
if ( IN_HaveWeapon_Name ( pnum , tok , & impulse ) )
2018-12-06 04:55:35 +00:00
best = impulse ;
}
if ( best )
{ //looks like we're switching away
2020-07-21 07:58:54 +00:00
CL_QueueImpulse ( pnum , best ) ;
2018-12-06 04:55:35 +00:00
}
}
}
//-fire should trigger an impulse 1 or something.
2019-08-19 16:15:31 +00:00
void IN_FireUp ( void )
2018-12-06 04:55:35 +00:00
{
int k ;
int impulse ;
//any args are used in the +fire version and linger through to the -fire.
//the only useful one is the keynum.
impulse = Cmd_Argc ( ) - 1 ;
k = atoi ( Cmd_Argv ( impulse ) ) ;
if ( k > = 32 )
impulse - - ; //scancode, don't treat that arg as a weapon number
else
k = - 1 ;
if ( KeyUp_Scan ( & in_attack , k ) )
IN_DoWeaponHide ( ) ;
}
2022-06-19 15:18:08 +00:00
2023-01-09 05:12:59 +00:00
qboolean IN_WeaponWheelIsShown ( void )
{
if ( ! ( in_wwheel . state [ 0 ] & 1 ) | | ! weaponinfo_count )
return false ;
return true ;
}
2023-01-09 05:14:38 +00:00
qboolean IN_WeaponWheelAccumulate ( int pnum , float x , float y , float threshhold ) //either mouse or controller
2022-06-19 15:18:08 +00:00
{
if ( ! ( in_wwheel . state [ pnum ] & 1 ) | | ! weaponinfo_count )
return false ;
2023-01-09 05:14:38 +00:00
if ( x * x + y * y > threshhold * threshhold ) //protects against deadzones.
{
wwheeldir [ pnum ] [ 0 ] + = x ;
wwheeldir [ pnum ] [ 1 ] + = y ;
}
2022-06-19 15:18:08 +00:00
return true ;
}
# include "shader.h"
qboolean IN_DrawWeaponWheel ( int pnum )
{
int w ;
float pos [ 2 ] , centre [ 2 ] ;
const float radius = 64 ;
float d , a ;
shader_t * s ;
if ( ! ( in_wwheel . state [ pnum ] & 1 ) | | ! weaponinfo_count )
return false ;
R2D_ImageColours ( 1 , 1 , 1 , 1 ) ;
centre [ 0 ] = cl . playerview [ pnum ] . gamerect . x + cl . playerview [ pnum ] . gamerect . width / 2 ;
centre [ 1 ] = cl . playerview [ pnum ] . gamerect . y + cl . playerview [ pnum ] . gamerect . height / 2 ;
d = DotProduct2 ( wwheeldir [ pnum ] , wwheeldir [ pnum ] ) ;
a = 32 ;
if ( d > a * a & & d )
{
wwheeldir [ pnum ] [ 0 ] * = a / sqrt ( d ) ;
wwheeldir [ pnum ] [ 1 ] * = a / sqrt ( d ) ;
}
a = atan2 ( wwheeldir [ pnum ] [ 1 ] , wwheeldir [ pnum ] [ 0 ] ) ;
w = ( a / ( 2 * M_PI ) + 1 ) * weaponinfo_count + 0.5 ;
w = w % weaponinfo_count ;
if ( w ! = wwheelsel [ pnum ] )
{
wwheelseltime [ pnum ] = realtime ;
wwheelsel [ pnum ] = w ;
}
s = R2D_SafeCachePic ( " gfx/weaponwheel.lmp " ) ;
if ( R_GetShaderSizes ( s , NULL , NULL , false ) > 0 )
R2D_Image ( centre [ 0 ] - radius * 2 , centre [ 1 ] - radius * 2 , radius * 4 , radius * 4 , 0 , 0 , 1 , 1 , s ) ;
for ( w = 0 ; w < weaponinfo_count ; w + + )
{
pos [ 0 ] = centre [ 0 ] + cos ( ( w * 2 * M_PI ) / weaponinfo_count ) * radius ;
pos [ 1 ] = centre [ 1 ] + sin ( ( w * 2 * M_PI ) / weaponinfo_count ) * radius ;
if ( weaponinfo [ w ] . icons [ 0 ] )
{ //draw a shadow
R2D_ImageColours ( 0 , 0 , 0 , 1 ) ;
R2D_Image ( pos [ 0 ] - 24 + 2 , pos [ 1 ] - 16 + 2 , 48 , 32 , 0 , 0 , 1 , 1 , R2D_SafeCachePic ( weaponinfo [ w ] . icons [ 0 ] ) ) ;
}
//and the real icon (dark if unavailable)
if ( IN_HaveWeapon_Idx ( pnum , w ) )
R2D_ImageColours ( 1 , 1 , 1 , 1 ) ;
else
R2D_ImageColours ( 0.2 , 0.2 , 0.2 , 1 ) ;
if ( w = = wwheelsel [ pnum ] )
d = 1 + sin ( ( realtime - wwheelseltime [ pnum ] ) * 10 ) ; //make it bounce
else
d = 0 ;
if ( cl . playerview [ pnum ] . stats [ STAT_ACTIVEWEAPON ] = = weaponinfo [ w ] . items_val & & weaponinfo [ w ] . icons [ 1 ] )
R2D_Image ( pos [ 0 ] - 24 - d , pos [ 1 ] - 16 - d , 48 , 32 , 0 , 0 , 1 , 1 , R2D_SafeCachePic ( weaponinfo [ w ] . icons [ 1 ] ) ) ;
else if ( weaponinfo [ w ] . icons [ 0 ] )
R2D_Image ( pos [ 0 ] - 24 - d , pos [ 1 ] - 16 - d , 48 , 32 , 0 , 0 , 1 , 1 , R2D_SafeCachePic ( weaponinfo [ w ] . icons [ 0 ] ) ) ;
else
Draw_FunStringWidth ( pos [ 0 ] - 32 - d , pos [ 1 ] - 4 - d , weaponinfo [ w ] . shortname , 64 , 2 , cl . playerview [ pnum ] . stats [ STAT_ACTIVEWEAPON ] = = weaponinfo [ w ] . items_val ) ;
}
R2D_ImageColours ( 1 , 1 , 1 , 1 ) ;
w = wwheelsel [ pnum ] ;
if ( weaponinfo [ w ] . icons [ 2 ] )
R2D_Image ( centre [ 0 ] - 12 , centre [ 1 ] - 12 , 24 , 24 , 0 , 0 , 1 , 1 , R2D_SafeCachePic ( weaponinfo [ w ] . icons [ 2 ] ) ) ;
Draw_FunStringWidth ( centre [ 0 ] - 32 , centre [ 1 ] - 28 , weaponinfo [ w ] . shortname , 64 , 2 , false ) ;
if ( weaponinfo [ w ] . ammostat > = 0 )
Draw_FunStringWidth ( centre [ 0 ] - 32 , centre [ 1 ] + 20 , va ( " %s%d " , ( cl . playerview [ pnum ] . stats [ weaponinfo [ w ] . ammostat ] < 20 ) ? S_COLOR_RED : " " , cl . playerview [ pnum ] . stats [ weaponinfo [ w ] . ammostat ] ) , 64 , 2 , false ) ;
pos [ 0 ] = centre [ 0 ] + cos ( a ) * radius * 0.6 ;
pos [ 1 ] = centre [ 1 ] + sin ( a ) * radius * 0.6 ;
Draw_FunString ( pos [ 0 ] , pos [ 1 ] , " X " ) ;
return true ;
}
static void IN_WWheelDown ( void )
{
# ifdef CSQC_DAT
int pnum = CL_TargettedSplit ( false ) ;
if ( CSQC_ConsoleCommand ( pnum , Cmd_Argv ( 0 ) ) )
return ;
# endif
if ( ! ( in_wwheel . state [ pnum ] & 1 ) )
{
size_t w ;
for ( w = 0 ; w < weaponinfo_count ; w + + )
{
if ( cl . playerview [ pnum ] . stats [ STAT_ACTIVEWEAPON ] = = weaponinfo [ w ] . items_val )
{ //this is our active weapon. start with it highlighted.
wwheelseltime [ pnum ] = realtime ;
wwheelsel [ pnum ] = w ;
wwheeldir [ pnum ] [ 0 ] = cos ( ( wwheelsel [ pnum ] * 2 * M_PI ) / weaponinfo_count ) * 16 ;
wwheeldir [ pnum ] [ 1 ] = sin ( ( wwheelsel [ pnum ] * 2 * M_PI ) / weaponinfo_count ) * 16 ;
break ;
}
}
}
KeyDown ( & in_wwheel , NULL ) ;
}
static void IN_WWheelUp ( void )
{
int pnum = CL_TargettedSplit ( false ) ;
# ifdef CSQC_DAT
if ( CSQC_ConsoleCommand ( pnum , Cmd_Argv ( 0 ) ) )
return ;
# endif
if ( ! KeyUp ( & in_wwheel ) )
return ;
if ( wwheelsel [ pnum ] < weaponinfo_count )
CL_QueueImpulse ( pnum , weaponinfo [ wwheelsel [ pnum ] ] . impulse ) ;
}
2018-12-06 04:55:35 +00:00
# else
# define IN_DoPostSelect()
# define IN_DoWeaponHide()
# endif
2017-12-09 21:22:46 +00:00
static void IN_KLookDown ( void ) { KeyDown ( & in_klook , NULL ) ; }
static void IN_KLookUp ( void ) { KeyUp ( & in_klook ) ; }
static void IN_MLookDown ( void ) { KeyDown ( & in_mlook , NULL ) ; }
static void IN_MLookUp ( void )
2010-08-14 00:15:07 +00:00
{
2010-08-14 03:17:33 +00:00
int pnum = CL_TargettedSplit ( false ) ;
2010-08-14 00:15:07 +00:00
KeyUp ( & in_mlook ) ;
if ( ! ( in_mlook . state [ pnum ] & 1 ) & & lookspring . ival )
2013-06-23 02:17:02 +00:00
V_StartPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
2017-12-09 21:22:46 +00:00
static void IN_UpDown ( void ) { KeyDown ( & in_up , & in_down ) ; }
static void IN_UpUp ( void ) { KeyUp ( & in_up ) ; }
static void IN_DownDown ( void ) { KeyDown ( & in_down , & in_up ) ; }
static void IN_DownUp ( void ) { KeyUp ( & in_down ) ; }
static void IN_LeftDown ( void ) { KeyDown ( & in_left , & in_right ) ; }
static void IN_LeftUp ( void ) { KeyUp ( & in_left ) ; }
static void IN_RightDown ( void ) { KeyDown ( & in_right , & in_left ) ; }
static void IN_RightUp ( void ) { KeyUp ( & in_right ) ; }
static void IN_ForwardDown ( void ) { KeyDown ( & in_forward , & in_back ) ; }
static void IN_ForwardUp ( void ) { KeyUp ( & in_forward ) ; }
static void IN_BackDown ( void ) { KeyDown ( & in_back , & in_forward ) ; }
static void IN_BackUp ( void ) { KeyUp ( & in_back ) ; }
static void IN_LookupDown ( void ) { KeyDown ( & in_lookup , & in_lookdown ) ; }
static void IN_LookupUp ( void ) { KeyUp ( & in_lookup ) ; }
static void IN_LookdownDown ( void ) { KeyDown ( & in_lookdown , & in_lookup ) ; }
static void IN_LookdownUp ( void ) { KeyUp ( & in_lookdown ) ; }
static void IN_MoveleftDown ( void ) { KeyDown ( & in_moveleft , & in_moveright ) ; }
static void IN_MoveleftUp ( void ) { KeyUp ( & in_moveleft ) ; }
static void IN_MoverightDown ( void ) { KeyDown ( & in_moveright , & in_moveleft ) ; }
static void IN_MoverightUp ( void ) { KeyUp ( & in_moveright ) ; }
static void IN_RollLeftDown ( void ) { KeyDown ( & in_rollleft , & in_rollright ) ; }
static void IN_RollLeftUp ( void ) { KeyUp ( & in_rollleft ) ; }
static void IN_RollRightDown ( void ) { KeyDown ( & in_rollright , & in_rollleft ) ; }
static void IN_RollRightUp ( void ) { KeyUp ( & in_rollright ) ; }
static void IN_SpeedDown ( void ) { KeyDown ( & in_speed , NULL ) ; }
static void IN_SpeedUp ( void ) { KeyUp ( & in_speed ) ; }
static void IN_StrafeDown ( void ) { KeyDown ( & in_strafe , NULL ) ; }
static void IN_StrafeUp ( void ) { KeyUp ( & in_strafe ) ; }
2018-12-06 04:55:35 +00:00
static void IN_AttackDown ( void ) { IN_DoPostSelect ( ) ; KeyDown ( & in_attack , NULL ) ; }
static void IN_AttackUp ( void ) { if ( KeyUp ( & in_attack ) ) IN_DoWeaponHide ( ) ; }
2017-12-09 21:22:46 +00:00
static void IN_UseDown ( void ) { KeyDown ( & in_use , NULL ) ; }
static void IN_UseUp ( void ) { KeyUp ( & in_use ) ; }
static void IN_JumpDown ( void )
2005-04-16 16:21:27 +00:00
{
2020-02-11 18:06:10 +00:00
qboolean up ;
2010-08-14 03:17:33 +00:00
int pnum = CL_TargettedSplit ( false ) ;
2017-05-28 15:42:32 +00:00
playerview_t * pv = & cl . playerview [ pnum ] ;
2005-04-16 16:21:27 +00:00
2020-02-11 18:06:10 +00:00
up = ( cls . state = = ca_active & & cl_smartjump . ival & & ! prox_inmenu . ival ) ;
if ( ! up )
up = false ;
2005-04-16 16:21:27 +00:00
# ifdef Q2CLIENT
2020-02-11 18:06:10 +00:00
else if ( cls . protocol = = CP_QUAKE2 )
up = true ; //always smartjump in q2.
2005-04-16 16:21:27 +00:00
# endif
2020-02-11 18:06:10 +00:00
else if ( pv - > spectator & & pv - > cam_state ! = CAM_FREECAM )
up = false ; //if we're tracking, don't confuse stuff.
2015-09-01 04:45:15 +00:00
# ifdef QUAKESTATS
2020-02-11 18:06:10 +00:00
else if ( ! pv - > spectator & & pv - > stats [ STAT_HEALTH ] < = 0 )
up = false ; //don't ever 'swim' when dead.
else if ( pv - > pmovetype = = PM_FLY | | pv - > pmovetype = = PM_6DOF | | pv - > pmovetype = = PM_SPECTATOR | | pv - > pmovetype = = PM_OLD_SPECTATOR )
up = true ; //fling/spectating
else if ( ( pv - > pmovetype = = PM_NORMAL | | pv - > pmovetype = = PM_WALLWALK ) & & pv - > waterlevel > = 2 & & ( ! cl . teamfortress | | ! ( in_forward . state [ pnum ] & 1 ) ) )
up = true ; //swimming. TF only (silently) smartjumps when NOT moving.
2015-09-01 04:45:15 +00:00
# endif
2005-04-16 16:21:27 +00:00
else
2020-02-11 18:06:10 +00:00
up = false ;
KeyDown ( ( up ? & in_up : & in_jump ) , & in_down ) ;
2005-04-16 16:21:27 +00:00
}
2017-12-09 21:22:46 +00:00
static void IN_JumpUp ( void )
2005-04-16 16:21:27 +00:00
{
2009-11-04 21:16:50 +00:00
if ( cl_smartjump . ival )
2005-04-16 16:21:27 +00:00
KeyUp ( & in_up ) ;
KeyUp ( & in_jump ) ;
}
2004-08-23 00:15:46 +00:00
2019-10-19 22:02:12 +00:00
static void IN_ButtonNDown ( void ) { KeyDown ( & in_button [ atoi ( Cmd_Argv ( 0 ) + 7 ) ] , NULL ) ; }
static void IN_ButtonNUp ( void ) { KeyUp ( & in_button [ atoi ( Cmd_Argv ( 0 ) + 7 ) ] ) ; }
2004-09-01 22:56:08 +00:00
2005-01-13 16:29:20 +00:00
float in_rotate ;
2017-12-09 21:22:46 +00:00
static void IN_Rotate_f ( void ) { in_rotate + = atoi ( Cmd_Argv ( 1 ) ) ; }
2005-01-13 16:29:20 +00:00
2004-09-01 22:56:08 +00:00
2015-06-15 20:11:27 +00:00
void IN_WriteButtons ( vfsfile_t * f , qboolean all )
{
int s , b ;
struct
{
kbutton_t * button ;
char * name ;
} buttons [ ] =
{
{ & in_mlook , " mlook " } ,
{ & in_klook , " klook " } ,
{ & in_left , " left " } ,
{ & in_right , " right " } ,
{ & in_forward , " forward " } ,
{ & in_back , " back " } ,
{ & in_lookup , " lookup " } ,
{ & in_lookdown , " lookdown " } ,
{ & in_moveleft , " moveleft " } ,
{ & in_moveright , " moveright " } ,
{ & in_strafe , " strafe " } ,
{ & in_speed , " speed " } ,
{ & in_use , " use " } ,
{ & in_jump , " jump " } ,
{ & in_attack , " attack " } ,
{ & in_rollleft , " rollleft " } ,
{ & in_rollright , " rollright " } ,
{ & in_up , " up " } ,
{ & in_down , " down " } ,
} ;
s = 0 ;
VFS_PRINTF ( f , " \n //Player 1 buttons \n " ) ;
for ( b = 0 ; b < countof ( buttons ) ; b + + )
{
2018-04-09 18:01:15 +00:00
if ( ( buttons [ b ] . button - > state [ s ] & 1 ) & & ( buttons [ b ] . button - > down [ s ] [ 0 ] = = - 1 | | buttons [ b ] . button - > down [ s ] [ 1 ] = = - 1 ) )
2015-06-15 20:11:27 +00:00
VFS_PRINTF ( f , " +%s \n " , buttons [ b ] . name ) ;
else if ( b | | all )
VFS_PRINTF ( f , " -%s \n " , buttons [ b ] . name ) ;
}
2018-10-11 10:31:23 +00:00
for ( b = 0 ; b < countof ( in_button ) ; b + + )
{
if ( ( in_button [ b ] . state [ s ] & 1 ) & & ( in_button [ b ] . down [ s ] [ 0 ] = = - 1 | | in_button [ b ] . down [ s ] [ 1 ] = = - 1 ) )
2019-10-19 22:02:12 +00:00
VFS_PRINTF ( f , " +button%i \n " , b ) ;
2018-10-11 10:31:23 +00:00
else
2019-10-19 22:02:12 +00:00
VFS_PRINTF ( f , " -button%i \n " , b ) ;
2018-10-11 10:31:23 +00:00
}
2018-04-09 18:01:15 +00:00
for ( s = 1 ; s < MAX_SPLITS ; s + + )
2015-06-15 20:11:27 +00:00
{
2018-04-09 18:01:15 +00:00
VFS_PRINTF ( f , " \n //Player %i buttons \n " , s ) ;
2015-06-15 20:11:27 +00:00
for ( b = 0 ; b < countof ( buttons ) ; b + + )
{
2018-04-09 18:01:15 +00:00
if ( ( buttons [ b ] . button - > state [ s ] & 1 ) & & ( buttons [ b ] . button - > down [ s ] [ 0 ] = = - 1 | | buttons [ b ] . button - > down [ s ] [ 1 ] = = - 1 ) )
VFS_PRINTF ( f , " +p%i %s \n " , s , buttons [ b ] . name ) ;
2015-06-15 20:11:27 +00:00
else if ( b | | all )
2018-04-09 18:01:15 +00:00
VFS_PRINTF ( f , " -p%i %s \n " , s , buttons [ b ] . name ) ;
2015-06-15 20:11:27 +00:00
}
2018-10-11 10:31:23 +00:00
for ( b = 0 ; b < countof ( in_button ) ; b + + )
{
if ( ( in_button [ b ] . state [ s ] & 1 ) & & ( in_button [ b ] . down [ s ] [ 0 ] = = - 1 | | in_button [ b ] . down [ s ] [ 1 ] = = - 1 ) )
2019-10-19 22:02:12 +00:00
VFS_PRINTF ( f , " +p%i button%i \n " , s , b ) ;
2018-10-11 10:31:23 +00:00
else
2019-10-19 22:02:12 +00:00
VFS_PRINTF ( f , " -p%i button%i \n " , s , b ) ;
2018-10-11 10:31:23 +00:00
}
2015-06-15 20:11:27 +00:00
}
2016-01-18 05:22:07 +00:00
//FIXME: save device remappings to config.
2015-06-15 20:11:27 +00:00
}
2004-08-23 00:15:46 +00:00
//This function incorporates Tonik's impulse 8 7 6 5 4 3 2 1 to select the prefered weapon on the basis of having it.
//It also incorporates split screen input as well as impulse buffering
void IN_Impulse ( void )
{
int newimp ;
2010-08-14 03:17:33 +00:00
int pnum = CL_TargettedSplit ( false ) ;
2004-08-23 00:15:46 +00:00
newimp = Q_atoi ( Cmd_Argv ( 1 ) ) ;
2015-09-01 04:45:15 +00:00
# ifdef QUAKESTATS
2004-08-23 00:15:46 +00:00
if ( Cmd_Argc ( ) > 2 )
{
2018-12-06 04:55:35 +00:00
int best = IN_BestWeapon_Args ( pnum , 1 , Cmd_Argc ( ) - 1 ) ;
2004-08-23 00:15:46 +00:00
if ( best )
newimp = best ;
}
2015-09-01 04:45:15 +00:00
# endif
2004-08-23 00:15:46 +00:00
2020-07-21 07:58:54 +00:00
CL_QueueImpulse ( pnum , newimp ) ;
2004-08-23 00:15:46 +00:00
}
2006-02-21 09:19:56 +00:00
void IN_Restart ( void )
2006-02-20 22:33:30 +00:00
{
IN_Shutdown ( ) ;
2006-05-10 22:12:20 +00:00
IN_ReInit ( ) ;
2016-01-18 05:22:07 +00:00
//FIXME: re-assert explicit device re-mappings
2006-02-20 22:33:30 +00:00
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = =
CL_KeyState
Returns 0.25 if a key was pressed and released during the frame ,
0.5 if it was pressed and held
0 if held then released , and
1.0 if held for the entire time
= = = = = = = = = = = = = = =
*/
2014-04-13 04:23:13 +00:00
float CL_KeyState ( kbutton_t * key , int pnum , qboolean noslowstart )
2004-08-23 00:15:46 +00:00
{
float val ;
qboolean impulsedown , impulseup , down ;
2014-04-13 04:23:13 +00:00
noslowstart = noslowstart & & cl_fastaccel . ival ;
2004-08-23 00:15:46 +00:00
impulsedown = key - > state [ pnum ] & 2 ;
impulseup = key - > state [ pnum ] & 4 ;
down = key - > state [ pnum ] & 1 ;
val = 0 ;
if ( impulsedown & & ! impulseup )
{
if ( down )
2014-04-13 04:23:13 +00:00
val = noslowstart ? 1.0 : 0.5 ; // pressed and held this frame
2004-08-23 00:15:46 +00:00
else
val = 0 ; // I_Error ();
}
if ( impulseup & & ! impulsedown )
{
if ( down )
val = 0 ; // I_Error ();
else
val = 0 ; // released this frame
}
if ( ! impulsedown & & ! impulseup )
{
if ( down )
val = 1.0 ; // held the entire frame
else
val = 0 ; // up the entire frame
}
if ( impulsedown & & impulseup )
{
if ( down )
val = 0.75 ; // released and re-pressed this frame
else
val = 0.25 ; // pressed and released this frame
}
key - > state [ pnum ] & = 1 ; // clear impulses
return val ;
}
2007-01-06 09:37:33 +00:00
void CL_ProxyMenuHook ( char * command , kbutton_t * key )
{
if ( ( key - > state [ 0 ] & 3 ) = = 3 ) //2 is impulse down, 1 is held down
{
key - > state [ 0 ] = 0 ; // clear impulses
Cbuf_AddText ( command , RESTRICT_DEFAULT ) ;
}
}
void CL_ProxyMenuHooks ( void )
{
2009-11-04 21:16:50 +00:00
if ( ! prox_inmenu . ival )
2007-01-06 09:37:33 +00:00
return ;
CL_ProxyMenuHook ( " say proxy:menu down \n " , & in_back ) ;
CL_ProxyMenuHook ( " say proxy:menu up \n " , & in_forward ) ;
2004-08-23 00:15:46 +00:00
2007-01-06 09:37:33 +00:00
CL_ProxyMenuHook ( " say proxy:menu left \n " , & in_left ) ;
CL_ProxyMenuHook ( " say proxy:menu right \n " , & in_right ) ;
CL_ProxyMenuHook ( " say proxy:menu left \n " , & in_moveleft ) ;
CL_ProxyMenuHook ( " say proxy:menu right \n " , & in_moveright ) ;
CL_ProxyMenuHook ( " say proxy:menu use \n " , & in_jump ) ;
}
2004-08-23 00:15:46 +00:00
//==========================================================================
2016-09-08 19:04:35 +00:00
cvar_t cl_upspeed = CVARF ( " cl_upspeed " , " 400 " , CVAR_ARCHIVE ) ;
cvar_t cl_forwardspeed = CVARF ( " cl_forwardspeed " , " 400 " , CVAR_ARCHIVE ) ;
2014-02-11 17:51:29 +00:00
cvar_t cl_backspeed = CVARFD ( " cl_backspeed " , " " , CVAR_ARCHIVE , " The base speed that you move backwards at. If empty, uses the value of cl_forwardspeed instead. " ) ;
2016-09-08 19:04:35 +00:00
cvar_t cl_sidespeed = CVARF ( " cl_sidespeed " , " 400 " , CVAR_ARCHIVE ) ;
2004-08-23 00:15:46 +00:00
2016-09-08 19:04:35 +00:00
cvar_t cl_movespeedkey = CVAR ( " cl_movespeedkey " , " 2.0 " ) ;
2004-08-23 00:15:46 +00:00
2016-09-08 19:04:35 +00:00
cvar_t cl_yawspeed = CVAR ( " cl_yawspeed " , " 140 " ) ;
cvar_t cl_pitchspeed = CVAR ( " cl_pitchspeed " , " 150 " ) ;
2004-08-23 00:15:46 +00:00
2016-09-08 19:04:35 +00:00
cvar_t cl_anglespeedkey = CVAR ( " cl_anglespeedkey " , " 1.5 " ) ;
2004-08-23 00:15:46 +00:00
2015-02-02 08:01:53 +00:00
2019-10-19 22:02:12 +00:00
# define GATHERBIT(bname,bit) if (bname.state[pnum] & 3) {bits |= (1u<<(bit));} bname.state[pnum] &= ~2;
2022-05-28 18:00:22 +00:00
# define UNUSEDBUTTON(bnum) if (in_button[bnum].state[pnum] & 3) {Con_Printf("+button%i is not supported on this protocol\n", bnum); } in_button[bnum].state[pnum] &= ~3;
2015-02-02 08:01:53 +00:00
void CL_GatherButtons ( usercmd_t * cmd , int pnum )
{
unsigned int bits = 0 ;
2018-10-11 10:31:23 +00:00
GATHERBIT ( in_attack , 0 ) ;
2019-10-19 22:02:12 +00:00
# ifdef Q3CLIENT
if ( cls . protocol = = CP_QUAKE3 )
{ //quake3's buttons are nice and simple, buttonN -> bit|=(1<<N)
int i ;
for ( i = 0 ; i < countof ( in_button ) ; i + + )
{
GATHERBIT ( in_button [ i ] , i ) ;
}
// bits |= 1<<1; //rtcw talking
// bits |= 1<<4; //rtcw walking
// bits |= 1<<7; //rtcw any key
cmd - > buttons = bits ;
return ;
}
# endif
//quakec's numbered buttons make no sense and have no sane relation to bit numbers
GATHERBIT ( in_button [ 0 ] , 0 ) ;
UNUSEDBUTTON ( 1 ) ; //officially, qc's button1 field is unusable (although qw folds button3 over to it)
GATHERBIT ( in_button [ 2 ] , 1 ) ; GATHERBIT ( in_jump , 1 ) ;
GATHERBIT ( in_button [ 3 ] , 2 ) ;
GATHERBIT ( in_button [ 4 ] , 3 ) ;
GATHERBIT ( in_button [ 5 ] , 4 ) ;
GATHERBIT ( in_button [ 6 ] , 5 ) ;
GATHERBIT ( in_button [ 7 ] , 6 ) ;
GATHERBIT ( in_button [ 8 ] , 7 ) ;
2018-10-11 10:31:23 +00:00
2021-04-14 05:21:04 +00:00
//more inconsistencies, as required for dpcompat.
2018-10-11 10:31:23 +00:00
GATHERBIT ( in_use , ( cls . protocol = = CP_QUAKEWORLD ) ? 4 : 8 ) ;
2021-04-14 05:21:04 +00:00
bits | = ( Key_Dest_Has ( ~ kdm_game ) ) ? ( 1u < < 9 ) : 0 ; //'buttonchat'. game is the lowest priority, anything else will take focus away. we consider that to mean 'chat' (although it could be menus).
bits | = ( cursor_active ) ? ( 1u < < 10 ) : 0 ; //'cursor_active'. prydon cursor stuff.
2019-10-19 22:02:12 +00:00
GATHERBIT ( in_button [ 9 ] , 11 ) ;
GATHERBIT ( in_button [ 10 ] , 12 ) ;
GATHERBIT ( in_button [ 11 ] , 13 ) ;
GATHERBIT ( in_button [ 12 ] , 14 ) ;
GATHERBIT ( in_button [ 13 ] , 15 ) ;
GATHERBIT ( in_button [ 14 ] , 16 ) ;
GATHERBIT ( in_button [ 15 ] , 17 ) ;
GATHERBIT ( in_button [ 16 ] , 18 ) ;
UNUSEDBUTTON ( 17 ) ;
UNUSEDBUTTON ( 18 ) ;
UNUSEDBUTTON ( 19 ) ;
// UNUSEDBUTTON(20);
2021-04-14 05:21:04 +00:00
//NQ protocol:
//bit 30 means input_weapon field is sent. figured out at time of sending.
//bit 31 means input_cursor* fields are sent. figured out at time of sending.
2019-07-16 02:59:12 +00:00
cmd - > buttons | = bits ;
2015-02-02 08:01:53 +00:00
}
2019-08-19 16:15:31 +00:00
void CL_ClearPendingCommands ( void )
{
size_t seat , i ;
memset ( & cl_pendingcmd , 0 , sizeof ( cl_pendingcmd ) ) ;
for ( seat = 0 ; seat < countof ( cl_pendingcmd ) ; seat + + )
{
for ( i = 0 ; i < 3 ; i + + )
cl_pendingcmd [ seat ] . angles [ i ] = ( ( int ) ( cl . playerview [ seat ] . viewangles [ i ] * 65536.0 / 360 ) & 65535 ) ;
}
}
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = =
CL_AdjustAngles
Moves the local angle positions
= = = = = = = = = = = = = = = =
*/
2009-05-24 10:11:17 +00:00
void CL_AdjustAngles ( int pnum , double frametime )
2004-08-23 00:15:46 +00:00
{
2005-01-13 16:29:20 +00:00
float speed , quant ;
2004-08-23 00:15:46 +00:00
float up , down ;
if ( in_speed . state [ pnum ] & 1 )
2007-08-23 21:25:18 +00:00
{
2009-11-04 21:16:50 +00:00
if ( ruleset_allow_frj . ival )
2020-01-23 18:53:52 +00:00
speed = cl_anglespeedkey . value ;
2007-08-23 21:25:18 +00:00
else
2020-01-23 18:53:52 +00:00
speed = bound ( - 2 , cl_anglespeedkey . value , 2 ) ;
2007-08-23 21:25:18 +00:00
}
2004-08-23 00:15:46 +00:00
else
2020-01-23 18:53:52 +00:00
speed = 1 ;
2004-08-23 00:15:46 +00:00
2006-07-17 17:33:35 +00:00
if ( in_rotate & & pnum = = 0 & & ! ( cl . fpd & FPD_LIMIT_YAW ) )
2005-01-13 16:29:20 +00:00
{
quant = in_rotate ;
2009-11-04 21:16:50 +00:00
if ( ! cl_instantrotate . ival )
2020-01-23 18:53:52 +00:00
quant * = speed * frametime ;
2005-01-13 16:29:20 +00:00
in_rotate - = quant ;
2009-11-04 21:16:50 +00:00
if ( ruleset_allow_frj . ival )
2012-07-05 19:42:36 +00:00
cl . playerview [ pnum ] . viewanglechange [ YAW ] + = quant ;
2005-01-13 16:29:20 +00:00
}
2004-08-23 00:15:46 +00:00
if ( ! ( in_strafe . state [ pnum ] & 1 ) )
{
2020-01-23 18:53:52 +00:00
quant = cl_yawspeed . value * speed ;
2020-01-09 15:35:40 +00:00
if ( ( cl . fpd & FPD_LIMIT_YAW ) | | ! ruleset_allow_frj . ival )
2006-07-17 17:33:35 +00:00
quant = bound ( - 900 , quant , 900 ) ;
2020-01-23 18:53:52 +00:00
quant * = frametime ;
cl . playerview [ pnum ] . viewanglechange [ YAW ] - = quant * CL_KeyState ( & in_right , pnum , false ) ;
cl . playerview [ pnum ] . viewanglechange [ YAW ] + = quant * CL_KeyState ( & in_left , pnum , false ) ;
2004-08-23 00:15:46 +00:00
}
if ( in_klook . state [ pnum ] & 1 )
{
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2020-01-23 18:53:52 +00:00
quant = cl_pitchspeed . value * speed ;
2020-01-09 15:35:40 +00:00
if ( ( cl . fpd & FPD_LIMIT_PITCH ) | | ! ruleset_allow_frj . ival )
2006-07-17 17:33:35 +00:00
quant = bound ( - 700 , quant , 700 ) ;
2020-01-23 18:53:52 +00:00
quant * = frametime ;
cl . playerview [ pnum ] . viewanglechange [ PITCH ] - = quant * CL_KeyState ( & in_forward , pnum , false ) ;
cl . playerview [ pnum ] . viewanglechange [ PITCH ] + = quant * CL_KeyState ( & in_back , pnum , false ) ;
2004-08-23 00:15:46 +00:00
}
2014-06-21 17:58:17 +00:00
2020-01-23 18:53:52 +00:00
quant = cl_rollspeed . value * speed ;
quant * = frametime ;
cl . playerview [ pnum ] . viewanglechange [ ROLL ] - = quant * CL_KeyState ( & in_rollleft , pnum , false ) ;
cl . playerview [ pnum ] . viewanglechange [ ROLL ] + = quant * CL_KeyState ( & in_rollright , pnum , false ) ;
2004-08-23 00:15:46 +00:00
2014-04-13 04:23:13 +00:00
up = CL_KeyState ( & in_lookup , pnum , false ) ;
down = CL_KeyState ( & in_lookdown , pnum , false ) ;
2007-08-23 21:25:18 +00:00
2020-01-23 18:53:52 +00:00
quant = cl_pitchspeed . value * speed ;
2020-01-09 15:35:40 +00:00
if ( ( cl . fpd & FPD_LIMIT_PITCH ) | | ! ruleset_allow_frj . ival )
quant = bound ( - 700 , quant , 700 ) ;
2020-01-23 18:53:52 +00:00
quant * = frametime ;
cl . playerview [ pnum ] . viewanglechange [ PITCH ] - = quant * up ;
cl . playerview [ pnum ] . viewanglechange [ PITCH ] + = quant * down ;
2004-08-23 00:15:46 +00:00
if ( up | | down )
2013-06-23 02:17:02 +00:00
V_StopPitchDrift ( & cl . playerview [ pnum ] ) ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = = = =
CL_BaseMove
Send the intended movement message to the server
= = = = = = = = = = = = = = = =
*/
2022-01-28 10:48:14 +00:00
static void CL_BaseMove ( vec3_t moves , int pnum )
2004-08-23 00:15:46 +00:00
{
2022-01-28 10:48:14 +00:00
float scale ;
2005-05-26 12:55:34 +00:00
//
// adjust for speed key
//
2022-01-28 10:48:14 +00:00
scale = ( ( in_speed . state [ pnum ] & 1 ) ^ cl_run . ival ) ? cl_movespeedkey . value : 1 ;
2004-08-23 00:15:46 +00:00
2022-01-28 10:48:14 +00:00
moves [ 0 ] = 0 ;
2004-08-23 00:15:46 +00:00
if ( ! ( in_klook . state [ pnum ] & 1 ) )
2022-01-28 10:48:14 +00:00
{
moves [ 0 ] + = scale * ( cl_forwardspeed . value * CL_KeyState ( & in_forward , pnum , true ) -
( * cl_backspeed . string ? cl_backspeed . value : cl_forwardspeed . value ) * CL_KeyState ( & in_back , pnum , true ) ) ;
2005-05-26 12:55:34 +00:00
}
2022-01-28 10:48:14 +00:00
moves [ 1 ] = scale * cl_sidespeed . value * ( CL_KeyState ( & in_moveright , pnum , true ) - CL_KeyState ( & in_moveleft , pnum , true ) ) * ( in_xflip . ival ? - 1 : 1 ) ;
if ( in_strafe . state [ pnum ] & 1 )
moves [ 1 ] + = scale * cl_sidespeed . value * ( CL_KeyState ( & in_right , pnum , true ) - CL_KeyState ( & in_left , pnum , true ) ) * ( in_xflip . ival ? - 1 : 1 ) ;
moves [ 2 ] = scale * cl_upspeed . value * ( CL_KeyState ( & in_up , pnum , true ) - CL_KeyState ( & in_down , pnum , true ) ) ;
2004-08-23 00:15:46 +00:00
}
2021-05-09 13:02:49 +00:00
void CL_ClampPitch ( int pnum , float frametime )
2004-08-23 00:15:46 +00:00
{
2013-03-12 22:47:42 +00:00
float mat [ 16 ] ;
2012-02-15 13:53:30 +00:00
float roll ;
2014-06-21 17:58:17 +00:00
playerview_t * pv = & cl . playerview [ pnum ] ;
2013-07-26 17:19:06 +00:00
2015-09-01 04:45:15 +00:00
if ( cl . intermissionmode ! = IM_NONE )
2013-07-26 17:19:06 +00:00
{
2014-06-21 17:58:17 +00:00
memset ( pv - > viewanglechange , 0 , sizeof ( pv - > viewanglechange ) ) ;
2013-07-26 17:19:06 +00:00
return ;
}
2015-03-03 00:14:43 +00:00
if ( pv - > pmovetype = = PM_6DOF )
2012-02-14 15:50:34 +00:00
{
2014-06-22 23:58:53 +00:00
// vec3_t impact;
// vec3_t norm;
2013-03-12 22:47:42 +00:00
float mat2 [ 16 ] ;
2014-06-22 23:58:53 +00:00
// vec3_t cross;
2013-03-12 22:47:42 +00:00
vec3_t view [ 4 ] ;
2014-06-22 23:58:53 +00:00
// float dot;
2014-06-21 17:58:17 +00:00
AngleVectors ( pv - > viewangles , view [ 0 ] , view [ 1 ] , view [ 2 ] ) ;
2012-02-14 15:50:34 +00:00
Matrix4x4_RM_FromVectors ( mat , view [ 0 ] , view [ 1 ] , view [ 2 ] , vec3_origin ) ;
2014-06-21 17:58:17 +00:00
Matrix4_Multiply ( Matrix4x4_CM_NewRotation ( - pv - > viewanglechange [ PITCH ] , 0 , 1 , 0 ) , mat , mat2 ) ;
Matrix4_Multiply ( Matrix4x4_CM_NewRotation ( pv - > viewanglechange [ YAW ] , 0 , 0 , 1 ) , mat2 , mat ) ;
# if 1
//roll angles
Matrix4_Multiply ( Matrix4x4_CM_NewRotation ( pv - > viewanglechange [ ROLL ] , 1 , 0 , 0 ) , mat , mat2 ) ;
# else
//auto-roll
2012-02-14 15:50:34 +00:00
Matrix3x4_RM_ToVectors ( mat , view [ 0 ] , view [ 1 ] , view [ 2 ] , view [ 3 ] ) ;
2014-06-21 17:58:17 +00:00
VectorMA ( pv - > simorg , - 48 , view [ 2 ] , view [ 3 ] ) ;
if ( ! TraceLineN ( pv - > simorg , view [ 3 ] , impact , norm ) )
2012-02-14 15:50:34 +00:00
{
norm [ 0 ] = 0 ;
norm [ 1 ] = 0 ;
norm [ 2 ] = 1 ;
}
2012-02-15 13:53:30 +00:00
/*keep the roll relative to the 'ground'*/
CrossProduct ( norm , view [ 2 ] , cross ) ;
dot = DotProduct ( view [ 0 ] , cross ) ;
roll = timestep * 360 * - ( dot ) ;
Matrix4_Multiply ( Matrix4x4_CM_NewRotation ( roll , 1 , 0 , 0 ) , mat , mat2 ) ;
2014-06-21 17:58:17 +00:00
# endif
2012-02-15 13:53:30 +00:00
Matrix3x4_RM_ToVectors ( mat2 , view [ 0 ] , view [ 1 ] , view [ 2 ] , view [ 3 ] ) ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
VectorAngles ( view [ 0 ] , view [ 2 ] , pv - > viewangles , false ) ;
2014-06-21 17:58:17 +00:00
VectorClear ( pv - > viewanglechange ) ;
2012-02-14 15:50:34 +00:00
2023-02-11 04:46:32 +00:00
//fixme: in_vraim stuff
VectorCopy ( pv - > viewangles , pv - > aimangles ) ;
2012-02-14 15:50:34 +00:00
return ;
}
2012-07-05 19:42:36 +00:00
# if 1
2014-06-21 17:58:17 +00:00
if ( ( pv - > gravitydir [ 2 ] ! = - 1 | | pv - > viewangles [ 2 ] ) )
2012-07-05 19:42:36 +00:00
{
float surfm [ 16 ] , invsurfm [ 16 ] ;
float viewm [ 16 ] ;
vec3_t view [ 4 ] ;
vec3_t surf [ 3 ] ;
vec3_t vang ;
void PerpendicularVector ( vec3_t dst , const vec3_t src ) ;
/*calc current view matrix relative to the surface*/
2014-06-21 17:58:17 +00:00
AngleVectors ( pv - > viewangles , view [ 0 ] , view [ 1 ] , view [ 2 ] ) ;
2012-07-05 19:42:36 +00:00
VectorNegate ( view [ 1 ] , view [ 1 ] ) ;
/*calculate the surface axis with up from the pmove code and right/forwards relative to the player's directions*/
2014-06-21 17:58:17 +00:00
if ( ! pv - > gravitydir [ 0 ] & & ! pv - > gravitydir [ 1 ] & & ! pv - > gravitydir [ 2 ] )
2012-07-05 19:42:36 +00:00
{
VectorSet ( surf [ 2 ] , 0 , 0 , 1 ) ;
}
else
{
2014-06-21 17:58:17 +00:00
VectorNegate ( pv - > gravitydir , surf [ 2 ] ) ;
2012-07-05 19:42:36 +00:00
}
VectorNormalize ( surf [ 2 ] ) ;
PerpendicularVector ( surf [ 1 ] , surf [ 2 ] ) ;
VectorNormalize ( surf [ 1 ] ) ;
CrossProduct ( surf [ 2 ] , surf [ 1 ] , surf [ 0 ] ) ;
VectorNegate ( surf [ 0 ] , surf [ 0 ] ) ;
VectorNormalize ( surf [ 0 ] ) ;
Matrix4x4_RM_FromVectors ( surfm , surf [ 0 ] , surf [ 1 ] , surf [ 2 ] , vec3_origin ) ;
Matrix3x4_InvertTo4x4_Simple ( surfm , invsurfm ) ;
/*calc current view matrix relative to the surface*/
Matrix4x4_RM_FromVectors ( viewm , view [ 0 ] , view [ 1 ] , view [ 2 ] , vec3_origin ) ;
Matrix4_Multiply ( viewm , invsurfm , mat ) ;
/*convert that back to angles*/
Matrix3x4_RM_ToVectors ( mat , view [ 0 ] , view [ 1 ] , view [ 2 ] , view [ 3 ] ) ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
VectorAngles ( view [ 0 ] , view [ 2 ] , vang , false ) ;
2012-07-05 19:42:36 +00:00
/*edit it*/
2014-06-21 17:58:17 +00:00
vang [ PITCH ] + = pv - > viewanglechange [ PITCH ] ;
vang [ YAW ] + = pv - > viewanglechange [ YAW ] ;
2013-12-29 22:48:28 +00:00
if ( vang [ PITCH ] < = - 180 )
2012-07-05 19:42:36 +00:00
vang [ PITCH ] + = 360 ;
if ( vang [ PITCH ] > 180 )
vang [ PITCH ] - = 360 ;
2013-12-29 22:48:28 +00:00
if ( vang [ ROLL ] > = 180 )
2012-07-05 19:42:36 +00:00
vang [ ROLL ] - = 360 ;
2013-12-29 22:48:28 +00:00
if ( vang [ ROLL ] < - 180 )
vang [ ROLL ] + = 360 ;
2012-07-05 19:42:36 +00:00
/*keep the player looking relative to their ground (smoothlyish)*/
if ( ! vang [ ROLL ] )
{
2014-06-21 17:58:17 +00:00
if ( ! pv - > viewanglechange [ PITCH ] & & ! pv - > viewanglechange [ YAW ] & & ! pv - > viewanglechange [ ROLL ] )
2023-02-11 04:46:32 +00:00
{
VectorCopy ( pv - > viewangles , pv - > aimangles ) ;
2012-07-05 19:42:36 +00:00
return ;
2023-02-11 04:46:32 +00:00
}
2012-07-05 19:42:36 +00:00
}
else
{
2018-09-23 19:35:24 +00:00
if ( fabs ( vang [ ROLL ] ) < frametime * 180 )
2012-07-05 19:42:36 +00:00
vang [ ROLL ] = 0 ;
else if ( vang [ ROLL ] > 0 )
2013-12-29 22:48:28 +00:00
{
2014-01-13 02:42:25 +00:00
// Con_Printf("Roll %f\n", vang[ROLL]);
2018-09-23 19:35:24 +00:00
vang [ ROLL ] - = frametime * 180 ;
2013-12-29 22:48:28 +00:00
}
2012-07-05 19:42:36 +00:00
else
2013-12-29 22:48:28 +00:00
{
2014-01-13 02:42:25 +00:00
// Con_Printf("Roll %f\n", vang[ROLL]);
2018-09-23 19:35:24 +00:00
vang [ ROLL ] + = frametime * 180 ;
2013-12-29 22:48:28 +00:00
}
2012-07-05 19:42:36 +00:00
}
2014-06-21 17:58:17 +00:00
VectorClear ( pv - > viewanglechange ) ;
2012-07-05 19:42:36 +00:00
/*clamp pitch*/
if ( vang [ PITCH ] > cl . maxpitch )
vang [ PITCH ] = cl . maxpitch ;
if ( vang [ PITCH ] < cl . minpitch )
vang [ PITCH ] = cl . minpitch ;
/*turn those angles back to a matrix*/
AngleVectors ( vang , view [ 0 ] , view [ 1 ] , view [ 2 ] ) ;
VectorNegate ( view [ 1 ] , view [ 1 ] ) ;
Matrix4x4_RM_FromVectors ( mat , view [ 0 ] , view [ 1 ] , view [ 2 ] , vec3_origin ) ;
/*rotate back into world space*/
Matrix4_Multiply ( mat , surfm , viewm ) ;
/*and figure out the final result*/
Matrix3x4_RM_ToVectors ( viewm , view [ 0 ] , view [ 1 ] , view [ 2 ] , view [ 3 ] ) ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
VectorAngles ( view [ 0 ] , view [ 2 ] , cl . playerview [ pnum ] . viewangles , false ) ;
2012-07-05 19:42:36 +00:00
2014-06-21 17:58:17 +00:00
if ( pv - > viewangles [ ROLL ] > = 360 )
pv - > viewangles [ ROLL ] - = 360 ;
if ( pv - > viewangles [ ROLL ] < 0 )
pv - > viewangles [ ROLL ] + = 360 ;
if ( pv - > viewangles [ PITCH ] < - 180 )
pv - > viewangles [ PITCH ] + = 360 ;
2023-02-11 04:46:32 +00:00
//fixme: in_vraim stuff
VectorCopy ( pv - > viewangles , pv - > aimangles ) ;
2012-07-05 19:42:36 +00:00
return ;
}
# endif
2014-06-21 17:58:17 +00:00
pv - > viewangles [ PITCH ] + = pv - > viewanglechange [ PITCH ] ;
pv - > viewangles [ YAW ] + = pv - > viewanglechange [ YAW ] ;
pv - > viewangles [ ROLL ] + = pv - > viewanglechange [ ROLL ] ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
pv - > viewangles [ YAW ] / = 360 ;
pv - > viewangles [ YAW ] = pv - > viewangles [ YAW ] - ( int ) pv - > viewangles [ YAW ] ;
pv - > viewangles [ YAW ] * = 360 ;
2014-06-21 17:58:17 +00:00
VectorClear ( pv - > viewanglechange ) ;
2012-02-14 15:50:34 +00:00
2021-05-09 13:02:49 +00:00
if ( in_vraim . ival & & ( pv - > vrdev [ VRDEV_HEAD ] . status & VRSTATUS_ANG ) )
{ //overcomplicated code to replace the pitch+roll angles and add to the yaw angle.
#if 0
matrix3x4 base , head , res ;
vec3_t na = { 0 , pv - > viewangles [ YAW ] , 0 } ;
vec3_t f , l , u , o ;
Matrix3x4_RM_FromAngles ( na , vec3_origin , base [ 0 ] ) ;
for ( i = 0 ; i < 3 ; i + + )
na [ i ] = SHORT2ANGLE ( pv - > vrdev [ VRDEV_HEAD ] . angles [ i ] ) ;
Matrix3x4_RM_FromAngles ( na , pv - > vrdev [ VRDEV_HEAD ] . origin , head [ 0 ] ) ;
Matrix3x4_Multiply ( head [ 0 ] , base [ 0 ] , res [ 0 ] ) ;
Matrix3x4_RM_ToVectors ( res [ 0 ] , f , l , u , o ) ;
VectorAngles ( f , u , pv - > aimangles , false ) ;
for ( i = 0 ; i < 3 ; i + + )
cmd - > angles [ i ] = ANGLE2SHORT ( na [ i ] ) ;
# else
pv - > aimangles [ PITCH ] = SHORT2ANGLE ( pv - > vrdev [ VRDEV_HEAD ] . angles [ PITCH ] ) ;
pv - > aimangles [ YAW ] = SHORT2ANGLE ( pv - > vrdev [ VRDEV_HEAD ] . angles [ YAW ] ) + pv - > viewangles [ YAW ] ;
pv - > aimangles [ ROLL ] = SHORT2ANGLE ( pv - > vrdev [ VRDEV_HEAD ] . angles [ ROLL ] ) ;
# endif
}
else
VectorCopy ( pv - > viewangles , pv - > aimangles ) ;
2004-08-23 00:15:46 +00:00
# ifdef Q2CLIENT
2005-05-26 12:55:34 +00:00
if ( cls . protocol = = CP_QUAKE2 )
2004-08-23 00:15:46 +00:00
{
2012-02-14 15:50:34 +00:00
float pitch ;
2016-01-18 05:22:07 +00:00
pitch = SHORT2ANGLE ( cl . q2frame . playerstate [ pnum ] . pmove . delta_angles [ PITCH ] ) ;
2004-08-23 00:15:46 +00:00
if ( pitch > 180 )
pitch - = 360 ;
2014-06-21 17:58:17 +00:00
if ( pv - > viewangles [ PITCH ] + pitch < - 360 )
pv - > viewangles [ PITCH ] + = 360 ; // wrapped
if ( pv - > viewangles [ PITCH ] + pitch > 360 )
pv - > viewangles [ PITCH ] - = 360 ; // wrapped
2004-08-23 00:15:46 +00:00
2014-06-21 17:58:17 +00:00
if ( pv - > viewangles [ PITCH ] + pitch > cl . maxpitch )
pv - > viewangles [ PITCH ] = cl . maxpitch - pitch ;
if ( pv - > viewangles [ PITCH ] + pitch < cl . minpitch )
pv - > viewangles [ PITCH ] = cl . minpitch - pitch ;
2004-08-23 00:15:46 +00:00
}
else
2009-05-31 11:46:57 +00:00
# endif
# ifdef Q3CLIENT
2009-11-04 21:16:50 +00:00
if ( cls . protocol = = CP_QUAKE3 ) //q3 expects the cgame to do it
2009-05-31 11:46:57 +00:00
{
//no-op
}
else
2004-08-23 00:15:46 +00:00
# endif
{
2014-06-21 17:58:17 +00:00
if ( pv - > viewangles [ PITCH ] > cl . maxpitch )
pv - > viewangles [ PITCH ] = cl . maxpitch ;
if ( pv - > viewangles [ PITCH ] < cl . minpitch )
pv - > viewangles [ PITCH ] = cl . minpitch ;
2021-05-09 13:02:49 +00:00
if ( pv - > aimangles [ PITCH ] > cl . maxpitch )
pv - > aimangles [ PITCH ] = cl . maxpitch ;
if ( pv - > aimangles [ PITCH ] < cl . minpitch )
pv - > aimangles [ PITCH ] = cl . minpitch ;
2009-11-04 21:16:50 +00:00
}
2012-02-14 15:50:34 +00:00
2012-02-15 13:53:30 +00:00
// if (cl.viewangles[pnum][ROLL] > 50)
// cl.viewangles[pnum][ROLL] = 50;
// if (cl.viewangles[pnum][ROLL] < -50)
// cl.viewangles[pnum][ROLL] = -50;
2018-09-23 19:35:24 +00:00
roll = frametime * pv - > viewangles [ ROLL ] * 30 ;
2014-06-21 17:58:17 +00:00
if ( ( pv - > viewangles [ ROLL ] - roll < 0 ) ! = ( pv - > viewangles [ ROLL ] < 0 ) )
pv - > viewangles [ ROLL ] = 0 ;
2012-02-15 13:53:30 +00:00
else
2018-09-23 19:35:24 +00:00
pv - > viewangles [ ROLL ] - = frametime * pv - > viewangles [ ROLL ] * 3 ;
2004-08-23 00:15:46 +00:00
}
/*
= = = = = = = = = = = = = =
CL_FinishMove
= = = = = = = = = = = = = =
*/
2017-08-29 02:29:06 +00:00
static void CL_FinishMove ( usercmd_t * cmd , int pnum )
2004-08-23 00:15:46 +00:00
{
2005-06-14 04:52:10 +00:00
int i ;
2004-08-23 00:15:46 +00:00
2018-09-23 19:35:24 +00:00
CL_ClampPitch ( pnum , 0 ) ;
2012-02-14 15:50:34 +00:00
2004-08-23 00:15:46 +00:00
//
2005-07-28 15:33:27 +00:00
// always dump the first two message, because it may contain leftover inputs
2004-08-23 00:15:46 +00:00
// from the last level
//
2013-03-12 22:53:23 +00:00
if ( cl . movesequence < = 2 )
2005-08-03 23:14:59 +00:00
{
cmd - > buttons = 0 ;
2004-08-23 00:15:46 +00:00
return ;
2005-08-03 23:14:59 +00:00
}
2004-08-23 00:15:46 +00:00
//
// figure button bits
//
2004-09-01 22:56:08 +00:00
2015-02-02 08:01:53 +00:00
CL_GatherButtons ( cmd , pnum ) ;
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < 3 ; i + + )
2021-05-09 13:02:49 +00:00
cmd - > angles [ i ] = ( int ) ( ANGLE2SHORT ( cl . playerview [ pnum ] . aimangles [ i ] ) ) & 65535 ;
cmd - > vr [ VRDEV_LEFT ] = cl . playerview [ pnum ] . vrdev [ VRDEV_LEFT ] ;
cmd - > vr [ VRDEV_RIGHT ] = cl . playerview [ pnum ] . vrdev [ VRDEV_RIGHT ] ;
cmd - > vr [ VRDEV_HEAD ] = cl . playerview [ pnum ] . vrdev [ VRDEV_HEAD ] ;
2004-08-23 00:15:46 +00:00
2010-08-16 02:03:02 +00:00
if ( in_impulsespending [ pnum ] & & ! cl . paused )
2004-08-23 00:15:46 +00:00
{
2020-07-21 07:58:54 +00:00
cmd - > impulse = in_impulse [ pnum ] [ ( in_nextimpulse [ pnum ] ) % IN_IMPULSECACHE ] ;
2004-08-23 00:15:46 +00:00
in_nextimpulse [ pnum ] + + ;
in_impulsespending [ pnum ] - - ;
}
else
cmd - > impulse = 0 ;
}
2021-07-17 15:10:01 +00:00
2022-01-28 10:48:14 +00:00
static void CL_AccumlateInput ( int plnum , float frametime /*extra contribution*/ , float framemsecs /*total accumulated*/ )
{
usercmd_t * cmd = & cl_pendingcmd [ plnum ] ;
int i ;
static vec3_t mousemovements [ MAX_SPLITS ] ;
vec3_t newmoves ;
float nscale = framemsecs ? framemsecs / ( framemsecs + cmd - > msec ) : 0 ;
float oscale = 1 - nscale ;
2022-07-28 02:16:54 +00:00
unsigned int st ;
2022-01-28 10:48:14 +00:00
CL_BaseMove ( newmoves , plnum ) ;
CL_AdjustAngles ( plnum , frametime ) ;
if ( ! cmd - > msec )
VectorClear ( mousemovements [ plnum ] ) ;
IN_Move ( mousemovements [ plnum ] , newmoves , plnum , frametime ) ;
CL_ClampPitch ( plnum , frametime ) ;
for ( i = 0 ; i < 3 ; i + + )
cmd - > angles [ i ] = ( ( int ) ( cl . playerview [ plnum ] . viewangles [ i ] * 65536.0 / 360 ) & 65535 ) ;
cmd - > fservertime = cl . servertime ;
cmd - > servertime = cl . time * 1000 ;
# ifdef CSQC_DAT
cmd - > fclienttime = realtime - cl . mapstarttime ;
# endif
cmd - > forwardmove = bound ( - 32768 , cmd - > forwardmove * oscale + newmoves [ 0 ] * nscale + mousemovements [ plnum ] [ 0 ] , 32767 ) ;
cmd - > sidemove = bound ( - 32768 , cmd - > sidemove * oscale + newmoves [ 1 ] * nscale + mousemovements [ plnum ] [ 1 ] , 32767 ) ;
cmd - > upmove = bound ( - 32768 , cmd - > upmove * oscale + newmoves [ 2 ] * nscale + mousemovements [ plnum ] [ 2 ] , 32767 ) ;
if ( ! cmd - > msec & & framemsecs )
{
CL_GatherButtons ( cmd , plnum ) ; //buttons are from the initial state. don't blend them.
CL_FinishMove ( cmd , plnum ) ;
Cbuf_Waited ( ) ; //its okay to stop waiting now
}
cmd - > msec = framemsecs ;
2022-07-28 02:16:54 +00:00
if ( cl . movesequence > = 1 )
{ //fix up the servertime value to make sure our msecs are actually correct.
st = cl . outframes [ ( cl . movesequence - 1 ) & UPDATE_MASK ] . cmd [ plnum ] . servertime + ( cmd - > msec ) ; //round it.
if ( abs ( ( int ) st - ( int ) cmd - > servertime ) < 50 )
{
cmd - > servertime = st ;
cmd - > fservertime = ( double ) st / 1000.0 ;
}
}
2022-01-28 10:48:14 +00:00
// if we are spectator, try autocam
// if (cl.spectator)
Cam_Track ( & cl . playerview [ plnum ] , & cl_pendingcmd [ plnum ] ) ;
Cam_FinishMove ( & cl . playerview [ plnum ] , & cl_pendingcmd [ plnum ] ) ;
}
2021-07-17 15:10:01 +00:00
static qboolean CLFTE_SendVRCmd ( sizebuf_t * buf , unsigned int seats )
{
//compute the delay between receiving the frame we're acking and when we're sending the new frame
unsigned int cldelay = ( realtime - cl . inframes [ cls . netchan . incoming_sequence & UPDATE_MASK ] . receivedtime ) * 10000 ; //this is to report actual network latency instead of just reporting our packet rate (framerates may still be a factor).
unsigned int lost = CL_CalcNet ( r_netgraph . value ) ; //report packetloss
unsigned int flags = 0 ;
unsigned int first = cl . ackedmovesequence + 1 ; //no point resending that which has already been acked.
unsigned int last = cl . movesequence + 1 ; //we want to ignore moveseq itself
unsigned int frame , seat , count , i ;
const usercmd_t * from , * to ;
qboolean dontdrop = false ;
if ( first > last )
first = last - 1 ;
if ( first < last - ( countof ( cl . outframes ) - 2 ) )
first = last - ( countof ( cl . outframes ) - 2 ) ;
if ( first < 1 )
first = 1 ;
if ( last < first )
count = 0 ;
else
count = last - first ;
if ( count > max ( 1 , cl_c2sMaxRedundancy . ival ) )
count = max ( 1 , cl_c2sMaxRedundancy . ival ) ;
if ( cl . inframes [ cls . netchan . incoming_sequence & UPDATE_MASK ] . receivedtime < 0 )
cldelay = 0 ; //erk?
MSG_WriteByte ( buf , clcfte_move ) ;
# ifdef NQPROT
if ( cls . protocol = = CP_NETQUAKE ) //nq uses fully separate packet+movement sequences (unlike qw).
MSG_WriteShort ( buf , ( last - 1 ) & 0xffff ) ;
# endif
if ( seats ! = 1 )
flags | = VRM_SEATS ;
if ( lost )
flags | = VRM_LOSS ;
if ( cldelay )
flags | = VRM_DELAY ;
if ( count ! = 3 )
flags | = VRM_FRAMES ;
if ( cl . numackframes )
flags | = VRM_ACKS ;
MSG_WriteUInt64 ( buf , flags ) ;
if ( flags & VRM_SEATS )
MSG_WriteUInt64 ( buf , seats ) ;
if ( flags & VRM_FRAMES )
MSG_WriteUInt64 ( buf , count ) ;
if ( flags & VRM_LOSS )
MSG_WriteByte ( buf , ( qbyte ) lost ) ;
if ( flags & VRM_DELAY )
MSG_WriteByte ( buf , bound ( 0 , cldelay , 255 ) ) ; //a byte should always be enough for any framerate above 40.
if ( flags & VRM_ACKS )
{
MSG_WriteUInt64 ( buf , cl . numackframes ) ;
for ( i = 0 ; i < cl . numackframes ; i + + )
MSG_WriteLong ( buf , cl . ackframes [ i ] ) ;
cl . numackframes = 0 ;
}
for ( seat = 0 ; seat < seats ; seat + + )
2021-08-04 21:16:57 +00:00
{
from = & nullcmd ;
2021-07-17 15:10:01 +00:00
for ( frame = last - count ; frame < last ; frame + + )
{
to = & cl . outframes [ frame & UPDATE_MASK ] . cmd [ seat ] ;
2021-08-04 21:16:57 +00:00
MSGFTE_WriteDeltaUsercmd ( buf , cl . playerview [ seat ] . baseangles , from , to ) ;
2021-07-17 15:10:01 +00:00
if ( to - > impulse & & ( int ) ( last - frame ) > = cl_c2sImpulseBackup . ival )
dontdrop = true ;
from = to ;
}
2021-08-04 21:16:57 +00:00
}
2021-07-17 15:10:01 +00:00
return dontdrop ;
}
2014-12-25 02:32:22 +00:00
void CL_UpdatePrydonCursor ( usercmd_t * from , int pnum )
2004-12-05 08:19:54 +00:00
{
2016-07-12 00:40:13 +00:00
int hit ;
2004-12-05 08:19:54 +00:00
vec3_t cursor_end ;
2005-08-03 23:14:59 +00:00
vec3_t temp ;
vec3_t cursor_impact_normal ;
2004-12-05 08:19:54 +00:00
2009-11-04 21:16:50 +00:00
cursor_active = true ;
if ( ! cl_prydoncursor . ival )
2004-12-05 08:19:54 +00:00
{ //center the cursor
2014-12-25 02:32:22 +00:00
from - > cursor_screen [ 0 ] = 0 ;
from - > cursor_screen [ 1 ] = 0 ;
2004-12-05 08:19:54 +00:00
}
2005-08-03 23:14:59 +00:00
else
{
2014-12-25 02:32:22 +00:00
from - > cursor_screen [ 0 ] = mousecursor_x / ( vid . width / 2.0f ) - 1 ;
from - > cursor_screen [ 1 ] = mousecursor_y / ( vid . height / 2.0f ) - 1 ;
if ( from - > cursor_screen [ 0 ] < - 1 )
from - > cursor_screen [ 0 ] = - 1 ;
if ( from - > cursor_screen [ 1 ] < - 1 )
from - > cursor_screen [ 1 ] = - 1 ;
2005-08-03 23:14:59 +00:00
2014-12-25 02:32:22 +00:00
if ( from - > cursor_screen [ 0 ] > 1 )
from - > cursor_screen [ 0 ] = 1 ;
if ( from - > cursor_screen [ 1 ] > 1 )
from - > cursor_screen [ 1 ] = 1 ;
2005-08-03 23:14:59 +00:00
}
2004-12-05 08:19:54 +00:00
2014-12-25 02:32:22 +00:00
VectorClear ( from - > cursor_start ) ;
temp [ 0 ] = ( from - > cursor_screen [ 0 ] + 1 ) / 2 ;
temp [ 1 ] = ( - from - > cursor_screen [ 1 ] + 1 ) / 2 ;
2005-08-03 23:14:59 +00:00
temp [ 2 ] = 1 ;
2004-12-05 08:19:54 +00:00
2014-12-25 02:32:22 +00:00
VectorCopy ( r_origin , from - > cursor_start ) ;
Matrix4x4_CM_UnProject ( temp , cursor_end , cl . playerview [ pnum ] . viewangles , from - > cursor_start , r_refdef . fov_x , r_refdef . fov_y ) ;
2004-12-05 08:19:54 +00:00
2005-02-06 02:47:36 +00:00
CL_SetSolidEntities ( ) ;
//don't bother with players, they don't exist in NQ...
2016-07-12 00:40:13 +00:00
CL_TraceLine ( from - > cursor_start , cursor_end , from - > cursor_impact , cursor_impact_normal , & hit ) ;
if ( hit > 0 )
from - > cursor_entitynumber = hit ;
else if ( hit < 0 )
from - > cursor_entitynumber = 0 ; //FIXME: ask csqc for the entity's entnum
2014-12-25 02:32:22 +00:00
else
from - > cursor_entitynumber = 0 ;
2013-03-12 23:24:15 +00:00
2011-01-03 03:52:37 +00:00
// P_RunParticleEffect(cursor_impact, vec3_origin, 15, 16);
2004-12-05 08:19:54 +00:00
}
2004-08-23 00:15:46 +00:00
# ifdef NQPROT
2008-06-12 20:47:13 +00:00
void CLNQ_SendMove ( usercmd_t * cmd , int pnum , sizebuf_t * buf )
2004-08-23 00:15:46 +00:00
{
int i ;
2021-04-14 05:21:04 +00:00
unsigned int bits ;
2004-12-05 08:19:54 +00:00
2005-05-26 12:55:34 +00:00
if ( cls . demoplayback ! = DPB_NONE )
return ; //err... don't bother... :)
//
2005-07-28 15:33:27 +00:00
// always dump the first two message, because it may contain leftover inputs
2005-05-26 12:55:34 +00:00
// from the last level
//
2013-03-12 22:53:23 +00:00
if ( cl . movesequence < = 2 | | cls . state = = ca_connected )
2011-10-27 15:46:36 +00:00
{
MSG_WriteByte ( buf , clc_nop ) ;
2005-05-26 12:55:34 +00:00
return ;
2011-10-27 15:46:36 +00:00
}
2005-05-26 12:55:34 +00:00
2022-01-16 18:41:44 +00:00
if ( cls . qex )
{
MSG_WriteByte ( buf , clc_delta ) ;
MSG_WriteULEB128 ( buf , cl . movesequence ) ;
}
2005-05-26 12:55:34 +00:00
MSG_WriteByte ( buf , clc_move ) ;
2004-08-23 00:15:46 +00:00
2016-10-22 07:06:51 +00:00
if ( cls . protocol_nq > = CPNQ_DP7 )
2013-09-06 22:57:44 +00:00
{
2017-08-29 02:29:06 +00:00
if ( ! cl_movement . ival )
2013-09-06 22:57:44 +00:00
MSG_WriteLong ( buf , 0 ) ;
else
MSG_WriteLong ( buf , cl . movesequence ) ;
}
2016-10-22 07:06:51 +00:00
else if ( cls . fteprotocolextensions2 & PEXT2_PREDINFO )
MSG_WriteShort ( buf , cl . movesequence & 0xffff ) ;
2005-05-26 12:55:34 +00:00
2021-07-17 15:10:01 +00:00
MSG_WriteFloat ( buf , cmd - > fservertime ) ; // use latest time. because ping reports!
2021-04-14 05:21:04 +00:00
2022-01-16 18:41:44 +00:00
if ( cls . qex )
2023-01-09 05:11:34 +00:00
MSG_WriteByte ( buf , 1 ) ;
2022-01-16 18:41:44 +00:00
2021-07-17 15:10:01 +00:00
for ( i = 0 ; i < 3 ; i + + )
{
if ( cls . protocol_nq = = CPNQ_FITZ666 | | ( cls . proquake_angles_hack & & buf - > prim . anglesize < = 1 ) )
2012-10-01 14:29:44 +00:00
{
2021-07-17 15:10:01 +00:00
//fitz/proquake protocols are always 16bit for this angle and 8bit elsewhere. rmq is always at least 16bit
//the above logic should satify everything.
MSG_WriteAngle16 ( buf , cl . playerview [ pnum ] . viewangles [ i ] ) ;
2012-10-01 14:29:44 +00:00
}
2021-07-17 15:10:01 +00:00
else
MSG_WriteAngle ( buf , cl . playerview [ pnum ] . viewangles [ i ] ) ;
}
2004-08-23 00:15:46 +00:00
2021-07-17 15:10:01 +00:00
MSG_WriteShort ( buf , cmd - > forwardmove ) ;
MSG_WriteShort ( buf , cmd - > sidemove ) ;
MSG_WriteShort ( buf , cmd - > upmove ) ;
2021-04-14 05:21:04 +00:00
2021-07-17 15:10:01 +00:00
bits = cmd - > buttons ;
if ( cls . fteprotocolextensions2 & PEXT2_PRYDONCURSOR )
{
if ( cmd - > cursor_screen [ 0 ] | | cmd - > cursor_screen [ 1 ] | |
cmd - > cursor_start [ 0 ] | | cmd - > cursor_start [ 1 ] | | cmd - > cursor_start [ 2 ] | |
cmd - > cursor_impact [ 0 ] | | cmd - > cursor_impact [ 1 ] | | cmd - > cursor_impact [ 2 ] | |
cmd - > cursor_entitynumber )
bits | = ( 1u < < 31 ) ; //set it if there's actually something to send.
MSG_WriteLong ( buf , bits ) ;
}
else if ( cls . protocol_nq > = CPNQ_DP6 )
{
MSG_WriteLong ( buf , bits ) ;
bits | = ( 1u < < 31 ) ; //unconditionally set it (without writing it)
}
else
MSG_WriteByte ( buf , cmd - > buttons ) ;
MSG_WriteByte ( buf , cmd - > impulse ) ;
2021-04-14 05:21:04 +00:00
2021-07-17 15:10:01 +00:00
if ( bits & ( 1u < < 31 ) )
{
MSG_WriteShort ( buf , cmd - > cursor_screen [ 0 ] * 32767.0f ) ;
MSG_WriteShort ( buf , cmd - > cursor_screen [ 1 ] * 32767.0f ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 0 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 1 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 2 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 0 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 1 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 2 ] ) ;
MSG_WriteEntity ( buf , cmd - > cursor_entitynumber ) ;
2013-03-12 22:53:23 +00:00
}
2004-08-23 00:15:46 +00:00
}
2005-05-26 12:55:34 +00:00
2015-04-21 04:12:00 +00:00
void QDECL Name_Callback ( struct cvar_s * var , char * oldvalue )
2006-05-06 02:53:36 +00:00
{
if ( cls . state < = ca_connected )
return ;
if ( cls . protocol ! = CP_NETQUAKE )
return ;
CL_SendClientCommand ( true , " name \" %s \" \n " , var - > string ) ;
}
2008-06-12 20:47:13 +00:00
void CLNQ_SendCmd ( sizebuf_t * buf )
2004-08-23 00:15:46 +00:00
{
2013-03-12 22:35:33 +00:00
int i ;
2013-09-06 22:57:44 +00:00
int seat ;
2013-03-12 22:53:23 +00:00
usercmd_t * cmd ;
2005-05-26 12:55:34 +00:00
2013-03-12 22:53:23 +00:00
i = cl . movesequence & UPDATE_MASK ;
cl . outframes [ i ] . senttime = realtime ;
2013-09-06 22:57:44 +00:00
cl . outframes [ i ] . latency = - 1 ;
cl . outframes [ i ] . server_message_num = cl . validsequence ;
cl . outframes [ i ] . cmd_sequence = cl . movesequence ;
2017-08-29 02:29:06 +00:00
cl . outframes [ i ] . sentgametime = cl . movesequence_time ;
2013-09-06 22:57:44 +00:00
for ( seat = 0 ; seat < cl . splitclients ; seat + + )
{
cmd = & cl . outframes [ i ] . cmd [ seat ] ;
2017-08-29 02:29:06 +00:00
* cmd = cl_pendingcmd [ seat ] ;
cmd - > fservertime = cl . movesequence_time ;
// cmd->msec = (cl.time - cl.outframes[(i-1)&UPDATE_MASK].sentgametime)*1000;
2013-03-12 22:53:23 +00:00
# ifdef CSQC_DAT
2013-09-06 22:57:44 +00:00
CSQC_Input_Frame ( seat , cmd ) ;
2013-03-12 22:53:23 +00:00
# endif
2013-09-06 22:57:44 +00:00
}
2019-08-19 16:15:31 +00:00
CL_ClearPendingCommands ( ) ;
2013-03-12 22:53:23 +00:00
//inputs are only sent once we receive an entity.
2021-07-17 15:10:01 +00:00
if ( cls . fteprotocolextensions2 & PEXT2_VRINPUTS )
CLFTE_SendVRCmd ( buf , ( cls . signon ! = 4 | | cls . state = = ca_connected ) ? 0 : cl . splitclients ) ;
else
2004-08-23 00:15:46 +00:00
{
2021-07-17 15:10:01 +00:00
if ( cls . signon = = 4 )
2013-09-06 22:57:44 +00:00
{
2021-07-17 15:10:01 +00:00
for ( seat = 0 ; seat < cl . splitclients ; seat + + )
{
// send the unreliable message
// if (independantphysics[seat].impulse && !cls.netchan.message.cursize)
// CLNQ_SendMove (&cl.outframes[i].cmd[seat], seat, &cls.netchan.message);
// else
CLNQ_SendMove ( & cl . outframes [ i ] . cmd [ seat ] , seat , buf ) ;
}
2013-09-06 22:57:44 +00:00
}
2021-07-17 15:10:01 +00:00
else
MSG_WriteByte ( buf , clc_nop ) ;
2004-08-23 00:15:46 +00:00
2021-07-17 15:10:01 +00:00
for ( i = 0 ; i < cl . numackframes ; i + + )
{
MSG_WriteByte ( buf , clcdp_ackframe ) ;
MSG_WriteLong ( buf , cl . ackframes [ i ] ) ;
}
cl . numackframes = 0 ;
2004-11-27 08:16:25 +00:00
}
2006-05-28 21:56:04 +00:00
}
# else
void Name_Callback ( struct cvar_s * var , char * oldvalue )
{
2004-08-23 00:15:46 +00:00
}
# endif
2017-08-29 02:29:06 +00:00
float CL_FilterTime ( double time , float wantfps , float limit , qboolean ignoreserver ) //now returns the extra time not taken in this slot. Note that negative 1 means uncapped.
2004-08-23 00:15:46 +00:00
{
float fps , fpscap ;
2015-08-28 03:13:45 +00:00
if ( cls . timedemo )
2005-04-16 16:21:27 +00:00
return - 1 ;
2004-08-23 00:15:46 +00:00
2015-08-28 03:13:45 +00:00
if ( cls . protocol = = CP_QUAKE3 )
ignoreserver = true ;
2010-12-05 02:46:07 +00:00
/*ignore the server if we're playing demos, sending to the server only as replies, or if its meant to be disabled (netfps depending on where its called from)*/
2013-09-06 22:57:44 +00:00
if ( cls . demoplayback ! = DPB_NONE | | ( cls . protocol ! = CP_QUAKEWORLD & & cls . protocol ! = CP_NETQUAKE ) | | ignoreserver )
2004-08-23 00:15:46 +00:00
{
2005-02-28 07:16:19 +00:00
if ( ! wantfps )
2005-04-16 16:21:27 +00:00
return - 1 ;
2016-12-07 18:45:25 +00:00
fps = max ( 1.0 , wantfps ) ;
2004-08-23 00:15:46 +00:00
}
else
{
fpscap = cls . maxfps ? max ( 30.0 , cls . maxfps ) : 0x7fff ;
2008-11-09 22:29:28 +00:00
# ifdef IRCCONNECT
if ( cls . netchan . remote_address . type = = NA_IRC )
fps = bound ( 0.1 , wantfps , fpscap ) ; //if we're connected via irc, allow a greatly reduced minimum cap
else
# endif
2005-06-14 04:52:10 +00:00
if ( wantfps < 1 )
fps = fpscap ;
2004-08-23 00:15:46 +00:00
else
2006-11-03 15:53:04 +00:00
fps = bound ( 6.7 , wantfps , fpscap ) ; //we actually cap ourselves to 150msecs (1000/7 = 142)
2004-08-23 00:15:46 +00:00
}
2015-10-11 11:34:58 +00:00
//its not time yet
2023-01-09 05:11:50 +00:00
if ( ignoreserver )
{ //don't try to hold to milliseconds.
if ( time < 1000 / fps )
return 0 ;
}
else
{
if ( time < ceil ( 1000 / fps ) )
return 0 ;
}
2004-08-23 00:15:46 +00:00
2015-10-11 11:34:58 +00:00
//clamp it if we have over 1.5 frame banked somehow
2017-08-29 02:29:06 +00:00
if ( limit & & time - ( 1000 / fps ) > ( 1000 / fps ) * limit )
return ( 1000 / fps ) * limit ;
2015-10-11 11:34:58 +00:00
//report how much spare time the caller now has
return time - ( 1000 / fps ) ;
2004-08-23 00:15:46 +00:00
}
2005-02-28 07:16:19 +00:00
typedef struct clcmdbuf_s {
struct clcmdbuf_s * next ;
int len ;
2005-03-23 22:14:08 +00:00
qboolean reliable ;
2021-07-17 15:10:10 +00:00
unsigned int seat ;
2005-02-28 07:16:19 +00:00
char command [ 4 ] ; //this is dynamically allocated, so this is variably sized.
} clcmdbuf_t ;
2021-07-17 15:10:10 +00:00
static clcmdbuf_t * clientcmdlist ;
void VARGS CL_SendSeatClientCommand ( qboolean reliable , unsigned int seat , char * format , . . . )
2005-02-28 07:16:19 +00:00
{
qboolean oldallow ;
va_list argptr ;
char string [ 2048 ] ;
clcmdbuf_t * buf , * prev ;
2008-01-09 00:52:31 +00:00
if ( cls . demoplayback & & cls . demoplayback ! = DPB_EZTV )
2006-01-21 00:06:49 +00:00
return ; //no point.
2005-02-28 07:16:19 +00:00
va_start ( argptr , format ) ;
2012-07-05 19:42:36 +00:00
Q_vsnprintfz ( string , sizeof ( string ) , format , argptr ) ;
2005-02-28 07:16:19 +00:00
va_end ( argptr ) ;
# ifdef Q3CLIENT
2005-06-04 04:20:20 +00:00
if ( cls . protocol = = CP_QUAKE3 )
2005-02-28 07:16:19 +00:00
{
2022-03-08 05:31:34 +00:00
q3 - > cl . SendClientCommand ( " %s " , string ) ;
2005-02-28 07:16:19 +00:00
return ;
}
# endif
2017-10-31 22:52:58 +00:00
oldallow = CL_AllowIndependantSendCmd ( false ) ;
2005-02-28 07:16:19 +00:00
buf = Z_Malloc ( sizeof ( * buf ) + strlen ( string ) ) ;
strcpy ( buf - > command , string ) ;
buf - > len = strlen ( buf - > command ) ;
2005-03-23 22:14:08 +00:00
buf - > reliable = reliable ;
2021-07-17 15:10:10 +00:00
buf - > seat = seat ;
2005-02-28 07:16:19 +00:00
//add to end of the list so that the first of the list is the first to be sent.
if ( ! clientcmdlist )
clientcmdlist = buf ;
else
{
for ( prev = clientcmdlist ; prev - > next ; prev = prev - > next )
;
prev - > next = buf ;
}
CL_AllowIndependantSendCmd ( oldallow ) ;
}
2021-07-17 15:10:10 +00:00
void VARGS CL_SendClientCommand ( qboolean reliable , char * format , . . . )
{
va_list argptr ;
char string [ 2048 ] ;
va_start ( argptr , format ) ;
Q_vsnprintfz ( string , sizeof ( string ) , format , argptr ) ;
va_end ( argptr ) ;
CL_SendSeatClientCommand ( reliable , 0 , " %s " , string ) ;
}
2005-02-28 07:16:19 +00:00
2018-08-23 06:03:31 +00:00
//sometimes a server will quickly restart twice.
//connected clients will then receive TWO 'new' commands - both with the same servercount value.
//the connection process then tries to proceed with two sets of commands until it fails catastrophically.
//by attempting to strip out dupe commands we can usually avoid the issue
//note that FTE servers track progress properly, so this is not an issue for us, but in the interests of compat with mvdsv...
//however, FTE servers can send a little faster, so warnings about this can be awkward.
2005-05-30 10:36:26 +00:00
int CL_RemoveClientCommands ( char * command )
{
clcmdbuf_t * next , * first ;
int removed = 0 ;
2005-08-07 18:08:13 +00:00
int len = strlen ( command ) ;
2005-05-30 10:36:26 +00:00
CL_AllowIndependantSendCmd ( false ) ;
if ( ! clientcmdlist )
return 0 ;
2005-08-07 18:08:13 +00:00
while ( ! strncmp ( clientcmdlist - > command , command , len ) )
2005-05-30 10:36:26 +00:00
{
next = clientcmdlist - > next ;
Z_Free ( clientcmdlist ) ;
clientcmdlist = next ;
removed + + ;
if ( ! clientcmdlist )
return removed ;
}
2005-06-14 04:52:10 +00:00
first = clientcmdlist ;
2005-05-30 10:36:26 +00:00
while ( first - > next )
{
2005-08-07 18:08:13 +00:00
if ( ! strncmp ( first - > next - > command , command , len ) )
2005-05-30 10:36:26 +00:00
{
next = first - > next - > next ;
Z_Free ( first - > next ) ;
first - > next = next ;
removed + + ;
}
2005-06-04 04:20:20 +00:00
else
first = first - > next ;
2005-05-30 10:36:26 +00:00
}
return removed ;
}
2005-02-28 07:16:19 +00:00
void CL_FlushClientCommands ( void )
{
clcmdbuf_t * next ;
CL_AllowIndependantSendCmd ( false ) ;
while ( clientcmdlist )
{
2005-05-30 10:36:26 +00:00
Con_DPrintf ( " Flushed command %s \n " , clientcmdlist - > command ) ;
2005-02-28 07:16:19 +00:00
next = clientcmdlist - > next ;
Z_Free ( clientcmdlist ) ;
clientcmdlist = next ;
}
}
qboolean runningindepphys ;
2011-07-03 16:24:53 +00:00
# ifdef MULTITHREAD
void * indeplock ;
void * indepthread ;
2007-07-23 18:52:11 +00:00
2017-10-31 22:52:58 +00:00
qboolean allowindepphys ;
qboolean CL_AllowIndependantSendCmd ( qboolean allow )
2007-07-23 18:52:11 +00:00
{
2017-10-31 22:52:58 +00:00
qboolean ret = allowindepphys ;
2007-07-23 18:52:11 +00:00
if ( ! runningindepphys )
2017-10-31 22:52:58 +00:00
return ret ;
2007-07-23 18:52:11 +00:00
if ( allowindepphys ! = allow & & runningindepphys )
{
if ( allow )
2011-10-27 15:46:36 +00:00
Sys_UnlockMutex ( indeplock ) ;
2007-07-23 18:52:11 +00:00
else
2011-10-27 15:46:36 +00:00
Sys_LockMutex ( indeplock ) ;
2007-07-23 18:52:11 +00:00
allowindepphys = allow ;
}
2017-10-31 22:52:58 +00:00
return ret ;
2007-07-23 18:52:11 +00:00
}
2011-07-03 16:24:53 +00:00
int CL_IndepPhysicsThread ( void * param )
2007-07-23 18:52:11 +00:00
{
2011-07-06 01:01:13 +00:00
double sleeptime ;
2007-07-23 18:52:11 +00:00
double fps ;
double time , lasttime ;
double spare ;
lasttime = Sys_DoubleTime ( ) ;
while ( runningindepphys )
{
time = Sys_DoubleTime ( ) ;
2017-08-29 02:29:06 +00:00
spare = CL_FilterTime ( ( time - lasttime ) * 1000 , cl_netfps . value , 1.5 , false ) ;
2007-07-23 18:52:11 +00:00
if ( spare )
{
time - = spare / 1000.0f ;
2011-10-27 15:46:36 +00:00
Sys_LockMutex ( indeplock ) ;
2007-07-23 18:52:11 +00:00
if ( cls . state )
2009-05-24 10:11:17 +00:00
CL_SendCmd ( time - lasttime , false ) ;
2007-07-23 18:52:11 +00:00
lasttime = time ;
2011-10-27 15:46:36 +00:00
Sys_UnlockMutex ( indeplock ) ;
2007-07-23 18:52:11 +00:00
}
fps = cl_netfps . value ;
if ( fps < 4 )
fps = 4 ;
while ( fps < 100 )
fps * = 2 ;
2011-07-06 01:01:13 +00:00
sleeptime = 1 / fps ;
2007-07-23 18:52:11 +00:00
2011-07-03 16:24:53 +00:00
Sys_Sleep ( sleeptime ) ;
2007-07-23 18:52:11 +00:00
}
2011-07-03 16:24:53 +00:00
return 0 ;
2007-07-23 18:52:11 +00:00
}
void CL_UseIndepPhysics ( qboolean allow )
{
if ( runningindepphys = = allow )
return ;
if ( allow )
{ //enable it
2011-07-03 16:24:53 +00:00
indeplock = Sys_CreateMutex ( ) ;
2007-07-23 18:52:11 +00:00
runningindepphys = true ;
2012-11-29 13:37:48 +00:00
indepthread = Sys_CreateThread ( " indepphys " , CL_IndepPhysicsThread , NULL , THREADP_HIGHEST , 8192 ) ;
2011-07-03 16:24:53 +00:00
allowindepphys = true ;
2007-07-23 18:52:11 +00:00
}
else
{
2020-03-25 21:29:30 +00:00
CL_AllowIndependantSendCmd ( true ) ;
2007-07-23 18:52:11 +00:00
//shut it down.
runningindepphys = false ; //tell thread to exit gracefully
2011-07-03 16:24:53 +00:00
Sys_WaitOnThread ( indepthread ) ;
2020-03-25 21:29:30 +00:00
indepthread = NULL ;
2011-07-03 16:24:53 +00:00
Sys_DestroyMutex ( indeplock ) ;
2020-03-25 21:29:30 +00:00
indeplock = NULL ;
2007-07-23 18:52:11 +00:00
}
}
2005-02-28 07:16:19 +00:00
# else
2017-10-31 22:52:58 +00:00
qboolean CL_AllowIndependantSendCmd ( qboolean allow )
2005-02-28 07:16:19 +00:00
{
2017-10-31 22:52:58 +00:00
return false ;
2005-02-28 07:16:19 +00:00
}
2005-03-24 17:19:25 +00:00
void CL_UseIndepPhysics ( qboolean allow )
{
}
2005-02-28 07:16:19 +00:00
# endif
2016-01-18 05:22:07 +00:00
void CL_UpdateSeats ( void )
{
if ( ! cls . netchan . message . cursize & & cl . allocated_client_slots > 1 & & cls . state = = ca_active & & cl . splitclients & & ( cls . fteprotocolextensions & PEXT_SPLITSCREEN ) & & cl . worldmodel )
{
2021-08-04 21:16:57 +00:00
int targ = bound ( 1 , cl_splitscreen . ival + 1 , MAX_SPLITS ) ;
2016-01-18 05:22:07 +00:00
if ( cl . splitclients < targ )
{
2017-05-28 15:42:32 +00:00
char * ver ;
2016-01-18 05:22:07 +00:00
char buffer [ 2048 ] ;
2018-07-05 16:21:44 +00:00
char infostr [ 2048 ] ;
infobuf_t * info = & cls . userinfo [ cl . splitclients ] ;
2016-01-18 05:22:07 +00:00
//some userinfos should always have a value
2018-07-05 16:21:44 +00:00
if ( ! * InfoBuf_ValueForKey ( info , " name " ) ) //$name-2
2021-08-04 21:18:20 +00:00
InfoBuf_SetKey ( info , " name " , va ( " %s-%i " , InfoBuf_ValueForKey ( & cls . userinfo [ 0 ] , " name " ) , cl . splitclients + 1 ) ) ;
2016-01-18 05:22:07 +00:00
if ( cls . protocol ! = CP_QUAKE2 )
{
2018-07-05 16:21:44 +00:00
if ( ! * InfoBuf_ValueForKey ( info , " team " ) ) //put players on the same team by default. this avoids team damage in coop, and if you're playing on the same computer then you probably want to be on the same team anyway.
InfoBuf_SetKey ( info , " team " , InfoBuf_ValueForKey ( & cls . userinfo [ 0 ] , " team " ) ) ;
if ( ! * InfoBuf_ValueForKey ( info , " bottomcolor " ) ) //bottom colour implies team in nq
InfoBuf_SetKey ( info , " bottomcolor " , InfoBuf_ValueForKey ( & cls . userinfo [ 0 ] , " bottomcolor " ) ) ;
if ( ! * InfoBuf_ValueForKey ( info , " topcolor " ) ) //should probably pick a random top colour or something
InfoBuf_SetKey ( info , " topcolor " , InfoBuf_ValueForKey ( & cls . userinfo [ 0 ] , " topcolor " ) ) ;
2016-01-18 05:22:07 +00:00
}
2018-07-05 16:21:44 +00:00
if ( ! * InfoBuf_ValueForKey ( info , " skin " ) ) //give players the same skin by default, because we can. q2 cares for teams. qw might as well (its not like anyone actually uses them thanks to enemy-skin forcing).
InfoBuf_SetKey ( info , " skin " , InfoBuf_ValueForKey ( & cls . userinfo [ 0 ] , " skin " ) ) ;
2021-06-25 18:50:42 +00:00
InfoBuf_SetKey ( info , " chat " , " " ) ;
2016-01-18 05:22:07 +00:00
2017-05-28 15:42:32 +00:00
# ifdef SVNREVISION
if ( strcmp ( STRINGIFY ( SVNREVISION ) , " - " ) )
ver = va ( " %s v%i.%02i %s " , DISTRIBUTION , FTE_VER_MAJOR , FTE_VER_MINOR , STRINGIFY ( SVNREVISION ) ) ;
else
# endif
ver = va ( " %s v%i.%02i " , DISTRIBUTION , FTE_VER_MAJOR , FTE_VER_MINOR ) ;
2018-07-05 16:21:44 +00:00
InfoBuf_SetStarKey ( info , " *ver " , ver ) ;
InfoBuf_ToString ( info , infostr , sizeof ( infostr ) , NULL , NULL , NULL , & cls . userinfosync , info ) ;
2017-05-28 15:42:32 +00:00
2021-08-04 21:16:57 +00:00
CL_SendClientCommand ( true , " addseat %i %s " , cl . splitclients + 1 , COM_QuotedString ( infostr , buffer , sizeof ( buffer ) , false ) ) ;
2016-01-18 05:22:07 +00:00
}
2018-07-05 16:21:44 +00:00
else if ( cl . splitclients > targ & & targ > = 1 )
2016-01-18 05:22:07 +00:00
CL_SendClientCommand ( true , " addseat %i " , targ ) ;
}
}
2008-06-12 20:47:13 +00:00
2004-08-23 00:15:46 +00:00
/*
= = = = = = = = = = = = = = = = =
CL_SendCmd
= = = = = = = = = = = = = = = = =
*/
vec3_t accum [ MAX_SPLITS ] ;
2008-06-12 20:47:13 +00:00
qboolean CL_WriteDeltas ( int plnum , sizebuf_t * buf )
{
int i ;
usercmd_t * cmd , * oldcmd ;
qboolean dontdrop = false ;
i = ( cls . netchan . outgoing_sequence - 2 ) & UPDATE_MASK ;
2013-03-12 22:53:23 +00:00
cmd = & cl . outframes [ i ] . cmd [ plnum ] ;
2009-11-04 21:16:50 +00:00
if ( cl_c2sImpulseBackup . ival > = 2 )
2008-06-12 20:47:13 +00:00
dontdrop = dontdrop | | cmd - > impulse ;
2021-04-14 05:21:04 +00:00
MSGCL_WriteDeltaUsercmd ( buf , & nullcmd , cmd ) ;
2008-06-12 20:47:13 +00:00
oldcmd = cmd ;
i = ( cls . netchan . outgoing_sequence - 1 ) & UPDATE_MASK ;
2009-11-04 21:16:50 +00:00
if ( cl_c2sImpulseBackup . ival > = 3 )
2008-06-12 20:47:13 +00:00
dontdrop = dontdrop | | cmd - > impulse ;
2013-03-12 22:53:23 +00:00
cmd = & cl . outframes [ i ] . cmd [ plnum ] ;
2021-04-14 05:21:04 +00:00
MSGCL_WriteDeltaUsercmd ( buf , oldcmd , cmd ) ;
2008-06-12 20:47:13 +00:00
oldcmd = cmd ;
i = ( cls . netchan . outgoing_sequence ) & UPDATE_MASK ;
2009-11-04 21:16:50 +00:00
if ( cl_c2sImpulseBackup . ival > = 1 )
2008-06-12 20:47:13 +00:00
dontdrop = dontdrop | | cmd - > impulse ;
2013-03-12 22:53:23 +00:00
cmd = & cl . outframes [ i ] . cmd [ plnum ] ;
2021-04-14 05:21:04 +00:00
MSGCL_WriteDeltaUsercmd ( buf , oldcmd , cmd ) ;
2008-06-12 20:47:13 +00:00
return dontdrop ;
}
2008-06-12 20:49:42 +00:00
# ifdef Q2CLIENT
2013-03-12 22:53:23 +00:00
qboolean CLQ2_SendCmd ( sizebuf_t * buf )
2008-06-12 20:47:13 +00:00
{
int seq_hash ;
2016-01-18 05:22:07 +00:00
qboolean dontdrop = false ;
2008-06-12 20:47:13 +00:00
usercmd_t * cmd ;
int checksumIndex , i ;
2014-02-11 17:51:29 +00:00
int lightlev ;
2016-01-18 05:22:07 +00:00
int seat ;
2008-06-12 20:47:13 +00:00
2015-05-14 03:06:58 +00:00
cl . movesequence = cls . netchan . outgoing_sequence ; //make sure its correct even over map changes.
seq_hash = cl . movesequence ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
for ( seat = 0 ; seat < cl . splitclients ; seat + + )
2008-06-12 20:47:13 +00:00
{
2016-01-18 05:22:07 +00:00
// send this and the previous cmds in the message, so
// if the last packet was dropped, it can be recovered
i = cl . movesequence & UPDATE_MASK ;
cmd = & cl . outframes [ i ] . cmd [ seat ] ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
//q2admin is retarded and kicks you if you get a stall.
if ( cmd - > msec > 100 )
cmd - > msec = 100 ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
MSG_WriteByte ( buf , clcq2_move ) ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
if ( seat )
{
//multi-seat still has an extra clc_move per seat
//but no checksum (pointless when its opensource anyway)
//no sequence (only seat 0 reports that)
checksumIndex = - 1 ;
}
else
{
// save the position for a checksum qbyte
if ( cls . protocol_q2 = = PROTOCOL_VERSION_R1Q2 | | cls . protocol_q2 = = PROTOCOL_VERSION_Q2PRO )
checksumIndex = - 1 ;
else
{
checksumIndex = buf - > cursize ;
MSG_WriteByte ( buf , 0 ) ;
}
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
if ( ! cl . q2frame . valid | | cl_nodelta . ival | | ( cls . demorecording & & ! cls . demohadkeyframe ) )
MSG_WriteLong ( buf , - 1 ) ; // no compression
else
MSG_WriteLong ( buf , cl . q2frame . serverframe ) ;
}
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
lightlev = R_LightPoint ( cl . playerview [ seat ] . simorg ) ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
// msecs = msecs - (double)msecstouse;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
i = cls . netchan . outgoing_sequence & UPDATE_MASK ;
cmd = & cl . outframes [ i ] . cmd [ seat ] ;
2017-08-29 02:29:06 +00:00
* cmd = cl_pendingcmd [ seat ] ;
2017-07-28 01:49:25 +00:00
2016-01-18 05:22:07 +00:00
cmd - > lightlevel = ( lightlev > 255 ) ? 255 : lightlev ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
cl . outframes [ i ] . senttime = realtime ;
cl . outframes [ i ] . latency = - 1 ;
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
if ( cmd - > buttons )
cmd - > buttons | = 128 ; //fixme: this isn't really what's meant by the anykey.
2008-06-12 20:47:13 +00:00
2016-01-18 05:22:07 +00:00
// calculate a checksum over the move commands
dontdrop | = CL_WriteDeltas ( seat , buf ) ;
if ( checksumIndex > = 0 )
{
buf - > data [ checksumIndex ] = Q2COM_BlockSequenceCRCByte (
buf - > data + checksumIndex + 1 , buf - > cursize - checksumIndex - 1 ,
seq_hash ) ;
}
2015-12-28 17:41:39 +00:00
}
2019-08-19 16:15:31 +00:00
CL_ClearPendingCommands ( ) ;
2008-06-12 20:47:13 +00:00
2015-12-28 17:41:39 +00:00
if ( cl . sendprespawn | | ! cls . protocol_q2 )
2008-06-12 20:47:13 +00:00
buf - > cursize = 0 ; //tastyspleen.net is alergic.
2016-01-18 05:22:07 +00:00
else
CL_UpdateSeats ( ) ;
2008-06-12 20:47:13 +00:00
return dontdrop ;
}
2008-06-12 20:49:42 +00:00
# endif
2008-06-12 20:47:13 +00:00
2015-08-10 18:28:23 +00:00
qboolean CLQW_SendCmd ( sizebuf_t * buf , qboolean actuallysend )
2008-06-12 20:47:13 +00:00
{
int seq_hash ;
qboolean dontdrop = false ;
usercmd_t * cmd ;
2009-11-04 21:16:50 +00:00
int checksumIndex , firstsize , plnum ;
2008-06-12 20:47:13 +00:00
int clientcount , lost ;
2013-03-12 22:53:23 +00:00
int curframe ;
2011-10-27 15:46:36 +00:00
int st = buf - > cursize ;
2016-02-10 23:23:43 +00:00
int chatstate ;
2008-06-12 20:47:13 +00:00
2013-03-12 22:53:23 +00:00
cl . movesequence = cls . netchan . outgoing_sequence ; //make sure its correct even over map changes.
2013-09-06 22:57:44 +00:00
curframe = cl . movesequence & UPDATE_MASK ;
seq_hash = cl . movesequence ;
cl . outframes [ curframe ] . server_message_num = cl . validsequence ;
cl . outframes [ curframe ] . cmd_sequence = cl . movesequence ;
cl . outframes [ curframe ] . senttime = realtime ;
cl . outframes [ curframe ] . latency = - 1 ;
2008-06-12 20:47:13 +00:00
// send this and the previous cmds in the message, so
// if the last packet was dropped, it can be recovered
clientcount = cl . splitclients ;
if ( ! clientcount )
clientcount = 1 ;
2016-02-10 23:23:43 +00:00
chatstate = 0 ;
2019-01-13 16:51:50 +00:00
if ( cl_sendchatstate . ival )
{
if ( Key_Dest_Has ( kdm_message | kdm_console | kdm_cwindows ) )
chatstate | = 1 ; //chatting
else if ( Key_Dest_Has ( ~ ( kdm_game | kdm_centerprint ) ) )
chatstate | = 2 ; //afk. ezquake sends chatting, but neither are really appropriate.
if ( ! vid . activeapp | | vid . isminimized )
chatstate | = 2 ; //afk.
//FIXME: flag as afk if no new inputs for a while.
}
2009-11-04 21:16:50 +00:00
for ( plnum = 0 ; plnum < clientcount ; plnum + + )
{
2016-02-10 23:23:43 +00:00
if ( cl . playerview [ plnum ] . chatstate ! = chatstate )
{
if ( chatstate )
CL_SetInfo ( plnum , " chat " , va ( " %i " , chatstate ) ) ;
else
CL_SetInfo ( plnum , " chat " , " " ) ;
cl . playerview [ plnum ] . chatstate = chatstate ;
}
2013-03-12 22:53:23 +00:00
cmd = & cl . outframes [ curframe ] . cmd [ plnum ] ;
2017-08-29 02:29:06 +00:00
* cmd = cl_pendingcmd [ plnum ] ;
2009-11-04 21:16:50 +00:00
cmd - > lightlevel = 0 ;
# ifdef CSQC_DAT
2015-10-11 11:34:58 +00:00
if ( ! runningindepphys )
CSQC_Input_Frame ( plnum , cmd ) ;
2009-11-04 21:16:50 +00:00
# endif
}
2019-08-19 16:15:31 +00:00
CL_ClearPendingCommands ( ) ;
2009-11-04 21:16:50 +00:00
2021-07-17 15:10:01 +00:00
if ( cls . fteprotocolextensions2 & PEXT2_VRINPUTS )
dontdrop = CLFTE_SendVRCmd ( buf , clientcount ) ;
else
2009-11-04 21:16:50 +00:00
{
2021-07-17 15:10:01 +00:00
cmd = & cl . outframes [ curframe ] . cmd [ 0 ] ;
if ( cmd - > cursor_screen [ 0 ] | | cmd - > cursor_screen [ 1 ] | | cmd - > cursor_entitynumber | |
cmd - > cursor_start [ 0 ] | | cmd - > cursor_start [ 1 ] | | cmd - > cursor_start [ 2 ] | |
cmd - > cursor_impact [ 0 ] | | cmd - > cursor_impact [ 1 ] | | cmd - > cursor_impact [ 2 ] )
{
MSG_WriteByte ( buf , clcfte_prydoncursor ) ;
MSG_WriteShort ( buf , cmd - > cursor_screen [ 0 ] * 32767.0f ) ;
MSG_WriteShort ( buf , cmd - > cursor_screen [ 1 ] * 32767.0f ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 0 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 1 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_start [ 2 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 0 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 1 ] ) ;
MSG_WriteFloat ( buf , cmd - > cursor_impact [ 2 ] ) ;
MSG_WriteEntity ( buf , cmd - > cursor_entitynumber ) ;
}
2009-11-04 21:16:50 +00:00
2021-07-17 15:10:01 +00:00
MSG_WriteByte ( buf , clc_move ) ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
// save the position for a checksum qbyte
checksumIndex = buf - > cursize ;
MSG_WriteByte ( buf , 0 ) ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
// write our lossage percentage
lost = CL_CalcNet ( r_netgraph . value ) ;
MSG_WriteByte ( buf , ( qbyte ) lost ) ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
firstsize = 0 ;
for ( plnum = 0 ; plnum < clientcount ; plnum + + )
{
cmd = & cl . outframes [ curframe ] . cmd [ plnum ] ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
if ( plnum )
MSG_WriteByte ( buf , clc_move ) ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
dontdrop = CL_WriteDeltas ( plnum , buf ) | | dontdrop ;
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
if ( ! firstsize )
firstsize = buf - > cursize ;
}
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
// calculate a checksum over the move commands
2008-06-12 20:47:13 +00:00
2021-07-17 15:10:01 +00:00
buf - > data [ checksumIndex ] = COM_BlockSequenceCRCByte (
buf - > data + checksumIndex + 1 , firstsize - checksumIndex - 1 ,
seq_hash ) ;
}
2008-06-12 20:47:13 +00:00
// request delta compression of entities
if ( cls . netchan . outgoing_sequence - cl . validsequence > = UPDATE_BACKUP - 1 )
cl . validsequence = 0 ;
2013-03-12 22:53:23 +00:00
//delta_sequence is the _expected_ previous sequences, so is set before it arrives.
2022-03-08 05:34:26 +00:00
if ( cl . validsequence & & ! cl_nodelta . ival & & cls . state = = ca_active ) // && !cls.demorecording)
2008-06-12 20:47:13 +00:00
{
MSG_WriteByte ( buf , clc_delta ) ;
// Con_Printf("%i\n", cl.validsequence);
MSG_WriteByte ( buf , cl . validsequence & 255 ) ;
}
2015-08-10 18:28:23 +00:00
if ( cl . sendprespawn | | ! actuallysend )
2013-09-06 22:57:44 +00:00
buf - > cursize = st ; //don't send movement commands while we're still supposedly downloading. mvdsv does not like that.
2015-06-24 17:59:57 +00:00
else
2016-01-18 05:22:07 +00:00
CL_UpdateSeats ( ) ;
2008-06-12 20:47:13 +00:00
return dontdrop ;
}
2018-07-05 16:21:44 +00:00
static void CL_SendUserinfoUpdate ( void )
{
const char * key = cls . userinfosync . keys [ 0 ] . name ;
infobuf_t * info = cls . userinfosync . keys [ 0 ] . context ;
size_t bloboffset = cls . userinfosync . keys [ 0 ] . syncpos ;
unsigned int seat = info - cls . userinfo ;
size_t blobsize ;
2019-03-12 05:04:27 +00:00
const char * blobdata = InfoBuf_BlobForKey ( info , key , & blobsize , NULL ) ;
2018-07-05 16:21:44 +00:00
size_t sendsize = blobsize - bloboffset ;
const char * s ;
qboolean final = true ;
char enckey [ 2048 ] ;
char encval [ 2048 ] ;
# ifdef Q3CLIENT
if ( cls . protocol = = CP_QUAKE3 )
{ //q3 sends it all in one go
char userinfo [ 2048 ] ;
InfoSync_Strip ( & cls . userinfosync , info ) ; //can't track this stuff. all or nothing.
2019-10-19 22:02:12 +00:00
if ( info = = & cls . userinfo [ 0 ] )
{
InfoBuf_ToString ( info , userinfo , sizeof ( userinfo ) , NULL , NULL , NULL , NULL , NULL ) ;
2022-03-08 05:31:34 +00:00
q3 - > cl . SendClientCommand ( " userinfo \" %s \" " , userinfo ) ;
2019-10-19 22:02:12 +00:00
}
2018-07-05 16:21:44 +00:00
return ;
}
# endif
# ifdef Q2CLIENT
if ( cls . protocol = = CP_QUAKE2 & & ! cls . fteprotocolextensions )
{
char userinfo [ 2048 ] ;
InfoSync_Strip ( & cls . userinfosync , info ) ; //can't track this stuff. all or nothing.
2019-10-19 22:02:12 +00:00
if ( info = = & cls . userinfo [ 0 ] )
{
InfoBuf_ToString ( info , userinfo , sizeof ( userinfo ) , NULL , NULL , NULL , NULL , NULL ) ;
2018-07-05 16:21:44 +00:00
2019-10-19 22:02:12 +00:00
MSG_WriteByte ( & cls . netchan . message , clcq2_userinfo ) ;
MSG_WriteString ( & cls . netchan . message , userinfo ) ;
}
2018-07-05 16:21:44 +00:00
return ;
}
# endif
if ( seat < max ( 1 , cl . splitclients ) )
{
if ( sendsize > 1023 )
{
final = false ;
sendsize = 1023 ; //should be a multiple of 3
}
if ( ! InfoBuf_EncodeString ( key , strlen ( key ) , enckey , sizeof ( enckey ) ) | |
! InfoBuf_EncodeString ( blobdata + bloboffset , sendsize , encval , sizeof ( encval ) ) )
{ //some buffer wasn't big enough... shouldn't happen.
InfoSync_Remove ( & cls . userinfosync , 0 ) ;
return ;
}
if ( final & & ! bloboffset & & * encval ! = ' \xff ' & & * encval ! = ' \xff ' )
{ //vanilla-compatible info.
2021-07-17 15:10:10 +00:00
s = va ( " setinfo \" %s \" \" %s \" " , enckey , encval ) ;
2018-07-05 16:21:44 +00:00
}
else if ( cls . fteprotocolextensions2 & PEXT2_INFOBLOBS )
{ //only flood servers that actually support it.
if ( final )
2021-07-17 15:10:10 +00:00
s = va ( " setinfo \" %s \" \" %s \" %u " , enckey , encval , ( unsigned int ) bloboffset ) ;
2018-07-05 16:21:44 +00:00
else
2021-07-17 15:10:10 +00:00
s = va ( " setinfo \" %s \" \" %s \" %u+ " , enckey , encval , ( unsigned int ) bloboffset ) ;
2018-07-05 16:21:44 +00:00
}
else
{ //server doesn't support it, just ignore the key
InfoSync_Remove ( & cls . userinfosync , 0 ) ;
return ;
}
2021-07-17 15:10:10 +00:00
if ( seat & & ( cls . fteprotocolextensions & PEXT_SPLITSCREEN ) )
{
MSG_WriteByte ( & cls . netchan . message , ( cls . protocol = = CP_QUAKE2 ) ? clcq2_stringcmd_seat : clcfte_stringcmd_seat ) ;
MSG_WriteByte ( & cls . netchan . message , seat ) ;
}
2018-07-05 16:21:44 +00:00
else
2021-07-17 15:10:10 +00:00
MSG_WriteByte ( & cls . netchan . message , ( cls . protocol = = CP_QUAKE2 ) ? clcq2_stringcmd : clc_stringcmd ) ;
2018-07-05 16:21:44 +00:00
MSG_WriteString ( & cls . netchan . message , s ) ;
}
if ( bloboffset + sendsize = = blobsize )
InfoSync_Remove ( & cls . userinfosync , 0 ) ;
else
cls . userinfosync . keys [ 0 ] . syncpos + = sendsize ;
}
2009-05-24 10:11:17 +00:00
void CL_SendCmd ( double frametime , qboolean mainloop )
2004-08-23 00:15:46 +00:00
{
sizebuf_t buf ;
2021-06-25 18:50:42 +00:00
qbyte data [ MAX_DATAGRAM * 16 ] ;
2004-08-23 00:15:46 +00:00
int i , plnum ;
2008-06-12 20:47:13 +00:00
usercmd_t * cmd ;
2005-05-26 12:55:34 +00:00
float wantfps ;
2015-08-10 18:28:23 +00:00
int fullsend ; //-1: send for sequence, with no usercmd. 0: update input frame, but don't send anything. 1: time for a new usercmd
2004-08-23 00:15:46 +00:00
static float pps_balance = 0 ;
static int dropcount = 0 ;
2007-05-26 00:39:03 +00:00
static double msecs ;
2015-10-11 11:34:58 +00:00
static double msecsround ;
2004-08-23 00:15:46 +00:00
qboolean dontdrop = false ;
2017-08-29 02:29:06 +00:00
float usetime ; //how many msecs we can use for the new frame
int msecstouse ; //usetime truncated to network precision (how much we'll actually eat)
float framemsecs ; //how long we're saying the input frame should be (differs from realtime with nq as we want to send frames reguarly, but note this might end up with funny-duration frames).
2017-12-15 06:56:40 +00:00
qboolean xonoticworkaround ;
2004-08-23 00:15:46 +00:00
2008-01-09 00:52:31 +00:00
clcmdbuf_t * next ;
2005-02-28 07:16:19 +00:00
2009-05-24 10:11:17 +00:00
if ( runningindepphys )
{
double curtime ;
static double lasttime ;
curtime = Sys_DoubleTime ( ) ;
frametime = curtime - lasttime ;
lasttime = curtime ;
}
2007-01-06 09:37:33 +00:00
CL_ProxyMenuHooks ( ) ;
2014-10-11 19:39:45 +00:00
if ( cls . demoplayback ! = DPB_NONE | | cls . state < = ca_demostart )
2004-08-23 00:15:46 +00:00
{
2014-09-02 02:44:43 +00:00
cursor_active = false ;
2014-10-05 20:04:11 +00:00
if ( ! cls . state | | cls . demoplayback = = DPB_MVD | | cls . demoplayback = = DPB_EZTV )
2004-08-23 00:15:46 +00:00
{
2005-06-07 04:40:16 +00:00
extern cvar_t cl_splitscreen ;
2013-03-12 22:53:23 +00:00
cl . ackedmovesequence = cl . movesequence ;
i = cl . movesequence & UPDATE_MASK ;
cl . movesequence + + ;
2013-10-21 05:20:13 +00:00
cl . outframes [ i ] . server_message_num = cl . validsequence ;
cl . outframes [ i ] . cmd_sequence = cl . movesequence ;
2013-03-12 22:53:23 +00:00
cl . outframes [ i ] . senttime = realtime ; // we haven't gotten a reply yet
// cl.outframes[i].receivedtime = -1; // we haven't gotten a reply yet
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
if ( cl . splitclients > cl_splitscreen . ival + 1 )
2005-06-07 04:40:16 +00:00
{
2009-11-04 21:16:50 +00:00
cl . splitclients = cl_splitscreen . ival + 1 ;
2005-06-07 04:40:16 +00:00
if ( cl . splitclients < 1 )
cl . splitclients = 1 ;
}
for ( plnum = 0 ; plnum < cl . splitclients ; plnum + + )
{
2017-05-28 15:42:32 +00:00
playerview_t * pv = & cl . playerview [ plnum ] ;
2013-03-12 22:53:23 +00:00
cmd = & cl . outframes [ i ] . cmd [ plnum ] ;
2004-08-23 00:15:46 +00:00
2022-01-28 10:48:14 +00:00
CL_AccumlateInput ( plnum , frametime , frametime * 1000 ) ;
* cmd = cl_pendingcmd [ plnum ] ;
memset ( & cl_pendingcmd [ plnum ] , 0 , sizeof ( * cmd ) ) ; //reset the pending for the next frame.
2013-10-21 05:20:13 +00:00
2014-10-05 20:04:11 +00:00
# ifdef CSQC_DAT
CSQC_Input_Frame ( plnum , cmd ) ;
# endif
if ( cls . state = = ca_active )
2013-10-21 05:20:13 +00:00
{
player_state_t * from , * to ;
from = & cl . inframes [ cl . ackedmovesequence & UPDATE_MASK ] . playerstate [ pv - > playernum ] ;
to = & cl . inframes [ cl . movesequence & UPDATE_MASK ] . playerstate [ pv - > playernum ] ;
CL_PredictUsercmd ( pv - > playernum , pv - > viewentity , from , to , & cl . outframes [ cl . ackedmovesequence & UPDATE_MASK ] . cmd [ plnum ] ) ;
}
2005-06-07 04:40:16 +00:00
}
2004-08-23 00:15:46 +00:00
2008-01-09 00:52:31 +00:00
while ( clientcmdlist )
{
next = clientcmdlist - > next ;
CL_Demo_ClientCommand ( clientcmdlist - > command ) ;
2017-03-04 19:36:06 +00:00
Con_DLPrintf ( 2 , " Sending stringcmd %s \n " , clientcmdlist - > command ) ;
2008-01-09 00:52:31 +00:00
Z_Free ( clientcmdlist ) ;
clientcmdlist = next ;
}
2013-03-12 22:53:23 +00:00
cls . netchan . outgoing_sequence = cl . movesequence ;
2004-08-23 00:15:46 +00:00
}
2022-01-28 10:48:14 +00:00
IN_Move ( NULL , NULL , 0 , frametime ) ;
2015-06-29 23:46:31 +00:00
Cbuf_Waited ( ) ; //its okay to stop waiting now
2004-08-23 00:15:46 +00:00
return ; // sendcmds come from the demo
}
2011-10-27 15:46:36 +00:00
memset ( & buf , 0 , sizeof ( buf ) ) ;
2005-03-23 22:14:08 +00:00
buf . maxsize = sizeof ( data ) ;
buf . cursize = 0 ;
buf . data = data ;
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
buf . prim = cls . netchan . message . prim ;
2005-03-23 22:14:08 +00:00
2017-12-15 06:56:40 +00:00
xonoticworkaround = cls . protocol = = CP_NETQUAKE & & CPNQ_IS_DP & & cl . time & & ! cl . paused ;
if ( xonoticworkaround )
2017-08-29 02:29:06 +00:00
{
if ( cl . movesequence_time > cl . time + 0.5 )
cl . movesequence_time = cl . time + 0.5 ; //shouldn't really happen
if ( cl . movesequence_time < cl . time - 0.5 )
cl . movesequence_time = cl . time - 0.5 ; //shouldn't really happen
framemsecs = ( cl . time - cl . movesequence_time ) * 1000 ;
wantfps = cl_netfps . value ;
2017-12-15 06:56:40 +00:00
usetime = CL_FilterTime ( framemsecs , wantfps , 5 , false ) ;
2017-08-29 02:29:06 +00:00
if ( usetime > 0 )
{
usetime = framemsecs - usetime ;
fullsend = true ;
}
else
{
usetime = framemsecs - usetime ;
fullsend = false ;
}
2017-12-15 06:56:40 +00:00
msecstouse = usetime ;
framemsecs = msecstouse ;
2017-12-10 13:47:25 +00:00
msecs = 0 ;
2017-08-29 02:29:06 +00:00
}
else
{
msecs + = frametime * 1000 ;
2005-03-28 00:11:59 +00:00
2017-08-29 02:29:06 +00:00
// Con_Printf("%f\n", msecs);
2004-08-23 00:15:46 +00:00
2017-08-29 02:29:06 +00:00
wantfps = cl_netfps . value ;
fullsend = true ;
2008-06-12 20:47:13 +00:00
2017-08-29 02:29:06 +00:00
msecstouse = 0 ;
2015-10-11 11:34:58 +00:00
2017-08-29 02:29:06 +00:00
# ifndef CLIENTONLY
if ( sv . state & & cls . state ! = ca_active )
2018-06-18 16:44:29 +00:00
{ //HACK: if we're also the server, spam like a crazy person until we're on the server, for faster apparent load times.
fullsend = - 1 ; //send no movement command.
2017-08-29 02:29:06 +00:00
msecstouse = usetime = msecs ;
2010-12-05 02:46:07 +00:00
}
2017-08-29 02:29:06 +00:00
else
# endif
2008-06-12 20:47:13 +00:00
{
2017-08-29 02:29:06 +00:00
// while we're not playing send a slow keepalive fullsend to stop mvdsv from screwing up
if ( cls . state < ca_active & & ! cls . download )
{
# ifdef IRCCONNECT //don't spam irc.
if ( cls . netchan . remote_address . type = = NA_IRC )
wantfps = 0.5 ;
else
# endif
wantfps = 12.5 ;
}
if ( ! runningindepphys & & ( cl_netfps . value > 0 | | ! fullsend ) )
{
float spare ;
2017-12-15 06:56:40 +00:00
spare = CL_FilterTime ( msecs , wantfps , ( /*cls.protocol == CP_NETQUAKE*/ 0 ? 0 : 1.5 ) , false ) ;
2017-08-29 02:29:06 +00:00
usetime = msecsround + ( msecs - spare ) ;
msecstouse = ( int ) usetime ;
if ( ! spare )
fullsend = false ;
else
{
msecsround = usetime - msecstouse ;
msecs = spare + msecstouse ;
}
}
2015-10-11 11:34:58 +00:00
else
{
2017-08-29 02:29:06 +00:00
usetime = msecsround + msecs ;
msecstouse = ( int ) usetime ;
2015-10-11 11:34:58 +00:00
msecsround = usetime - msecstouse ;
}
}
2008-06-12 20:47:13 +00:00
2017-08-29 02:29:06 +00:00
if ( msecstouse > 200 ) // cap at 200 to avoid servers splitting movement more than four times
msecstouse = 200 ;
2015-10-11 11:34:58 +00:00
2017-08-29 02:29:06 +00:00
// align msecstouse to avoid servers wasting our msecs
if ( msecstouse > 100 )
msecstouse & = ~ 3 ; // align to 4
else if ( msecstouse > 50 )
msecstouse & = ~ 1 ; // align to 2
2015-10-11 11:34:58 +00:00
2017-08-29 02:29:06 +00:00
if ( msecstouse < = 0 ) //FIXME
fullsend = false ;
if ( usetime < = 0 )
return ; //infinite frame times = weirdness.
framemsecs = msecstouse ;
if ( cls . protocol = = CP_NETQUAKE )
2017-12-15 06:56:40 +00:00
framemsecs = 1000 * ( cl . time - cl . movesequence_time ) ;
2017-08-29 02:29:06 +00:00
}
2015-10-11 11:34:58 +00:00
2009-04-01 22:03:56 +00:00
# ifdef HLCLIENT
2018-03-04 14:41:16 +00:00
if ( ! CLHL_BuildUserInput ( msecstouse , & cl_pendingcmd [ 0 ] ) )
2009-04-01 22:03:56 +00:00
# endif
2017-09-20 11:27:13 +00:00
for ( plnum = 0 ; plnum < ( cl . splitclients ? cl . splitclients : 1 ) ; plnum + + )
2022-01-28 10:48:14 +00:00
CL_AccumlateInput ( plnum , frametime , framemsecs ) ;
2004-08-23 00:15:46 +00:00
2009-05-24 10:11:17 +00:00
//the main loop isn't allowed to send
if ( runningindepphys & & mainloop )
return ;
2008-06-12 20:47:13 +00:00
// if (skipcmd)
// return;
2005-06-04 04:20:20 +00:00
2015-10-11 11:34:58 +00:00
if ( ! fullsend )
2008-06-12 20:47:13 +00:00
return ; // when we're actually playing we try to match netfps exactly to avoid gameplay problems
2004-08-23 00:15:46 +00:00
2014-02-07 15:17:43 +00:00
// if (msecstouse > 127)
// Con_Printf("%i\n", msecstouse, msecs);
2014-02-07 08:38:40 +00:00
2018-03-04 14:41:16 +00:00
//HACK: 1000/77 = 12.98. nudge it just under so we never appear to be using 83fps at 77fps (which can trip cheat detection in mods that expect 72 fps when many servers are configured for 77)
//so lets just never use 12.
if ( fullsend & & cls . maxfps = = 77 )
for ( plnum = 0 ; plnum < ( cl . splitclients ? cl . splitclients : 1 ) ; plnum + + )
if ( cl_pendingcmd [ plnum ] . msec > 12.9 & & cl_pendingcmd [ plnum ] . msec < 13 )
cl_pendingcmd [ plnum ] . msec = 13 ;
2011-06-16 02:03:57 +00:00
# ifdef NQPROT
if ( cls . protocol ! = CP_NETQUAKE | | cls . netchan . nqreliable_allowed )
# endif
2004-08-23 00:15:46 +00:00
{
2011-06-16 02:03:57 +00:00
CL_SendDownloadReq ( & buf ) ;
2019-04-07 16:41:09 +00:00
//only start spamming userinfo blobs once we receive the initial serverinfo.
while ( cls . userinfosync . numkeys & & cls . netchan . message . cursize < 512 & & ( cl . haveserverinfo | | cls . protocol = = CP_QUAKE2 | | cls . protocol = = CP_QUAKE3 ) )
CL_SendUserinfoUpdate ( ) ;
2011-06-16 02:03:57 +00:00
while ( clientcmdlist )
2004-08-23 00:15:46 +00:00
{
2011-06-16 02:03:57 +00:00
next = clientcmdlist - > next ;
if ( clientcmdlist - > reliable )
{
2011-10-27 15:46:36 +00:00
if ( cls . netchan . message . cursize + 2 + strlen ( clientcmdlist - > command ) + 100 > cls . netchan . message . maxsize )
2011-06-16 02:03:57 +00:00
break ;
2019-08-16 06:58:37 +00:00
if ( ! strncmp ( clientcmdlist - > command , " spawn " , 5 ) & & cls . userinfosync . numkeys & & cl . haveserverinfo )
2019-04-07 16:41:09 +00:00
break ; //HACK: don't send the spawn until all pending userinfos have been flushed.
2021-07-17 15:10:10 +00:00
if ( clientcmdlist - > seat & & ( cls . fteprotocolextensions & PEXT_SPLITSCREEN ) )
{
MSG_WriteByte ( & cls . netchan . message , clcfte_stringcmd_seat ) ;
MSG_WriteByte ( & cls . netchan . message , clientcmdlist - > seat ) ;
}
else
MSG_WriteByte ( & cls . netchan . message , clc_stringcmd ) ;
2011-06-16 02:03:57 +00:00
MSG_WriteString ( & cls . netchan . message , clientcmdlist - > command ) ;
}
else
2008-11-09 22:29:28 +00:00
{
2011-10-27 15:46:36 +00:00
if ( buf . cursize + 2 + strlen ( clientcmdlist - > command ) + 100 < = buf . maxsize )
2011-06-16 02:03:57 +00:00
{
2021-07-17 15:10:10 +00:00
if ( clientcmdlist - > seat & & ( cls . fteprotocolextensions & PEXT_SPLITSCREEN ) )
{
MSG_WriteByte ( & cls . netchan . message , clcfte_stringcmd_seat ) ;
MSG_WriteByte ( & cls . netchan . message , clientcmdlist - > seat ) ;
}
else
MSG_WriteByte ( & buf , clc_stringcmd ) ;
2011-06-16 02:03:57 +00:00
MSG_WriteString ( & buf , clientcmdlist - > command ) ;
}
2008-11-09 22:29:28 +00:00
}
2017-03-04 19:36:06 +00:00
Con_DLPrintf ( 2 , " Sending stringcmd %s \n " , clientcmdlist - > command ) ;
2011-06-16 02:03:57 +00:00
Z_Free ( clientcmdlist ) ;
clientcmdlist = next ;
2008-06-12 20:47:13 +00:00
}
}
2004-08-23 00:15:46 +00:00
2008-06-12 20:47:13 +00:00
// if we're not doing clc_moves and etc, don't continue unless we wrote something previous
// or we have something on the reliable buffer (or we're loopback and don't care about flooding)
if ( ! fullsend & & cls . netchan . remote_address . type ! = NA_LOOPBACK & & buf . cursize < 1 & & cls . netchan . message . cursize < 1 )
2013-09-06 22:57:44 +00:00
return ;
2004-08-23 00:15:46 +00:00
2008-06-12 20:47:13 +00:00
if ( fullsend )
{
2014-05-10 13:42:13 +00:00
if ( ! cls . state )
{
msecs - = ( double ) msecstouse ;
return ;
}
2014-09-02 02:44:43 +00:00
cursor_active = false ;
2014-12-25 02:32:22 +00:00
2017-08-29 02:29:06 +00:00
for ( plnum = 0 ; plnum < cl . splitclients ; plnum + + )
2014-12-25 02:32:22 +00:00
{
2017-08-29 02:29:06 +00:00
cmd = & cl_pendingcmd [ plnum ] ;
if ( ( ( cls . fteprotocolextensions2 & PEXT2_PRYDONCURSOR ) | | ( cls . protocol = = CP_NETQUAKE & & cls . protocol_nq > = CPNQ_DP6 ) ) & &
( * cl_prydoncursor . string & & cl_prydoncursor . ival > = 0 ) & & cls . state = = ca_active )
CL_UpdatePrydonCursor ( cmd , plnum ) ;
else
{
Vector2Clear ( cmd - > cursor_screen ) ;
VectorClear ( cmd - > cursor_start ) ;
VectorClear ( cmd - > cursor_impact ) ;
cmd - > cursor_entitynumber = 0 ;
}
2014-12-25 02:32:22 +00:00
}
2017-12-15 06:56:40 +00:00
if ( xonoticworkaround )
cl . movesequence_time + = msecstouse / 1000.0 ;
else
cl . movesequence_time = cl . time ;
2008-06-12 20:47:13 +00:00
switch ( cls . protocol )
2004-08-23 00:15:46 +00:00
{
2008-06-12 20:47:13 +00:00
# ifdef NQPROT
case CP_NETQUAKE :
msecs - = ( double ) msecstouse ;
CLNQ_SendCmd ( & buf ) ;
2017-08-29 02:29:06 +00:00
dontdrop = true ;
2008-06-12 20:47:13 +00:00
break ;
2004-08-23 00:15:46 +00:00
# endif
2008-06-12 20:47:13 +00:00
case CP_QUAKEWORLD :
msecs - = ( double ) msecstouse ;
2015-08-10 18:28:23 +00:00
dontdrop = CLQW_SendCmd ( & buf , fullsend = = true ) ;
2008-06-12 20:47:13 +00:00
break ;
2004-08-23 00:15:46 +00:00
# ifdef Q2CLIENT
2008-06-12 20:47:13 +00:00
case CP_QUAKE2 :
msecs - = ( double ) msecstouse ;
2013-03-12 22:53:23 +00:00
dontdrop = CLQ2_SendCmd ( & buf ) ;
2008-06-12 20:47:13 +00:00
break ;
2004-08-23 00:15:46 +00:00
# endif
2008-06-12 20:47:13 +00:00
# ifdef Q3CLIENT
case CP_QUAKE3 :
2016-11-25 08:14:54 +00:00
msecs - = ( double ) msecstouse ;
2022-03-08 05:31:34 +00:00
i = cl . movesequence & UPDATE_MASK ;
memcpy ( cl . outframes [ i ] . cmd , cl_pendingcmd , sizeof ( usercmd_t ) * bound ( 1 , cl . splitclients , MAX_SPLITS ) ) ;
cl . outframes [ i ] . cmd_sequence = cl . movesequence + + ;
q3 - > cl . SendCmd ( cls . sockets , cl . outframes [ i ] . cmd , cl . movesequence , cl . time ) ;
cls . netchan . outgoing_sequence = cl . movesequence ;
2019-08-19 16:15:31 +00:00
CL_ClearPendingCommands ( ) ;
2016-11-25 08:14:54 +00:00
//don't bank too much, because that results in banking speedcheats
if ( msecs > 200 )
msecs = 200 ;
2008-06-12 20:47:13 +00:00
return ; // Q3 does it's own thing
2004-08-23 00:15:46 +00:00
# endif
2008-06-12 20:47:13 +00:00
default :
2009-05-24 10:11:17 +00:00
Host_EndGame ( " Invalid protocol in CL_SendCmd: %i " , cls . protocol ) ;
2008-06-12 20:47:13 +00:00
return ;
}
2004-08-23 00:15:46 +00:00
2017-08-29 02:29:06 +00:00
if ( cls . demorecording )
CL_WriteDemoCmd ( & cl . outframes [ cl . movesequence & UPDATE_MASK ] . cmd [ 0 ] ) ;
2004-08-23 00:15:46 +00:00
2017-08-29 02:29:06 +00:00
// Con_DPrintf("generated sequence %i\n", cl.movesequence);
cl . movesequence + + ;
2004-08-23 00:15:46 +00:00
2017-08-29 02:29:06 +00:00
//clear enough of the pending command for the next frame.
for ( plnum = 0 ; plnum < cl . splitclients ; plnum + + )
{
2021-09-15 20:33:54 +00:00
cl_pendingcmd [ plnum ] . sequence = cl . movesequence ;
2017-08-29 02:29:06 +00:00
cl_pendingcmd [ plnum ] . msec = 0 ;
cl_pendingcmd [ plnum ] . impulse = 0 ;
2018-09-29 17:31:58 +00:00
// cl_pendingcmd[plnum].buttons = 0;
2017-08-29 02:29:06 +00:00
}
}
2013-03-12 22:53:23 +00:00
2008-11-09 22:29:28 +00:00
# ifdef IRCCONNECT
if ( cls . netchan . remote_address . type = = NA_IRC )
{
if ( dropcount > = 2 )
{
dropcount = 0 ;
}
else
{
// don't count this message when calculating PL
2017-08-29 02:29:06 +00:00
cl . outframes [ cls . netchan . outgoing_sequence & UPDATE_MASK ] . latency = - 3 ;
2008-11-09 22:29:28 +00:00
// drop this message
cls . netchan . outgoing_sequence + + ;
dropcount + + ;
return ;
}
}
else
# endif
//shamelessly stolen from fuhquake
2009-11-04 21:16:50 +00:00
if ( cl_c2spps . ival > 0 )
2004-08-23 00:15:46 +00:00
{
2005-03-20 02:57:11 +00:00
pps_balance + = frametime ;
2004-08-23 00:15:46 +00:00
// never drop more than 2 messages in a row -- that'll cause PL
// and don't drop if one of the last two movemessages have an impulse
if ( pps_balance > 0 | | dropcount > = 2 | | dontdrop )
{
float pps ;
2009-11-04 21:16:50 +00:00
pps = cl_c2spps . ival ;
2004-08-23 00:15:46 +00:00
if ( pps < 10 ) pps = 10 ;
if ( pps > 72 ) pps = 72 ;
pps_balance - = 1 / pps ;
// bound pps_balance. FIXME: is there a better way?
if ( pps_balance > 0.1 ) pps_balance = 0.1 ;
if ( pps_balance < - 0.1 ) pps_balance = - 0.1 ;
dropcount = 0 ;
}
else
{
// don't count this message when calculating PL
2018-01-23 01:22:29 +00:00
cl . outframes [ ( cl . movesequence - 1 ) & UPDATE_MASK ] . latency = - 3 ;
2004-08-23 00:15:46 +00:00
// drop this message
cls . netchan . outgoing_sequence + + ;
dropcount + + ;
return ;
}
}
else
{
pps_balance = 0 ;
dropcount = 0 ;
}
2011-09-05 01:48:23 +00:00
# ifdef VOICECHAT
2013-05-11 05:03:07 +00:00
if ( cls . protocol = = CP_QUAKE2 )
S_Voip_Transmit ( clcq2_voicechat , & buf ) ;
else
2015-04-14 23:12:17 +00:00
S_Voip_Transmit ( clcfte_voicechat , & buf ) ;
2010-11-15 02:40:31 +00:00
# endif
2004-08-23 00:15:46 +00:00
//
// deliver the message
//
2015-10-11 11:34:58 +00:00
cls . netchan . dupe = cl_c2sdupe . ival ;
2015-10-27 15:20:15 +00:00
Netchan_Transmit ( & cls . netchan , buf . cursize , buf . data , 2500 ) ;
//don't bank too much, because that results in banking speedcheats
if ( msecs > 200 )
msecs = 200 ;
2004-08-23 00:15:46 +00:00
if ( cls . netchan . fatal_error )
{
cls . netchan . fatal_error = false ;
cls . netchan . message . overflowed = false ;
cls . netchan . message . cursize = 0 ;
}
}
2007-06-20 00:02:54 +00:00
void CL_SendCvar_f ( void )
{
cvar_t * var ;
char * val ;
char * name = Cmd_Argv ( 1 ) ;
var = Cvar_FindVar ( name ) ;
if ( ! var )
val = " " ;
else if ( var - > flags & CVAR_NOUNSAFEEXPAND )
val = " " ;
else
val = var - > string ;
2021-07-17 15:10:10 +00:00
CL_SendSeatClientCommand ( true , CL_TargettedSplit ( false ) , " sentcvar %s \" %s \" " , name , val ) ;
2007-06-20 00:02:54 +00:00
}
2005-05-13 10:42:48 +00:00
/*
= = = = = = = = = = = =
CL_InitInput
= = = = = = = = = = = =
*/
void CL_InitInput ( void )
{
2021-06-25 18:50:42 +00:00
static char pcmd [ MAX_SPLITS ] [ 3 ] [ 6 ] ;
2018-10-11 10:31:23 +00:00
unsigned int sp , i ;
2005-05-13 10:42:48 +00:00
# define inputnetworkcvargroup "client networking options"
2005-05-19 02:53:03 +00:00
cl . splitclients = 1 ;
2004-08-23 00:15:46 +00:00
2005-01-13 16:29:20 +00:00
Cmd_AddCommand ( " rotate " , IN_Rotate_f ) ;
2006-02-20 22:33:30 +00:00
Cmd_AddCommand ( " in_restart " , IN_Restart ) ;
2007-06-20 00:02:54 +00:00
Cmd_AddCommand ( " sendcvar " , CL_SendCvar_f ) ;
2005-01-13 16:29:20 +00:00
2014-04-13 04:23:13 +00:00
Cvar_Register ( & cl_fastaccel , inputnetworkcvargroup ) ;
2011-09-05 01:48:23 +00:00
Cvar_Register ( & in_xflip , inputnetworkcvargroup ) ;
2021-05-09 13:02:49 +00:00
Cvar_Register ( & in_vraim , inputnetworkcvargroup ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_nodelta , inputnetworkcvargroup ) ;
2007-01-06 09:37:33 +00:00
Cvar_Register ( & prox_inmenu , inputnetworkcvargroup ) ;
2015-10-11 11:34:58 +00:00
Cvar_Register ( & cl_c2sdupe , inputnetworkcvargroup ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_c2sImpulseBackup , inputnetworkcvargroup ) ;
2021-07-17 15:10:01 +00:00
Cvar_Register ( & cl_c2sMaxRedundancy , inputnetworkcvargroup ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_c2spps , inputnetworkcvargroup ) ;
2008-01-22 17:00:05 +00:00
Cvar_Register ( & cl_queueimpulses , inputnetworkcvargroup ) ;
2004-08-23 00:15:46 +00:00
Cvar_Register ( & cl_netfps , inputnetworkcvargroup ) ;
2014-02-11 17:51:29 +00:00
Cvar_Register ( & cl_run , inputnetworkcvargroup ) ;
2017-12-09 21:22:46 +00:00
Cvar_Register ( & cl_iDrive , inputnetworkcvargroup ) ;
2005-04-16 16:21:27 +00:00
2017-08-29 02:29:06 +00:00
# ifdef NQPROT
Cvar_Register ( & cl_movement , inputnetworkcvargroup ) ;
# endif
2019-01-13 16:51:50 +00:00
Cvar_Register ( & cl_sendchatstate , inputnetworkcvargroup ) ;
2005-04-16 16:21:27 +00:00
Cvar_Register ( & cl_smartjump , inputnetworkcvargroup ) ;
2005-08-03 23:14:59 +00:00
Cvar_Register ( & cl_prydoncursor , inputnetworkcvargroup ) ;
2005-08-11 04:14:33 +00:00
Cvar_Register ( & cl_instantrotate , inputnetworkcvargroup ) ;
2015-03-03 00:14:43 +00:00
Cvar_Register ( & cl_forceseat , inputnetworkcvargroup ) ;
2010-08-14 00:15:07 +00:00
for ( sp = 0 ; sp < MAX_SPLITS ; sp + + )
{
2013-07-14 12:22:51 +00:00
Q_snprintfz ( pcmd [ sp ] [ 0 ] , sizeof ( pcmd [ sp ] [ 0 ] ) , " p%i " , sp + 1 ) ;
Q_snprintfz ( pcmd [ sp ] [ 1 ] , sizeof ( pcmd [ sp ] [ 1 ] ) , " +p%i " , sp + 1 ) ;
Q_snprintfz ( pcmd [ sp ] [ 2 ] , sizeof ( pcmd [ sp ] [ 2 ] ) , " -p%i " , sp + 1 ) ;
Cmd_AddCommand ( pcmd [ sp ] [ 0 ] , CL_Split_f ) ;
Cmd_AddCommand ( pcmd [ sp ] [ 1 ] , CL_Split_f ) ;
Cmd_AddCommand ( pcmd [ sp ] [ 2 ] , CL_Split_f ) ;
2011-09-22 15:57:16 +00:00
2012-02-27 12:23:15 +00:00
/*default mlook to pressed, (on android we split the two sides of the screen)*/
2010-08-14 00:15:07 +00:00
in_mlook . state [ sp ] = 1 ;
}
2012-02-12 05:18:31 +00:00
/*then alternative arged ones*/
Cmd_AddCommand ( " p " , CL_SplitA_f ) ;
Cmd_AddCommand ( " +p " , CL_SplitA_f ) ;
Cmd_AddCommand ( " -p " , CL_SplitA_f ) ;
2010-08-14 00:15:07 +00:00
Cmd_AddCommand ( " +moveup " , IN_UpDown ) ;
Cmd_AddCommand ( " -moveup " , IN_UpUp ) ;
Cmd_AddCommand ( " +movedown " , IN_DownDown ) ;
Cmd_AddCommand ( " -movedown " , IN_DownUp ) ;
Cmd_AddCommand ( " +left " , IN_LeftDown ) ;
Cmd_AddCommand ( " -left " , IN_LeftUp ) ;
Cmd_AddCommand ( " +right " , IN_RightDown ) ;
Cmd_AddCommand ( " -right " , IN_RightUp ) ;
Cmd_AddCommand ( " +forward " , IN_ForwardDown ) ;
Cmd_AddCommand ( " -forward " , IN_ForwardUp ) ;
Cmd_AddCommand ( " +back " , IN_BackDown ) ;
Cmd_AddCommand ( " -back " , IN_BackUp ) ;
Cmd_AddCommand ( " +lookup " , IN_LookupDown ) ;
Cmd_AddCommand ( " -lookup " , IN_LookupUp ) ;
Cmd_AddCommand ( " +lookdown " , IN_LookdownDown ) ;
Cmd_AddCommand ( " -lookdown " , IN_LookdownUp ) ;
Cmd_AddCommand ( " +strafe " , IN_StrafeDown ) ;
Cmd_AddCommand ( " -strafe " , IN_StrafeUp ) ;
Cmd_AddCommand ( " +moveleft " , IN_MoveleftDown ) ;
Cmd_AddCommand ( " -moveleft " , IN_MoveleftUp ) ;
Cmd_AddCommand ( " +moveright " , IN_MoverightDown ) ;
Cmd_AddCommand ( " -moveright " , IN_MoverightUp ) ;
2014-06-21 17:58:17 +00:00
Cmd_AddCommand ( " +rollleft " , IN_RollLeftDown ) ;
Cmd_AddCommand ( " -rollleft " , IN_RollLeftUp ) ;
Cmd_AddCommand ( " +rollright " , IN_RollRightDown ) ;
Cmd_AddCommand ( " -rollright " , IN_RollRightUp ) ;
2010-08-14 00:15:07 +00:00
Cmd_AddCommand ( " +speed " , IN_SpeedDown ) ;
Cmd_AddCommand ( " -speed " , IN_SpeedUp ) ;
Cmd_AddCommand ( " +attack " , IN_AttackDown ) ;
Cmd_AddCommand ( " -attack " , IN_AttackUp ) ;
Cmd_AddCommand ( " +use " , IN_UseDown ) ;
Cmd_AddCommand ( " -use " , IN_UseUp ) ;
Cmd_AddCommand ( " +jump " , IN_JumpDown ) ;
Cmd_AddCommand ( " -jump " , IN_JumpUp ) ;
2018-12-06 04:55:35 +00:00
Cmd_AddCommandD ( " impulse " , IN_Impulse , " Sends an impulse number to the server (read: weapon change). " ) ;
2010-08-14 00:15:07 +00:00
Cmd_AddCommand ( " +klook " , IN_KLookDown ) ;
Cmd_AddCommand ( " -klook " , IN_KLookUp ) ;
Cmd_AddCommand ( " +mlook " , IN_MLookDown ) ;
2011-09-22 15:57:16 +00:00
Cmd_AddCommand ( " -mlook " , IN_MLookUp ) ;
2010-08-14 00:15:07 +00:00
2018-12-06 04:55:35 +00:00
# ifdef QUAKESTATS
2022-06-19 15:18:08 +00:00
Cmd_AddCommand ( " +weaponwheel " , IN_WWheelDown ) ;
Cmd_AddCommand ( " -weaponwheel " , IN_WWheelUp ) ;
Cmd_AddCommandD ( " register_bestweapon " , IN_RegisterWeapon_f , " Normally set via a mod's default.cfg file " ) ;
Cmd_AddCommandD ( " bestweapon " , IN_Impulse , " Works like 'impulse', for compat with other engines. " ) ;
2018-12-06 04:55:35 +00:00
Cvar_Register ( & cl_weaponhide , inputnetworkcvargroup ) ;
Cvar_Register ( & cl_weaponhide_preference , inputnetworkcvargroup ) ;
Cvar_Register ( & cl_weaponpreselect , inputnetworkcvargroup ) ;
Cvar_Register ( & cl_weaponforgetorder , inputnetworkcvargroup ) ;
Cvar_Register ( & r_viewpreselgun , inputnetworkcvargroup ) ;
# endif
2018-10-11 10:31:23 +00:00
for ( i = 0 ; i < countof ( in_button ) ; i + + )
{
static char bcmd [ countof ( in_button ) ] [ 2 ] [ 10 ] ;
2019-10-19 22:02:12 +00:00
Q_snprintfz ( bcmd [ i ] [ 0 ] , sizeof ( bcmd [ sp ] [ 0 ] ) , " +button%i " , i ) ;
Q_snprintfz ( bcmd [ i ] [ 1 ] , sizeof ( bcmd [ sp ] [ 1 ] ) , " -button%i " , i ) ;
2018-12-06 04:55:35 +00:00
Cmd_AddCommandD ( bcmd [ i ] [ 0 ] , IN_ButtonNDown , " This auxilliary command has mod-specific behaviour (often none). " ) ;
2018-10-11 10:31:23 +00:00
Cmd_AddCommand ( bcmd [ i ] [ 1 ] , IN_ButtonNUp ) ;
}
2004-08-23 00:15:46 +00:00
}