From 924d5b1c6d70c39ef5377ad628ee7f1f71a449dd Mon Sep 17 00:00:00 2001 From: Jan Korneffel Date: Sat, 7 Oct 2023 23:28:25 +0200 Subject: [PATCH 1/4] Adjust match for `maps` command to work with CS2 --- backend/src/matchMap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/matchMap.ts b/backend/src/matchMap.ts index 99afec5..d5c6863 100644 --- a/backend/src/matchMap.ts +++ b/backend/src/matchMap.ts @@ -168,7 +168,7 @@ export const loadMap = async (match: Match.Match, matchMap: IMatchMap) => { await Match.say(match, `MAP WILL BE CHANGED TO ${matchMap.name} IN 15 SECONDS`); match.log(`change map to ${matchMap.name} (in 15 seconds)`); const response = await Match.execRcon(match, `maps ${matchMap.name}`); - if (!response.includes(` ${matchMap.name}.bsp`)) { + if (!response.includes(matchMap.name)) { match.log(`Map ${matchMap.name} could not be found on the server`); await Match.say(match, `Map ${matchMap.name} could not be found on the server`); return; From 28374365079ebac34182c638c3703e7d97b4812a Mon Sep 17 00:00:00 2001 From: Jan Korneffel Date: Sun, 8 Oct 2023 02:18:35 +0200 Subject: [PATCH 2/4] Change config var pattern and boolean return values for cs2 --- backend/src/match.ts | 2 +- backend/src/matchMap.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/match.ts b/backend/src/match.ts index e3825db..64fb099 100644 --- a/backend/src/match.ts +++ b/backend/src/match.ts @@ -266,7 +266,7 @@ export const say = async (match: Match, message: string) => { export const getConfigVar = async (match: Match, configVar: string): Promise => { const response = await execRcon(match, configVar); - const configVarPattern = new RegExp(`^"${configVar}" = "(.*?)"`); + const configVarPattern = new RegExp(`^${configVar} = (.*)`); const configVarMatch = response.match(configVarPattern); if (configVarMatch) { return configVarMatch[1]!; diff --git a/backend/src/matchMap.ts b/backend/src/matchMap.ts index d5c6863..877bce4 100644 --- a/backend/src/matchMap.ts +++ b/backend/src/matchMap.ts @@ -215,7 +215,7 @@ const startMatch = async (match: Match.Match, matchMap: IMatchMap) => { }; const refreshOvertimeAndMaxRoundsSettings = async (match: Match.Match, matchMap: IMatchMap) => { - matchMap.overTimeEnabled = (await Match.getConfigVar(match, 'mp_overtime_enable')) === '1'; + matchMap.overTimeEnabled = !!(await Match.getConfigVar(match, 'mp_overtime_enable')); matchMap.overTimeMaxRounds = parseInt(await Match.getConfigVar(match, 'mp_overtime_maxrounds')); matchMap.maxRounds = parseInt(await Match.getConfigVar(match, 'mp_maxrounds')); MatchService.scheduleSave(match); From 1d928bcda8fc1c94523b83713d504a7c48ce71ba Mon Sep 17 00:00:00 2001 From: Jens Forstmann <19289807+JensForstmann@users.noreply.github.com> Date: Sun, 8 Oct 2023 13:43:38 +0200 Subject: [PATCH 3/4] Fix overtime enabled --- backend/src/matchMap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/matchMap.ts b/backend/src/matchMap.ts index 877bce4..6feb89f 100644 --- a/backend/src/matchMap.ts +++ b/backend/src/matchMap.ts @@ -215,7 +215,7 @@ const startMatch = async (match: Match.Match, matchMap: IMatchMap) => { }; const refreshOvertimeAndMaxRoundsSettings = async (match: Match.Match, matchMap: IMatchMap) => { - matchMap.overTimeEnabled = !!(await Match.getConfigVar(match, 'mp_overtime_enable')); + matchMap.overTimeEnabled = (await Match.getConfigVar(match, 'mp_overtime_enable')) === "true"; matchMap.overTimeMaxRounds = parseInt(await Match.getConfigVar(match, 'mp_overtime_maxrounds')); matchMap.maxRounds = parseInt(await Match.getConfigVar(match, 'mp_maxrounds')); MatchService.scheduleSave(match); From 73b1a8af4374b403763f7a7a7c8cefbc3e8b1ca4 Mon Sep 17 00:00:00 2001 From: Jens Forstmann <19289807+JensForstmann@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:16:56 +0200 Subject: [PATCH 4/4] Improve check for existing maps on the server --- backend/src/matchMap.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/matchMap.ts b/backend/src/matchMap.ts index 6feb89f..85dae36 100644 --- a/backend/src/matchMap.ts +++ b/backend/src/matchMap.ts @@ -168,7 +168,8 @@ export const loadMap = async (match: Match.Match, matchMap: IMatchMap) => { await Match.say(match, `MAP WILL BE CHANGED TO ${matchMap.name} IN 15 SECONDS`); match.log(`change map to ${matchMap.name} (in 15 seconds)`); const response = await Match.execRcon(match, `maps ${matchMap.name}`); - if (!response.includes(matchMap.name)) { + const maps = response.trim().split("\n").map((map) => map.trim()); + if (!maps.includes(matchMap.name)) { match.log(`Map ${matchMap.name} could not be found on the server`); await Match.say(match, `Map ${matchMap.name} could not be found on the server`); return;