diff --git a/squad-server/index.js b/squad-server/index.js index 5538c5f..5ac2033 100644 --- a/squad-server/index.js +++ b/squad-server/index.js @@ -81,6 +81,8 @@ export default class SquadServer extends EventEmitter { await this.updateLayerInformation(); await this.updateA2SInformation(); + await this.logParser.watch(); + Logger.verbose('SquadServer', 1, `Watching ${this.serverName}...`); await this.pingSquadJSAPI(); @@ -159,6 +161,8 @@ export default class SquadServer extends EventEmitter { this.rcon.on('SQUAD_CREATED', async (data) => { data.player = await this.getPlayerBySteamID(data.playerSteamID, true); + data.player.squadID = data.squadID; + delete data.playerName; delete data.playerSteamID; @@ -485,6 +489,13 @@ export default class SquadServer extends EventEmitter { }); } + if (this.a2sPlayerCount > 0 && players.length === 0) + Logger.verbose( + 'SquadServer', + 1, + `Real Player Count: ${this.a2sPlayerCount} but loaded ${players.length}` + ); + this.emit('UPDATED_PLAYER_INFORMATION'); } catch (err) { Logger.verbose('SquadServer', 1, 'Failed to update player list.', err); diff --git a/squad-server/rcon.js b/squad-server/rcon.js index 4052233..3d7153d 100644 --- a/squad-server/rcon.js +++ b/squad-server/rcon.js @@ -144,24 +144,19 @@ export default class SquadRcon extends Rcon { for (const line of response.split('\n')) { const match = line.match( - /ID: ([0-9]+) \| Online IDs: EOS: ([0-9a-f]{32}) steam: (\d{17}) \| Name: (.+) \| Team ID: ([0-9]+) \| Squad ID: ([0-9]+|N\/A) \| Is Leader: (True|False) \| Role: ([A-Za-z0-9_]*)\b/ + /^ID: (?\d+) \| Online IDs: EOS: (?[a-f\d]{32}) (?:steam: (?\d{17}) )?\| Name: (?.+) \| Team ID: (?\d|N\/A) \| Squad ID: (?\d+|N\/A) \| Is Leader: (?True|False) \| Role: (?.+)$/ ); if (!match) continue; - if (server && server.rcon) server.rcon.addIds(match[3], match[2]); + if (server?.rcon?.addIds) server.rcon.addIds(match[3], match[2]); - players.push({ - playerID: match[1], - EOSID: match[2], - steamID: match[3], - name: match[4], - teamID: match[5], - squadID: match[6] !== 'N/A' ? match[5] : null, - isLeader: match[7] === 'True', - isSquadLeader: match[7] === 'True', - role: match[8], - rconRole: match[8] - }); + const data = match.groups; + data.isLeader = data.isLeader === 'True'; + data.squadID = data.squadID !== 'N/A' ? data.squadID : null; + data.isSquadLeader = match[7] === 'True'; + data.rconRole = match[8]; + + players.push(data); } return players; @@ -178,9 +173,9 @@ export default class SquadRcon extends Rcon { for (const line of responseSquad.split('\n')) { const match = line.match( - /ID: ([0-9]+) \| Name: (.+) \| Size: ([0-9]+) \| Locked: (True|False) \| Creator Name: (.+) \| Creator Online IDs: EOS: ([0-9a-f]{32}) steam: (\d{17})/ + /ID: (\d+) \| Name: (.+) \| Size: (\d+) \| Locked: (True|False) \| Creator Name: (.+) \| Creator Online IDs: EOS: ([a-f\d]{32}) steam: (\d{17})/ ); - const matchSide = line.match(/Team ID: (1|2) \((.+)\)/); + const matchSide = line.match(/Team ID: (\d) \((.+)\)/); if (matchSide) { teamID = matchSide[1]; teamName = matchSide[2]; @@ -192,6 +187,7 @@ export default class SquadRcon extends Rcon { size: match[3], locked: match[4], creatorName: match[5], + creatorEOSID: match[6], creatorSteamID: match[7], teamID: teamID, teamName: teamName