mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
add warsow
This commit is contained in:
parent
a777ec79e1
commit
935f61c4ad
3 changed files with 33 additions and 8 deletions
|
@ -30,6 +30,7 @@
|
||||||
"bignum": ">=0.6.1",
|
"bignum": ">=0.6.1",
|
||||||
"async": ">=0.2.9",
|
"async": ">=0.2.9",
|
||||||
"compressjs": ">=1.0.0",
|
"compressjs": ">=1.0.0",
|
||||||
"gbxremote": ">=0.1.2"
|
"gbxremote": ">=0.1.2",
|
||||||
|
"request": ">=2.22.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,21 @@ module.exports = require('./core').extend({
|
||||||
state.players = [];
|
state.players = [];
|
||||||
while(!reader.done()) {
|
while(!reader.done()) {
|
||||||
var player = reader.string();
|
var player = reader.string();
|
||||||
var split = player.split('"');
|
|
||||||
var split1 = split[0].split(' ');
|
|
||||||
|
|
||||||
var frags = parseInt(split1[0]);
|
var args = [];
|
||||||
var ping = parseInt(split1[1]);
|
var split = player.split('"');
|
||||||
var name = split[1] || '';
|
var inQuote = false;
|
||||||
var address = split[3] || '';
|
for(var i = 0; i < split; i++) {
|
||||||
|
var part = split[i];
|
||||||
|
var inQuote = (i%2 == 1);
|
||||||
|
if(inQuote) args.push(part);
|
||||||
|
else args = args.concat(part.split(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
var frags = parseInt(args[0]);
|
||||||
|
var ping = parseInt(args[1]);
|
||||||
|
var name = args[2] || '';
|
||||||
|
var address = args[3] || '';
|
||||||
|
|
||||||
state.players.push({
|
state.players.push({
|
||||||
frags:frags, ping:ping, name:name, address:address
|
frags:frags, ping:ping, name:name, address:address
|
||||||
|
|
16
protocols/warsow.js
Normal file
16
protocols/warsow.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module.exports = require('./quake3').extend({
|
||||||
|
init: function() {
|
||||||
|
this._super();
|
||||||
|
this.options.port = 44400;
|
||||||
|
},
|
||||||
|
prepState: function(state) {
|
||||||
|
this._super(state);
|
||||||
|
if(state.players) {
|
||||||
|
for(var i = 0; i < state.players.length; i++) {
|
||||||
|
var player = state.players[i];
|
||||||
|
player.team = player.address;
|
||||||
|
delete player.address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue