Skip to content

Commit

Permalink
Properly terminate BattleStream (fixes regression caused by smogon#5210)
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibo committed Mar 9, 2019
1 parent d5710ac commit 6a871e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sim/battle-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class BattleStream extends Streams.ObjectReadWriteStream {
options.send = (t: string, data: any) => {
if (Array.isArray(data)) data = data.join("\n");
this.push(`${t}\n${data}`);
if (type === 'end' && !this.keepAlive) {
if (t === 'end' && !this.keepAlive) {
this.push(null);
this._destroy();
}
Expand Down Expand Up @@ -290,7 +290,7 @@ export class BattleTextStream extends Streams.ReadWriteStream {
this.battleStream.end();
}
async _listen() {
let message: string;
let message;
// tslint:disable-next-line:no-conditional-assignment
while ((message = await this.battleStream.read())) {
if (!message.endsWith('\n')) message += '\n';
Expand Down
4 changes: 2 additions & 2 deletions sim/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3047,13 +3047,13 @@ export class Battle extends Dex.ModdedDex {
}
}

// tslint:disable-next-line:ban-types
// tslint:disable-next-line:ban-types
addMove(...args: (string | number | Function | AnyObject)[]) {
this.lastMoveLine = this.log.length;
this.log.push(`|${args.join('|')}`);
}

// tslint:disable-next-line:ban-types
// tslint:disable-next-line:ban-types
attrLastMove(...args: (string | number | Function | AnyObject)[]) {
if (this.lastMoveLine < 0) return;
if (this.log[this.lastMoveLine].startsWith('|-anim|')) {
Expand Down

0 comments on commit 6a871e0

Please sign in to comment.