mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-13 07:21:31 +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)
|
if (cmd)
|
||||||
{
|
{
|
||||||
int dump = buf.cursize;
|
int dump = buf.cursize;
|
||||||
|
unsigned int bits = cmd->buttons;
|
||||||
|
|
||||||
//
|
//
|
||||||
// send the movement message
|
// send the movement message
|
||||||
|
@ -457,25 +458,38 @@ void CL_SendMove (const usercmd_t *cmd)
|
||||||
MSG_WriteShort (&buf, cmd->sidemove);
|
MSG_WriteShort (&buf, cmd->sidemove);
|
||||||
MSG_WriteShort (&buf, cmd->upmove);
|
MSG_WriteShort (&buf, cmd->upmove);
|
||||||
|
|
||||||
|
if (cl.protocol_pext2 & PEXT2_PRYDONCURSOR)
|
||||||
if (cl.protocol == PROTOCOL_VERSION_DP7)
|
|
||||||
{
|
{
|
||||||
MSG_WriteLong (&buf, cmd->buttons);
|
if (cmd->weapon)
|
||||||
MSG_WriteByte (&buf, cmd->impulse);
|
bits |= (1u<<30);
|
||||||
MSG_WriteShort(&buf, 32767);//cursor x
|
if (cmd->cursor_screen[0] || cmd->cursor_screen[1] ||
|
||||||
MSG_WriteShort(&buf, 32767);//cursor y
|
cmd->cursor_start[0] || cmd->cursor_start[1] || cmd->cursor_start[2] ||
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[0]); //start (view pos)
|
cmd->cursor_impact[0] || cmd->cursor_impact[1] || cmd->cursor_impact[2] ||
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[1]);
|
cmd->cursor_entitynumber)
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[2]);
|
bits |= (1u<<31);
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[0]); //impact
|
MSG_WriteLong (&buf, bits);
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[1]);
|
}
|
||||||
MSG_WriteFloat(&buf, r_refdef.vieworg[2]);
|
else if (cl.protocol == PROTOCOL_VERSION_DP7)
|
||||||
MSG_WriteShort(&buf, 0); //entity
|
{
|
||||||
|
MSG_WriteLong (&buf, bits);
|
||||||
|
bits |= (1u<<31);
|
||||||
}
|
}
|
||||||
else
|
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_WriteShort(&buf, cmd->cursor_screen[0] * 32767);
|
||||||
MSG_WriteByte (&buf, cmd->impulse);
|
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;
|
in_impulse = 0;
|
||||||
|
|
||||||
|
|
|
@ -1202,6 +1202,17 @@ void CL_CSQC_SetInputs(usercmd_t *cmd, qboolean set)
|
||||||
*qcvm->extglobals.input_buttons = cmd->buttons;
|
*qcvm->extglobals.input_buttons = cmd->buttons;
|
||||||
if (qcvm->extglobals.input_impulse)
|
if (qcvm->extglobals.input_impulse)
|
||||||
*qcvm->extglobals.input_impulse = cmd->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
|
else
|
||||||
{
|
{
|
||||||
|
@ -1219,6 +1230,17 @@ void CL_CSQC_SetInputs(usercmd_t *cmd, qboolean set)
|
||||||
cmd->buttons = *qcvm->extglobals.input_buttons;
|
cmd->buttons = *qcvm->extglobals.input_buttons;
|
||||||
if (qcvm->extglobals.input_impulse)
|
if (qcvm->extglobals.input_impulse)
|
||||||
cmd->impulse = *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);
|
PR_SwitchQCVM(&cl.qcvm);
|
||||||
CL_CSQC_SetInputs(&cmd, true);
|
CL_CSQC_SetInputs(&cmd, true);
|
||||||
PR_ExecuteProgram(cl.qcvm.extfuncs.CSQC_Input_Frame);
|
PR_ExecuteProgram(cl.qcvm.extfuncs.CSQC_Input_Frame);
|
||||||
// CL_CSQC_SetInputs(&cmd, false);
|
CL_CSQC_SetInputs(&cmd, false);
|
||||||
PR_SwitchQCVM(NULL);
|
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_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);
|
#define QCEXTGLOBAL_VECTOR(n) qcvm->extglobals.n = PR_FindExtGlobal(ev_vector, #n);
|
||||||
QCEXTGLOBALS_COMMON
|
QCEXTGLOBALS_COMMON
|
||||||
QCEXTGLOBALS_GAME
|
QCEXTGLOBALS_GAME
|
||||||
QCEXTGLOBALS_CSQC
|
QCEXTGLOBALS_CSQC
|
||||||
#undef QCEXTGLOBAL_FLOAT
|
#undef QCEXTGLOBAL_FLOAT
|
||||||
|
#undef QCEXTGLOBAL_INT
|
||||||
#undef QCEXTGLOBAL_VECTOR
|
#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.
|
//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
|
#undef QCEXTFUNC
|
||||||
|
|
||||||
|
#define QCEXTGLOBAL_INT(n) fprintf(f, "int " #n ";\n");
|
||||||
#define QCEXTGLOBAL_FLOAT(n) fprintf(f, "float " #n ";\n");
|
#define QCEXTGLOBAL_FLOAT(n) fprintf(f, "float " #n ";\n");
|
||||||
#define QCEXTGLOBAL_VECTOR(n) fprintf(f, "vector " #n ";\n");
|
#define QCEXTGLOBAL_VECTOR(n) fprintf(f, "vector " #n ";\n");
|
||||||
QCEXTGLOBALS_COMMON
|
QCEXTGLOBALS_COMMON
|
||||||
|
@ -8096,6 +8099,7 @@ void PR_DumpPlatform_f(void)
|
||||||
{
|
{
|
||||||
QCEXTGLOBALS_CSQC
|
QCEXTGLOBALS_CSQC
|
||||||
}
|
}
|
||||||
|
#undef QCEXTGLOBAL_INT
|
||||||
#undef QCEXTGLOBAL_FLOAT
|
#undef QCEXTGLOBAL_FLOAT
|
||||||
#undef QCEXTGLOBAL_VECTOR
|
#undef QCEXTGLOBAL_VECTOR
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,11 @@ struct pr_extglobals_s
|
||||||
QCEXTGLOBAL_VECTOR(input_angles)\
|
QCEXTGLOBAL_VECTOR(input_angles)\
|
||||||
QCEXTGLOBAL_FLOAT(input_buttons)\
|
QCEXTGLOBAL_FLOAT(input_buttons)\
|
||||||
QCEXTGLOBAL_FLOAT(input_impulse)\
|
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)\
|
QCEXTGLOBAL_FLOAT(physics_mode)\
|
||||||
//end
|
//end
|
||||||
#define QCEXTGLOBALS_CSQC \
|
#define QCEXTGLOBALS_CSQC \
|
||||||
|
@ -239,11 +244,13 @@ struct pr_extglobals_s
|
||||||
QCEXTGLOBAL_FLOAT(servercommandframe)\
|
QCEXTGLOBAL_FLOAT(servercommandframe)\
|
||||||
//end
|
//end
|
||||||
#define QCEXTGLOBAL_FLOAT(n) float *n;
|
#define QCEXTGLOBAL_FLOAT(n) float *n;
|
||||||
|
#define QCEXTGLOBAL_INT(n) int *n;
|
||||||
#define QCEXTGLOBAL_VECTOR(n) float *n;
|
#define QCEXTGLOBAL_VECTOR(n) float *n;
|
||||||
QCEXTGLOBALS_COMMON
|
QCEXTGLOBALS_COMMON
|
||||||
QCEXTGLOBALS_GAME
|
QCEXTGLOBALS_GAME
|
||||||
QCEXTGLOBALS_CSQC
|
QCEXTGLOBALS_CSQC
|
||||||
#undef QCEXTGLOBAL_FLOAT
|
#undef QCEXTGLOBAL_FLOAT
|
||||||
|
#undef QCEXTGLOBAL_INT
|
||||||
#undef QCEXTGLOBAL_VECTOR
|
#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_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_NEWSIZEENCODING 0x00000040 //richer size encoding, for more precise bboxes.
|
||||||
#define PEXT2_INFOBLOBS 0x00000080 //unbounded userinfo
|
#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_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_SETANGLEDELTA|PEXT2_VOICECHAT|PEXT2_REPLACEMENTDELTAS|PEXT2_MAXPLAYERS|PEXT2_PREDINFO) //pext2 flags that we understand+support
|
#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_VOICECHAT|PEXT2_REPLACEMENTDELTAS |PEXT2_PREDINFO)
|
#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:
|
// if the high bit of the servercmd is set, the low bits are fast update flags:
|
||||||
#define U_MOREBITS (1<<0)
|
#define U_MOREBITS (1<<0)
|
||||||
|
@ -477,6 +477,14 @@ typedef struct
|
||||||
unsigned int impulse;
|
unsigned int impulse;
|
||||||
|
|
||||||
unsigned int sequence;
|
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;
|
} usercmd_t;
|
||||||
|
|
||||||
#endif /* _QUAKE_PROTOCOL_H */
|
#endif /* _QUAKE_PROTOCOL_H */
|
||||||
|
|
|
@ -450,6 +450,10 @@ void SV_ReadClientMove (usercmd_t *move)
|
||||||
vec3_t angle;
|
vec3_t angle;
|
||||||
int buttonbits;
|
int buttonbits;
|
||||||
int newimpulse;
|
int newimpulse;
|
||||||
|
unsigned int inweapon;
|
||||||
|
float curs_screen[2];
|
||||||
|
vec3_t curs_start, curs_impact;
|
||||||
|
unsigned int curs_entity;
|
||||||
eval_t *eval;
|
eval_t *eval;
|
||||||
qboolean drop = false;
|
qboolean drop = false;
|
||||||
float timestamp;
|
float timestamp;
|
||||||
|
@ -484,9 +488,24 @@ void SV_ReadClientMove (usercmd_t *move)
|
||||||
movevalues[0] = MSG_ReadShort ();
|
movevalues[0] = MSG_ReadShort ();
|
||||||
movevalues[1] = MSG_ReadShort ();
|
movevalues[1] = MSG_ReadShort ();
|
||||||
movevalues[2] = 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();
|
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)
|
if (drop)
|
||||||
return; //okay, we don't care about that then
|
return; //okay, we don't care about that then
|
||||||
|
|
||||||
|
@ -559,17 +578,20 @@ void SV_ReadClientMove (usercmd_t *move)
|
||||||
if (qcvm->extglobals.input_impulse)
|
if (qcvm->extglobals.input_impulse)
|
||||||
*qcvm->extglobals.input_impulse = newimpulse;
|
*qcvm->extglobals.input_impulse = newimpulse;
|
||||||
if (qcvm->extglobals.input_movevalues)
|
if (qcvm->extglobals.input_movevalues)
|
||||||
{
|
VectorCopy(movevalues, 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];
|
|
||||||
}
|
|
||||||
if (qcvm->extglobals.input_angles)
|
if (qcvm->extglobals.input_angles)
|
||||||
{
|
VectorCopy(angle, qcvm->extglobals.input_angles);
|
||||||
qcvm->extglobals.input_angles[0] = angle[0];
|
if (qcvm->extglobals.input_weapon)
|
||||||
qcvm->extglobals.input_angles[1] = angle[1];
|
*qcvm->extglobals.input_weapon = inweapon;
|
||||||
qcvm->extglobals.input_angles[2] = angle[2];
|
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_global_struct->self = EDICT_TO_PROG(host_client->edict);
|
||||||
PR_ExecuteProgram(qcvm->extfuncs.SV_RunClientCommand);
|
PR_ExecuteProgram(qcvm->extfuncs.SV_RunClientCommand);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue