mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-12 23:50:47 -05:00
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:
parent
a89e5906e5
commit
d3cf957668
|
|
@ -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 + "'.)");
|
||||
|
||||
|
|
|
|||
4
rooms.js
4
rooms.js
|
|
@ -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) {
|
||||
|
|
|
|||
4
users.js
4
users.js
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user