Fixed a merging issue

This commit is contained in:
Jeremiah Billmann
2014-10-23 16:54:23 +00:00
parent 3e869e6d9b
commit ff67b5e945
3 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -405,7 +405,7 @@ var GarageServerIO = (function (socketio) {
newState = _options.onInterpolation(positions.previous.state, positions.target.state, amount);
entity.state = newState = _options.onInterpolation(entity.state, newState, _stateController.smoothingFactor);
}
else if (entity.inputController.sequenceNumber === 1) {
else {
entity.state = entity.latestUpdate().state;
}
}
+10 -10
View File
@@ -39,9 +39,9 @@ function GarageServer(socketio, options) {
this.registerSocketEvents(options);
this.game = new garageServerGame(options, function (state, region) {
if (!region) {
socketio.of(namespace).emit('update' ,state);
socketio.of(namespace).emit('u' ,state);
} else {
socketio.of(namespace).in(region).emit('update' ,state);
socketio.of(namespace).in(region).emit('u' ,state);
}
});
}
@@ -53,7 +53,7 @@ GarageServer.prototype.registerSocketEvents = function (options) {
if (options.logging) {
console.log('garageserver.io:: socket ' + socket.id + ' connection');
}
socket.emit('state', {
socket.emit('s', {
physicsDelta: (options.physicsInterval ? options.physicsInterval : 15) / 1000,
smoothingFactor: options.smoothingFactor ? options.smoothingFactor : 0.3,
interpolation: options.interpolation ? options.interpolation : false,
@@ -72,21 +72,21 @@ GarageServer.prototype.registerSocketEvents = function (options) {
self.onPlayerDisconnect(socket, options);
});
socket.on('input', function (data) {
socket.on('i', function (data) {
if (options.logging) {
console.log('garageserver.io:: socket input ' + socket.id + ' ' + data[0] + ' ' + data[1]);
}
self.onPlayerInput(socket, data, options);
});
socket.on('ping', function (data) {
socket.on('p', function (data) {
if (options.logging) {
console.log('garageserver.io:: socket ping ' + data);
}
self.onPing(socket, data, options);
});
socket.on('event', function (data) {
socket.on('e', function (data) {
if (options.logging) {
console.log('garageserver.io:: event ' + data);
}
@@ -106,7 +106,7 @@ GarageServer.prototype.onPlayerConnect = function (socket, options) {
GarageServer.prototype.onPlayerDisconnect = function (socket, options) {
this.game.removePlayer(socket.id);
socket.broadcast.emit('removePlayer', socket.id);
socket.broadcast.emit('rp', socket.id);
if (options.onPlayerDisconnect) {
options.onPlayerDisconnect(socket);
}
@@ -120,7 +120,7 @@ GarageServer.prototype.onPlayerInput = function (socket, input, options) {
};
GarageServer.prototype.onPing = function (socket, data, options) {
socket.emit('ping', data);
socket.emit('p', data);
if (options.onPing) {
options.onPing(socket, data);
}
@@ -155,7 +155,7 @@ GarageServer.prototype.addEntity = function (id) {
};
GarageServer.prototype.removeEntity = function (id) {
this.io.of(this.socketPath).emit('removeEntity', id);
this.io.of(this.socketPath).emit('re', id);
this.game.removeEntity(id);
};
@@ -164,7 +164,7 @@ GarageServer.prototype.sendPlayerEvent = function (id, data) {
};
GarageServer.prototype.sendPlayersEvent = function (data) {
this.io.of(this.socketPath).emit('event', data);
this.io.of(this.socketPath).emit('e', data);
};
GarageServer.prototype.setPlayerRegion = function (id, region) {
+1 -1
View File
@@ -118,7 +118,7 @@ GarageServerGame.prototype.addPlayerInput = function (id, input, sequence, time)
GarageServerGame.prototype.sendPlayerEvent = function (id, data) {
this.playerController.entities.some(function (player) {
if (player.id === id) {
player.socket.emit('event', data);
player.socket.emit('e', data);
return true;
}
});