“Lag” Compensation Technique

and code that does it

Neil “haste” Toronto

Introduction

Unlagged started as a mod for me. I don't think there's any shame in that, since it ends up benefitting so many other people at the same time. Still, I probably wouldn't have given the questions a second thought if I had a connection that got me sub-50 pings to a bunch of different servers...

I don't have the most evil of Internet connections, but it really is sporadic sometimes. It's not unusual for my ping to fluctuate between 100 and 150, which does terrible things to my rail aim.

Unlagged 1.0 was an attempt to fix that, using a server-side technique called “backward reconciliation.” Except for a bug in the interpolation code, it worked fairly well.

Unlagged 2.01 started in Ultra Freeze Tag, for which I finally gained a remote test server (thanks, Crimson!) and was able to do some serious debugging. Except for prediction error (which happens when, say, you get hit by a rocket right before you fire), the backward reconciliation is now as perfect as a client-side hit test.

After I finished that, things got out of hand, and here's what it includes now:

Unlagged 2.01 really is an attempt at making Internet play as smooth as possible, and it generally succeeds. I am aware that not everyone (including mod authors) agrees with full lag compensation for instant-hit weapons, and that's fine. You'll definitely want the rest of it even if you don't implement that part. Playing an Unlagged mod without full lag compensation and cl_timenudge at -30 feels almost like playing with 80ms shaved off of your ping.

We'll start by examining some Quake 3 networking fundamentals, both terminology and process. Then I'll describe the problems we're trying to solve and explain the solution we'll apply to them. After that, we finally merge the code in. (Most of it is cut-and-paste, but some of it may need changes made to it, depending on how different your mod is from vanilla Quake 3.) That will be followed by code walk-throughs, tips for testing, descriptions of possible extensions, and common questions and non-technical and technical answers to them.

Next: Quake 3 Networking Primer