node-gamedig/protocols/geneshift.js
CosminPerRam da7a4a6334
Remove Players::setNum and stabilize field numplayers (#389)
* Remove Players Set Num

* Stabilize numplayers on armagetron

* Stabilize numplayers on ase

* Stabilize numplayers on assettocorsa

* Optimize away a variable declaration

* Stabilize numplayers on buildandshoot

* Stabilize numplayers on cs2d

* Fix wrong raw field parsed on Doom3

* Updated CHANGELOG and README regarding doom3 fix and numplayers

* Stabilize numplayers on doom3

* Stabilize numplayers on eco

* Stabilize numplayers on ffow

* Stabilize numplayers on quake2

* Stabilize numplayers on gamespy1

* Stabilize numplayers on gamespy2

* Stabilize numplayers on gamespy3

* Remove reductant numplayers setter in jc2mp

* Stabilize numplayers on kspdmp

* Stabilize numplayers on mafia2mp

* Stabilize numplayers on minecraftvanilla and remove players empty placeholders

* Stabilize numplayers on nadeo

* Stabilize numplayers on samp and reduce unused setters

* Stabilize numplayers on terraria

* Stabilize numplayers on tribes1

* Stabilize numplayers on unreal2

* Stabilize numplayers on valve

* Stabilize numplayers on ventrilo

* Battlefield: Set numplayers from info, not players

* Stabilize numplayers on minecraft

* Stabilize numplayers on teamspeak2

* Stabilize numplayers on teamspeak3

* Update CHANGELOG.md to add removal of players placeholders

* Replaced minecraft gamespy numplayers
2023-10-27 19:48:56 +03:00

47 lines
1.4 KiB
JavaScript

import Core from './core.js'
export default class geneshift extends Core {
async run (state) {
await this.tcpPing()
const body = await this.request({
url: 'http://geneshift.net/game/receiveLobby.php'
})
const split = body.split('<br/>')
let found = null
for (const line of split) {
const fields = line.split('::')
const ip = fields[2]
const port = fields[3]
if (ip === this.options.address && parseInt(port) === this.options.port) {
found = fields
break
}
}
if (found === null) {
throw new Error('Server not found in list')
}
state.raw.countrycode = found[0]
state.raw.country = found[1]
state.name = found[4]
state.map = found[5]
state.numplayers = parseInt(found[6])
state.maxplayers = parseInt(found[7])
// fields[8] is unknown?
state.raw.rules = found[9]
state.raw.gamemode = parseInt(found[10])
state.raw.gangsters = parseInt(found[11])
state.raw.cashrate = parseInt(found[12])
state.raw.missions = !!parseInt(found[13])
state.raw.vehicles = !!parseInt(found[14])
state.raw.customweapons = !!parseInt(found[15])
state.raw.friendlyfire = !!parseInt(found[16])
state.raw.mercs = !!parseInt(found[17])
// fields[18] is unknown? listen server?
state.raw.version = found[19]
}
}