diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 52cea4884..a6eec1d7d 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -2272,6 +2272,8 @@ static void CL_TransitionPacketEntities(int newsequence, packet_entities_t *newp else frac = (servertime-oldpack->servertime)/(newpack->servertime-oldpack->servertime); + cl.lerpentssequence = newsequence; + oldpnum=0; for (newpnum=0 ; newpnumnum_entities ; newpnum++) { @@ -2299,6 +2301,8 @@ static void CL_TransitionPacketEntities(int newsequence, packet_entities_t *newp cl.maxlerpents = newmaxle; } le = &cl.lerpents[snew->number]; + le->sequence = newsequence; + le->entstate = snew; VectorSubtract(snew->origin, sold->origin, move); if (DotProduct(move, move) > 200*200 || snew->modelindex != sold->modelindex) diff --git a/engine/client/client.h b/engine/client/client.h index 6d0363029..25b7c8771 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -527,6 +527,7 @@ typedef struct frame_t frames[UPDATE_BACKUP]; lerpents_t *lerpents; int maxlerpents; //number of slots allocated. + int lerpentssequence; lerpents_t lerpplayers[MAX_CLIENTS]; // information for local display diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 178dad9ab..1b7cd3c94 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -3842,6 +3842,101 @@ static void QCBUILTIN PF_DeltaListen(progfuncs_t *prinst, struct globalvars_s *p } } +static void QCBUILTIN PF_getentity(progfuncs_t *prinst, struct globalvars_s *pr_globals) +{ + int entnum = G_FLOAT(OFS_PARM0); + int fldnum = G_FLOAT(OFS_PARM1); + + if (fldnum == GE_MAXENTS) + { + G_FLOAT(OFS_RETURN) = cl.maxlerpents; + return; + } + + if (entnum >= cl.maxlerpents || !cl.lerpentssequence || cl.lerpents[entnum].sequence != cl.lerpentssequence) + { + Con_Printf("PF_getentity: entity %i is not valid\n", fldnum); + VectorCopy(vec3_origin, G_VECTOR(OFS_RETURN)); + return; + } + switch(fldnum) + { + case GE_ACTIVE: + G_FLOAT(OFS_RETURN) = 1; + break; + case GE_ORIGIN: + /*lerped position*/ + VectorCopy(cl.lerpents[entnum].origin, G_VECTOR(OFS_RETURN)); + break; + case GE_SCALE: + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->scale / 16.0f; + break; + case GE_ALPHA: + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->trans / 255.0f; + break; + case GE_COLORMOD: + G_FLOAT(OFS_RETURN+0) = cl.lerpents[entnum].entstate->colormod[0] / 8.0f; + G_FLOAT(OFS_RETURN+1) = cl.lerpents[entnum].entstate->colormod[1] / 8.0f; + G_FLOAT(OFS_RETURN+2) = cl.lerpents[entnum].entstate->colormod[2] / 8.0f; + break; + case GE_SKIN: + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->skinnum; + break; + case GE_LIGHT: + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->abslight; + break; + case GE_MINS: + G_FLOAT(OFS_RETURN+0) = -(cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = -(cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+2) = -((cl.lerpents[entnum].entstate->solid>>5) & 31); + break; + case GE_MAXS: + G_FLOAT(OFS_RETURN+0) = (cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = (cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = ((cl.lerpents[entnum].entstate->solid>>10) & 63) - 32; + break; + case GE_ABSMIN: + G_FLOAT(OFS_RETURN+0) = cl.lerpents[entnum].origin[0] + -(cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = cl.lerpents[entnum].origin[1] + -(cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+2) = cl.lerpents[entnum].origin[2] + -((cl.lerpents[entnum].entstate->solid>>5) & 31); + break; + case GE_ABSMAX: + G_FLOAT(OFS_RETURN+0) = cl.lerpents[entnum].origin[0] + (cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = cl.lerpents[entnum].origin[1] + (cl.lerpents[entnum].entstate->solid & 31); + G_FLOAT(OFS_RETURN+1) = cl.lerpents[entnum].origin[2] + ((cl.lerpents[entnum].entstate->solid>>10) & 63) - 32; + break; + case GE_ORIGINANDVECTORS: + VectorCopy(cl.lerpents[entnum].origin, G_VECTOR(OFS_RETURN)); + AngleVectors(cl.lerpents[entnum].angles, csqcg.forward, csqcg.right, csqcg.up); + break; + case GE_FORWARD: + AngleVectors(cl.lerpents[entnum].angles, G_VECTOR(OFS_RETURN), NULL, NULL); + break; + case GE_RIGHT: + AngleVectors(cl.lerpents[entnum].angles, NULL, G_VECTOR(OFS_RETURN), NULL); + break; + case GE_UP: + AngleVectors(cl.lerpents[entnum].angles, NULL, NULL, G_VECTOR(OFS_RETURN)); + break; + case GE_PANTSCOLOR: + if (cl.lerpents[entnum].entstate->colormap <= cl.allocated_client_slots && !(cl.lerpents[entnum].entstate->dpflags & RENDER_COLORMAPPED)) + G_FLOAT(OFS_RETURN) = cl.players[cl.lerpents[entnum].entstate->colormap].tbottomcolor; + else + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->colormap & 15; + break; + case GE_SHIRTCOLOR: + if (cl.lerpents[entnum].entstate->colormap <= cl.allocated_client_slots && !(cl.lerpents[entnum].entstate->dpflags & RENDER_COLORMAPPED)) + G_FLOAT(OFS_RETURN) = cl.players[cl.lerpents[entnum].entstate->colormap].ttopcolor; + else + G_FLOAT(OFS_RETURN) = cl.lerpents[entnum].entstate->colormap>>4; + break; + default: + Con_Printf("PF_getentity: field %i is not supported\n", fldnum); + VectorCopy(vec3_origin, G_VECTOR(OFS_RETURN)); + break; + } +} + #if 1 @@ -4505,11 +4600,14 @@ static struct { //DP_SV_WRITEPICTURE {"WritePicture", PF_ReadPicture, 501}, // #501 void(float to, string s, float sz) WritePicture - //no 502 documented +// {"boxparticles", PF_Fixme, 502}, //DP_QC_WHICHPACK {"whichpack", PF_whichpack, 503}, // #503 string(string filename) whichpack +//DP_CSQC_QUERYRENDERENTITY + {"getentity", PF_getentity, 504}, // #504 __variant(float entnum, fload fieldnum) getentity + //DP_QC_URI_ESCAPE {"uri_escape", PF_uri_escape, 510}, // #510 string(string in) uri_escape {"uri_unescape", PF_uri_unescape, 511}, // #511 string(string in) uri_unescape = #511; diff --git a/engine/common/pr_common.h b/engine/common/pr_common.h index e91d24e52..90b9f6dfd 100644 --- a/engine/common/pr_common.h +++ b/engine/common/pr_common.h @@ -475,3 +475,25 @@ enum csqc_input_event CSIE_MOUSEABS = 3, /*x, y, devid*/ CSIE_ACCELEROMETER = 4 /*x, y, z*/ }; + +enum +{ + GE_MAXENTS = -1, + GE_ACTIVE = 0, + GE_ORIGIN = 1, + GE_FORWARD = 2, + GE_RIGHT = 3, + GE_UP = 4, + GE_SCALE = 5, + GE_ORIGINANDVECTORS = 6, + GE_ALPHA = 7, + GE_COLORMOD = 8, + GE_PANTSCOLOR = 9, + GE_SHIRTCOLOR = 10, + GE_SKIN = 11, + GE_MINS = 12, + GE_MAXS = 13, + GE_ABSMIN = 14, + GE_ABSMAX = 15, + GE_LIGHT = 16 +}; \ No newline at end of file diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index a30bd0e5b..162314d32 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -9221,7 +9221,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs //DP_QC_WHICHPACK {"whichpack", PF_whichpack, 0, 0, 0, 503, "string(string filename)"},// //DP_CSQC_QUERYRENDERENTITY - {"getentity", PF_Fixme, 0, 0, 0, 504 "__variant(float entnum, fload fieldnum)"}, + {"getentity", PF_Fixme, 0, 0, 0, 504, "__variant(float entnum, fload fieldnum)"}, //DP_QC_URI_ESCAPE {"uri_escape", PF_uri_escape, 0, 0, 0, 510, "string(string in)"},//