Room aliases map to room ids on load

This change will be applied to /roomalias commands only in an
upcoming patch, in order to keep hotpatch-compatibility
This commit is contained in:
Ivo Julca 2015-09-01 17:29:26 -05:00
parent a89e5906e5
commit d3cf957668
3 changed files with 6 additions and 6 deletions

View File

@ -261,7 +261,7 @@ var commands = exports.commands = {
var id = toId(target);
if (!id) return this.parse('/help makechatroom');
// Check if the name already exists as a room or alias
if (Rooms.rooms[id] || Rooms.get(id) || Rooms.aliases[id]) return this.sendReply("The room '" + target + "' already exists.");
if (Rooms.search(id)) return this.sendReply("The room '" + target + "' already exists.");
if (Rooms.global.addChatRoom(target)) {
if (cmd === 'makeprivatechatroom') {
var targetRoom = Rooms.search(target);
@ -473,7 +473,7 @@ var commands = exports.commands = {
if (!this.can('setalias')) return false;
var alias = toId(target);
if (!alias.length || !Rooms.aliases[alias]) return this.sendReply("Please specify an existing alias.");
if (Rooms.aliases[alias] !== room) return this.sendReply("You may only remove an alias from the current room.");
if (toId(Rooms.aliases[alias]) !== room.id) return this.sendReply("You may only remove an alias from the current room.");
this.privateModCommand("(" + user.name + " removed the room alias '" + target + "'.)");

View File

@ -327,7 +327,7 @@ var GlobalRoom = (function () {
var room = Rooms.createChatRoom(id, this.chatRoomData[i].title, this.chatRoomData[i]);
if (room.aliases) {
for (var a = 0; a < room.aliases.length; a++) {
aliases[room.aliases[a]] = room;
aliases[room.aliases[a]] = id;
}
}
this.chatRooms.push(room);
@ -1702,7 +1702,7 @@ function getRoom(roomid, fallback) {
}
Rooms.get = getRoom;
Rooms.search = function (name, fallback) {
return getRoom(name) || getRoom(toId(name)) || Rooms.aliases[toId(name)] || (fallback ? rooms.global : undefined);
return getRoom(name) || getRoom(toId(name)) || getRoom(Rooms.aliases[toId(name)]) || (fallback ? rooms.global : undefined);
};
Rooms.createBattle = function (roomid, format, p1, p2, options) {

View File

@ -1351,8 +1351,8 @@ User = (function () {
}
}
if (Rooms.aliases[toId(roomid)] === room) {
connection.send(">" + toId(roomid) + "\n|deinit");
if (toId(Rooms.aliases[roomid]) === room.id) {
connection.send(">" + roomid + "\n|deinit");
}
var joinResult = this.joinRoom(room, connection);