Skip to content

Commit

Permalink
[MP] Fix ROFF system using incorrect time value.
Browse files Browse the repository at this point in the history
The ROFF system previously used engine time instead of module time when setting the time values for trajectories of shared entities. This caused issues when the server module time has been reset on map change, because the game module would misinterpret the trajectories.
  • Loading branch information
Daggolin committed Sep 16, 2023
1 parent 802c9b1 commit 677d7b1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions codemp/qcommon/RoffSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ qboolean CROFFSystem::Play( int entID, int id, qboolean doTranslation, qboolean

roffing_ent->mEntID = entID;
roffing_ent->mROFFID = id;
roffing_ent->mNextROFFTime = svs.time;
roffing_ent->mNextROFFTime = sv.time;
roffing_ent->mROFFFrame = 0;
roffing_ent->mKill = qfalse;
roffing_ent->mSignal = qtrue; // TODO: hook up the real signal code
Expand Down Expand Up @@ -864,7 +864,7 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff
float *origin = NULL, *angle = NULL;


if ( svs.time < roff_ent->mNextROFFTime )
if ( sv.time < roff_ent->mNextROFFTime )
{ // Not time to roff yet
return qtrue;
}
Expand Down Expand Up @@ -900,8 +900,8 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff

if ( roff_ent->mROFFFrame >= roff->mROFFEntries )
{ // we are done roffing, so stop moving and flag this ent to be removed
SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, svs.time, roff->mLerp );
SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, svs.time, roff->mLerp );
SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, sv.time, roff->mLerp );
SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, sv.time, roff->mLerp );
if (!roff_ent->mIsClient)
{
ent->r.mIsRoffing = qfalse;
Expand All @@ -922,11 +922,11 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff
}

// Set up our origin interpolation
SetLerp( originTrajectory, TR_LINEAR, origin, result, svs.time, roff->mLerp );
SetLerp( originTrajectory, TR_LINEAR, origin, result, sv.time, roff->mLerp );

// Set up our angle interpolation
SetLerp( angleTrajectory, TR_LINEAR, angle,
roff->mMoveRotateList[roff_ent->mROFFFrame].mRotateOffset, svs.time, roff->mLerp );
roff->mMoveRotateList[roff_ent->mROFFFrame].mRotateOffset, sv.time, roff->mLerp );

if (roff->mMoveRotateList[roff_ent->mROFFFrame].mStartNote >= 0)
{
Expand All @@ -940,7 +940,7 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff

// Advance ROFF frames and lock to a 10hz cycle
roff_ent->mROFFFrame++;
roff_ent->mNextROFFTime = svs.time + roff->mFrameTime;
roff_ent->mNextROFFTime = sv.time + roff->mFrameTime;

//rww - npcs need to know when they're getting roff'd
if ( !roff_ent->mIsClient )
Expand Down Expand Up @@ -1044,8 +1044,8 @@ qboolean CROFFSystem::ClearLerp( SROFFEntity *roff_ent )
angle = ent->r.currentAngles;
}

SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, svs.time, ROFF_SAMPLE_RATE );
SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, svs.time, ROFF_SAMPLE_RATE );
SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, sv.time, ROFF_SAMPLE_RATE );
SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, sv.time, ROFF_SAMPLE_RATE );

return qtrue;
}
Expand Down

0 comments on commit 677d7b1

Please sign in to comment.