Skip to content

Commit

Permalink
fix: update the server layer extraction (#363)
Browse files Browse the repository at this point in the history
Co-authored-by: Marek <[email protected]>
  • Loading branch information
denizetkar and werewolfboy13 authored Aug 10, 2024
1 parent 3f09545 commit f99aacf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions squad-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ export default class SquadServer extends EventEmitter {
const nextMap = await this.rcon.getNextMap();
const nextMapToBeVoted = nextMap.layer === 'To be voted';

const currentLayer = await Layers.getLayerByName(currentMap.layer);
const nextLayer = nextMapToBeVoted ? null : await Layers.getLayerByName(nextMap.layer);
const currentLayer = await Layers.getLayerById(currentMap.layer);
const nextLayer = nextMapToBeVoted ? null : await Layers.getLayerById(nextMap.layer);

if (this.layerHistory.length === 0) {
this.layerHistory.unshift({ layer: currentLayer, time: Date.now() });
Expand Down
4 changes: 2 additions & 2 deletions squad-server/layers/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Layers {
return null;
}

getLayerByName(name) {
return this.getLayerByCondition((layer) => layer.name === name);
getLayerById(layerId) {
return this.getLayerByCondition((layer) => layer.layerid === layerId);
}

getLayerByClassname(classname) {
Expand Down
4 changes: 2 additions & 2 deletions squad-server/rcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ export default class SquadRcon extends Rcon {

async getCurrentMap() {
const response = await this.execute('ShowCurrentMap');
const match = response.match(/^Current level is (.*), layer is (.*)/);
const match = response.match(/^Current level is ([^,]*), layer is ([^,]*)/);
return { level: match[1], layer: match[2] };
}

async getNextMap() {
const response = await this.execute('ShowNextMap');
const match = response.match(/^Next level is (.*), layer is (.*)/);
const match = response.match(/^Next level is ([^,]*), layer is ([^,]*)/);
return {
level: match ? (match[1] !== '' ? match[1] : null) : null,
layer: match ? (match[2] !== 'To be voted' ? match[2] : null) : null
Expand Down

0 comments on commit f99aacf

Please sign in to comment.