Permanent Interp fix


#1

This works for all Source games. I just got an email from Ross who got an email from Valve with a fix to the jittering problem we’ve had, so this way, we don’t need to lower the interp or have to deal with choppy NPC animations. Here’s the email:

The change you need to make is in src/game/client/c_baseentity.cpp.

There is a member function called C_BaseEntity::GetInterpolationAmount(). In the code that I would like to get out the door, we actually call into the engine to find out specific information about any demo that might currently be playing. Since we don’t ship the source code for the engine, you’re going to need to tailor it a bit for your specific case.

The code that will likely ship to the SDK (that relies on calling IsPlayingDemoALocallyRecordedDemo() in the engine) is below. Highlighted are the modified lines from what you have. Let me know if this isn’t the case. Also, note that the final line of this method (the return) is equivalent to what was already there, just cleaner.

float C_BaseEntity::GetInterpolationAmount( int flags )
{
// If single player server is “skipping ticks” everything needs to interpolate for a bit longer
int serverTickMultiple = 1;
if ( IsSimulatingOnAlternateTicks() )
{
serverTickMultiple = 2;
}

  if ( GetPredictable() || IsClientCreated() )
  {
        return TICK_INTERVAL * serverTickMultiple;
  }

  // Always fully interpolate during multi-player or during demo playback, if the recorded
  // demo was recorded locally.
  const bool bPlayingDemo = engine->IsPlayingDemo();
  const bool bPlayingMultiplayer = !bPlayingDemo && ( gpGlobals->maxClients > 1 );
  const bool bPlayingNonLocallyRecordedDemo = bPlayingDemo && !engine->IsPlayingDemoALocallyRecordedDemo();
  if ( bPlayingMultiplayer || bPlayingNonLocallyRecordedDemo )      {
        return AdjustInterpolationAmount( this, TICKS_TO_TIME( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );
  }

  int expandedServerTickMultiple = serverTickMultiple;
  if ( IsEngineThreaded() )
  {
        expandedServerTickMultiple += g_nThreadModeTicks;
  }

  if ( IsAnimatedEveryTick() && IsSimulatedEveryTick() )
  {
        return TICK_INTERVAL * expandedServerTickMultiple;
  }

  if ( ( flags & LATCH_ANIMATION_VAR ) && IsAnimatedEveryTick() )
  {
        return TICK_INTERVAL * expandedServerTickMultiple;
  }
  if ( ( flags & LATCH_SIMULATION_VAR ) && IsSimulatedEveryTick() )
  {
        return TICK_INTERVAL * expandedServerTickMultiple;
  }

  return AdjustInterpolationAmount( this, TICKS_TO_TIME( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );

}
So, I believe the bit you would want to change here is this line:

  const bool bPlayingNonLocallyRecordedDemo = false;

I haven’t looked at this code in a while, so it’s possible that I’ve got it backwards (in which case you’d want to set this to ‘true’), but I’m pretty sure this is what you want.

You could also install a ConVar if you wanted to have control over this for any reason. You would do so by placing a ConVar somewhere else in c_baseentity.cpp and replacing ‘false’ in this case with your_con_var.GetBool().


#2

Sweet. I won’t be able to try it myself until at least late night tomorrow, but if someone else could and would post how it worked it here that’d be great.


#3

The good news is, it compiles!

I’ve put the DLL files into the Dropbox folder, see if they work


#4

Hmm, I’m not sure if that did it on my end.


#5

Oops, I realised that I set it to true, not false, try again (with the files in the other folder)