mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 15:17:36 +00:00
Massive revamp for standardization of output
This commit is contained in:
parent
397d09d9d3
commit
007f1ffb8b
15 changed files with 153 additions and 119 deletions
|
|
@ -5,54 +5,55 @@ module.exports = require('./core').extend({
|
|||
this._super();
|
||||
this.encoding = 'latin1';
|
||||
},
|
||||
run: function() {
|
||||
run: function(state) {
|
||||
|
||||
var self = this;
|
||||
var state = {};
|
||||
|
||||
async.series([
|
||||
function(c) {
|
||||
self.sendPacket(0,true,function(b) {
|
||||
var reader = self.reader(b);
|
||||
state.serverid = reader.uint(4);
|
||||
state.ip = reader.pascal();
|
||||
state.port = reader.uint(4);
|
||||
state.queryport = reader.uint(4);
|
||||
state.raw.serverid = reader.uint(4);
|
||||
state.raw.ip = reader.pascal();
|
||||
state.raw.port = reader.uint(4);
|
||||
state.raw.queryport = reader.uint(4);
|
||||
state.name = reader.pascal();
|
||||
state.map = reader.pascal();
|
||||
state.gametype = reader.pascal();
|
||||
state.numplayers = reader.uint(4);
|
||||
state.raw.gametype = reader.pascal();
|
||||
state.raw.numplayers = reader.uint(4);
|
||||
state.maxplayers = reader.uint(4);
|
||||
state.ping = reader.uint(4);
|
||||
state.raw.ping = reader.uint(4);
|
||||
c();
|
||||
});
|
||||
},
|
||||
function(c) {
|
||||
self.sendPacket(1,true,function(b) {
|
||||
var reader = self.reader(b);
|
||||
state.mutators = [];
|
||||
state.rules = {};
|
||||
state.raw.mutators = [];
|
||||
state.raw.rules = {};
|
||||
while(!reader.done()) {
|
||||
var key = reader.pascal();
|
||||
var value = reader.pascal();
|
||||
if(key == 'Mutator') state.mutators.push(value);
|
||||
else state.rules[key] = value;
|
||||
if(key == 'Mutator') state.raw.mutators.push(value);
|
||||
else state.raw.rules[key] = value;
|
||||
}
|
||||
|
||||
if('GamePassword' in state.raw.rules)
|
||||
state.password = state.raw.rules.GamePassword != 'True';
|
||||
|
||||
c();
|
||||
});
|
||||
},
|
||||
function(c) {
|
||||
self.sendPacket(2,false,function(b) {
|
||||
var reader = self.reader(b);
|
||||
state.players = [];
|
||||
while(!reader.done()) {
|
||||
var id = reader.uint(4);
|
||||
console.log(b.slice(reader.offset()));
|
||||
var name = reader.pascal();
|
||||
var ping = reader.uint(4);
|
||||
var score = reader.uint(4);
|
||||
reader.skip(4);
|
||||
state.players.push({
|
||||
(ping == 0 ? state.bots : state.players).push({
|
||||
id: id, name: name, ping: ping, score: score
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue