Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Counter-Strike 2 support #20

Merged
merged 4 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading