1
0
Fork 0
forked from fte/fteqw

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:
Spoike 2014-12-25 02:32:22 +00:00
parent dec0230c7d
commit c57dbc7ca4
10 changed files with 114 additions and 72 deletions

View file

@ -153,7 +153,6 @@ int in_impulse[MAX_SPLITS][IN_IMPULSECACHE];
int in_nextimpulse[MAX_SPLITS]; int in_nextimpulse[MAX_SPLITS];
int in_impulsespending[MAX_SPLITS]; int in_impulsespending[MAX_SPLITS];
float cursor_screen[2];
qboolean cursor_active; qboolean cursor_active;
@ -865,8 +864,9 @@ void CL_FinishMove (usercmd_t *cmd, int msecs, int pnum)
cmd->impulse = 0; 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 cursor_end;
vec3_t temp; vec3_t temp;
@ -876,22 +876,22 @@ void CL_UpdatePrydonCursor(usercmd_t *from, float cursor_screen[2], vec3_t curso
if (!cl_prydoncursor.ival) if (!cl_prydoncursor.ival)
{ //center the cursor { //center the cursor
cursor_screen[0] = 0; from->cursor_screen[0] = 0;
cursor_screen[1] = 0; from->cursor_screen[1] = 0;
} }
else else
{ {
cursor_screen[0] = mousecursor_x/(vid.width/2.0f) - 1; from->cursor_screen[0] = mousecursor_x/(vid.width/2.0f) - 1;
cursor_screen[1] = mousecursor_y/(vid.height/2.0f) - 1; from->cursor_screen[1] = mousecursor_y/(vid.height/2.0f) - 1;
if (cursor_screen[0] < -1) if (from->cursor_screen[0] < -1)
cursor_screen[0] = -1; from->cursor_screen[0] = -1;
if (cursor_screen[1] < -1) if (from->cursor_screen[1] < -1)
cursor_screen[1] = -1; from->cursor_screen[1] = -1;
if (cursor_screen[0] > 1) if (from->cursor_screen[0] > 1)
cursor_screen[0] = 1; from->cursor_screen[0] = 1;
if (cursor_screen[1] > 1) if (from->cursor_screen[1] > 1)
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); VectorClear(from->cursor_start);
temp[0] = (cursor_screen[0]+1)/2; temp[0] = (from->cursor_screen[0]+1)/2;
temp[1] = (-cursor_screen[1]+1)/2; temp[1] = (-from->cursor_screen[1]+1)/2;
temp[2] = 1; temp[2] = 1;
VectorCopy(r_origin, cursor_start); VectorCopy(r_origin, from->cursor_start);
Matrix4x4_CM_UnProject(temp, cursor_end, cl.playerview[0].viewangles, cursor_start, r_refdef.fov_x, r_refdef.fov_y); Matrix4x4_CM_UnProject(temp, cursor_end, cl.playerview[pnum].viewangles, from->cursor_start, r_refdef.fov_x, r_refdef.fov_y);
CL_SetSolidEntities(); CL_SetSolidEntities();
//don't bother with players, they don't exist in NQ... //don't bother with players, they don't exist in NQ...
TraceLineN(cursor_start, cursor_end, cursor_impact, cursor_impact_normal); hit = TraceLineN(from->cursor_start, cursor_end, from->cursor_impact, cursor_impact_normal);
if (hit)
*entnum = 0; from->cursor_entitynumber = hit-1;
else
from->cursor_entitynumber = 0;
// P_RunParticleEffect(cursor_impact, vec3_origin, 15, 16); // 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)) 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_WriteLong (buf, cmd->buttons);
MSG_WriteByte (buf, cmd->impulse); MSG_WriteByte (buf, cmd->impulse);
MSG_WriteShort (buf, cursor_screen[0] * 32767.0f); MSG_WriteShort (buf, cmd->cursor_screen[0] * 32767.0f);
MSG_WriteShort (buf, cursor_screen[1] * 32767.0f); MSG_WriteShort (buf, cmd->cursor_screen[1] * 32767.0f);
MSG_WriteFloat (buf, cursor_start[0]); MSG_WriteFloat (buf, cmd->cursor_start[0]);
MSG_WriteFloat (buf, cursor_start[1]); MSG_WriteFloat (buf, cmd->cursor_start[1]);
MSG_WriteFloat (buf, cursor_start[2]); MSG_WriteFloat (buf, cmd->cursor_start[2]);
MSG_WriteFloat (buf, cursor_impact[0]); MSG_WriteFloat (buf, cmd->cursor_impact[0]);
MSG_WriteFloat (buf, cursor_impact[1]); MSG_WriteFloat (buf, cmd->cursor_impact[1]);
MSG_WriteFloat (buf, cursor_impact[2]); MSG_WriteFloat (buf, cmd->cursor_impact[2]);
MSG_WriteEntity (buf, cursor_entitynumber); MSG_WriteEntity (buf, cmd->cursor_entitynumber);
} }
else else
{ {
@ -1453,22 +1450,21 @@ qboolean CLQW_SendCmd (sizebuf_t *buf)
memset(&independantphysics[plnum], 0, sizeof(independantphysics[plnum])); 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]; 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_WriteByte (buf, clc_prydoncursor);
MSG_WriteShort(buf, cursor_screen[0] * 32767.0f); MSG_WriteShort(buf, cmd->cursor_screen[0] * 32767.0f);
MSG_WriteShort(buf, cursor_screen[1] * 32767.0f); MSG_WriteShort(buf, cmd->cursor_screen[1] * 32767.0f);
MSG_WriteFloat(buf, cursor_start[0]); MSG_WriteFloat(buf, cmd->cursor_start[0]);
MSG_WriteFloat(buf, cursor_start[1]); MSG_WriteFloat(buf, cmd->cursor_start[1]);
MSG_WriteFloat(buf, cursor_start[2]); MSG_WriteFloat(buf, cmd->cursor_start[2]);
MSG_WriteFloat(buf, cursor_impact[0]); MSG_WriteFloat(buf, cmd->cursor_impact[0]);
MSG_WriteFloat(buf, cursor_impact[1]); MSG_WriteFloat(buf, cmd->cursor_impact[1]);
MSG_WriteFloat(buf, cursor_impact[2]); MSG_WriteFloat(buf, cmd->cursor_impact[2]);
MSG_WriteEntity(buf, cursor_entitynumber); MSG_WriteEntity(buf, cmd->cursor_entitynumber);
} }
MSG_WriteByte (buf, clc_move); MSG_WriteByte (buf, clc_move);
@ -1782,6 +1778,19 @@ void CL_SendCmd (double frametime, qboolean mainloop)
return; return;
} }
cursor_active = false; 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) switch (cls.protocol)
{ {
#ifdef NQPROT #ifdef NQPROT

View file

@ -975,7 +975,7 @@ extern unsigned int cl_maxstris;
extern char emodel_name[], pmodel_name[], prespawn_name[], modellist_name[], soundlist_name[]; 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 // cl_input

View file

@ -5737,7 +5737,7 @@ static void PScript_DrawParticleTypes (void)
void (*sparkfanparticles)(int count, particle_t **plist, plooks_t *type)=GL_DrawTrifanParticle; void (*sparkfanparticles)(int count, particle_t **plist, plooks_t *type)=GL_DrawTrifanParticle;
void (*sparktexturedparticles)(int count, particle_t **plist, plooks_t *type)=GL_DrawTexturedSparkParticle; 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 *pdraw, *bdraw;
void (*tdraw)(scenetris_t *t, particle_t *p, plooks_t *type); void (*tdraw)(scenetris_t *t, particle_t *p, plooks_t *type);

View file

@ -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_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_servertime, "input_servertime"); /*float filled by getinputstate, read by runplayerphysics*/ \
globalfloat(input_clienttime, "input_clienttime"); /*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 { typedef struct {
@ -2518,6 +2522,18 @@ static void cs_set_input_state (usercmd_t *cmd)
*csqcg.input_servertime = cmd->servertime/1000.0f; *csqcg.input_servertime = cmd->servertime/1000.0f;
if (csqcg.input_clienttime) if (csqcg.input_clienttime)
*csqcg.input_clienttime = cmd->fclienttime/1000.0f; *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) 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; cmd->weapon = *csqcg.input_weapon;
if (csqcg.input_servertime) if (csqcg.input_servertime)
cmd->servertime = *csqcg.input_servertime*1000; 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 //#343

View file

@ -197,14 +197,17 @@ void P_Shutdown(void)
pe = NULL; 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; trace_t trace;
float len, bestlen; float len, bestlen;
int i; int i;
vec3_t delta, ts, te; vec3_t delta, ts, te;
physent_t *pe; physent_t *pe;
qboolean clipped=false; int result=0;
vec3_t axis[3]; vec3_t axis[3];
memset (&trace, 0, sizeof(trace)); 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); VectorCopy (end, impact);
for (i=0 ; i< pmove.numphysent ; i++) for (i=0 ; i < pmove.numphysent ; i++)
{ {
pe = &pmove.physents[i]; pe = &pmove.physents[i];
if (pe->nonsolid) 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); VectorAdd (pe->origin, trace.endpos, impact);
} }
clipped=true; result = pe->info+1;
} }
if (trace.startsolid) if (trace.startsolid)
{ {
@ -261,14 +264,7 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
} }
} }
if (clipped) return result;
{
return true;
}
else
{
return false;
}
} }
//handy utility... //handy utility...

View file

@ -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 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 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 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 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 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]) #define Vector2Interpolate(a, bness, b, c) FloatInterpolate((a)[0], bness, (b)[0], (c)[0]),FloatInterpolate((a)[1], bness, (b)[1], (c)[1])

View file

@ -55,8 +55,9 @@ static void PF_Warningf(pubprogfuncs_t *prinst, const char *fmt, ...)
vsnprintf (string, sizeof(string)-1, fmt, argptr); vsnprintf (string, sizeof(string)-1, fmt, argptr);
va_end (argptr); va_end (argptr);
Con_Printf("%s", string); if (developer.ival)
PR_StackTrace(prinst, false); PR_StackTrace(prinst, false);
Con_Printf("%s", string);
} }
char *PF_VarString (pubprogfuncs_t *prinst, int first, struct globalvars_s *pr_globals) char *PF_VarString (pubprogfuncs_t *prinst, int first, struct globalvars_s *pr_globals)

View file

@ -1048,6 +1048,11 @@ typedef struct usercmd_s
int servertime; int servertime;
float fservertime; float fservertime;
float fclienttime; float fclienttime;
vec2_t cursor_screen;
vec3_t cursor_start;
vec3_t cursor_impact;
int cursor_entitynumber;
} usercmd_t; } usercmd_t;
typedef struct q2usercmd_s typedef struct q2usercmd_s

View file

@ -10446,6 +10446,11 @@ void PR_DumpPlatform_f(void)
{"input_buttons", "float", QW|NQ}, {"input_buttons", "float", QW|NQ},
{"input_impulse", "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 comfieldfloat(name,desc) {#name, ".float", FL, desc},
#define comfieldvector(name,desc) {#name, ".vector", FL, desc}, #define comfieldvector(name,desc) {#name, ".vector", FL, desc},
#define comfieldentity(name,desc) {#name, ".entity", FL, desc}, #define comfieldentity(name,desc) {#name, ".entity", FL, desc},

View file

@ -6458,7 +6458,7 @@ void SV_ReadPrydonCursor(void)
entnum = MSGSV_ReadEntity(host_client); entnum = MSGSV_ReadEntity(host_client);
if (entnum >= sv.world.max_edicts) 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; entnum = 0;
} }
// as requested by FrikaC, cursor_trace_ent is reset to world if the // as requested by FrikaC, cursor_trace_ent is reset to world if the