2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_input.c
|
|
|
|
|
2001-07-15 00:03:11 +00:00
|
|
|
builds an intended movement command to send to the server
|
2001-02-19 21:15:25 +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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-04-11 07:57:08 +00:00
|
|
|
#include "QF/input.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/keys.h"
|
|
|
|
#include "QF/msg.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "nq/include/chase.h"
|
|
|
|
#include "nq/include/client.h"
|
|
|
|
#include "nq/include/host.h"
|
2001-04-15 21:11:41 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
2001-07-15 00:03:11 +00:00
|
|
|
KEY BUTTONS
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-15 00:03:11 +00:00
|
|
|
Continuous button event tracking is complicated by the fact that two
|
|
|
|
different input sources (say, mouse button 1 and the control key) can
|
2010-01-13 06:42:26 +00:00
|
|
|
both press the same button, but the button should be released only when
|
2001-07-15 00:03:11 +00:00
|
|
|
both of the pressing key have been released.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-15 00:03:11 +00:00
|
|
|
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.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-15 00:03:11 +00:00
|
|
|
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
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
kbutton_t in_left, in_right, in_forward, in_back;
|
|
|
|
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
2001-10-23 16:55:23 +00:00
|
|
|
kbutton_t in_use, in_jump, in_attack;
|
2001-02-26 06:48:02 +00:00
|
|
|
kbutton_t in_up, in_down;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int in_impulse;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-08-24 00:53:54 +00:00
|
|
|
void (*write_angles) (sizebuf_t *sb, const vec3_t angles);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-19 18:56:16 +00:00
|
|
|
KeyPress (void *_b)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-19 18:56:16 +00:00
|
|
|
kbutton_t *b = _b;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *c;
|
2001-08-29 02:12:57 +00:00
|
|
|
int k;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
c = Cmd_Argv (1);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (c[0])
|
2001-02-26 06:48:02 +00:00
|
|
|
k = atoi (c);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
k = -1; // typed manually at the console for
|
2001-07-15 00:03:11 +00:00
|
|
|
// continuous down
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (k == b->down[0] || k == b->down[1])
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // repeating key
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!b->down[0])
|
|
|
|
b->down[0] = k;
|
|
|
|
else if (!b->down[1])
|
|
|
|
b->down[1] = k;
|
2001-02-26 06:48:02 +00:00
|
|
|
else {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Three keys down for a button!\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (b->state & 1)
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // still down
|
|
|
|
b->state |= 1 + 2; // down + impulse down
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-19 18:56:16 +00:00
|
|
|
KeyRelease (void *_b)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-19 18:56:16 +00:00
|
|
|
kbutton_t *b = _b;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *c;
|
2001-08-29 02:12:57 +00:00
|
|
|
int k;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
c = Cmd_Argv (1);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (c[0])
|
2001-02-26 06:48:02 +00:00
|
|
|
k = atoi (c);
|
|
|
|
else { // typed manually at the console,
|
2001-07-15 00:03:11 +00:00
|
|
|
// assume for unsticking, so clear
|
|
|
|
// all
|
2001-02-19 21:15:25 +00:00
|
|
|
b->down[0] = b->down[1] = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
b->state = 4; // impulse up
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (b->down[0] == k)
|
|
|
|
b->down[0] = 0;
|
|
|
|
else if (b->down[1] == k)
|
|
|
|
b->down[1] = 0;
|
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // key up without coresponding down
|
2001-07-15 00:03:11 +00:00
|
|
|
// (menu pass through)
|
2001-02-19 21:15:25 +00:00
|
|
|
if (b->down[0] || b->down[1])
|
2012-05-21 23:23:22 +00:00
|
|
|
return; // some other key is still holding it
|
2001-07-15 00:03:11 +00:00
|
|
|
// down
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!(b->state & 1))
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // still up (this should not happen)
|
|
|
|
b->state &= ~1; // now up
|
|
|
|
b->state |= 4; // impulse up
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-19 18:56:16 +00:00
|
|
|
IN_MLookRelease (void *data)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2004-02-03 05:16:22 +00:00
|
|
|
KeyRelease (&in_mlook);
|
2011-06-19 00:49:39 +00:00
|
|
|
if (!freelook && lookspring->int_val)
|
2001-02-26 06:48:02 +00:00
|
|
|
V_StartPitchDrift ();
|
|
|
|
}
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-19 18:56:16 +00:00
|
|
|
IN_Impulse (void *data)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
|
|
|
in_impulse = atoi (Cmd_Argv (1));
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-05-14 03:08:24 +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
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
float
|
|
|
|
CL_KeyState (kbutton_t *key)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float val;
|
|
|
|
qboolean impulsedown, impulseup, down;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
impulsedown = key->state & 2;
|
|
|
|
impulseup = key->state & 4;
|
|
|
|
down = key->state & 1;
|
|
|
|
val = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (impulsedown && !impulseup) {
|
|
|
|
if (down)
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0.5; // pressed and held this frame
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0; // I_Error ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
if (impulseup && !impulsedown) {
|
|
|
|
if (down)
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0; // I_Error ();
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0; // released this frame
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
if (!impulsedown && !impulseup) {
|
|
|
|
if (down)
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 1.0; // held the entire frame
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0; // up the entire frame
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
if (impulsedown && impulseup) {
|
|
|
|
if (down)
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0.75; // released and re-pressed this frame
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-02-26 06:48:02 +00:00
|
|
|
val = 0.25; // pressed and released this frame
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
key->state &= 1; // clear impulses
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_anglespeedkey;
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_backspeed;
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_forwardspeed;
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_movespeedkey;
|
|
|
|
cvar_t *cl_pitchspeed;
|
2001-05-14 03:08:24 +00:00
|
|
|
cvar_t *cl_sidespeed;
|
|
|
|
cvar_t *cl_upspeed;
|
|
|
|
cvar_t *cl_yawspeed;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
/*
|
2001-05-14 03:08:24 +00:00
|
|
|
CL_AdjustAngles
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
Moves the local angle positions
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_AdjustAngles (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-06-19 00:49:39 +00:00
|
|
|
float down, up;
|
|
|
|
float pitchspeed, yawspeed;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2011-06-19 00:49:39 +00:00
|
|
|
pitchspeed = cl_pitchspeed->value;
|
|
|
|
yawspeed = cl_yawspeed->value;
|
|
|
|
|
|
|
|
if (in_speed.state & 1) {
|
|
|
|
pitchspeed *= cl_anglespeedkey->value;
|
|
|
|
yawspeed *= cl_anglespeedkey->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cl.fpd & FPD_LIMIT_PITCH) && pitchspeed > FPD_MAXPITCH)
|
|
|
|
pitchspeed = FPD_MAXPITCH;
|
|
|
|
if ((cl.fpd & FPD_LIMIT_YAW) && yawspeed > FPD_MAXYAW)
|
|
|
|
yawspeed = FPD_MAXYAW;
|
|
|
|
|
|
|
|
pitchspeed *= host_frametime;
|
|
|
|
yawspeed *= host_frametime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(in_strafe.state & 1)) {
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[YAW] -= yawspeed * CL_KeyState (&in_right);
|
|
|
|
cl.viewstate.angles[YAW] += yawspeed * CL_KeyState (&in_left);
|
|
|
|
cl.viewstate.angles[YAW] = anglemod (cl.viewstate.angles[YAW]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (in_klook.state & 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
V_StopPitchDrift ();
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH] -= pitchspeed * CL_KeyState (&in_forward);
|
|
|
|
cl.viewstate.angles[PITCH] += pitchspeed * CL_KeyState (&in_back);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
up = CL_KeyState (&in_lookup);
|
2001-02-26 06:48:02 +00:00
|
|
|
down = CL_KeyState (&in_lookdown);
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH] -= pitchspeed * up;
|
|
|
|
cl.viewstate.angles[PITCH] += pitchspeed * down;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (up || down)
|
|
|
|
V_StopPitchDrift ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2011-06-19 00:49:39 +00:00
|
|
|
// FIXME: Need to clean up view angle limits
|
2021-03-19 11:18:45 +00:00
|
|
|
if (cl.viewstate.angles[PITCH] > 80)
|
|
|
|
cl.viewstate.angles[PITCH] = 80;
|
|
|
|
if (cl.viewstate.angles[PITCH] < -70)
|
|
|
|
cl.viewstate.angles[PITCH] = -70;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
if (cl.viewstate.angles[ROLL] > 50)
|
|
|
|
cl.viewstate.angles[ROLL] = 50;
|
|
|
|
if (cl.viewstate.angles[ROLL] < -50)
|
|
|
|
cl.viewstate.angles[ROLL] = -50;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 03:08:24 +00:00
|
|
|
CL_BaseMove
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 03:08:24 +00:00
|
|
|
Send the intended movement message to the server
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_BaseMove (usercmd_t *cmd)
|
|
|
|
{
|
2021-03-19 16:48:26 +00:00
|
|
|
if (cls.state != ca_active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2021-03-19 16:48:26 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_AdjustAngles ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
memset (cmd, 0, sizeof (*cmd));
|
|
|
|
|
|
|
|
if (in_strafe.state & 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right);
|
|
|
|
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright);
|
|
|
|
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft);
|
|
|
|
|
|
|
|
cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up);
|
|
|
|
cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!(in_klook.state & 1)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward);
|
|
|
|
cmd->forwardmove -= cl_backspeed->value * CL_KeyState (&in_back);
|
2001-02-26 06:48:02 +00:00
|
|
|
}
|
2001-05-14 03:08:24 +00:00
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// adjust for speed key
|
2001-02-26 06:48:02 +00:00
|
|
|
if (in_speed.state & 1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cmd->forwardmove *= cl_movespeedkey->value;
|
|
|
|
cmd->sidemove *= cl_movespeedkey->value;
|
|
|
|
cmd->upmove *= cl_movespeedkey->value;
|
|
|
|
}
|
2001-04-11 07:57:08 +00:00
|
|
|
|
|
|
|
if (freelook)
|
|
|
|
V_StopPitchDrift ();
|
|
|
|
|
|
|
|
viewdelta.angles[0] = viewdelta.angles[1] = viewdelta.angles[2] = 0;
|
|
|
|
viewdelta.position[0] = viewdelta.position[1] = viewdelta.position[2] = 0;
|
|
|
|
|
|
|
|
IN_Move ();
|
|
|
|
|
2001-09-28 07:51:15 +00:00
|
|
|
// adjust for chase camera angles
|
2021-03-19 11:18:45 +00:00
|
|
|
/*FIXME:chase figure out just what this does and get it working
|
2011-06-19 00:49:39 +00:00
|
|
|
if (cl.chase
|
|
|
|
&& (chase_active->int_val == 2 || chase_active->int_val == 3)) {
|
|
|
|
vec3_t forward, right, up, f, r;
|
|
|
|
vec3_t dir = {0, 0, 0};
|
2004-02-03 05:16:22 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
dir[1] = r_data->refdef->viewangles[1] - cl.viewstate.angles[1];
|
2001-09-28 07:51:15 +00:00
|
|
|
AngleVectors (dir, forward, right, up);
|
2001-12-11 20:49:10 +00:00
|
|
|
VectorScale (forward, cmd->forwardmove, f);
|
2004-02-03 05:16:22 +00:00
|
|
|
VectorScale (right, cmd->sidemove, r);
|
2001-12-11 20:49:10 +00:00
|
|
|
cmd->forwardmove = f[0] + r[0];
|
2004-02-03 05:16:22 +00:00
|
|
|
cmd->sidemove = f[1] + r[1];
|
2001-12-11 20:49:10 +00:00
|
|
|
VectorScale (forward, viewdelta.position[2], f);
|
2004-02-03 05:16:22 +00:00
|
|
|
VectorScale (right, viewdelta.position[0], r);
|
|
|
|
viewdelta.position[2] = f[0] + r[0];
|
2001-12-11 20:49:10 +00:00
|
|
|
viewdelta.position[0] = (f[1] + r[1]) * -1;
|
2001-09-28 07:51:15 +00:00
|
|
|
}
|
2021-03-19 11:18:45 +00:00
|
|
|
*/
|
2001-09-28 07:51:15 +00:00
|
|
|
|
2001-04-11 07:57:08 +00:00
|
|
|
cmd->forwardmove += viewdelta.position[2] * m_forward->value;
|
|
|
|
cmd->sidemove += viewdelta.position[0] * m_side->value;
|
|
|
|
cmd->upmove += viewdelta.position[1];
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH] += viewdelta.angles[PITCH] * m_pitch->value;
|
|
|
|
cl.viewstate.angles[YAW] += viewdelta.angles[YAW] * m_yaw->value;
|
|
|
|
cl.viewstate.angles[ROLL] += viewdelta.angles[ROLL];
|
2001-04-11 07:57:08 +00:00
|
|
|
|
|
|
|
if (freelook && !(in_strafe.state & 1)) {
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH]
|
|
|
|
= bound (-70, cl.viewstate.angles[PITCH], 80);
|
2001-04-11 07:57:08 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_SendMove (usercmd_t *cmd)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
byte data[128];
|
2001-12-12 21:56:09 +00:00
|
|
|
int bits;
|
2001-08-29 02:12:57 +00:00
|
|
|
sizebuf_t buf;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
buf.maxsize = 128;
|
|
|
|
buf.cursize = 0;
|
|
|
|
buf.data = data;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.cmd = *cmd;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// send the movement message
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&buf, clc_move);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2004-02-03 05:16:22 +00:00
|
|
|
MSG_WriteFloat (&buf, cl.mtime[0]); // so server can get ping times
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
write_angles (&buf, cl.viewstate.angles);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
MSG_WriteShort (&buf, cmd->forwardmove);
|
|
|
|
MSG_WriteShort (&buf, cmd->sidemove);
|
|
|
|
MSG_WriteShort (&buf, cmd->upmove);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// send button bits
|
2001-02-19 21:15:25 +00:00
|
|
|
bits = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (in_attack.state & 3)
|
2001-02-19 21:15:25 +00:00
|
|
|
bits |= 1;
|
|
|
|
in_attack.state &= ~2;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (in_jump.state & 3)
|
|
|
|
bits |= 2;
|
|
|
|
in_jump.state &= ~2;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteByte (&buf, bits);
|
|
|
|
|
|
|
|
MSG_WriteByte (&buf, in_impulse);
|
2001-02-19 21:15:25 +00:00
|
|
|
in_impulse = 0;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// deliver the message
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.demoplayback)
|
|
|
|
return;
|
|
|
|
|
2001-08-29 02:12:57 +00:00
|
|
|
// always dump the first two message, because it may contain leftover
|
|
|
|
// inputs from the last level
|
2001-02-19 21:15:25 +00:00
|
|
|
if (++cl.movemessages <= 2)
|
|
|
|
return;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("CL_SendMove: lost server connection\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Disconnect ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2011-06-19 00:49:39 +00:00
|
|
|
CL_Input_Init (void)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2021-03-19 18:56:16 +00:00
|
|
|
Cmd_AddDataCommand ("+moveup", KeyPress, &in_up,
|
|
|
|
"When active the player is swimming up in a liquid");
|
|
|
|
Cmd_AddDataCommand ("-moveup", KeyRelease, &in_up,
|
|
|
|
"When active the player is not swimming up in a "
|
|
|
|
"liquid");
|
|
|
|
Cmd_AddDataCommand ("+movedown", KeyPress, &in_down,
|
|
|
|
"When active the player is swimming down in a liquid");
|
|
|
|
Cmd_AddDataCommand ("-movedown", KeyRelease, &in_down,
|
|
|
|
"When active the player is not swimming down in a "
|
|
|
|
"liquid");
|
|
|
|
Cmd_AddDataCommand ("+left", KeyPress, &in_left,
|
|
|
|
"When active the player is turning left");
|
|
|
|
Cmd_AddDataCommand ("-left", KeyRelease, &in_left,
|
|
|
|
"When active the player is not turning left");
|
|
|
|
Cmd_AddDataCommand ("+right", KeyPress, &in_right,
|
|
|
|
"When active the player is turning right");
|
|
|
|
Cmd_AddDataCommand ("-right", KeyRelease, &in_right,
|
|
|
|
"When active the player is not turning right");
|
|
|
|
Cmd_AddDataCommand ("+forward", KeyPress, &in_forward,
|
|
|
|
"When active the player is moving forward");
|
|
|
|
Cmd_AddDataCommand ("-forward", KeyRelease, &in_forward,
|
|
|
|
"When active the player is not moving forward");
|
|
|
|
Cmd_AddDataCommand ("+back", KeyPress, &in_back,
|
|
|
|
"When active the player is moving backwards");
|
|
|
|
Cmd_AddDataCommand ("-back", KeyRelease, &in_back,
|
|
|
|
"When active the player is not moving backwards");
|
|
|
|
Cmd_AddDataCommand ("+lookup", KeyPress, &in_lookup,
|
|
|
|
"When active the player's view is looking up");
|
|
|
|
Cmd_AddDataCommand ("-lookup", KeyRelease, &in_lookup,
|
|
|
|
"When active the player's view is not looking up");
|
|
|
|
Cmd_AddDataCommand ("+lookdown", KeyPress, &in_lookdown,
|
|
|
|
"When active the player's view is looking down");
|
|
|
|
Cmd_AddDataCommand ("-lookdown", KeyRelease, &in_lookdown,
|
|
|
|
"When active the player's view is not looking up");
|
|
|
|
Cmd_AddDataCommand ("+strafe", KeyPress, &in_strafe,
|
|
|
|
"When active, +left and +right function like "
|
|
|
|
"+moveleft and +moveright");
|
|
|
|
Cmd_AddDataCommand ("-strafe", KeyRelease, &in_strafe,
|
|
|
|
"When active, +left and +right stop functioning like "
|
|
|
|
"+moveleft and +moveright");
|
|
|
|
Cmd_AddDataCommand ("+moveleft", KeyPress, &in_moveleft,
|
|
|
|
"When active the player is strafing left");
|
|
|
|
Cmd_AddDataCommand ("-moveleft", KeyRelease, &in_moveleft,
|
|
|
|
"When active the player is not strafing left");
|
|
|
|
Cmd_AddDataCommand ("+moveright", KeyPress, &in_moveright,
|
|
|
|
"When active the player is strafing right");
|
|
|
|
Cmd_AddDataCommand ("-moveright", KeyRelease, &in_moveright,
|
|
|
|
"When active the player is not strafing right");
|
|
|
|
Cmd_AddDataCommand ("+speed", KeyPress, &in_speed,
|
|
|
|
"When active the player is running");
|
|
|
|
Cmd_AddDataCommand ("-speed", KeyRelease, &in_speed,
|
|
|
|
"When active the player is not running");
|
|
|
|
Cmd_AddDataCommand ("+attack", KeyPress, &in_attack,
|
|
|
|
"When active player is firing/using current weapon");
|
|
|
|
Cmd_AddDataCommand ("-attack", KeyRelease, &in_attack,
|
|
|
|
"When active player is not firing/using current "
|
|
|
|
"weapon");
|
|
|
|
Cmd_AddDataCommand ("+use", KeyPress, &in_use,
|
|
|
|
"Non-functional. Left over command for opening doors "
|
|
|
|
"and triggering switches");
|
|
|
|
Cmd_AddDataCommand ("-use", KeyRelease, &in_use,
|
|
|
|
"Non-functional. Left over command for opening doors "
|
|
|
|
"and triggering switches");
|
|
|
|
Cmd_AddDataCommand ("+jump", KeyPress, &in_jump,
|
|
|
|
"When active the player is jumping");
|
|
|
|
Cmd_AddDataCommand ("-jump", KeyRelease, &in_jump,
|
|
|
|
"When active the player is not jumping");
|
|
|
|
Cmd_AddDataCommand ("impulse", IN_Impulse, 0,
|
|
|
|
"Call a game function or QuakeC function.");
|
|
|
|
Cmd_AddDataCommand ("+klook", KeyPress, &in_klook,
|
|
|
|
"When active, +forward and +back perform +lookup and "
|
|
|
|
"+lookdown");
|
|
|
|
Cmd_AddDataCommand ("-klook", KeyRelease, &in_klook,
|
|
|
|
"When active, +forward and +back don't perform "
|
|
|
|
"+lookup and +lookdown");
|
|
|
|
Cmd_AddDataCommand ("+mlook", KeyPress, &in_mlook,
|
|
|
|
"When active moving the mouse or joystick forwards "
|
|
|
|
"and backwards performs +lookup and "
|
|
|
|
"+lookdown");
|
|
|
|
Cmd_AddDataCommand ("-mlook", IN_MLookRelease, &in_mlook,
|
|
|
|
"When active moving the mouse or joystick forwards "
|
|
|
|
"and backwards doesn't perform +lookup and +lookdown");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|