mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Fix crash in bestof when expiring battles
The main important change is that when `room.destroy()` is called on an unfinished battle, `room.parent?.game?.onBattleWin?.()` is now called (it was previously only called for tours, not bestof). The rest is just about moving the relevant code to more sensible places.
This commit is contained in:
parent
7c103da51d
commit
6bccd4f622
|
|
@ -1239,7 +1239,10 @@ export class RoomBattle extends RoomGame<RoomBattlePlayer> {
|
|||
}
|
||||
|
||||
override destroy() {
|
||||
this.setEnded();
|
||||
if (!this.ended) {
|
||||
this.setEnded();
|
||||
this.room.parent?.game?.onBattleWin?.(this.room, '');
|
||||
}
|
||||
for (const player of this.players) {
|
||||
player.destroy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1106,9 +1106,10 @@ export abstract class BasicRoom {
|
|||
destroy(): void {
|
||||
// deallocate ourself
|
||||
|
||||
if (this.battle && this.tour) {
|
||||
// resolve state of the tournament;
|
||||
if (!this.battle.ended) this.tour.onBattleWin(this as any as GameRoom, '');
|
||||
if (this.game) {
|
||||
this.game.destroy();
|
||||
this.game = null;
|
||||
this.battle = null;
|
||||
this.tour = null;
|
||||
}
|
||||
|
||||
|
|
@ -1132,11 +1133,6 @@ export abstract class BasicRoom {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.game) {
|
||||
this.game.destroy();
|
||||
this.game = null;
|
||||
this.battle = null;
|
||||
}
|
||||
this.active = false;
|
||||
|
||||
// Ensure there aren't any pending messages that could restart the expire timer
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user