Skip to content

Commit

Permalink
Move SV_CheckMovingGround into SV_Physics (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm authored Dec 9, 2024
1 parent e83b324 commit 4afb6e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 35 deletions.
23 changes: 1 addition & 22 deletions rehlds/engine/sv_phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1491,28 +1491,7 @@ void SV_Physics()
if (i > 0 && i <= g_psvs.maxclients)
continue;

if (ent->v.flags & FL_ONGROUND)
{
edict_t *groundentity = ent->v.groundentity;
if (groundentity && (groundentity->v.flags & FL_CONVEYOR))
{
if (ent->v.flags & FL_BASEVELOCITY)
VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity);
else
VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity);

ent->v.flags |= FL_BASEVELOCITY;
}
}

if (!(ent->v.flags & FL_BASEVELOCITY))
{
// Apply momentum (add in half of the previous frame of velocity first)
VectorMA(ent->v.velocity, (host_frametime * 0.5f + 1.0f), ent->v.basevelocity, ent->v.velocity);
VectorClear(ent->v.basevelocity);
}

ent->v.flags &= ~FL_BASEVELOCITY;
SV_CheckMovingGround(ent, host_frametime);

switch (ent->v.movetype)
{
Expand Down
24 changes: 11 additions & 13 deletions rehlds/engine/sv_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,35 +686,33 @@ qboolean SV_PlayerRunThink(edict_t *ent, float frametime, double clienttimebase)
return ent->free == 0;
}

void SV_CheckMovingGround(edict_t *player, float frametime)
void SV_CheckMovingGround(edict_t *ent, float frametime)
{
edict_t *groundentity;

if (player->v.flags & FL_ONGROUND)
if (ent->v.flags & FL_ONGROUND)
{
groundentity = player->v.groundentity;
groundentity = ent->v.groundentity;
if (groundentity)
{
if (groundentity->v.flags & FL_CONVEYOR)
{
if (player->v.flags & FL_BASEVELOCITY)
VectorMA(player->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, player->v.basevelocity);
if (ent->v.flags & FL_BASEVELOCITY)
VectorMA(ent->v.basevelocity, groundentity->v.speed, groundentity->v.movedir, ent->v.basevelocity);
else
VectorScale(groundentity->v.movedir, groundentity->v.speed, player->v.basevelocity);
player->v.flags |= FL_BASEVELOCITY;
VectorScale(groundentity->v.movedir, groundentity->v.speed, ent->v.basevelocity);
ent->v.flags |= FL_BASEVELOCITY;
}
}
}

if (!(player->v.flags & FL_BASEVELOCITY))
if (!(ent->v.flags & FL_BASEVELOCITY))
{
VectorMA(player->v.velocity, frametime * 0.5f + 1.0f, player->v.basevelocity, player->v.velocity);
player->v.basevelocity[0] = 0;
player->v.basevelocity[1] = 0;
player->v.basevelocity[2] = 0;
VectorMA(ent->v.velocity, frametime * 0.5f + 1.0f, ent->v.basevelocity, ent->v.velocity);
VectorClear(ent->v.basevelocity);
}

player->v.flags &= ~FL_BASEVELOCITY;
ent->v.flags &= ~FL_BASEVELOCITY;
}

void SV_ConvertPMTrace(trace_t *dest, pmtrace_t *src, edict_t *ent)
Expand Down

0 comments on commit 4afb6e3

Please sign in to comment.