From 7f8bd47500a38009d5ca88f96c0037ba0615e10c Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Wed, 10 Jun 2020 13:13:10 -0400 Subject: [PATCH] Implement EXT_WRATH fields --- clvm_cmds.c | 24 ++++++++++++++---------- prvm_offsets.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ sv_move.c | 17 ++++++++++------- sv_phys.c | 9 ++++++--- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index bf915331..19980cab 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -592,12 +592,13 @@ static void VM_CL_checkbottom (prvm_prog_t *prog) vec3_t mins, maxs, start, stop; trace_t trace; int x, y; - float mid, bottom; + float mid, bottom, stepheight; VM_SAFEPARMCOUNT(1, VM_CL_checkbottom); ent = PRVM_G_EDICT(OFS_PARM0); PRVM_G_FLOAT(OFS_RETURN) = 0; + stepheight = sv_stepheight.value + PRVM_clientedictfloat(ent, stepheight_delta); VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins); VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs); @@ -628,7 +629,7 @@ realcheck: // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0])*0.5; start[1] = stop[1] = (mins[1] + maxs[1])*0.5; - stop[2] = start[2] - 2*sv_stepheight.value; + stop[2] = start[2] - 2*stepheight; trace = CL_TraceLine(start, stop, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, true, true, NULL, true, false); if (trace.fraction == 1.0) @@ -647,7 +648,7 @@ realcheck: if (trace.fraction != 1.0 && trace.endpos[2] > bottom) bottom = trace.endpos[2]; - if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value) + if (trace.fraction == 1.0 || mid - trace.endpos[2] > stepheight) return; } @@ -3432,8 +3433,9 @@ static qboolean CL_CheckBottom (prvm_edict_t *ent) vec3_t mins, maxs, start, stop; trace_t trace; int x, y; - float mid, bottom; + float mid, bottom, stepheight; + stepheight = sv_stepheight.value + PRVM_clientedictfloat(ent, stepheight_delta); VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, mins), mins); VectorAdd (PRVM_clientedictvector(ent, origin), PRVM_clientedictvector(ent, maxs), maxs); @@ -3461,7 +3463,7 @@ realcheck: // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0])*0.5; start[1] = stop[1] = (mins[1] + maxs[1])*0.5; - stop[2] = start[2] - 2*sv_stepheight.value; + stop[2] = start[2] - 2*stepheight; trace = CL_TraceLine(start, stop, MOVE_NOMONSTERS, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, true, false, NULL, true, false); if (trace.fraction == 1.0) @@ -3479,7 +3481,7 @@ realcheck: if (trace.fraction != 1.0 && trace.endpos[2] > bottom) bottom = trace.endpos[2]; - if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value) + if (trace.fraction == 1.0 || mid - trace.endpos[2] > stepheight) return false; } @@ -3498,13 +3500,15 @@ possible, no move is done and false is returned static qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace) { prvm_prog_t *prog = CLVM_prog; - float dz; + float dz, stepheight; vec3_t oldorg, neworg, end, traceendpos; vec3_t mins, maxs, start; trace_t trace; int i, svent; prvm_edict_t *enemy; + stepheight = sv_stepheight.value + PRVM_clientedictfloat(ent, stepheight_delta); + // try the move VectorCopy(PRVM_clientedictvector(ent, mins), mins); VectorCopy(PRVM_clientedictvector(ent, maxs), maxs); @@ -3552,9 +3556,9 @@ static qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qb } // push down from a step height above the wished position - neworg[2] += sv_stepheight.value; + neworg[2] += stepheight; VectorCopy (neworg, end); - end[2] -= sv_stepheight.value*2; + end[2] -= stepheight*2; trace = CL_TraceBox(neworg, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, true, true, &svent, true); if (settrace) @@ -3562,7 +3566,7 @@ static qboolean CL_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qb if (trace.startsolid) { - neworg[2] -= sv_stepheight.value; + neworg[2] -= stepheight; trace = CL_TraceBox(neworg, mins, maxs, end, MOVE_NORMAL, ent, CL_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value, true, true, &svent, true); if (settrace) CL_VM_SetTraceGlobals(prog, &trace, svent); diff --git a/prvm_offsets.h b/prvm_offsets.h index 5eada948..cd0f0f37 100644 --- a/prvm_offsets.h +++ b/prvm_offsets.h @@ -48,6 +48,7 @@ PRVM_DECLARE_clientfieldfloat(shadertime) PRVM_DECLARE_clientfieldfloat(skeletonindex) PRVM_DECLARE_clientfieldfloat(skin) PRVM_DECLARE_clientfieldfloat(solid) +PRVM_DECLARE_clientfieldfloat(stepheight_delta) PRVM_DECLARE_clientfieldfloat(tag_index) PRVM_DECLARE_clientfieldfloat(userwavefunc_param0) PRVM_DECLARE_clientfieldfloat(userwavefunc_param1) @@ -372,6 +373,7 @@ PRVM_DECLARE_field(skin) PRVM_DECLARE_field(solid) PRVM_DECLARE_field(sounds) PRVM_DECLARE_field(spawnflags) +PRVM_DECLARE_field(stepheight_delta) PRVM_DECLARE_field(style) PRVM_DECLARE_field(tag_entity) PRVM_DECLARE_field(tag_index) @@ -504,6 +506,54 @@ PRVM_DECLARE_global(parm13) PRVM_DECLARE_global(parm14) PRVM_DECLARE_global(parm15) PRVM_DECLARE_global(parm16) +PRVM_DECLARE_global(parm17) +PRVM_DECLARE_global(parm18) +PRVM_DECLARE_global(parm19) +PRVM_DECLARE_global(parm20) +PRVM_DECLARE_global(parm21) +PRVM_DECLARE_global(parm22) +PRVM_DECLARE_global(parm23) +PRVM_DECLARE_global(parm24) +PRVM_DECLARE_global(parm25) +PRVM_DECLARE_global(parm26) +PRVM_DECLARE_global(parm27) +PRVM_DECLARE_global(parm28) +PRVM_DECLARE_global(parm29) +PRVM_DECLARE_global(parm30) +PRVM_DECLARE_global(parm31) +PRVM_DECLARE_global(parm32) +PRVM_DECLARE_global(parm33) +PRVM_DECLARE_global(parm34) +PRVM_DECLARE_global(parm35) +PRVM_DECLARE_global(parm36) +PRVM_DECLARE_global(parm37) +PRVM_DECLARE_global(parm38) +PRVM_DECLARE_global(parm39) +PRVM_DECLARE_global(parm40) +PRVM_DECLARE_global(parm41) +PRVM_DECLARE_global(parm42) +PRVM_DECLARE_global(parm43) +PRVM_DECLARE_global(parm44) +PRVM_DECLARE_global(parm45) +PRVM_DECLARE_global(parm46) +PRVM_DECLARE_global(parm47) +PRVM_DECLARE_global(parm48) +PRVM_DECLARE_global(parm49) +PRVM_DECLARE_global(parm50) +PRVM_DECLARE_global(parm51) +PRVM_DECLARE_global(parm52) +PRVM_DECLARE_global(parm53) +PRVM_DECLARE_global(parm54) +PRVM_DECLARE_global(parm55) +PRVM_DECLARE_global(parm56) +PRVM_DECLARE_global(parm57) +PRVM_DECLARE_global(parm58) +PRVM_DECLARE_global(parm59) +PRVM_DECLARE_global(parm60) +PRVM_DECLARE_global(parm61) +PRVM_DECLARE_global(parm62) +PRVM_DECLARE_global(parm63) +PRVM_DECLARE_global(parm64) PRVM_DECLARE_global(particle_airfriction) PRVM_DECLARE_global(particle_alpha) PRVM_DECLARE_global(particle_alphafade) @@ -715,6 +765,7 @@ PRVM_DECLARE_serverfieldfloat(skin) PRVM_DECLARE_serverfieldfloat(solid) PRVM_DECLARE_serverfieldfloat(sounds) PRVM_DECLARE_serverfieldfloat(spawnflags) +PRVM_DECLARE_serverfieldfloat(stepheight_delta) PRVM_DECLARE_serverfieldfloat(style) PRVM_DECLARE_serverfieldfloat(tag_index) PRVM_DECLARE_serverfieldfloat(takedamage) diff --git a/sv_move.c b/sv_move.c index ced05ac1..8d99e92a 100644 --- a/sv_move.c +++ b/sv_move.c @@ -39,8 +39,9 @@ qboolean SV_CheckBottom (prvm_edict_t *ent) vec3_t mins, maxs, start, stop; trace_t trace; int x, y; - float mid, bottom; + float mid, bottom, stepheight; + stepheight = sv_stepheight.value + PRVM_serveredictfloat(ent, stepheight_delta); VectorAdd (PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, mins), mins); VectorAdd (PRVM_serveredictvector(ent, origin), PRVM_serveredictvector(ent, maxs), maxs); @@ -70,7 +71,7 @@ realcheck: // the midpoint must be within 16 of the bottom start[0] = stop[0] = (mins[0] + maxs[0])*0.5; start[1] = stop[1] = (mins[1] + maxs[1])*0.5; - stop[2] = start[2] - 2*sv_stepheight.value; + stop[2] = start[2] - 2*stepheight; trace = SV_TraceLine(start, stop, MOVE_NOMONSTERS, ent, SV_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value); if (trace.fraction == 1.0) @@ -88,7 +89,7 @@ realcheck: if (trace.fraction != 1.0 && trace.endpos[2] > bottom) bottom = trace.endpos[2]; - if (trace.fraction == 1.0 || mid - trace.endpos[2] > sv_stepheight.value) + if (trace.fraction == 1.0 || mid - trace.endpos[2] > stepheight) return false; } @@ -109,12 +110,14 @@ possible, no move is done and false is returned qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean noenemy, qboolean settrace) { prvm_prog_t *prog = SVVM_prog; - float dz; + float dz, stepheight; vec3_t oldorg, neworg, end, traceendpos, entorigin, entmins, entmaxs; trace_t trace; int i; prvm_edict_t *enemy; + stepheight = sv_stepheight.value + PRVM_serveredictfloat(ent, stepheight_delta); + // try the move VectorCopy (PRVM_serveredictvector(ent, origin), oldorg); VectorAdd (PRVM_serveredictvector(ent, origin), move, neworg); @@ -168,15 +171,15 @@ qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink, qboolean } // push down from a step height above the wished position - neworg[2] += sv_stepheight.value; + neworg[2] += stepheight; VectorCopy (neworg, end); - end[2] -= sv_stepheight.value*2; + end[2] -= stepheight*2; trace = SV_TraceBox(neworg, entmins, entmaxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value); if (trace.startsolid) { - neworg[2] -= sv_stepheight.value; + neworg[2] -= stepheight; trace = SV_TraceBox(neworg, entmins, entmaxs, end, MOVE_NORMAL, ent, SV_GenericHitSuperContentsMask(ent), 0, 0, collision_extendmovelength.value); if (trace.startsolid) return false; diff --git a/sv_phys.c b/sv_phys.c index 3c58d62d..ef8e707f 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -2312,6 +2312,7 @@ static void SV_WalkMove (prvm_edict_t *ent) vec3_t upmove, downmove, start_origin, start_velocity, stepnormal, originalmove_origin, originalmove_velocity, entmins, entmaxs; trace_t downtrace, trace; qboolean applygravity; + float stepheight; // if frametime is 0 (due to client sending the same timestamp twice), // don't move @@ -2321,6 +2322,8 @@ static void SV_WalkMove (prvm_edict_t *ent) if (sv_gameplayfix_unstickplayers.integer) SV_CheckStuck (ent); + stepheight = sv_stepheight.value + PRVM_serveredictfloat(ent, stepheight_delta); + applygravity = !SV_CheckWater (ent) && PRVM_serveredictfloat(ent, movetype) == MOVETYPE_WALK && ! ((int)PRVM_serveredictfloat(ent, flags) & FL_WATERJUMP); SV_CheckVelocity(ent); @@ -2331,7 +2334,7 @@ static void SV_WalkMove (prvm_edict_t *ent) VectorCopy (PRVM_serveredictvector(ent, origin), start_origin); VectorCopy (PRVM_serveredictvector(ent, velocity), start_velocity); - clip = SV_FlyMove (ent, sv.frametime, applygravity, NULL, hitsupercontentsmask, skipsupercontentsmask, skipmaterialflagsmask, sv_gameplayfix_stepmultipletimes.integer ? sv_stepheight.value : 0); + clip = SV_FlyMove (ent, sv.frametime, applygravity, NULL, hitsupercontentsmask, skipsupercontentsmask, skipmaterialflagsmask, sv_gameplayfix_stepmultipletimes.integer ? stepheight : 0); if(sv_gameplayfix_downtracesupportsongroundflag.integer) if(!(clip & 1)) @@ -2405,7 +2408,7 @@ static void SV_WalkMove (prvm_edict_t *ent) // move up VectorClear (upmove); - upmove[2] = sv_stepheight.value; + upmove[2] = stepheight; if(!SV_PushEntity(&trace, ent, upmove, true)) { // we got teleported when upstepping... must abort the move @@ -2457,7 +2460,7 @@ static void SV_WalkMove (prvm_edict_t *ent) // move down VectorClear (downmove); - downmove[2] = -sv_stepheight.value + start_velocity[2]*sv.frametime; + downmove[2] = -stepheight + start_velocity[2]*sv.frametime; if(!SV_PushEntity (&downtrace, ent, downmove, true)) { // we got teleported when downstepping... must abort the move -- 2.39.2