This commit is contained in:
Jeremiah Billmann
2013-07-17 21:45:00 -04:00
parent f5452bc984
commit c7e66e5f5e
6 changed files with 16 additions and 11 deletions
+3 -2
View File
@@ -2,10 +2,11 @@ var history = require('./history');
exports = module.exports = Entity;
function Entity (id) {
function Entity (id, maxHistorySecondBuffer) {
this.state = {};
this.sequence = 1;
this.id = id;
this.maxHistorySecondBuffer = maxHistorySecondBuffer;
this.stateHistory = [];
}
@@ -19,7 +20,7 @@ Entity.prototype = {
var minTime, spliceTo = 0, newHistory = new history(state, executionTime);
this.stateHistory.push(newHistory);
minTime = this.stateHistory[this.stateHistory.length - 1].executionTime - 1000;
minTime = this.stateHistory[this.stateHistory.length - 1].executionTime - this.maxHistorySecondBuffer;
for (var i = 0; i < this.stateHistory.length; i ++) {
if (this.stateHistory[i].executionTime > minTime) {
+2 -2
View File
@@ -2,8 +2,8 @@ var entity = require('./entity');
exports = module.exports = Player;
function Player (client) {
entity.call(this, client.id);
function Player (client, maxHistorySecondBuffer) {
entity.call(this, client.id, maxHistorySecondBuffer);
this.client = client;
this.inputs = [];
}