Skip to content

Commit

Permalink
Multiplayer RoffSystem Fixes (#1165)
Browse files Browse the repository at this point in the history
* [MP] Fix ROFF system using incorrect time value.

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.

* [MP] Fix roff not working on 64 bit builds.

Change type of mVersion in TROFFHeader and TROFF2Header from long to int.
  • Loading branch information
Daggolin committed Sep 16, 2023
1 parent 802c9b1 commit f90488d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 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
4 changes: 2 additions & 2 deletions codemp/qcommon/RoffSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CROFFSystem
//-------------------------------
{
char mHeader[4]; // should match roff_string defined above
long mVersion; // version num, supported version defined above
int mVersion; // version num, supported version defined above
float mCount; // I think this is a float because of a limitation of the roff exporter

} TROFFHeader;
Expand All @@ -81,7 +81,7 @@ class CROFFSystem
//-------------------------------
{
char mHeader[4]; // should match roff_string defined above
long mVersion; // version num, supported version defined above
int mVersion; // version num, supported version defined above
int mCount; // I think this is a float because of a limitation of the roff exporter
int mFrameRate; // Frame rate the roff should be played at
int mNumNotes; // number of notes (null terminated strings) after the roff data
Expand Down

0 comments on commit f90488d

Please sign in to comment.