diff --git a/play.pokemonshowdown.com/src/battle-log.ts b/play.pokemonshowdown.com/src/battle-log.ts index 393628767..12ebc9429 100644 --- a/play.pokemonshowdown.com/src/battle-log.ts +++ b/play.pokemonshowdown.com/src/battle-log.ts @@ -143,7 +143,6 @@ export class BattleLog { let divClass = 'chat'; let divHTML = ''; let noNotify: boolean | undefined; - if (!['join', 'j', 'leave', 'l'].includes(args[0])) this.joinLeave = null; if (!['name', 'n'].includes(args[0])) this.lastRename = null; switch (args[0]) { case 'chat': case 'c': case 'c:': @@ -332,9 +331,13 @@ export class BattleLog { default: this.addBattleMessage(args, kwArgs); + this.joinLeave = null; return; } - if (divHTML) this.addDiv(divClass, divHTML, preempt); + if (divHTML) { + this.addDiv(divClass, divHTML, preempt); + this.joinLeave = null; + } } addBattleMessage(args: Args, kwArgs?: KWArgs) { switch (args[0]) { diff --git a/play.pokemonshowdown.com/src/battle-team-editor.tsx b/play.pokemonshowdown.com/src/battle-team-editor.tsx index 74ca78f1c..0e6209822 100644 --- a/play.pokemonshowdown.com/src/battle-team-editor.tsx +++ b/play.pokemonshowdown.com/src/battle-team-editor.tsx @@ -693,6 +693,7 @@ export class TeamEditor extends preact.Component<{ override render() { this.editor ||= new TeamEditorState(this.props.team); const editor = this.editor; + window.editor = editor; // debug editor.setReadonly(!!this.props.readOnly); editor.narrow = this.props.narrow ?? document.body.offsetWidth < 500; if (this.props.team.format !== editor.format) { diff --git a/play.pokemonshowdown.com/src/battle-teams.ts b/play.pokemonshowdown.com/src/battle-teams.ts index 370d0862e..1f82e7893 100644 --- a/play.pokemonshowdown.com/src/battle-teams.ts +++ b/play.pokemonshowdown.com/src/battle-teams.ts @@ -155,6 +155,7 @@ export const Teams = new class { const team = []; let i = 0; let j = 0; + let lastI = 0; while (true) { const set: Teams.PokemonSet = {} as any; @@ -263,8 +264,9 @@ export const Teams = new class { set.dynamaxLevel = (misc[4] ? Number(misc[4]) : undefined); set.teraType = misc[5] || undefined; } - if (j < 0) break; i = j + 1; + if (j < 0 || i <= lastI) break; + lastI = i; } return team; @@ -274,6 +276,7 @@ export const Teams = new class { const team = []; let i = 0; + let lastI = 0; while (true) { const name = buf.slice(i, buf.indexOf('|', i)); @@ -287,7 +290,8 @@ export const Teams = new class { i = buf.indexOf(']', i) + 1; - if (i < 1) break; + if (i < 1 || i <= lastI) break; + lastI = i; } return team; diff --git a/play.pokemonshowdown.com/src/client-main.ts b/play.pokemonshowdown.com/src/client-main.ts index 1be1f2d45..3519f7fb5 100644 --- a/play.pokemonshowdown.com/src/client-main.ts +++ b/play.pokemonshowdown.com/src/client-main.ts @@ -2067,7 +2067,7 @@ export const PS = new class extends PSModel { continue; } case 'deinit': { room = PS.rooms[roomid2]; - if (room) { + if (room && room.connected !== 'expired') { room.connected = false; this.removeRoom(room); } @@ -2589,8 +2589,15 @@ export const PS = new class extends PSModel { if (this.popups.length && room.id === this.popups[this.popups.length - 1]) { this.popups.pop(); - PS.room = this.popups.length ? PS.rooms[this.popups[this.popups.length - 1]]! : - PS.rooms[room.parentRoomid ?? PS.panel.id] || PS.panel; + if (this.popups.length) { + // focus topmost popup + PS.room = PS.rooms[this.popups[this.popups.length - 1]]!; + } else { + // if popup parent is a mini-window, focus popup parent + PS.room = PS.rooms[room.parentRoomid ?? PS.panel.id] || PS.panel; + // otherwise focus current panel + if (PS.room.location !== 'mini-window' || PS.panel !== PS.mainmenu) PS.room = PS.panel; + } } if (wasFocused) { diff --git a/play.pokemonshowdown.com/src/panel-chat.tsx b/play.pokemonshowdown.com/src/panel-chat.tsx index c86425006..5f805ebd7 100644 --- a/play.pokemonshowdown.com/src/panel-chat.tsx +++ b/play.pokemonshowdown.com/src/panel-chat.tsx @@ -260,7 +260,9 @@ export class ChatRoom extends PSRoom { message = args[2]; } if (toID(name) === PS.user.userid) return false; - if (message.startsWith(`/raw `)) return false; + if (message.startsWith(`/raw `) || message.startsWith(`/uhtml`) || message.startsWith(`/uhtmlchange`)) { + return false; + } const lastMessageDates = Dex.prefs('logtimes') || (PS.prefs.set('logtimes', {}), Dex.prefs('logtimes')); if (!lastMessageDates[PS.server.id]) lastMessageDates[PS.server.id] = {}; diff --git a/play.pokemonshowdown.com/src/panel-teamdropdown.tsx b/play.pokemonshowdown.com/src/panel-teamdropdown.tsx index e2add4f29..76e9eb6d3 100644 --- a/play.pokemonshowdown.com/src/panel-teamdropdown.tsx +++ b/play.pokemonshowdown.com/src/panel-teamdropdown.tsx @@ -129,7 +129,8 @@ export class PSTeambuilder { if (line.startsWith('Move:')) line = line.slice(4); line = line.slice(line.charAt(1) === ' ' ? 2 : 1); if (line.startsWith('Hidden Power [')) { - const hpType = line.slice(14, -1) as Dex.TypeName; + let hpType = line.slice(14, line.indexOf(']')) as Dex.TypeName; + if (hpType.includes(']') || hpType.includes('[')) hpType = '' as any; line = 'Hidden Power ' + hpType; set.hpType = hpType; }