mirror of
https://github.com/logsol/chuck.js.git
synced 2026-06-26 00:52:33 +00:00
Remove server reconciliation in favor of pure client prediction
The reconciliation system caused visible teleportation at high latency (e.g. 250ms Germany→Korea): position corrections snapped the local player and thrown items back to stale server states. - Drop the inputAck/seq tracking, InputBuffer, and applyReconciliation. The client predicts locally and the server stays authoritative via the existing worldUpdate broadcast; own-doll updates remain ignored. - Override Item.setUpdateData on the client so in-flight items run free on local Box2D physics (client and server share the same throw impulse) and only sync when stationary or far out of sync. This keeps grab-sensor contact accurate while eliminating mid-flight snapping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a0481ed867
commit
d39a55e20e
8 changed files with 31 additions and 152 deletions
|
|
@ -11,7 +11,6 @@ function(Parent, nc, Parser) {
|
|||
function PlayerController(player) {
|
||||
|
||||
Parent.call(this, player);
|
||||
this._lastProcessedSeq = 0;
|
||||
}
|
||||
|
||||
PlayerController.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -30,14 +29,7 @@ function(Parent, nc, Parser) {
|
|||
}
|
||||
|
||||
for (var command in message) {
|
||||
var commandOptions = message[command];
|
||||
|
||||
// Track sequence number from client input commands
|
||||
if (commandOptions && typeof commandOptions === 'object' && commandOptions._seq !== undefined) {
|
||||
this._lastProcessedSeq = commandOptions._seq;
|
||||
}
|
||||
|
||||
this[command].call(this, commandOptions);
|
||||
this[command].call(this, message[command]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -120,23 +120,6 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player,
|
|||
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);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue