From ac6605e0d7ead9dd6772315a67be2c1930866747 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 19 Aug 2021 06:02:03 +0000 Subject: [PATCH] Tweak inputs some more. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6023 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/pr_csqc.c | 9 +++++++ engine/common/common.c | 51 ++++++++++++++++++++++++++------------- engine/common/pr_common.h | 3 +++ engine/common/protocol.h | 1 + engine/server/pr_cmds.c | 43 ++++++++++++++++++--------------- engine/server/progdefs.h | 3 +++ engine/server/sv_user.c | 8 +++--- 7 files changed, 78 insertions(+), 40 deletions(-) diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 14bd0e9f4..e7d973f1b 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -248,6 +248,7 @@ static void CSQC_FindGlobals(qboolean nofuncs) csqcg.input_head_status = csqcg.input_left_status = csqcg.input_right_status = NULL; csqcg.input_head_angles = csqcg.input_left_angles = csqcg.input_right_angles = NULL; csqcg.input_head_origin = csqcg.input_left_origin = csqcg.input_right_origin = NULL; + csqcg.input_head_weapon = csqcg.input_left_weapon = csqcg.input_right_weapon = NULL; } else if (csqcg.CSQC_UpdateView || csqcg.CSQC_UpdateViewLoading) { //full csqc AND simplecsqc's entry points at the same time are a bad idea that just result in confusion. @@ -3871,6 +3872,8 @@ static void cs_set_input_state (usercmd_t *cmd) csqcg.input_head_avelocity[1] = SHORT2ANGLE(cmd->vr[VRDEV_HEAD].avelocity[1]); csqcg.input_head_avelocity[2] = SHORT2ANGLE(cmd->vr[VRDEV_HEAD].avelocity[2]); } + if (csqcg.input_head_weapon) + *csqcg.input_head_weapon = cmd->vr[VRDEV_HEAD].weapon; if (csqcg.input_left_status) *csqcg.input_left_status = cmd->vr[VRDEV_LEFT].status; @@ -3971,6 +3974,8 @@ static void cs_get_input_state (usercmd_t *cmd) cmd->vr[VRDEV_HEAD].avelocity[1] = ANGLE2SHORT(csqcg.input_head_avelocity[1]); cmd->vr[VRDEV_HEAD].avelocity[2] = ANGLE2SHORT(csqcg.input_head_avelocity[2]); } + if (csqcg.input_head_weapon) + cmd->vr[VRDEV_HEAD].weapon = *csqcg.input_head_weapon; if (csqcg.input_left_status) cmd->vr[VRDEV_LEFT].status = *csqcg.input_left_status; @@ -3990,6 +3995,8 @@ static void cs_get_input_state (usercmd_t *cmd) cmd->vr[VRDEV_LEFT].avelocity[1] = ANGLE2SHORT(csqcg.input_left_avelocity[1]); cmd->vr[VRDEV_LEFT].avelocity[2] = ANGLE2SHORT(csqcg.input_left_avelocity[2]); } + if (csqcg.input_left_weapon) + cmd->vr[VRDEV_LEFT].weapon = *csqcg.input_left_weapon; if (csqcg.input_right_status) cmd->vr[VRDEV_RIGHT].status = *csqcg.input_right_status; @@ -4009,6 +4016,8 @@ static void cs_get_input_state (usercmd_t *cmd) cmd->vr[VRDEV_RIGHT].avelocity[1] = ANGLE2SHORT(csqcg.input_right_avelocity[1]); cmd->vr[VRDEV_RIGHT].avelocity[2] = ANGLE2SHORT(csqcg.input_right_avelocity[2]); } + if (csqcg.input_right_weapon) + cmd->vr[VRDEV_RIGHT].weapon = *csqcg.input_right_weapon; } //sets implicit pause (only works when singleplayer) diff --git a/engine/common/common.c b/engine/common/common.c index 9db00eb13..3f80507a1 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -1353,6 +1353,13 @@ void MSGQ2_WriteDeltaUsercmd (sizebuf_t *buf, const usercmd_t *from, const userc //#define UC_UNUSED (1<<31) #define UC_UNSUPPORTED (~(UC_ANGLE1 | UC_ANGLE2 | UC_ANGLE3 | UC_FORWARD | UC_RIGHT | UC_BUTTONS | UC_IMPULSE | UC_UP | UC_ABSANG | UC_BIGMOVES | UC_WEAPON | UC_CURSORFLDS | UC_LIGHTLEV | UC_VR_HEAD | UC_VR_RIGHT | UC_VR_LEFT)) +#define UC_VR_STATUS (1<<0) +#define UC_VR_ANG (1<<1) +#define UC_VR_AVEL (1<<2) +#define UC_VR_ORG (1<<3) +#define UC_VR_VEL (1<<4) +#define UC_VR_WEAPON (1<<5) + #ifdef HAVE_CLIENT fte_inlinestatic qboolean MSG_CompareVR(int i, const usercmd_t *from, const usercmd_t *cmd) { @@ -1366,42 +1373,49 @@ fte_inlinestatic qboolean MSG_CompareVR(int i, const usercmd_t *from, const user } static void MSG_WriteVR(int i, sizebuf_t *buf, const usercmd_t *from, const usercmd_t *cmd) { - quint64_t status = cmd->vr[i].status; - status <<= 4; + unsigned int bits = 0; + if (cmd->vr[i].status != from->vr[i].status) + bits |= UC_VR_STATUS; if (cmd->vr[i].angles[0] != from->vr[i].angles[0] || cmd->vr[i].angles[1] != from->vr[i].angles[1] || cmd->vr[i].angles[2] != from->vr[i].angles[2]) - status |= VRSTATUS_ANG; + bits |= UC_VR_ANG; if (cmd->vr[i].avelocity[0] != from->vr[i].avelocity[0] || cmd->vr[i].avelocity[1] != from->vr[i].avelocity[1] || cmd->vr[i].avelocity[2] != from->vr[i].avelocity[2]) - status |= VRSTATUS_AVEL; + bits |= UC_VR_AVEL; if (cmd->vr[i].origin[0] != from->vr[i].origin[0] || cmd->vr[i].origin[1] != from->vr[i].origin[1] || cmd->vr[i].origin[2] != from->vr[i].origin[2]) - status |= VRSTATUS_ORG; + bits |= UC_VR_ORG; if (cmd->vr[i].velocity[0] != from->vr[i].velocity[0] || cmd->vr[i].velocity[1] != from->vr[i].velocity[1] || cmd->vr[i].velocity[2] != from->vr[i].velocity[2]) - status |= VRSTATUS_VEL; + bits |= UC_VR_VEL; + if (cmd->vr[i].weapon != from->vr[i].weapon) + bits |= UC_VR_WEAPON; - MSG_WriteUInt64(buf,status); - if (status & VRSTATUS_ANG) + MSG_WriteUInt64(buf, bits); + if (bits & UC_VR_STATUS) + MSG_WriteUInt64(buf, cmd->vr[i].status); + if (bits & UC_VR_ANG) { MSG_WriteShort(buf, cmd->vr[i].angles[0]); MSG_WriteShort(buf, cmd->vr[i].angles[1]); MSG_WriteShort(buf, cmd->vr[i].angles[2]); } - if (status & VRSTATUS_AVEL) + if (bits & UC_VR_AVEL) { MSG_WriteShort(buf, cmd->vr[i].avelocity[0]); MSG_WriteShort(buf, cmd->vr[i].avelocity[1]); MSG_WriteShort(buf, cmd->vr[i].avelocity[2]); } - if (status & VRSTATUS_ORG) + if (bits & UC_VR_ORG) { MSG_WriteFloat(buf, cmd->vr[i].origin[0]); MSG_WriteFloat(buf, cmd->vr[i].origin[1]); MSG_WriteFloat(buf, cmd->vr[i].origin[2]); } - if (status & VRSTATUS_VEL) + if (bits & UC_VR_VEL) { MSG_WriteFloat(buf, cmd->vr[i].velocity[0]); MSG_WriteFloat(buf, cmd->vr[i].velocity[1]); MSG_WriteFloat(buf, cmd->vr[i].velocity[2]); } + if (bits & UC_VR_WEAPON) + MSG_WriteUInt64(buf, cmd->vr[i].weapon); } void MSGFTE_WriteDeltaUsercmd (sizebuf_t *buf, const short baseangles[3], const usercmd_t *from, const usercmd_t *cmd) { @@ -1533,32 +1547,35 @@ void MSGFTE_WriteDeltaUsercmd (sizebuf_t *buf, const short baseangles[3], const #ifdef HAVE_SERVER static void MSG_ReadVR(int i, usercmd_t *cmd) { - quint64_t status = MSG_ReadUInt64(); - cmd->vr[i].status = status>>4; - if (status & VRSTATUS_ANG) + quint64_t bits = MSG_ReadUInt64(); + if (bits & UC_VR_STATUS) + cmd->vr[i].status = MSG_ReadUInt64(); + if (bits & UC_VR_ANG) { cmd->vr[i].angles[0] = MSG_ReadShort(); cmd->vr[i].angles[1] = MSG_ReadShort(); cmd->vr[i].angles[2] = MSG_ReadShort(); } - if (status & VRSTATUS_AVEL) + if (bits & UC_VR_AVEL) { cmd->vr[i].avelocity[0] = MSG_ReadShort(); cmd->vr[i].avelocity[1] = MSG_ReadShort(); cmd->vr[i].avelocity[2] = MSG_ReadShort(); } - if (status & VRSTATUS_ORG) + if (bits & UC_VR_ORG) { cmd->vr[i].origin[0] = MSG_ReadFloat(); cmd->vr[i].origin[1] = MSG_ReadFloat(); cmd->vr[i].origin[2] = MSG_ReadFloat(); } - if (status & VRSTATUS_VEL) + if (bits & UC_VR_VEL) { cmd->vr[i].velocity[0] = MSG_ReadFloat(); cmd->vr[i].velocity[1] = MSG_ReadFloat(); cmd->vr[i].velocity[2] = MSG_ReadFloat(); } + if (bits & UC_VR_WEAPON) + cmd->vr[i].weapon = MSG_ReadUInt64(); } void MSGFTE_ReadDeltaUsercmd (const usercmd_t *from, usercmd_t *cmd) { diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index 2a19941fb..0dc9022c9 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -1133,16 +1133,19 @@ enum globalvector(input_head_angles) /*filled by getinputstate, for vr*/ \ globalvector(input_head_velocity) /*filled by getinputstate, for vr*/ \ globalvector(input_head_avelocity) /*filled by getinputstate, for vr*/ \ + globaluint (input_head_weapon) /*filled by getinputstate, for vr*/ \ globaluint (input_left_status) /*filled by getinputstate, for vr*/ \ globalvector(input_left_origin) /*filled by getinputstate, for vr*/ \ globalvector(input_left_angles) /*filled by getinputstate, for vr*/ \ globalvector(input_left_velocity) /*filled by getinputstate, for vr*/ \ globalvector(input_left_avelocity) /*filled by getinputstate, for vr*/ \ + globaluint (input_left_weapon) /*filled by getinputstate, for vr*/ \ globaluint (input_right_status) /*filled by getinputstate, for vr*/ \ globalvector(input_right_origin) /*filled by getinputstate, for vr*/ \ globalvector(input_right_angles) /*filled by getinputstate, for vr*/ \ globalvector(input_right_velocity) /*filled by getinputstate, for vr*/ \ globalvector(input_right_avelocity) /*filled by getinputstate, for vr*/ \ + globaluint (input_right_weapon) /*filled by getinputstate, for vr*/ \ \ globalvector(global_gravitydir) /*vector used when .gravitydir is 0 0 0 */ \ globalfloat (dimension_default) /*float default value for dimension_hit+dimension_solid*/ \ diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 0c38c76d4..227f25aaa 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -1210,6 +1210,7 @@ struct vrdevinfo_s short avelocity[3]; vec3_t origin; vec3_t velocity; + unsigned int weapon; #define VRDEV_LEFT 0 #define VRDEV_RIGHT 1 #define VRDEV_HEAD 2 diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 9efadc5fa..557916f34 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -957,16 +957,19 @@ void PR_LoadGlabalStruct(qboolean muted) globalvec (false, input_head_angles) \ globalvec (false, input_head_velocity) \ globalvec (false, input_head_avelocity) \ + globaluint (false, input_head_weapon) \ globaluint (false, input_left_status) \ globalvec (false, input_left_origin) \ globalvec (false, input_left_angles) \ globalvec (false, input_left_velocity) \ globalvec (false, input_left_avelocity) \ + globaluint (false, input_left_weapon) \ globaluint (false, input_right_status) \ globalvec (false, input_right_origin) \ globalvec (false, input_right_angles) \ globalvec (false, input_right_velocity) \ globalvec (false, input_right_avelocity) \ + globaluint (false, input_right_weapon) \ globalfloat (false, input_servertime) \ \ globalint (false, serverid) \ @@ -10323,18 +10326,9 @@ void SV_SetSSQCInputs(usercmd_t *ucmd) #define ANGLE2SHORT(x) (x) * (65536/360.0) if (pr_global_ptrs->input_angles) { - if (sv_player->v->fixangle) - { //hate this, but somehow still pending - (pr_global_struct->input_angles)[0] = sv_player->v->angles[0]; - (pr_global_struct->input_angles)[1] = sv_player->v->angles[1]; - (pr_global_struct->input_angles)[2] = sv_player->v->angles[2]; - } - else - { - (pr_global_struct->input_angles)[0] = SHORT2ANGLE(ucmd->angles[0]); - (pr_global_struct->input_angles)[1] = SHORT2ANGLE(ucmd->angles[1]); - (pr_global_struct->input_angles)[2] = SHORT2ANGLE(ucmd->angles[2]); - } + (pr_global_struct->input_angles)[0] = SHORT2ANGLE(ucmd->angles[0]); + (pr_global_struct->input_angles)[1] = SHORT2ANGLE(ucmd->angles[1]); + (pr_global_struct->input_angles)[2] = SHORT2ANGLE(ucmd->angles[2]); } if (pr_global_ptrs->input_movevalues) @@ -10381,6 +10375,8 @@ void SV_SetSSQCInputs(usercmd_t *ucmd) (pr_global_struct->input_head_avelocity)[1] = SHORT2ANGLE(ucmd->vr[VRDEV_HEAD].avelocity[1]); (pr_global_struct->input_head_avelocity)[2] = SHORT2ANGLE(ucmd->vr[VRDEV_HEAD].avelocity[2]); } + if (pr_global_ptrs->input_head_weapon) + pr_global_struct->input_head_weapon = ucmd->vr[VRDEV_HEAD].weapon; if (pr_global_ptrs->input_left_status) pr_global_struct->input_left_status = ucmd->vr[VRDEV_LEFT].status; @@ -10400,6 +10396,8 @@ void SV_SetSSQCInputs(usercmd_t *ucmd) (pr_global_struct->input_left_avelocity)[1] = SHORT2ANGLE(ucmd->vr[VRDEV_LEFT].avelocity[1]); (pr_global_struct->input_left_avelocity)[2] = SHORT2ANGLE(ucmd->vr[VRDEV_LEFT].avelocity[2]); } + if (pr_global_ptrs->input_left_weapon) + pr_global_struct->input_left_weapon = ucmd->vr[VRDEV_LEFT].weapon; if (pr_global_ptrs->input_right_status) pr_global_struct->input_right_status = ucmd->vr[VRDEV_RIGHT].status; @@ -10419,6 +10417,8 @@ void SV_SetSSQCInputs(usercmd_t *ucmd) (pr_global_struct->input_right_avelocity)[1] = SHORT2ANGLE(ucmd->vr[VRDEV_RIGHT].avelocity[1]); (pr_global_struct->input_right_avelocity)[2] = SHORT2ANGLE(ucmd->vr[VRDEV_RIGHT].avelocity[2]); } + if (pr_global_ptrs->input_right_weapon) + pr_global_struct->input_right_weapon = ucmd->vr[VRDEV_RIGHT].weapon; } //EXT_CSQC_1 (called when a movement command is received. runs full acceleration + movement) @@ -10441,6 +10441,18 @@ qboolean SV_RunFullQCMovement(client_t *client, usercmd_t *ucmd) } #endif + if (host_client->state && host_client->protocol != SCP_BAD) + { + if (!sv_player->v->fixangle) + { + sv_player->v->v_angle[0] = SHORT2ANGLE(ucmd->angles[0]); + sv_player->v->v_angle[1] = SHORT2ANGLE(ucmd->angles[1]); + sv_player->v->v_angle[2] = SHORT2ANGLE(ucmd->angles[2]); + } + sv_player->xv->movement[0] = ucmd->forwardmove; + sv_player->xv->movement[1] = ucmd->sidemove; + sv_player->xv->movement[2] = ucmd->upmove; + } VectorCopy(sv_player->v->v_angle, startangle); #ifdef HEXEN2 @@ -10458,13 +10470,6 @@ qboolean SV_RunFullQCMovement(client_t *client, usercmd_t *ucmd) sv_player->v->button0 = 0; } - if (host_client->state && host_client->protocol != SCP_BAD) - { - sv_player->xv->movement[0] = ucmd->forwardmove; - sv_player->xv->movement[1] = ucmd->sidemove; - sv_player->xv->movement[2] = ucmd->upmove; - } - WPhys_CheckVelocity(&sv.world, (wedict_t*)sv_player); // diff --git a/engine/server/progdefs.h b/engine/server/progdefs.h index ccf38d232..3c01157fd 100644 --- a/engine/server/progdefs.h +++ b/engine/server/progdefs.h @@ -122,16 +122,19 @@ typedef struct nqglobalvars_s pvec3_t *input_head_angles; pvec3_t *input_head_velocity; pvec3_t *input_head_avelocity; + puint_t *input_head_weapon; puint_t *input_left_status; pvec3_t *input_left_origin; pvec3_t *input_left_angles; pvec3_t *input_left_velocity; pvec3_t *input_left_avelocity; + puint_t *input_left_weapon; puint_t *input_right_status; pvec3_t *input_right_origin; pvec3_t *input_right_angles; pvec3_t *input_right_velocity; pvec3_t *input_right_avelocity; + puint_t *input_right_weapon; pvec3_t *global_gravitydir; pvec_t *spawnparamglobals[NUM_SPAWN_PARMS]; diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 144941e9e..ca17ceb87 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -8253,12 +8253,12 @@ void SV_ExecuteClientMessage (client_t *cl) //store the info for the physics code to pick up the next time it ticks. //yeah, nq sucks. split->isindependant = false; - if (!split->edict->v->fixangle) + /*if (!split->edict->v->fixangle) { split->edict->v->v_angle[0] = newcmd.angles[0]* (360.0/65536); split->edict->v->v_angle[1] = newcmd.angles[1]* (360.0/65536); split->edict->v->v_angle[2] = newcmd.angles[2]* (360.0/65536); - } + }*/ if (newcmd.impulse)// && SV_FilterImpulse(newcmd.impulse, host_client->trustlevel)) split->edict->v->impulse = newcmd.impulse; @@ -8750,9 +8750,9 @@ void SVNQ_ReadClientMove (qboolean forceangle16) } } - host_client->edict->v->v_angle[0] = SHORT2ANGLE(cmd.angles[0]); + /*host_client->edict->v->v_angle[0] = SHORT2ANGLE(cmd.angles[0]); host_client->edict->v->v_angle[1] = SHORT2ANGLE(cmd.angles[1]); - host_client->edict->v->v_angle[2] = SHORT2ANGLE(cmd.angles[2]); + host_client->edict->v->v_angle[2] = SHORT2ANGLE(cmd.angles[2]);*/ if (SV_RunFullQCMovement(host_client, &cmd)) { //mod provides its own movement logic. this forces independance.