fix leaving : splice not slice !!

This commit is contained in:
Romain Beaumont 2015-08-27 00:23:19 +02:00
parent 213fe7d84b
commit 8010ae86bd

View file

@ -181,17 +181,18 @@ function inject(serv,player)
player._client.on('end', function () { player._client.on('end', function () {
serv.broadcast(player.username + ' quit the game.', "yellow"); serv.broadcast(player.username + ' quit the game.', "yellow");
player._writeOthers('player_info',{ player._writeOthers('player_info', {
action: 4, action: 4,
data: [{ data: [{
UUID: transformUuid(player._client.uuid) UUID: transformUuid(player._client.uuid)
}] }]
}); });
player._writeOthers('entity_destroy',{'entityIds':[player.entity.id]}); player._writeOthers('entity_destroy', {'entityIds': [player.entity.id]});
player.emit('disconnect'); player.emit('disconnect');
var index=serv.players.indexOf(player); var index = serv.players.indexOf(player);
if(index>-1) if (index > -1) {
serv.players.slice(index,1); serv.players.splice(index,1);
}
delete serv.uuidToPlayer[player._client.uuid]; delete serv.uuidToPlayer[player._client.uuid];
}); });