mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
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:
parent
e6089687ed
commit
71e4b4e847
9 changed files with 162 additions and 149 deletions
37
app/Game/Client/InputBuffer.js
Normal file
37
app/Game/Client/InputBuffer.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
define([
|
||||
],
|
||||
|
||||
function () {
|
||||
|
||||
"use strict";
|
||||
|
||||
var MAX_BUFFER_SIZE = 300;
|
||||
|
||||
function InputBuffer() {
|
||||
this._buffer = [];
|
||||
}
|
||||
|
||||
InputBuffer.prototype.add = function(entry) {
|
||||
this._buffer.push(entry);
|
||||
if (this._buffer.length > MAX_BUFFER_SIZE) {
|
||||
this._buffer.shift();
|
||||
}
|
||||
};
|
||||
|
||||
InputBuffer.prototype.acknowledgeUpTo = function(seq) {
|
||||
while (this._buffer.length > 0 && this._buffer[0].seq <= seq) {
|
||||
this._buffer.shift();
|
||||
}
|
||||
};
|
||||
|
||||
InputBuffer.prototype.getUnacknowledged = function() {
|
||||
return this._buffer;
|
||||
};
|
||||
|
||||
InputBuffer.prototype.clear = function() {
|
||||
this._buffer = [];
|
||||
};
|
||||
|
||||
return InputBuffer;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue