GoldSrc Networking, Part 4: The Client -- Prediction & Interpolation
How the GoldSrc client reconstructs snapshots, interpolates other players, replays your commands, and corrects prediction errors. Part 4 of a four-part reverse-engineering series.
A Counter-Strike 1.6 server can send 20 updates per second while the client renders 100 frames. The client fills the intervals between updates in two different ways: it predicts the local player's movement from input and interpolates other players' movement from received positions.
Prediction makes local controls respond before the server confirms the result. Interpolation produces smooth remote movement despite the lower update rate, at the cost of displaying it slightly in the past. These two processes account for much of the difference between the server's current state and the frame shown on screen.
This final part of the series covers how the client reconstructs server updates, uses them for rendering and prediction, and corrects its results. Part 3 covers the server side of the same exchange.
GoldSrc Networking series, Part 4 of 4:
- Part 1: The High-Level Overview: the client-server model and the networking stack.
- Part 2: Transmission: packets, reliability, bit serialization, and deltas.
- Part 3: The Server: snapshots, movement commands, and lag compensation.
- 👉 (this article) Part 4: The Client -- Prediction & Interpolation: snapshot parsing, interpolation, prediction, and correction.
Snapshot Histories and Delta Recovery¶
The server update is the common starting point for prediction and rendering, but each uses a different part of it. The local player and weapon state arrives through svc_clientdata; the surrounding players and objects arrive through svc_packetentities or svc_deltapacketentities. These share the packet with the sound, HUD, and other messages covered in Part 2. A delta entity update contains changes relative to an earlier snapshot, so the client has to reconstruct that state before using it.
In multiplayer, the client stores decoded snapshots in a 64-slot ring buffer1. A delta update identifies the earlier snapshot needed to reconstruct its state. The server maintains a corresponding history for each client and can choose a reference that the client has acknowledged.
Once reconstructed, the update becomes part of two different calculations. Prediction advances the local player from the confirmed state using commands already entered. Remote rendering uses the received positions to extend each entity's movement history. That history lets the client draw between updates, although a turn that happened entirely between two samples remains unknown to it.
flowchart TB
local["svc_clientdata<br/>Player and weapon state"] --> snapshot["Reconstruct snapshot"]
entities["svc_packetentities or svc_deltapacketentities<br/>Visible entity states"] --> snapshot
snapshot -->|save for later deltas| ring[("64-slot snapshot ring")]
snapshot -->|local state| predict["Replay pending commands<br/>for local prediction"]
snapshot -->|entity states| positions[("Per-entity position histories")]
positions --> render["Interpolate remote entities<br/>for rendering"]
classDef message fill:#22303f,stroke:#3d5a80,color:#e0e6ed;
classDef process fill:#2d3b52,stroke:#5a7db0,color:#eef2f7;
classDef history fill:#263a3e,stroke:#559482,color:#eef7f4;
class local,entities message
class snapshot,predict,render process
class ring,positions history
Decoded server state supplies snapshot history, local prediction, and remote-entity rendering.
A Missing Delta Reference Requires an Independent Update¶
Delta compression makes earlier snapshots part of the decoding process. Losing a packet therefore matters less than losing the particular reference a later update depends on. Because the server can encode against an older acknowledged snapshot, a gap in delivery does not necessarily prevent the client from reconstructing the updates that follow.
Acknowledgments let the server select a reference the client has received. If that reference is too old or otherwise unusable, the client rejects the entity frame and stops advertising a valid delta reference. The server must then supply an update that can be decoded independently of the previous snapshots.
This independent update can still use entity baselines and field compression. “Full” describes its independence from an earlier snapshot, rather than an uncompressed copy of every object in the map.
Remote Player Interpolation and Extrapolation¶
At 20 updates per second, remote positions arrive roughly 50 ms apart. A client rendering at 100 FPS produces a frame every 10 ms. Displaying only the received positions would leave each player stationary for several frames before jumping to the next update.
Interpolation calculates a position between two recorded samples for each rendered frame. The later sample must already be available, which is why the renderer uses a time in the past. The stored positions then describe movement on both sides of the time being drawn.

Position samples arrive every 50 ms; interpolation supplies positions for the rendered frames between them.
The ex_interp Render Delay¶
In build 8684, remote players are drawn at the client's current time minus ex_interp, whose default is 0.1 seconds. This delay gives updates time to arrive before their positions are needed for rendering.
The history can contain several records newer than the target time, but a rendered position uses the two adjacent samples surrounding that time. At client time 10.02 s, a 100 ms delay produces a render time of 9.92 s. Samples at 9.90 and 9.95 s provide the endpoints; the rendered position lies 40% of the way between them.

The renderer uses the samples at 9.90 and 9.95 s to draw 9.92 s. In this example, 9.95 s is the latest received position.
The two selected samples can both be older than the latest received update. They are chosen by their timestamps, with the pair changing as render time advances through the history. This separates the benefit of frequent updates from the benefit of delay: more samples describe movement in greater detail, while waiting gives those samples time to arrive. Once render time passes the newest available record, interpolation gives way to extrapolation.
The displayed remote position is also affected by network latency: even the latest received update describes an earlier server state. Lag compensation accounts for both latency and the reported interpolation delay when selecting the server time used for a hit test. The server-side calculation from Part 3 is:
targettime = realtime - clientLatency - cl_interptime + sv_unlagpush
Here, cl_interptime represents the interpolation delay reported to the server. The local player follows the prediction path instead of this delayed remote-player path.
Teleports and Model Types Break the Interpolation Rule¶
Interpolation assumes that the positions between its endpoints represent plausible movement. A teleport breaks that assumption, so GoldSrc treats a remote player's position change of more than 128 units on any one axis as a teleport2. It resets the position history and seeds it from a stored sample. The server can also request a reset.
Doors, platforms, and projectiles follow paths determined by their model and movement types. Some blend recorded positions; others calculate movement from a starting point, destination, and travel time3. Brush models have an additional condition: r_bmodelinterp controls whether they use the brush-model interpolation path.
The implementation also explains why local testing can produce different movement from an online connection. For non-brush MOVETYPE_STEP entities without parametric movement3, Counter-Strike and Condition Zero use model interpolation remotely but copy the current position directly on loopback. That difference comes from the connection check itself:
isCstrike = (g_bIsCStrike || g_bIsCZero) ? TRUE : FALSE;
if ((m == MOVETYPE_NONE || m == MOVETYPE_WALK ||
m == MOVETYPE_FLY || m == MOVETYPE_STEP) &&
(!isCstrike || m != MOVETYPE_STEP || UserIsConnectedOnLoopback()))
{
VectorCopy(ent->curstate.origin, ent->origin);
VectorCopy(ent->curstate.angles, ent->angles);
}
else
{
CL_InterpolateModel(ent);
}
The Latency Trade-Off in ex_interp¶
A smaller ex_interp displays more recent movement but leaves less time for the later sample to arrive. A larger delay tolerates more variation in update delivery while displaying older positions. The setting changes the render time, not the frequency of incoming samples: at 20 updates per second, those samples remain roughly 50 ms apart.
This dependence on update frequency is reflected in the limits applied by build 8684. The minimum delay is roughly one requested update interval, calculated from cl_updaterate4; lower values are raised with some rounding tolerance. The upper limits are 100 ms for a normal player and 200 ms for a spectator. Since these checks use the requested rate, uneven or slower delivery can still leave the renderer without both samples.
lerp_msec and Hit Registration¶
lerp_msec is a field in each client movement command that reports the interpolation delay in milliseconds. The server uses it to account for the age of the displayed player positions when performing lag compensation.
A shot is aimed at an interpolated position, and the firing command takes additional time to reach the server. Testing only against the server's current positions would ignore both delays. As described in Part 3, the server rewinds player positions using its measured latency and the stored interpolation report before testing the shot.
There is a small timing distinction here: the hit test uses the interpolation report already stored on the server. The report arriving with the new commands is stored only after that batch runs. A change in the client's reported delay therefore affects later processing rather than the batch carrying it.
sequenceDiagram
participant Server as GoldSrc server
participant Client as GoldSrc client
Server-->>Client: Remote player position samples
Client->>Client: Draw at client time minus ex_interp
Client->>Server: Firing command containing lerp_msec
Server->>Server: Rewind using measured latency and last stored lerp_msec
Server->>Server: Test shot against rewound player
Server->>Server: Store new lerp_msec for later commands
The server uses the stored interpolation report for the hit test, then stores the new report for later commands.
Local Movement Prediction and Command Replay¶
Client-side prediction applies local input before the server confirms it. The client has the player's commands, the map, and the movement rules, allowing it to calculate movement immediately while the server processes the same commands independently.
Waiting for confirmation would make the response to every movement depend on a network round trip, plus server processing and update scheduling. The outbound and return delays need not be equal5, but both contribute to that wait. Prediction allows the initial response to happen locally, with later server updates supplying the authoritative state for correction.
Shared Movement Physics and Command Replay¶
The shared movement code makes this possible without maintaining a separate approximation of the server's physics. Acceleration, friction, gravity, and collisions follow the same rules on both sides. Each command covers a short interval, whose duration becomes the simulation step in PM_PlayerMove:
pmove->frametime = pmove->cmd.msec * 0.001;
The conversion from milliseconds to seconds ties the simulated movement to the command's duration. Replay runs that interval again from the state supplied by the server, including velocity, ground contact, and duck or water state. Correcting only the position would leave other inputs to the movement calculation inconsistent.
By the time a server update arrives, local prediction has usually advanced beyond it. The client therefore uses the confirmed state as a starting point and replays the commands that remain unacknowledged6. This preserves the movement performed since that update while incorporating the server's correction. The saved prediction for the acknowledged command also gives the client a direct comparison with the server's result.
Shared physics does not eliminate prediction errors, because the two sides can have different collision data. The client uses the entity positions it has received, including other players when cl_solid_players is enabled. The server may already have those players or moving platforms somewhere else. The same input can consequently produce different movement, which the next server update corrects.
The client can also interpolate between adjacent local prediction results for rendering. That smoothing belongs to local prediction; it does not use the delayed remote-player history.
Weapon Prediction and Effects during Replay¶
Firing and reloading use the same approach to avoid waiting for confirmation. Counter-Strike updates ammunition, attack timers, and the visible weapon locally, then recalculates that state when commands are replayed from a server update. The command's random seed is reused as well, so replay does not introduce a different random result into an otherwise identical calculation.
Replay introduces a problem for sounds and animations: the same firing command may be calculated several times, even though it represents one shot. GoldSrc tracks whether a command's effects have already run. The runfuncs argument passed to HUD_PostRunCmd lets weapon prediction update its state without repeating those effects7. Footsteps follow the same principle: replay still updates which foot steps next, but skips audio that has already played.
The separation between simulation and effects matters even within a single engine frame. A server packet can supply a new starting state and trigger another prediction pass before rendering. Movement and weapon state are then calculated again, while the effects already produced by those commands remain suppressed.
Hit detection and damage remain server decisions. There is also a connection between weapon prediction and lag compensation: Counter-Strike's server checks both cl_lw, the weapon-prediction setting, and cl_lc, the lag-compensation preference. Disabling either skips the rewind even with sv_unlag enabled, so cl_lw affects more than the local weapon presentation.
Prediction Errors and Visual Correction¶
A prediction error is the difference between the server-confirmed position and the client's saved prediction for the same command. Comparing corresponding points in command history matters because the client's current prediction has usually advanced beyond the state described by an incoming update.
The confirmed state becomes the starting point for replay. GoldSrc then handles the visible correction separately, allowing small differences to be smoothed without delaying the corrected simulation.
Prediction Error Thresholds: 0.25 and 64 Units¶
In multiplayer, prediction errors above 0.25 and up to 64 units start the visual correction timer. Errors above 64 units clear the stored prediction-error vector without starting a new timer8. That branch does not cancel an existing timer, so smoothing already in progress may continue.
This 64-unit threshold applies to local prediction errors. The separate 128-unit per-axis check resets remote-player interpolation history after a suspected teleport.
With cl_showerror enabled, prediction errors above 0.5 and up to 64 units appear as on-screen diagnostic messages. Errors above 0.25 and up to 0.5 units can trigger smoothing without displaying a message; errors above 64 units take the separate branch and are not reported either.
cl_smoothtime Changes How Correction Looks¶
cl_smoothtime controls how long the visual correction lasts, with a default of 0.1 seconds. Replay uses the corrected server state immediately, while the displayed position blends toward the new prediction over subsequent frames.
Because smoothing happens after replay, its duration affects how the correction looks without improving the prediction itself. A longer interval spreads the visible adjustment over more frames; cl_nosmooth disables the blend. In either case, the simulation already uses the corrected state.
The correction also has to account for prediction running more than once per frame. A second pass after a server packet leaves the smoothing timer unchanged, so the extra calculation does not shorten the blend. Movement on a moving ground entity can cancel smoothing altogether.
Conclusion¶
And that completes the four parts. We started with GoldSrc's Quake foundations and followed the networking code from the socket to the frame on screen. What stands out across the series is how much of the design depends on retaining earlier state. Acknowledgments establish what arrived, snapshots provide references for delta compression, and movement histories let both sides calculate positions at a different point in time.
Part 1 outlined the client-server model and the layers inherited from Quake. Part 2 covered how those layers carry the data: UDP, the NetChannel, bit packing, and delta compression. The bandwidth savings come with dependencies. A delta needs its reference state, reliable data needs acknowledgment, and both sides need the same field definitions to decode the stream.
Part 3 showed how the server uses that machinery to process commands, build a separate update for each client, and rewind players for hit detection. The client side completes the explanation. Local movement is predicted ahead of confirmation, remote movement is drawn from older samples, and server updates correct the differences. The frame being displayed therefore contains positions calculated for different times, even though they appear together on screen.
That is also why there is no single setting that removes every kind of delay. Sending updates more often cannot eliminate their travel time. Reducing interpolation leaves less time for the next sample to arrive. Prediction makes local input responsive, but its result still depends on state that the server may later correct. Lag compensation accounts for the delayed view when testing a shot, while leaving the consequences of that rewind visible to the other player.
GoldSrc makes these compromises throughout the stack, from the number of bits used for a field to the time chosen for a hit test. Looking at the implementation makes the familiar effects of online play much less mysterious: smooth movement, corrections, and disagreements over a hit all follow from how the engine handles information that arrives late or incomplete.
Thanks for reading! ☕
-
The buffer holds 64 snapshots; the time they cover depends on how frequently usable snapshots arrive. ↩
-
The check applies to each axis separately. A displacement of 127 units on both X and Y exceeds 128 units diagonally but does not trigger this check. ↩
-
Parametric movement calculates an entity's position from a starting point, destination, and start/end times, rather than interpolating between received position-history records. ↩↩
-
cl_updateratespecifies the requested server update rate. Actual updates may arrive less frequently or unevenly. ↩ -
Round-trip time measures the combined outbound and return delay; it does not establish the latency in either direction separately. ↩
-
Backup commands can be sent again in later packets to cover loss. Replay is about which commands the server has processed, not simply which commands the client has transmitted once. ↩
-
This distinction applies to local presentation during replay. It does not turn a locally predicted attack into a server-confirmed hit; the server still runs its own command and hit test. ↩
-
The prediction-error vector and the smoothing timer are separate. Clearing the vector does not reset the timer; replay still uses the server-confirmed state. ↩