From a052a414c32ca130bedc4b0b2db79581098d9a0b Mon Sep 17 00:00:00 2001 From: Jeremiah Billmann Date: Sun, 30 Jun 2013 16:05:26 -0400 Subject: [PATCH] Progress: Interpolation Correction --- client/garageserver.io.js | 8 ++++++-- lib/server/garageservergame.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/garageserver.io.js b/client/garageserver.io.js index a256284..34dec2f 100644 --- a/client/garageserver.io.js +++ b/client/garageserver.io.js @@ -21,9 +21,11 @@ window.GarageServerIO = (function (window, socketio) { function StateController() { this.state = {}; this.time; - this.delta; + this.physicsDelta; + this.stateDelta; this.playerId; this.pingDelay = 100; + this.renderTime = 0; this.fps = 0; this.fpsLastUpdate = (new Date()) * 1 - 1; this.fpsFilter = 50; @@ -31,6 +33,7 @@ window.GarageServerIO = (function (window, socketio) { StateController.prototype = { setTime: function (serverTime, delay) { this.time = serverTime - delay; + this.renderTime = this.time; } }; @@ -226,8 +229,9 @@ window.GarageServerIO = (function (window, socketio) { }, updateState = function (data) { + _stateController.stateDelta = data.stateDelta; + _stateController.physicsDelta = data.physicsDelta; _stateController.setTime(data.time, _options.interpolationDelay ? _options.interpolationDelay : 100); - _stateController.delta = data.delta; updatePlayersState(data); updateEntitiesState(data); diff --git a/lib/server/garageservergame.js b/lib/server/garageservergame.js index 67d157f..8a5cce5 100644 --- a/lib/server/garageservergame.js +++ b/lib/server/garageservergame.js @@ -19,7 +19,7 @@ GarageServerGame.prototype.updateState = function (options) { GarageServerGame.prototype.updatePlayers = function (options) { var currentTime = new Date().getTime() - this.startTime, - state = { time: currentTime, delta: this.physicsInterval, playerStates: [] }; + state = { time: currentTime, physicsDelta: this.physicsInterval, stateDelta: this.stateInterval, playerStates: [] }; this.players.forEach(function (player) { state.playerStates.push({ id: player.client.id, state: player.state, seq: player.sequence });