node-gamedig/protocols/jc2mp.js

23 lines
663 B
JavaScript
Raw Normal View History

const Gamespy3 = require('./gamespy3');
2014-10-29 08:02:03 +01:00
// supposedly, gamespy3 is the "official" query protocol for jcmp,
2019-01-10 13:03:07 +01:00
// but it's broken (requires useOnlySingleSplit), and may not include some player names
class Jc2mp extends Gamespy3 {
2017-08-09 12:32:09 +02:00
constructor() {
super();
this.useOnlySingleSplit = true;
2019-01-09 12:35:11 +01:00
this.isJc2mp = true;
2019-01-10 13:03:07 +01:00
this.encoding = 'utf8';
2017-08-09 12:32:09 +02:00
}
2019-01-09 12:35:11 +01:00
async run(state) {
2019-01-10 13:03:07 +01:00
await super.run(state);
2017-08-09 12:32:09 +02:00
if(!state.players.length && parseInt(state.raw.numplayers)) {
for(let i = 0; i < parseInt(state.raw.numplayers); i++) {
state.players.push({});
}
}
}
}
module.exports = Jc2mp;