mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-26 02:39:38 -05:00
Roomlogs: Don't count certain protocol messages for Room#nthMessageHandlers
Previously, join/leave/userstats/etc would all count against the nthMessageHandlers (which is relevant for repeats), and this is most definitely incorrect behavior.
This commit is contained in:
parent
73696f5d71
commit
866722f70d
|
|
@ -56,6 +56,7 @@ export class Roomlog {
|
|||
* Scrollback log
|
||||
*/
|
||||
log: string[];
|
||||
visibleMessageCount = 0;
|
||||
broadcastBuffer: string[];
|
||||
/**
|
||||
* undefined = uninitialized,
|
||||
|
|
@ -143,6 +144,11 @@ export class Roomlog {
|
|||
}
|
||||
add(message: string) {
|
||||
this.roomlog(message);
|
||||
// |uhtml gets both uhtml and uhtmlchange
|
||||
// which are visible and so should be counted
|
||||
if (['|c|', '|c:|', '|raw|', '|html|', '|uhtml'].some(k => message.startsWith(k))) {
|
||||
this.visibleMessageCount++;
|
||||
}
|
||||
message = this.withTimestamp(message);
|
||||
this.log.push(message);
|
||||
this.broadcastBuffer.push(message);
|
||||
|
|
@ -275,8 +281,8 @@ export class Roomlog {
|
|||
/**
|
||||
* Returns the total number of lines in the roomlog, including truncated lines.
|
||||
*/
|
||||
getLineCount() {
|
||||
return this.log.length + this.numTruncatedLines;
|
||||
getLineCount(onlyVisible = true) {
|
||||
return (onlyVisible ? this.visibleMessageCount : this.log.length) + this.numTruncatedLines;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user