fix ad flooding bug
This commit is contained in:
parent
a2be4e8d51
commit
2800e80c17
|
@ -1,5 +1,8 @@
|
|||
# Changelog
|
||||
|
||||
## 1.19.2
|
||||
* Fixed a bug that could lead to ad flooding if the client experienced frequent connection drops
|
||||
|
||||
## 1.19.1
|
||||
* Performance improvement for players who connect multiple characters at the same time
|
||||
* Limit max height of the status message banner on character profile
|
||||
|
|
|
@ -62,8 +62,9 @@
|
|||
...this.conversation.settings,
|
||||
|
||||
adSettings: {
|
||||
ads: this.ads.map((ad: string) => ad.trim()).filter((ad: string) => (ad.length > 0)),
|
||||
randomOrder: this.randomOrder
|
||||
...this.conversation.settings.adSettings,
|
||||
ads: this.ads.map((ad: string) => ad.trim()).filter((ad: string) => (ad.length > 0)),
|
||||
randomOrder: this.randomOrder
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -107,7 +107,11 @@ export class AdManager {
|
|||
Math.random() * AdManager.POST_VARIANCE;
|
||||
|
||||
this.adIndex = this.adIndex + 1;
|
||||
this.nextPostDue = new Date(Date.now() + nextInMs);
|
||||
|
||||
this.nextPostDue = new Date(Math.max(
|
||||
Date.now() + nextInMs,
|
||||
chanConv.settings.adSettings.lastAdTimestamp + (core.connection.vars.lfrp_flood * 1000)
|
||||
));
|
||||
|
||||
// tslint:disable-next-line: no-unnecessary-type-assertion
|
||||
this.interval = setTimeout(
|
||||
|
@ -165,7 +169,12 @@ export class AdManager {
|
|||
|
||||
this.adIndex = 0;
|
||||
this.active = true;
|
||||
this.nextPostDue = new Date(Date.now() + initialWait);
|
||||
|
||||
this.nextPostDue = new Date(Math.max(
|
||||
Date.now() + initialWait,
|
||||
this.conversation.settings.adSettings.lastAdTimestamp + (core.connection.vars.lfrp_flood * 1000)
|
||||
));
|
||||
|
||||
this.expireDue = new Date(Date.now() + AdManager.POSTING_PERIOD);
|
||||
this.adMap = this.generateAdMap();
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ export class Settings implements ISettings {
|
|||
export class AdSettings implements Conversation.AdSettings {
|
||||
ads: string[] = [];
|
||||
randomOrder = false;
|
||||
lastAdTimestamp = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +110,7 @@ export class ConversationSettings implements Conversation.Settings {
|
|||
highlightWords: string[] = [];
|
||||
joinMessages = Conversation.Setting.Default;
|
||||
defaultHighlights = true;
|
||||
adSettings: Conversation.AdSettings = { ads: [], randomOrder: false };
|
||||
adSettings: Conversation.AdSettings = { ads: [], randomOrder: false, lastAdTimestamp: 0 };
|
||||
}
|
||||
|
||||
function pad(num: number): string | number {
|
||||
|
|
|
@ -484,6 +484,8 @@ class ChannelConversation extends Conversation implements Interfaces.ChannelConv
|
|||
);
|
||||
|
||||
this.nextAd = Date.now() + core.connection.vars.lfrp_flood * 1000;
|
||||
|
||||
this.settings.adSettings.lastAdTimestamp = Date.now();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ export namespace Conversation {
|
|||
export interface AdSettings {
|
||||
readonly ads: string[];
|
||||
readonly randomOrder: boolean;
|
||||
lastAdTimestamp: number;
|
||||
}
|
||||
|
||||
export const enum UnreadState { None, Unread, Mention }
|
||||
|
|
Loading…
Reference in New Issue