From f99aacf6be6d8c57a5acdb1e0a15169f9e96e2d4 Mon Sep 17 00:00:00 2001 From: Deniz Etkar Date: Sat, 10 Aug 2024 04:34:34 +0200 Subject: [PATCH] fix: update the server layer extraction (#363) Co-authored-by: Marek --- squad-server/index.js | 4 ++-- squad-server/layers/layers.js | 4 ++-- squad-server/rcon.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/squad-server/index.js b/squad-server/index.js index 49f0ea937..43a68b563 100644 --- a/squad-server/index.js +++ b/squad-server/index.js @@ -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() }); diff --git a/squad-server/layers/layers.js b/squad-server/layers/layers.js index b2cc4daae..6e8290145 100644 --- a/squad-server/layers/layers.js +++ b/squad-server/layers/layers.js @@ -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) { diff --git a/squad-server/rcon.js b/squad-server/rcon.js index 9d1719a2e..2355d6d27 100644 --- a/squad-server/rcon.js +++ b/squad-server/rcon.js @@ -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