From b8196ea6061110dd29a42cb24e35df03cd8ce7d6 Mon Sep 17 00:00:00 2001 From: JensForstmann <19289807+JensForstmann@users.noreply.github.com> Date: Thu, 2 Nov 2023 18:15:56 +0100 Subject: [PATCH] Fix incorrect warnings about being in the wrong team --- backend/src/match.ts | 15 +++++++++++++++ backend/src/matchMap.ts | 1 + 2 files changed, 16 insertions(+) diff --git a/backend/src/match.ts b/backend/src/match.ts index f32a6a1..20993c4 100644 --- a/backend/src/match.ts +++ b/backend/src/match.ts @@ -39,6 +39,7 @@ export interface Match { periodicTimerId?: NodeJS.Timeout; logBuffer: string[]; log: (msg: string) => void; + warnAboutWrongTeam: boolean; } export const createFromData = async (data: IMatch) => { @@ -46,6 +47,7 @@ export const createFromData = async (data: IMatch) => { data: data, logBuffer: [], log: () => {}, + warnAboutWrongTeam: true, }; match.data = addChangeListener(data, createOnDataChangeHandler(match)); match.log = createLogger(match); @@ -468,6 +470,16 @@ const onLogLine = async (match: Match, line: string) => { } return; } + + // World triggered "Match_Start" on "de_dust2" + const matchStartPattern = /World triggered "Match_Start" on .*/; + const matchStartMatch = line.match( + new RegExp(dateTimePattern.source + matchStartPattern.source) + ); + if (matchStartMatch) { + match.warnAboutWrongTeam = true; + return; + } } catch (err) { match.log('Error in onLogLine' + err); } @@ -682,6 +694,9 @@ const sayWrongTeamOrSide = async ( currentSite: 'CT' | 'TERRORIST', currentTeamAB: TTeamAB ) => { + if (!match.warnAboutWrongTeam) { + return; + } const currentTeam = getTeamByAB(match, currentTeamAB); const otherTeam = getTeamByAB(match, getOtherTeamAB(currentTeamAB)); await say( diff --git a/backend/src/matchMap.ts b/backend/src/matchMap.ts index a5e5333..9a2dc79 100644 --- a/backend/src/matchMap.ts +++ b/backend/src/matchMap.ts @@ -431,6 +431,7 @@ const onSwitchCommand: commands.CommandHandler = async (e) => { await Match.say(match, `${escapeRconString(team.name)} WANTS TO SWITCH SIDES`); match.log(`${teamAB} (${team.name} - ${player.name}) wants to switch sides`); await Match.execRcon(match, 'mp_swapteams'); + match.warnAboutWrongTeam = false; // temporarily disable warning about wrong team, will be set to true again after match start matchMap.startAsCtTeam = getOtherTeamAB(matchMap.startAsCtTeam); MatchService.scheduleSave(match); await startMatch(match, matchMap);