mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-18 09:40:38 +01:00
a7c3b5474c
* add top level version on existing entries * start adding version on new protocols WIP * add version to more games * more games with version * add more games * more version * even more games with version * add 'delete state.raw.version' * fix delete version * Update CHANGELOG.md * add version in Results.js * more games * add new game * more games * add version on README * add new game * other game * new game * add unreal2 version * add ventrilo version * add eldewrito eldewrito * add beammp version * fix starmade version * add new version in samp protocol * docs: tweak the changelog line a bit --------- Co-authored-by: CosminPerRam <cosmin.p@live.com>
45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
import Core from './core.js'
|
|
|
|
export default class ase extends Core {
|
|
async run (state) {
|
|
const buffer = await this.udpSend('s', (buffer) => {
|
|
const reader = this.reader(buffer)
|
|
const header = reader.string(4)
|
|
if (header === 'EYE1') return reader.rest()
|
|
})
|
|
|
|
const reader = this.reader(buffer)
|
|
state.raw.gamename = this.readString(reader)
|
|
state.gamePort = parseInt(this.readString(reader))
|
|
state.name = this.readString(reader)
|
|
state.raw.gametype = this.readString(reader)
|
|
state.map = this.readString(reader)
|
|
state.version = this.readString(reader)
|
|
state.password = this.readString(reader) === '1'
|
|
state.numplayers = parseInt(this.readString(reader))
|
|
state.maxplayers = parseInt(this.readString(reader))
|
|
|
|
while (!reader.done()) {
|
|
const key = this.readString(reader)
|
|
if (!key) break
|
|
const value = this.readString(reader)
|
|
state.raw[key] = value
|
|
}
|
|
|
|
while (!reader.done()) {
|
|
const flags = reader.uint(1)
|
|
const player = {}
|
|
if (flags & 1) player.name = this.readString(reader)
|
|
if (flags & 2) player.team = this.readString(reader)
|
|
if (flags & 4) player.skin = this.readString(reader)
|
|
if (flags & 8) player.score = parseInt(this.readString(reader))
|
|
if (flags & 16) player.ping = parseInt(this.readString(reader))
|
|
if (flags & 32) player.time = parseInt(this.readString(reader))
|
|
state.players.push(player)
|
|
}
|
|
}
|
|
|
|
readString (reader) {
|
|
return reader.pascalString(1, -1)
|
|
}
|
|
}
|