Misc tidying
This commit is contained in:
parent
a3c14a8d42
commit
add06a7d8f
|
@ -4,6 +4,8 @@ var argv = require('optimist').argv;
|
|||
|
||||
var debug = argv.debug;
|
||||
delete argv.debug;
|
||||
var outputFormat = argv.output;
|
||||
delete argv.output;
|
||||
|
||||
var options = {};
|
||||
for(var key in argv) {
|
||||
|
@ -22,6 +24,10 @@ if(debug) Gamedig.debug = true;
|
|||
Gamedig.query(
|
||||
options,
|
||||
function(state) {
|
||||
console.log(state);
|
||||
if(outputFormat == 'pretty') {
|
||||
console.log(JSON.stringify(state,null,' '));
|
||||
} else {
|
||||
console.log(JSON.stringify(state));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -19,8 +19,6 @@ module.exports = require('./protocols/gamespy3').extend({
|
|||
},
|
||||
finalizeState: function(state) {
|
||||
this._super(state);
|
||||
console.log(state.players.length);
|
||||
console.log(state.raw.numplayers);
|
||||
if(!state.players.length && parseInt(state.raw.numplayers)) {
|
||||
for(var i = 0; i < parseInt(state.raw.numplayers); i++) {
|
||||
state.players.push({});
|
||||
|
|
|
@ -10,7 +10,7 @@ var udpSocket = dgram.createSocket('udp4');
|
|||
udpSocket.unref();
|
||||
udpSocket.bind(21943);
|
||||
udpSocket.on('message', function(buffer, rinfo) {
|
||||
if(Gamedig.debug) console.log("Received",buffer,rinfo.address,rinfo.port);
|
||||
if(Gamedig.debug) console.log(rinfo.address+':'+rinfo.port+" <-- "+buffer.toString('hex'));
|
||||
for(var i = 0; i < activeQueries.length; i++) {
|
||||
var query = activeQueries[i];
|
||||
if(
|
||||
|
|
|
@ -105,6 +105,9 @@ Reader.prototype = {
|
|||
this.i += 4;
|
||||
return r;
|
||||
},
|
||||
rest: function() {
|
||||
return this.buffer.slice(this.i);
|
||||
},
|
||||
done: function() {
|
||||
return this.i >= this.buffer.length;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue