Remove restrictions on concurrent battle searches (#6462)

https://www.smogon.com/forums/threads/improve-searching-for-concurrent-ladder-battles.3660989/
This commit is contained in:
Kirk Scheibelhut 2020-03-16 21:17:34 -07:00 committed by GitHub
parent f4ae5b435f
commit 17501fc001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 42 deletions

View File

@ -406,17 +406,6 @@ class Ladder extends LadderStore {
return;
}
const roomid = this.needsToMove(user);
if (roomid) {
connection.popup(`Error: You need to make a move in <<${roomid}>> before you can look for another battle.\n\n(This restriction doesn't apply in the first five turns of a battle.)`);
return;
}
if (roomid === null && Date.now() < user.lastDecision + 3 * SECONDS) {
connection.popup(`Error: You need to wait until after making a move before you can look for another battle.\n\n(This restriction doesn't apply in the first five turns of a battle.)`);
return;
}
const oldUserid = user.id;
const search = await this.prepBattle(connection, format.rated ? 'rated' : 'unrated', null, format.rated !== false);
@ -426,31 +415,6 @@ class Ladder extends LadderStore {
this.addSearch(search, user);
}
/**
* null = all battles ok
* undefined = not in any battle
*/
needsToMove(user: User) {
let out;
for (const roomid of user.games) {
const room = Rooms.get(roomid);
if (!room || !room.battle || !room.battle.playerTable[user.id]) continue;
const battle: RoomBattle = room.battle;
if (battle.requestCount <= 16) {
// it's fine as long as it's before turn 5
// to be safe, we count off 8 requests for Team Preview, U-turn, and faints
continue;
}
if (Dex.getFormat(battle.format).allowMultisearch) {
continue;
}
const player = battle.playerTable[user.id];
if (!player.request.isWait) return roomid;
out = null;
}
return out;
}
/**
* Verifies whether or not a match made between two users is valid. Returns
*/

View File

@ -606,7 +606,6 @@ export class RoomBattle extends RoomGames.RoomGame {
player.sendRoom(`|error|[Invalid choice] Sorry, too late to make a different move; the next turn has already started`);
return;
}
user.lastDecision = Date.now();
request.isWait = true;
request.choice = choice;

View File

@ -448,8 +448,6 @@ export class User extends Chat.MessageContext {
permalocked: string | ID | null;
prevNames: {[id: /** ID */ string]: string};
/** Millisecond timestamp for last battle decision */
lastDecision: number;
lastChallenge: number;
lastPM: string;
team: string;
@ -522,8 +520,6 @@ export class User extends Chat.MessageContext {
this.permalocked = null;
this.prevNames = Object.create(null);
this.lastDecision = 0;
// misc state
this.lastChallenge = 0;
this.lastPM = '';

View File

@ -1157,7 +1157,6 @@ interface FormatsData extends EventMethods {
restricted?: string[];
ruleset?: string[];
searchShow?: boolean;
allowMultisearch?: boolean;
team?: string;
teamLength?: {validate?: [number, number], battle?: number};
threads?: string[];