Skip to content

Commit

Permalink
Restauring deleted code that shouldn't have been deleted (fixing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerenaux committed May 7, 2017
1 parent 1ffc1bb commit 74aa06c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/server/AOI.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ AOI.prototype.clear = function(){

AOI.prototype.addEntity = function(entity,previous){
this.entities.push(entity);
if(entity.constructor.name == 'Player') GameServer.server.addToRoom(entity.socketID,'AOI'+this.id);
GameServer.handleAOItransition(entity,previous);
};

AOI.prototype.deleteEntity = function(entity) {
var idx = this.entities.indexOf(entity);
if (idx >= 0) this.entities.splice( idx, 1 );
if(entity.constructor.name == 'Player') GameServer.server.leaveRoom(entity.socketID,'AOI'+this.id);
};

module.exports.AOI = AOI;
10 changes: 10 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ server.getNbConnected =function(){
return Object.keys(gs.players).length;
};

server.addToRoom = function(socketID,room){
var socket = server.getSocket(socketID);
socket.join(room);
};

server.leaveRoom = function(socketID,room){
var socket = server.getSocket(socketID);
if(socket) socket.leave(room);
};

server.sendID = function(socket,playerID){
socket.emit('pid',playerID);
};
Expand Down

0 comments on commit 74aa06c

Please sign in to comment.