Skip to content

Commit

Permalink
Add sv_gameplayfix_elevators cvar
Browse files Browse the repository at this point in the history
If an entity is standing on a platform and gets blocked by it,
try nudging it up a bit first to get it unstuck.

Cvar values:
0 = no fix (vanilla behavior)
1 = fix players only
2 = fix all entities (default)
  • Loading branch information
andrei-drexler authored and codeflorist committed Aug 2, 2024
1 parent a8cac22 commit edb41a9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Quake/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void SV_Init (void)
extern cvar_t sv_idealpitchscale;
extern cvar_t sv_aim;
extern cvar_t sv_altnoclip; //johnfitz
extern cvar_t sv_gameplayfix_elevators;

sv.edicts = NULL; // ericw -- sv.edicts switched to use malloc()

Expand All @@ -106,6 +107,7 @@ void SV_Init (void)
Cvar_RegisterVariable (&sv_nostep);
Cvar_RegisterVariable (&sv_freezenonclients);
Cvar_RegisterVariable (&sv_altnoclip); //johnfitz
Cvar_RegisterVariable (&sv_gameplayfix_elevators);

Cmd_AddCommand ("sv_protocol", &SV_Protocol_f); //johnfitz

Expand Down
16 changes: 16 additions & 0 deletions Quake/sv_phys.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ trace_t SV_PushEntity (edict_t *ent, vec3_t push)
SV_PushMove
============
*/
cvar_t sv_gameplayfix_elevators = {"sv_gameplayfix_elevators", "2", CVAR_ARCHIVE}; // 0=off; 1=clients only; 2=all entities
void SV_PushMove (edict_t *pusher, float movetime)
{
int i, e;
Expand Down Expand Up @@ -474,6 +475,7 @@ void SV_PushMove (edict_t *pusher, float movetime)
check = NEXT_EDICT(sv.edicts);
for (e=1 ; e<sv.num_edicts ; e++, check = NEXT_EDICT(check))
{
qboolean riding;
if (check->free)
continue;
if (check->v.movetype == MOVETYPE_PUSH
Expand All @@ -496,7 +498,11 @@ void SV_PushMove (edict_t *pusher, float movetime)
// see if the ent's bbox is inside the pusher's final position
if (!SV_TestEntityPosition (check))
continue;

riding = false;
}
else
riding = true;

// remove the onground flag for non-players
if (check->v.movetype != MOVETYPE_WALK)
Expand Down Expand Up @@ -525,6 +531,16 @@ void SV_PushMove (edict_t *pusher, float movetime)
continue;
}

// try moving the entity up a bit if it's blocked by the pusher while also standing on it
if (riding && block == pusher &&
(sv_gameplayfix_elevators.value >= 2.f ||
(sv_gameplayfix_elevators.value && e <= svs.maxclients)))
{
check->v.origin[2] += DIST_EPSILON;
if (!SV_TestEntityPosition (check))
continue;
}

VectorCopy (entorig, check->v.origin);
SV_LinkEdict (check, true);

Expand Down
2 changes: 1 addition & 1 deletion Quake/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ edict_t *SV_TestEntityPosition (edict_t *ent)
trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, 0, ent);

if (trace.startsolid)
return sv.edicts;
return trace.ent ? trace.ent : sv.edicts;

return NULL;
}
Expand Down

0 comments on commit edb41a9

Please sign in to comment.