mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +00:00
Add input_cursor_* fields to csqc and ssqc for use as custom csqc->ssqc data.
This commit is contained in:
parent
b186ba61cb
commit
c59f3e56f6
6 changed files with 107 additions and 30 deletions
|
@ -415,6 +415,7 @@ void CL_SendMove (const usercmd_t *cmd)
|
|||
if (cmd)
|
||||
{
|
||||
int dump = buf.cursize;
|
||||
unsigned int bits = cmd->buttons;
|
||||
|
||||
//
|
||||
// send the movement message
|
||||
|
@ -457,25 +458,38 @@ void CL_SendMove (const usercmd_t *cmd)
|
|||
MSG_WriteShort (&buf, cmd->sidemove);
|
||||
MSG_WriteShort (&buf, cmd->upmove);
|
||||
|
||||
|
||||
if (cl.protocol == PROTOCOL_VERSION_DP7)
|
||||
if (cl.protocol_pext2 & PEXT2_PRYDONCURSOR)
|
||||
{
|
||||
MSG_WriteLong (&buf, cmd->buttons);
|
||||
MSG_WriteByte (&buf, cmd->impulse);
|
||||
MSG_WriteShort(&buf, 32767);//cursor x
|
||||
MSG_WriteShort(&buf, 32767);//cursor y
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[0]); //start (view pos)
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[1]);
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[2]);
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[0]); //impact
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[1]);
|
||||
MSG_WriteFloat(&buf, r_refdef.vieworg[2]);
|
||||
MSG_WriteShort(&buf, 0); //entity
|
||||
if (cmd->weapon)
|
||||
bits |= (1u<<30);
|
||||
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);
|
||||
MSG_WriteLong (&buf, bits);
|
||||
}
|
||||
else if (cl.protocol == PROTOCOL_VERSION_DP7)
|
||||
{
|
||||
MSG_WriteLong (&buf, bits);
|
||||
bits |= (1u<<31);
|
||||
}
|
||||
else
|
||||
MSG_WriteByte (&buf, bits);
|
||||
MSG_WriteByte (&buf, cmd->impulse);
|
||||
if (bits & (1u<<30))
|
||||
MSG_WriteLong (&buf, cmd->weapon);
|
||||
if (bits & (1u<<31))
|
||||
{
|
||||
MSG_WriteByte (&buf, cmd->buttons);
|
||||
MSG_WriteByte (&buf, cmd->impulse);
|
||||
MSG_WriteShort(&buf, cmd->cursor_screen[0] * 32767);
|
||||
MSG_WriteShort(&buf, cmd->cursor_screen[1] * 32767);
|
||||
MSG_WriteFloat(&buf, cmd->cursor_start[0]); //start (view pos)
|
||||
MSG_WriteFloat(&buf, cmd->cursor_start[1]);
|
||||
MSG_WriteFloat(&buf, cmd->cursor_start[2]);
|
||||
MSG_WriteFloat(&buf, cmd->cursor_impact[0]); //impact
|
||||
MSG_WriteFloat(&buf, cmd->cursor_impact[1]);
|
||||
MSG_WriteFloat(&buf, cmd->cursor_impact[2]);
|
||||
MSG_WriteEntity(&buf, cmd->cursor_entitynumber, cl.protocol_pext2);
|
||||
}
|
||||
in_impulse = 0;
|
||||
|
||||
|
|
|
@ -1202,6 +1202,17 @@ void CL_CSQC_SetInputs(usercmd_t *cmd, qboolean set)
|
|||
*qcvm->extglobals.input_buttons = cmd->buttons;
|
||||
if (qcvm->extglobals.input_impulse)
|
||||
*qcvm->extglobals.input_impulse = cmd->impulse;
|
||||
|
||||
if (qcvm->extglobals.input_weapon)
|
||||
*qcvm->extglobals.input_weapon = cmd->weapon;
|
||||
if (qcvm->extglobals.input_cursor_screen)
|
||||
qcvm->extglobals.input_cursor_screen[0] = cmd->cursor_screen[0], qcvm->extglobals.input_cursor_screen[1] = cmd->cursor_screen[1];
|
||||
if (qcvm->extglobals.input_cursor_trace_start)
|
||||
VectorCopy(cmd->cursor_start, qcvm->extglobals.input_cursor_trace_start);
|
||||
if (qcvm->extglobals.input_cursor_trace_endpos)
|
||||
VectorCopy(cmd->cursor_impact, qcvm->extglobals.input_cursor_trace_endpos);
|
||||
if (qcvm->extglobals.input_cursor_entitynumber)
|
||||
*qcvm->extglobals.input_cursor_entitynumber = cmd->cursor_entitynumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1219,6 +1230,17 @@ void CL_CSQC_SetInputs(usercmd_t *cmd, qboolean set)
|
|||
cmd->buttons = *qcvm->extglobals.input_buttons;
|
||||
if (qcvm->extglobals.input_impulse)
|
||||
cmd->impulse = *qcvm->extglobals.input_impulse;
|
||||
|
||||
if (qcvm->extglobals.input_weapon)
|
||||
cmd->weapon = *qcvm->extglobals.input_weapon;
|
||||
if (qcvm->extglobals.input_cursor_screen)
|
||||
cmd->cursor_screen[0] = qcvm->extglobals.input_cursor_screen[0], cmd->cursor_screen[1] = qcvm->extglobals.input_cursor_screen[1];
|
||||
if (qcvm->extglobals.input_cursor_trace_start)
|
||||
VectorCopy(qcvm->extglobals.input_cursor_trace_start, cmd->cursor_start);
|
||||
if (qcvm->extglobals.input_cursor_trace_endpos)
|
||||
VectorCopy(qcvm->extglobals.input_cursor_trace_endpos, cmd->cursor_impact);
|
||||
if (qcvm->extglobals.input_cursor_entitynumber)
|
||||
cmd->cursor_entitynumber = *qcvm->extglobals.input_cursor_entitynumber;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1274,7 @@ void CL_SendCmd (void)
|
|||
PR_SwitchQCVM(&cl.qcvm);
|
||||
CL_CSQC_SetInputs(&cmd, true);
|
||||
PR_ExecuteProgram(cl.qcvm.extfuncs.CSQC_Input_Frame);
|
||||
// CL_CSQC_SetInputs(&cmd, false);
|
||||
CL_CSQC_SetInputs(&cmd, false);
|
||||
PR_SwitchQCVM(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -7833,11 +7833,13 @@ void PR_EnableExtensions(ddef_t *pr_globaldefs)
|
|||
|
||||
|
||||
#define QCEXTGLOBAL_FLOAT(n) qcvm->extglobals.n = PR_FindExtGlobal(ev_float, #n);
|
||||
#define QCEXTGLOBAL_INT(n) qcvm->extglobals.n = PR_FindExtGlobal(ev_ext_integer, #n);
|
||||
#define QCEXTGLOBAL_VECTOR(n) qcvm->extglobals.n = PR_FindExtGlobal(ev_vector, #n);
|
||||
QCEXTGLOBALS_COMMON
|
||||
QCEXTGLOBALS_GAME
|
||||
QCEXTGLOBALS_CSQC
|
||||
#undef QCEXTGLOBAL_FLOAT
|
||||
#undef QCEXTGLOBAL_INT
|
||||
#undef QCEXTGLOBAL_VECTOR
|
||||
|
||||
//any #0 functions are remapped to their builtins here, so we don't have to tweak the VM in an obscure potentially-breaking way.
|
||||
|
@ -8085,6 +8087,7 @@ void PR_DumpPlatform_f(void)
|
|||
}
|
||||
#undef QCEXTFUNC
|
||||
|
||||
#define QCEXTGLOBAL_INT(n) fprintf(f, "int " #n ";\n");
|
||||
#define QCEXTGLOBAL_FLOAT(n) fprintf(f, "float " #n ";\n");
|
||||
#define QCEXTGLOBAL_VECTOR(n) fprintf(f, "vector " #n ";\n");
|
||||
QCEXTGLOBALS_COMMON
|
||||
|
@ -8096,6 +8099,7 @@ void PR_DumpPlatform_f(void)
|
|||
{
|
||||
QCEXTGLOBALS_CSQC
|
||||
}
|
||||
#undef QCEXTGLOBAL_INT
|
||||
#undef QCEXTGLOBAL_FLOAT
|
||||
#undef QCEXTGLOBAL_VECTOR
|
||||
|
||||
|
|
|
@ -224,6 +224,11 @@ struct pr_extglobals_s
|
|||
QCEXTGLOBAL_VECTOR(input_angles)\
|
||||
QCEXTGLOBAL_FLOAT(input_buttons)\
|
||||
QCEXTGLOBAL_FLOAT(input_impulse)\
|
||||
QCEXTGLOBAL_INT(input_weapon)\
|
||||
QCEXTGLOBAL_VECTOR(input_cursor_screen)\
|
||||
QCEXTGLOBAL_VECTOR(input_cursor_trace_start)\
|
||||
QCEXTGLOBAL_VECTOR(input_cursor_trace_endpos)\
|
||||
QCEXTGLOBAL_FLOAT(input_cursor_entitynumber)\
|
||||
QCEXTGLOBAL_FLOAT(physics_mode)\
|
||||
//end
|
||||
#define QCEXTGLOBALS_CSQC \
|
||||
|
@ -239,11 +244,13 @@ struct pr_extglobals_s
|
|||
QCEXTGLOBAL_FLOAT(servercommandframe)\
|
||||
//end
|
||||
#define QCEXTGLOBAL_FLOAT(n) float *n;
|
||||
#define QCEXTGLOBAL_INT(n) int *n;
|
||||
#define QCEXTGLOBAL_VECTOR(n) float *n;
|
||||
QCEXTGLOBALS_COMMON
|
||||
QCEXTGLOBALS_GAME
|
||||
QCEXTGLOBALS_CSQC
|
||||
#undef QCEXTGLOBAL_FLOAT
|
||||
#undef QCEXTGLOBAL_INT
|
||||
#undef QCEXTGLOBAL_VECTOR
|
||||
};
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define PEXT2_PREDINFO 0x00000020 //provides input acks and reworks stats such that clc_clientdata becomes redundant.
|
||||
#define PEXT2_NEWSIZEENCODING 0x00000040 //richer size encoding, for more precise bboxes.
|
||||
#define PEXT2_INFOBLOBS 0x00000080 //unbounded userinfo
|
||||
#define PEXT2_ACCEPTED_CLIENT (PEXT2_SUPPORTED_CLIENT|PEXT2_NEWSIZEENCODING|PEXT2_PRYDONCURSOR|PEXT2_INFOBLOBS) //pext2 flags that we can parse, but don't want to advertise (for demos)
|
||||
#define PEXT2_SUPPORTED_CLIENT (PEXT2_SETANGLEDELTA|PEXT2_VOICECHAT|PEXT2_REPLACEMENTDELTAS|PEXT2_MAXPLAYERS|PEXT2_PREDINFO) //pext2 flags that we understand+support
|
||||
#define PEXT2_SUPPORTED_SERVER ( PEXT2_VOICECHAT|PEXT2_REPLACEMENTDELTAS |PEXT2_PREDINFO)
|
||||
#define PEXT2_ACCEPTED_CLIENT (PEXT2_SUPPORTED_CLIENT|PEXT2_NEWSIZEENCODING|PEXT2_INFOBLOBS) //pext2 flags that we can parse, but don't want to advertise (for demos)
|
||||
#define PEXT2_SUPPORTED_CLIENT (PEXT2_PRYDONCURSOR|PEXT2_VOICECHAT|PEXT2_SETANGLEDELTA|PEXT2_REPLACEMENTDELTAS|PEXT2_MAXPLAYERS|PEXT2_PREDINFO) //pext2 flags that we understand+support
|
||||
#define PEXT2_SUPPORTED_SERVER (PEXT2_PRYDONCURSOR|PEXT2_VOICECHAT| PEXT2_REPLACEMENTDELTAS |PEXT2_PREDINFO)
|
||||
|
||||
// if the high bit of the servercmd is set, the low bits are fast update flags:
|
||||
#define U_MOREBITS (1<<0)
|
||||
|
@ -477,6 +477,14 @@ typedef struct
|
|||
unsigned int impulse;
|
||||
|
||||
unsigned int sequence;
|
||||
|
||||
|
||||
int weapon;
|
||||
//prydon cursor crap
|
||||
float cursor_screen[2]; //-1 to 1
|
||||
vec3_t cursor_start; //world coord
|
||||
vec3_t cursor_impact; //world coord
|
||||
int cursor_entitynumber;//usually 0
|
||||
} usercmd_t;
|
||||
|
||||
#endif /* _QUAKE_PROTOCOL_H */
|
||||
|
|
|
@ -450,6 +450,10 @@ void SV_ReadClientMove (usercmd_t *move)
|
|||
vec3_t angle;
|
||||
int buttonbits;
|
||||
int newimpulse;
|
||||
unsigned int inweapon;
|
||||
float curs_screen[2];
|
||||
vec3_t curs_start, curs_impact;
|
||||
unsigned int curs_entity;
|
||||
eval_t *eval;
|
||||
qboolean drop = false;
|
||||
float timestamp;
|
||||
|
@ -484,9 +488,24 @@ void SV_ReadClientMove (usercmd_t *move)
|
|||
movevalues[0] = MSG_ReadShort ();
|
||||
movevalues[1] = MSG_ReadShort ();
|
||||
movevalues[2] = MSG_ReadShort ();
|
||||
buttonbits = MSG_ReadByte();
|
||||
if (host_client->protocol_pext2 & PEXT2_PRYDONCURSOR)
|
||||
buttonbits = MSG_ReadLong();
|
||||
else
|
||||
buttonbits = MSG_ReadByte();
|
||||
newimpulse = MSG_ReadByte();
|
||||
|
||||
inweapon = (buttonbits & (1u<<30))?MSG_ReadLong():0;
|
||||
curs_screen[0] = (buttonbits & (1u<<31))?MSG_ReadShort()/32767.0:0;
|
||||
curs_screen[1] = (buttonbits & (1u<<31))?MSG_ReadShort()/32767.0:0;
|
||||
curs_start[0] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_start[1] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_start[2] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_impact[0] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_impact[1] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_impact[2] = (buttonbits & (1u<<31))?MSG_ReadFloat():0;
|
||||
curs_entity = (buttonbits & (1u<<31))?MSG_ReadEntity(host_client->protocol_pext2):0;
|
||||
buttonbits &= ~((1u<<30)|(1u<<31));
|
||||
|
||||
if (drop)
|
||||
return; //okay, we don't care about that then
|
||||
|
||||
|
@ -559,17 +578,20 @@ void SV_ReadClientMove (usercmd_t *move)
|
|||
if (qcvm->extglobals.input_impulse)
|
||||
*qcvm->extglobals.input_impulse = newimpulse;
|
||||
if (qcvm->extglobals.input_movevalues)
|
||||
{
|
||||
qcvm->extglobals.input_movevalues[0] = movevalues[0];
|
||||
qcvm->extglobals.input_movevalues[1] = movevalues[1];
|
||||
qcvm->extglobals.input_movevalues[2] = movevalues[2];
|
||||
}
|
||||
VectorCopy(movevalues, qcvm->extglobals.input_movevalues);
|
||||
if (qcvm->extglobals.input_angles)
|
||||
{
|
||||
qcvm->extglobals.input_angles[0] = angle[0];
|
||||
qcvm->extglobals.input_angles[1] = angle[1];
|
||||
qcvm->extglobals.input_angles[2] = angle[2];
|
||||
}
|
||||
VectorCopy(angle, qcvm->extglobals.input_angles);
|
||||
if (qcvm->extglobals.input_weapon)
|
||||
*qcvm->extglobals.input_weapon = inweapon;
|
||||
if (qcvm->extglobals.input_cursor_screen)
|
||||
qcvm->extglobals.input_cursor_screen[0] = curs_screen[0], qcvm->extglobals.input_cursor_screen[1] = curs_screen[1];
|
||||
if (qcvm->extglobals.input_cursor_trace_start)
|
||||
VectorCopy(curs_start, qcvm->extglobals.input_cursor_trace_start);
|
||||
if (qcvm->extglobals.input_cursor_trace_endpos)
|
||||
VectorCopy(curs_impact, qcvm->extglobals.input_cursor_trace_endpos);
|
||||
if (qcvm->extglobals.input_cursor_entitynumber)
|
||||
*qcvm->extglobals.input_cursor_entitynumber = curs_entity;
|
||||
|
||||
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
|
||||
PR_ExecuteProgram(qcvm->extfuncs.SV_RunClientCommand);
|
||||
|
||||
|
|
Loading…
Reference in a new issue