mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-08-06 12:50:11 +08:00
Resolved #19
This commit is contained in:
@@ -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,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 = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user