Skip to content

Commit

Permalink
Fix other references to Room.users
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibo committed Apr 22, 2019
1 parent ccd9897 commit 7ed7e9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
7 changes: 4 additions & 3 deletions js/client-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
if (m2 && (m2[0] === '/' || m2[0] === '!')) spaceprefix = '';

for (var i in users) {
if (spaceprefix && users[i].substr(1).replace(/[^A-Za-z0-9 ]+/g, '').toLowerCase().substr(0, spaceprefix.length) === spaceprefix) {
if (spaceprefix && users[i].name.substr(1).replace(/[^A-Za-z0-9 ]+/g, '').toLowerCase().substr(0, spaceprefix.length) === spaceprefix) {
candidates.push([i, m2[1].length]);
} else if (idprefix && i.substr(0, idprefix.length) === idprefix) {
candidates.push([i, m1[1].length]);
Expand Down Expand Up @@ -352,8 +352,9 @@
// Substitute in the tab-completed name.
var candidate = this.tabComplete.candidates[this.tabComplete.index];
var substituteUserId = candidate[0];
if (!users[substituteUserId]) return true;
var name = users[substituteUserId].substr(1);
var substituteUser = users[substituteUserId];
if (!substituteUser) return true;
var name = substituteUser.name.substr(1);
name = Dex.getShortName(name);
var fullPrefix = this.tabComplete.prefix.substr(0, candidate[1]) + name;
$textbox.val(fullPrefix + text.substr(idx));
Expand Down
22 changes: 14 additions & 8 deletions src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3139,9 +3139,9 @@ class Battle {
case 'join': case 'j': {
if (this.roomid) {
let room = app!.rooms[this.roomid];
let user = args[1];
let userid = toUserid(user);
if (/^[a-z0-9]/i.test(user)) user = ' ' + user;
let user = BattleTextParser.parseNameParts(args[1]);
let userid = toUserid(user.name);
if (/^[a-z0-9]/i.test(user.name)) user.name = ' ' + user.name;
if (!room.users[userid]) room.userCount.users++;
room.users[userid] = user;
room.userList.add(userid);
Expand Down Expand Up @@ -3172,11 +3172,17 @@ class Battle {
case 'name': case 'n': {
if (this.roomid) {
let room = app!.rooms[this.roomid];
let newuser = args[1];
let olduser = args[2];
let userid = toUserid(newuser);
room.users[userid] = newuser;
room.userList.remove(olduser);
let user = BattleTextParser.parseNameParts(args[1]);
let oldid = args[2];
if (toUserid(oldid) === app!.user.get('userid')) {
app!.user.set({
away: user.away,
status: user.status,
});
}
let userid = toUserid(user.name);
room.users[userid] = user;
room.userList.remove(oldid);
room.userList.add(userid);
}
if (!this.ignoreSpects) {
Expand Down

0 comments on commit 7ed7e9f

Please sign in to comment.