diff --git a/battles.js b/battles.js index fede4661d4..a45923d303 100644 --- a/battles.js +++ b/battles.js @@ -2006,7 +2006,6 @@ var Battle = (function() { this.win(); }; Battle.prototype.win = function(side) { - var winSide = false; if (this.ended) { return false; } @@ -3296,6 +3295,12 @@ var Battle = (function() { Battle.prototype.leave = function(slot) { if (slot === 'p1' || slot === 'p2') { var side = this[slot]; + if (!side) { + console.log('**** '+slot+' tried to leave before it was possible in '+this.id); + require('./crashlogger.js')({stack: '**** '+slot+' tried to leave before it was possible in '+this.id}, 'A simulator process'); + return; + } + side.emitUpdate({side:'none'}); side.isActive = false; this.add('player', slot); diff --git a/rooms.js b/rooms.js index 5007e57b68..b14cff5584 100644 --- a/rooms.js +++ b/rooms.js @@ -938,7 +938,7 @@ var BattleRoom = (function() { } return user; }; - GlobalRoom.prototype.onUpdateIdentity = function() {}; + BattleRoom.prototype.onUpdateIdentity = function() {}; BattleRoom.prototype.onLeave = function(user) { if (!user) return; // ... if (user.battles[this.id]) { diff --git a/users.js b/users.js index 64a278e382..696a786c70 100644 --- a/users.js +++ b/users.js @@ -1042,10 +1042,11 @@ exports.checkBanned = checkBanned; exports.checkLocked = checkLocked; function unban(name) { + var success; var userid = toId(name); for (var ip in bannedIps) { - if (Users.bannedIps[ip] === userid) { - delete Users.bannedIps[ip]; + if (bannedIps[ip] === userid) { + delete bannedIps[ip]; success = true; } }