Add KSP:DMP fixes #78

This commit is contained in:
mmorrison 2018-02-13 03:24:40 -06:00
parent ca4ffe5614
commit 86422d576e
4 changed files with 41 additions and 1 deletions

View file

@ -202,6 +202,7 @@ Games List
* Killing Floor 2 (killingfloor2) [[Separate Query Port](#separate-query-port)] * Killing Floor 2 (killingfloor2) [[Separate Query Port](#separate-query-port)]
* Kingpin: Life of Crime (kingpin) [[Separate Query Port](#separate-query-port)] * Kingpin: Life of Crime (kingpin) [[Separate Query Port](#separate-query-port)]
* KISS Psycho Circus (kisspc) [[Separate Query Port](#separate-query-port)] * KISS Psycho Circus (kisspc) [[Separate Query Port](#separate-query-port)]
* DMP - KSP Multiplayer (kspdmp) [[Separate Query Port](#separate-query-port)]
* KzMod (kzmod) * KzMod (kzmod)
* Left 4 Dead (left4dead) * Left 4 Dead (left4dead)
* Left 4 Dead 2 (left4dead2) * Left 4 Dead 2 (left4dead2)

View file

@ -152,6 +152,7 @@ killingfloor|Killing Floor|killingfloor|port=7707,port_query_offset=1
killingfloor2|Killing Floor 2|valve|port=7777,port_query=27015 killingfloor2|Killing Floor 2|valve|port=7777,port_query=27015
kingpin|Kingpin: Life of Crime|gamespy1|port=31510,port_query_offset=-10 kingpin|Kingpin: Life of Crime|gamespy1|port=31510,port_query_offset=-10
kisspc|KISS Psycho Circus|gamespy1|port=7777,port_query_offset=1 kisspc|KISS Psycho Circus|gamespy1|port=7777,port_query_offset=1
kspdmp|DMP - KSP Multiplayer|kspdmp|port=6702,port_query_offset=1
kzmod|KzMod|valve kzmod|KzMod|valve
left4dead|Left 4 Dead|valve left4dead|Left 4 Dead|valve
left4dead2|Left 4 Dead 2|valve left4dead2|Left 4 Dead 2|valve

38
protocols/kspdmp.js Normal file
View file

@ -0,0 +1,38 @@
const request = require('request');
class Kspdmp extends require('./core') {
run(state) {
request({
uri: 'http://'+this.options.address+':'+this.options.port_query,
timeout: this.options.socketTimeout
}, (e,r,body) => {
if(e) return this.fatal('HTTP error');
let json;
try {
json = JSON.parse(body);
} catch(e) {
return this.fatal('Invalid JSON');
}
for (const one of json.players) {
state.players.push({name:one.nickname,team:one.team});
}
for (const key of Object.keys(json)) {
state.raw[key] = json[key];
}
state.name = json.server_name;
state.maxplayers = json.max_players;
if (json.players) {
const split = json.players.split(', ');
for (const name of split) {
state.players.push({name:name});
}
}
this.finish(state);
});
}
}
module.exports = Kspdmp;

View file

@ -4,7 +4,7 @@ class Terraria extends require('./core') {
run(state) { run(state) {
request({ request({
uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status', uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status',
timeout: 3000, timeout: this.options.socketTimeout,
qs: { qs: {
players: 'true', players: 'true',
token: this.options.token token: this.options.token