give csqc the ability to rewrite/override prydon cursor information.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4805 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
dec0230c7d
commit
c57dbc7ca4
10 changed files with 114 additions and 72 deletions
|
@ -153,7 +153,6 @@ int in_impulse[MAX_SPLITS][IN_IMPULSECACHE];
|
|||
int in_nextimpulse[MAX_SPLITS];
|
||||
int in_impulsespending[MAX_SPLITS];
|
||||
|
||||
float cursor_screen[2];
|
||||
qboolean cursor_active;
|
||||
|
||||
|
||||
|
@ -865,8 +864,9 @@ void CL_FinishMove (usercmd_t *cmd, int msecs, int pnum)
|
|||
cmd->impulse = 0;
|
||||
}
|
||||
|
||||
void CL_UpdatePrydonCursor(usercmd_t *from, float cursor_screen[2], vec3_t cursor_start, vec3_t cursor_impact, int *entnum)
|
||||
void CL_UpdatePrydonCursor(usercmd_t *from, int pnum)
|
||||
{
|
||||
unsigned int hit;
|
||||
vec3_t cursor_end;
|
||||
|
||||
vec3_t temp;
|
||||
|
@ -876,22 +876,22 @@ void CL_UpdatePrydonCursor(usercmd_t *from, float cursor_screen[2], vec3_t curso
|
|||
|
||||
if (!cl_prydoncursor.ival)
|
||||
{ //center the cursor
|
||||
cursor_screen[0] = 0;
|
||||
cursor_screen[1] = 0;
|
||||
from->cursor_screen[0] = 0;
|
||||
from->cursor_screen[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor_screen[0] = mousecursor_x/(vid.width/2.0f) - 1;
|
||||
cursor_screen[1] = mousecursor_y/(vid.height/2.0f) - 1;
|
||||
if (cursor_screen[0] < -1)
|
||||
cursor_screen[0] = -1;
|
||||
if (cursor_screen[1] < -1)
|
||||
cursor_screen[1] = -1;
|
||||
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;
|
||||
|
||||
if (cursor_screen[0] > 1)
|
||||
cursor_screen[0] = 1;
|
||||
if (cursor_screen[1] > 1)
|
||||
cursor_screen[1] = 1;
|
||||
if (from->cursor_screen[0] > 1)
|
||||
from->cursor_screen[0] = 1;
|
||||
if (from->cursor_screen[1] > 1)
|
||||
from->cursor_screen[1] = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -917,20 +917,22 @@ void CL_UpdatePrydonCursor(usercmd_t *from, float cursor_screen[2], vec3_t curso
|
|||
}
|
||||
*/
|
||||
|
||||
VectorClear(cursor_start);
|
||||
temp[0] = (cursor_screen[0]+1)/2;
|
||||
temp[1] = (-cursor_screen[1]+1)/2;
|
||||
VectorClear(from->cursor_start);
|
||||
temp[0] = (from->cursor_screen[0]+1)/2;
|
||||
temp[1] = (-from->cursor_screen[1]+1)/2;
|
||||
temp[2] = 1;
|
||||
|
||||
VectorCopy(r_origin, cursor_start);
|
||||
Matrix4x4_CM_UnProject(temp, cursor_end, cl.playerview[0].viewangles, cursor_start, r_refdef.fov_x, r_refdef.fov_y);
|
||||
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);
|
||||
|
||||
CL_SetSolidEntities();
|
||||
//don't bother with players, they don't exist in NQ...
|
||||
|
||||
TraceLineN(cursor_start, cursor_end, cursor_impact, cursor_impact_normal);
|
||||
|
||||
*entnum = 0;
|
||||
hit = TraceLineN(from->cursor_start, cursor_end, from->cursor_impact, cursor_impact_normal);
|
||||
if (hit)
|
||||
from->cursor_entitynumber = hit-1;
|
||||
else
|
||||
from->cursor_entitynumber = 0;
|
||||
|
||||
// P_RunParticleEffect(cursor_impact, vec3_origin, 15, 16);
|
||||
}
|
||||
|
@ -983,22 +985,17 @@ void CLNQ_SendMove (usercmd_t *cmd, int pnum, sizebuf_t *buf)
|
|||
|
||||
if (cls.protocol_nq >= CPNQ_DP6 || (cls.fteprotocolextensions2 & PEXT2_PRYDONCURSOR))
|
||||
{
|
||||
vec3_t cursor_start, cursor_impact;
|
||||
int cursor_entitynumber;
|
||||
|
||||
CL_UpdatePrydonCursor(cmd, cursor_screen, cursor_start, cursor_impact, &cursor_entitynumber);
|
||||
|
||||
MSG_WriteLong (buf, cmd->buttons);
|
||||
MSG_WriteByte (buf, cmd->impulse);
|
||||
MSG_WriteShort (buf, cursor_screen[0] * 32767.0f);
|
||||
MSG_WriteShort (buf, cursor_screen[1] * 32767.0f);
|
||||
MSG_WriteFloat (buf, cursor_start[0]);
|
||||
MSG_WriteFloat (buf, cursor_start[1]);
|
||||
MSG_WriteFloat (buf, cursor_start[2]);
|
||||
MSG_WriteFloat (buf, cursor_impact[0]);
|
||||
MSG_WriteFloat (buf, cursor_impact[1]);
|
||||
MSG_WriteFloat (buf, cursor_impact[2]);
|
||||
MSG_WriteEntity (buf, cursor_entitynumber);
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1453,22 +1450,21 @@ qboolean CLQW_SendCmd (sizebuf_t *buf)
|
|||
memset(&independantphysics[plnum], 0, sizeof(independantphysics[plnum]));
|
||||
}
|
||||
|
||||
if ((cls.fteprotocolextensions2 & PEXT2_PRYDONCURSOR) && (*cl_prydoncursor.string && cl_prydoncursor.ival >= 0) && cls.state == ca_active)
|
||||
{
|
||||
vec3_t cursor_start, cursor_impact;
|
||||
int cursor_entitynumber = 0;
|
||||
cmd = &cl.outframes[curframe].cmd[0];
|
||||
CL_UpdatePrydonCursor(cmd, cursor_screen, cursor_start, cursor_impact, &cursor_entitynumber);
|
||||
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, clc_prydoncursor);
|
||||
MSG_WriteShort(buf, cursor_screen[0] * 32767.0f);
|
||||
MSG_WriteShort(buf, cursor_screen[1] * 32767.0f);
|
||||
MSG_WriteFloat(buf, cursor_start[0]);
|
||||
MSG_WriteFloat(buf, cursor_start[1]);
|
||||
MSG_WriteFloat(buf, cursor_start[2]);
|
||||
MSG_WriteFloat(buf, cursor_impact[0]);
|
||||
MSG_WriteFloat(buf, cursor_impact[1]);
|
||||
MSG_WriteFloat(buf, cursor_impact[2]);
|
||||
MSG_WriteEntity(buf, cursor_entitynumber);
|
||||
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);
|
||||
}
|
||||
|
||||
MSG_WriteByte (buf, clc_move);
|
||||
|
@ -1782,6 +1778,19 @@ void CL_SendCmd (double frametime, qboolean mainloop)
|
|||
return;
|
||||
}
|
||||
cursor_active = false;
|
||||
|
||||
cmd = &independantphysics[0];
|
||||
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, 0);
|
||||
else
|
||||
{
|
||||
Vector2Clear(cmd->cursor_screen);
|
||||
VectorClear(cmd->cursor_start);
|
||||
VectorClear(cmd->cursor_impact);
|
||||
cmd->cursor_entitynumber = 0;
|
||||
}
|
||||
|
||||
switch (cls.protocol)
|
||||
{
|
||||
#ifdef NQPROT
|
||||
|
|
|
@ -975,7 +975,7 @@ extern unsigned int cl_maxstris;
|
|||
|
||||
extern char emodel_name[], pmodel_name[], prespawn_name[], modellist_name[], soundlist_name[];
|
||||
|
||||
qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
|
||||
unsigned int TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
|
||||
|
||||
//
|
||||
// cl_input
|
||||
|
|
|
@ -5737,7 +5737,7 @@ static void PScript_DrawParticleTypes (void)
|
|||
void (*sparkfanparticles)(int count, particle_t **plist, plooks_t *type)=GL_DrawTrifanParticle;
|
||||
void (*sparktexturedparticles)(int count, particle_t **plist, plooks_t *type)=GL_DrawTexturedSparkParticle;
|
||||
|
||||
qboolean (*tr) (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
|
||||
unsigned int (*tr) (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
|
||||
void *pdraw, *bdraw;
|
||||
void (*tdraw)(scenetris_t *t, particle_t *p, plooks_t *type);
|
||||
|
||||
|
|
|
@ -176,6 +176,10 @@ extern sfx_t *cl_sfx_r_exp3;
|
|||
globalfloat(input_weapon, "input_weapon"); /*unused float filled by getinputstate, read by runplayerphysics*/ \
|
||||
globalfloat(input_servertime, "input_servertime"); /*float filled by getinputstate, read by runplayerphysics*/ \
|
||||
globalfloat(input_clienttime, "input_clienttime"); /*float filled by getinputstate, read by runplayerphysics*/ \
|
||||
globalvector(input_cursor_screen, "input_cursor_screen"); /*float filled by getinputstate*/ \
|
||||
globalvector(input_cursor_start, "input_cursor_trace_start"); /*float filled by getinputstate*/ \
|
||||
globalvector(input_cursor_impact, "input_cursor_trace_endpos"); /*float filled by getinputstate*/ \
|
||||
globalfloat(input_cursor_entitynumber, "input_cursor_entitynumber"); /*float filled by getinputstate*/ \
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -2518,6 +2522,18 @@ static void cs_set_input_state (usercmd_t *cmd)
|
|||
*csqcg.input_servertime = cmd->servertime/1000.0f;
|
||||
if (csqcg.input_clienttime)
|
||||
*csqcg.input_clienttime = cmd->fclienttime/1000.0f;
|
||||
|
||||
if (csqcg.input_cursor_screen)
|
||||
{
|
||||
Vector2Copy(cmd->cursor_screen, csqcg.input_cursor_screen);
|
||||
csqcg.input_cursor_screen[2] = 0;
|
||||
}
|
||||
if (csqcg.input_cursor_start)
|
||||
VectorCopy(cmd->cursor_start, csqcg.input_cursor_start);
|
||||
if (csqcg.input_cursor_impact)
|
||||
VectorCopy(cmd->cursor_impact, csqcg.input_cursor_impact);
|
||||
if (csqcg.input_cursor_entitynumber)
|
||||
*csqcg.input_cursor_entitynumber = cmd->cursor_entitynumber;
|
||||
}
|
||||
|
||||
static void cs_get_input_state (usercmd_t *cmd)
|
||||
|
@ -2547,6 +2563,15 @@ static void cs_get_input_state (usercmd_t *cmd)
|
|||
cmd->weapon = *csqcg.input_weapon;
|
||||
if (csqcg.input_servertime)
|
||||
cmd->servertime = *csqcg.input_servertime*1000;
|
||||
|
||||
if (csqcg.input_cursor_screen)
|
||||
Vector2Copy(csqcg.input_cursor_screen, cmd->cursor_screen);
|
||||
if (csqcg.input_cursor_start)
|
||||
VectorCopy(csqcg.input_cursor_start, cmd->cursor_start);
|
||||
if (csqcg.input_cursor_impact)
|
||||
VectorCopy(csqcg.input_cursor_impact, cmd->cursor_impact);
|
||||
if (csqcg.input_cursor_entitynumber)
|
||||
cmd->cursor_entitynumber = *csqcg.input_cursor_entitynumber;
|
||||
}
|
||||
|
||||
//#343
|
||||
|
|
|
@ -197,14 +197,17 @@ void P_Shutdown(void)
|
|||
pe = NULL;
|
||||
}
|
||||
|
||||
qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
||||
//0 says hit nothing.
|
||||
//1 says hit world
|
||||
//>1 says hit some entity
|
||||
unsigned int TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
||||
{
|
||||
trace_t trace;
|
||||
float len, bestlen;
|
||||
int i;
|
||||
vec3_t delta, ts, te;
|
||||
physent_t *pe;
|
||||
qboolean clipped=false;
|
||||
int result=0;
|
||||
vec3_t axis[3];
|
||||
|
||||
memset (&trace, 0, sizeof(trace));
|
||||
|
@ -214,7 +217,7 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
|||
|
||||
VectorCopy (end, impact);
|
||||
|
||||
for (i=0 ; i< pmove.numphysent ; i++)
|
||||
for (i=0 ; i < pmove.numphysent ; i++)
|
||||
{
|
||||
pe = &pmove.physents[i];
|
||||
if (pe->nonsolid)
|
||||
|
@ -243,7 +246,7 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
|||
VectorAdd (pe->origin, trace.endpos, impact);
|
||||
}
|
||||
|
||||
clipped=true;
|
||||
result = pe->info+1;
|
||||
}
|
||||
if (trace.startsolid)
|
||||
{
|
||||
|
@ -261,14 +264,7 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
|
|||
}
|
||||
}
|
||||
|
||||
if (clipped)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//handy utility...
|
||||
|
|
|
@ -87,6 +87,7 @@ extern vec3_t vec3_origin;
|
|||
#define VectorEquals(a,b) ((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2])
|
||||
#define VectorAvg(a,b,c) ((c)[0]=((a)[0]+(b)[0])*0.5f,(c)[1]=((a)[1]+(b)[1])*0.5f, (c)[2]=((a)[2]+(b)[2])*0.5f)
|
||||
#define VectorInterpolate(a, bness, b, c) FloatInterpolate((a)[0], bness, (b)[0], (c)[0]),FloatInterpolate((a)[1], bness, (b)[1], (c)[1]),FloatInterpolate((a)[2], bness, (b)[2], (c)[2])
|
||||
#define Vector2Clear(a) ((a)[0]=(a)[1]=0)
|
||||
#define Vector2Copy(a,b) do{(b)[0]=(a)[0];(b)[1]=(a)[1];}while(0)
|
||||
#define Vector2Set(r,x,y) do{(r)[0] = x; (r)[1] = y;}while(0)
|
||||
#define Vector2Interpolate(a, bness, b, c) FloatInterpolate((a)[0], bness, (b)[0], (c)[0]),FloatInterpolate((a)[1], bness, (b)[1], (c)[1])
|
||||
|
|
|
@ -55,8 +55,9 @@ static void PF_Warningf(pubprogfuncs_t *prinst, const char *fmt, ...)
|
|||
vsnprintf (string, sizeof(string)-1, fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
Con_Printf("%s", string);
|
||||
if (developer.ival)
|
||||
PR_StackTrace(prinst, false);
|
||||
Con_Printf("%s", string);
|
||||
}
|
||||
|
||||
char *PF_VarString (pubprogfuncs_t *prinst, int first, struct globalvars_s *pr_globals)
|
||||
|
|
|
@ -1048,6 +1048,11 @@ typedef struct usercmd_s
|
|||
int servertime;
|
||||
float fservertime;
|
||||
float fclienttime;
|
||||
|
||||
vec2_t cursor_screen;
|
||||
vec3_t cursor_start;
|
||||
vec3_t cursor_impact;
|
||||
int cursor_entitynumber;
|
||||
} usercmd_t;
|
||||
|
||||
typedef struct q2usercmd_s
|
||||
|
|
|
@ -10446,6 +10446,11 @@ void PR_DumpPlatform_f(void)
|
|||
{"input_buttons", "float", QW|NQ},
|
||||
{"input_impulse", "float", QW|NQ},
|
||||
|
||||
{"input_cursor_screen", "vector", CS/*|QW|NQ*/},
|
||||
{"input_cursor_trace_start", "vector", CS/*|QW|NQ*/},
|
||||
{"input_cursor_trace_endpos", "vector", CS/*|QW|NQ*/},
|
||||
{"input_cursor_trace_entnum", "float", CS/*|QW|NQ*/},
|
||||
|
||||
#define comfieldfloat(name,desc) {#name, ".float", FL, desc},
|
||||
#define comfieldvector(name,desc) {#name, ".vector", FL, desc},
|
||||
#define comfieldentity(name,desc) {#name, ".entity", FL, desc},
|
||||
|
|
|
@ -6458,7 +6458,7 @@ void SV_ReadPrydonCursor(void)
|
|||
entnum = MSGSV_ReadEntity(host_client);
|
||||
if (entnum >= sv.world.max_edicts)
|
||||
{
|
||||
Con_DPrintf("SV_ReadPrydonCursor: client send bad cursor_entitynumber\n");
|
||||
Con_DPrintf("SV_ReadPrydonCursor: client sent bad cursor_entitynumber\n");
|
||||
entnum = 0;
|
||||
}
|
||||
// as requested by FrikaC, cursor_trace_ent is reset to world if the
|
||||
|
|
Loading…
Reference in a new issue