From be3d1edcae07035ff53d60306bb6b9a37d1593eb Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Fri, 5 Dec 2025 08:43:33 +0000 Subject: [PATCH] Preact: Fix format normalization Fixes #2552 --- play.pokemonshowdown.com/src/battle-log.ts | 11 +++++++++++ play.pokemonshowdown.com/src/panel-chat.tsx | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-log.ts b/play.pokemonshowdown.com/src/battle-log.ts index c39f2beb4..1438a37d6 100644 --- a/play.pokemonshowdown.com/src/battle-log.ts +++ b/play.pokemonshowdown.com/src/battle-log.ts @@ -1086,6 +1086,17 @@ export class BattleLog { } return this.escapeHTML(this.formatName(formatid, fixGen6)); } + static formatId(format: string): ID { + const atIndex = format.indexOf('@@@'); + if (atIndex >= 0) { + format = toID(format.slice(0, atIndex)) + format.slice(atIndex).trim(); + } else { + format = toID(format); + } + if (!format) return '' as ID; + if (!format.startsWith('gen')) format = `${Dex.modid}${format}`; + return format as ID; + } /** * Do not store this output anywhere; it removes the generation number * for the current gen. diff --git a/play.pokemonshowdown.com/src/panel-chat.tsx b/play.pokemonshowdown.com/src/panel-chat.tsx index d788a7c38..75379be50 100644 --- a/play.pokemonshowdown.com/src/panel-chat.tsx +++ b/play.pokemonshowdown.com/src/panel-chat.tsx @@ -313,8 +313,7 @@ export class ChatRoom extends PSRoom { format = target; targetUser = this.pmTarget; } - format = (format || '').trim(); - if (!format.startsWith('gen')) format = `${Dex.modid}${format}`; + format = BattleLog.formatId(format || ''); PS.mainmenu.makeQuery('userdetails', targetUser).then(data => { if (data.rooms === false) return this.errorReply('This player does not exist or is not online.'); PS.join(`challenge-${toID(targetUser)}` as RoomID, { args: { format } });