Skip to content

Commit

Permalink
Merge pull request #20 from ovee/cs2: Add Counter-Strike 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
JensForstmann authored Oct 8, 2023
2 parents 26240a4 + 73b1a8a commit 35cf781
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const say = async (match: Match, message: string) => {

export const getConfigVar = async (match: Match, configVar: string): Promise<string> => {
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]!;
Expand Down
5 changes: 3 additions & 2 deletions backend/src/matchMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}.bsp`)) {
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;
Expand Down Expand Up @@ -215,7 +216,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')) === "true";
matchMap.overTimeMaxRounds = parseInt(await Match.getConfigVar(match, 'mp_overtime_maxrounds'));
matchMap.maxRounds = parseInt(await Match.getConfigVar(match, 'mp_maxrounds'));
MatchService.scheduleSave(match);
Expand Down

0 comments on commit 35cf781

Please sign in to comment.