Replace cheat-detection teleport with server reconciliation

The old PUNKBUSTER check compared client-reported position to server
position and snapped the player back when latency made them diverge,
which felt like getting teleported under any real network conditions.

Replaces that with proper client-side prediction + reconciliation:
client tags each input with a sequence number and keeps an input
buffer; server tracks the last processed sequence and reports its
authoritative position via a per-user inputAck alongside each
worldUpdate. The client only corrects when the actual disagreement
exceeds what the unacked input time can explain — so steady-state
movement runs purely on local physics, and only genuine unexpected
events (collisions, being hit) trigger a smooth blend toward the
server state.

Includes adaptive threshold scaling so high-latency sessions don't
false-positive corrections during normal running.
This commit is contained in:
Jeena 2026-05-11 00:37:42 +00:00
parent e6089687ed
commit 71e4b4e847
9 changed files with 162 additions and 149 deletions

View file

@ -113,13 +113,30 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
};
GameController.prototype.updateWorld = function () {
var update = this.getWorldUpdateObject(false);
if(Object.getOwnPropertyNames(update).length > 0) {
nc.trigger(nc.ns.channel.to.client.gameCommand.broadcast, "worldUpdate", update);
}
// Send per-user input acknowledgments for server reconciliation
for (var id in this.players) {
var player = this.players[id];
if (player.isSpawned() && player.playerController._lastProcessedSeq > 0) {
var body = player.doll.body;
nc.trigger(
nc.ns.channel.to.client.user.gameCommand.send + id,
"inputAck",
{
seq: player.playerController._lastProcessedSeq,
p: { x: body.GetPosition().x, y: body.GetPosition().y },
lv: { x: body.GetLinearVelocity().x, y: body.GetLinearVelocity().y }
}
);
}
}
this.worldUpdateTimeout = setTimeout(this.updateWorld.bind(this), Settings.NETWORK_UPDATE_INTERVAL);
};