fix: wait 30s from mapchange for seeding mode

This commit is contained in:
Davide Fantino 2023-03-18 01:59:54 +01:00
parent 931f1ab7d0
commit 3148ee9bca

View File

@ -335,6 +335,7 @@ export default class MapVote extends DiscordBasePlugin {
this.verbose(1, "Checking seeding mode"); this.verbose(1, "Checking seeding mode");
const maxSeedingModePlayerCount = Math.max(this.options.nextLayerSeedingModePlayerCount, this.options.instantSeedingModePlayerCount); const maxSeedingModePlayerCount = Math.max(this.options.nextLayerSeedingModePlayerCount, this.options.instantSeedingModePlayerCount);
if (this.server.players.length >= 1 && this.server.players.length < maxSeedingModePlayerCount) { if (this.server.players.length >= 1 && this.server.players.length < maxSeedingModePlayerCount) {
if (+(new Date()) - +this.server.layerHistory[ 0 ].time > 30 * 1000) {
const seedingMaps = Layers.layers.filter((l) => l.layerid && l.gamemode.toLowerCase() == this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase()))) const seedingMaps = Layers.layers.filter((l) => l.layerid && l.gamemode.toLowerCase() == this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase())))
const rndMap = randomElement(seedingMaps); const rndMap = randomElement(seedingMaps);
@ -348,7 +349,6 @@ export default class MapVote extends DiscordBasePlugin {
} }
} else this.verbose(1, "Bad data (currentLayer). Seeding mode for current layer skipped to prevent errors."); } else this.verbose(1, "Bad data (currentLayer). Seeding mode for current layer skipped to prevent errors.");
if (+(new Date()) - +this.server.layerHistory[ 0 ].time > 30 * 1000) {
if (this.server.nextLayer) { if (this.server.nextLayer) {
const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid)) const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid))
let rndMap2; let rndMap2;
@ -360,8 +360,7 @@ export default class MapVote extends DiscordBasePlugin {
this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `); this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `);
} }
} else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors."); } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors.");
} } else this.verbose(1, `Waiting 30 seconds from mapchange before entering seeding mode`);
} else this.verbose(1, `Player count doesn't allow seeding mode (${this.server.players.length}/${maxSeedingModePlayerCount})`); } else this.verbose(1, `Player count doesn't allow seeding mode (${this.server.players.length}/${maxSeedingModePlayerCount})`);
} else this.verbose(1, "Seeding mode disabled in config"); } else this.verbose(1, "Seeding mode disabled in config");
} else console.log("[MapVote][1] Bad data (this/this.server/this.options). Seeding mode skipped to prevent errors."); } else console.log("[MapVote][1] Bad data (this/this.server/this.options). Seeding mode skipped to prevent errors.");