From 516edf690deffe357d1680ecf232633e7a16a388 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 23 Mar 2013 21:05:13 -0500 Subject: [PATCH] Patch userLeave bug (Issue#14 --- channel.js | 5 ++++- chatcommand.js | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/channel.js b/channel.js index dd9f0757..8040a459 100644 --- a/channel.js +++ b/channel.js @@ -326,7 +326,10 @@ Channel.prototype.userLeave = function(user) { if(this.leader == user) { this.changeLeader(""); } - this.users.splice(this.users.indexOf(user), 1); + var idx = this.users.indexOf(user); + if(idx >= 0 && idx < this.users.length) + this.users.splice(idx, 1); + console.log(this.users.length); this.updateUsercount(); if(user.name != "") { this.sendAll('userLeave', { diff --git a/chatcommand.js b/chatcommand.js index 50dfd646..498b6104 100644 --- a/chatcommand.js +++ b/chatcommand.js @@ -33,7 +33,6 @@ function handleKick(chan, user, args) { } if(kickee) { kickee.socket.disconnect(); - chan.userLeave(kickee); } } } @@ -50,7 +49,6 @@ function handleBan(chan, user, args) { if(kickee) { chan.ipbans.push(kickee.ip); kickee.socket.disconnect(); - chan.userLeave(kickee); } } }