mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
Fix issues with corrupt strings in unreal2 protocol
This commit is contained in:
parent
f952652251
commit
2915d962a8
5 changed files with 57 additions and 16 deletions
|
@ -158,7 +158,7 @@ Supported Games
|
||||||
* TrackMania 2 (trackmania2) [[Additional Notes](#nadeo-shootmania--trackmania--etc)]
|
* TrackMania 2 (trackmania2) [[Additional Notes](#nadeo-shootmania--trackmania--etc)]
|
||||||
* TrackMania Forever (trackmaniaforever) [[Additional Notes](#nadeo-shootmania--trackmania--etc)]
|
* TrackMania Forever (trackmaniaforever) [[Additional Notes](#nadeo-shootmania--trackmania--etc)]
|
||||||
* Unreal Tournament (ut) [[Separate Query Port - Usually port+1](#separate-query-port)]
|
* Unreal Tournament (ut) [[Separate Query Port - Usually port+1](#separate-query-port)]
|
||||||
* Unreal Tournament 2004 (ut2004)
|
* Unreal Tournament 2004 (ut2004) [[Separate Query Port - Usually port+1](#separate-query-port)]
|
||||||
* Unreal Tournament 3 (ut3) [[Separate Query Port - Usually 6500](#separate-query-port)]
|
* Unreal Tournament 3 (ut3) [[Separate Query Port - Usually 6500](#separate-query-port)]
|
||||||
* Warsow (warsow)
|
* Warsow (warsow)
|
||||||
* Wolfenstein 2009 (wolfenstein2009)
|
* Wolfenstein 2009 (wolfenstein2009)
|
||||||
|
|
|
@ -5,8 +5,6 @@ module.exports = require('./protocols/unreal2').extend({
|
||||||
this.pretty = 'Killing Floor';
|
this.pretty = 'Killing Floor';
|
||||||
},
|
},
|
||||||
readExtraInfo: function(reader,state) {
|
readExtraInfo: function(reader,state) {
|
||||||
state.raw.numplayers = reader.uint(4);
|
|
||||||
state.maxplayers = reader.uint(4);
|
|
||||||
state.raw.wavecurrent = reader.uint(4);
|
state.raw.wavecurrent = reader.uint(4);
|
||||||
state.raw.wavetotal = reader.uint(4);
|
state.raw.wavetotal = reader.uint(4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,24 @@ module.exports = Class.extend(EventEmitter,{
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
debugBuffer: function(buffer) {
|
||||||
|
var out = '';
|
||||||
|
var out2 = '';
|
||||||
|
for(var i = 0; i < buffer.length; i++) {
|
||||||
|
var sliced = buffer.slice(i,i+1);
|
||||||
|
out += sliced.toString('hex')+' ';
|
||||||
|
var chr = sliced.toString();
|
||||||
|
if(chr < ' ' || chr > '~') chr = ' ';
|
||||||
|
out2 += chr+' ';
|
||||||
|
if(out.length > 60) {
|
||||||
|
console.log(out);
|
||||||
|
console.log(out2);
|
||||||
|
out = out2 = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(out);
|
||||||
|
console.log(out2);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,10 @@ module.exports = require('./core').extend({
|
||||||
state.raw.port = reader.uint(4);
|
state.raw.port = reader.uint(4);
|
||||||
state.raw.queryport = reader.uint(4);
|
state.raw.queryport = reader.uint(4);
|
||||||
state.name = self.readUnrealString(reader,true);
|
state.name = self.readUnrealString(reader,true);
|
||||||
self.readUnrealString(reader); // unknown?
|
|
||||||
state.map = self.readUnrealString(reader,true);
|
state.map = self.readUnrealString(reader,true);
|
||||||
state.raw.gametype = self.readUnrealString(reader,true);
|
state.raw.gametype = self.readUnrealString(reader,true);
|
||||||
|
state.raw.numplayers = reader.uint(4);
|
||||||
|
state.maxplayers = reader.uint(4);
|
||||||
self.readExtraInfo(reader,state);
|
self.readExtraInfo(reader,state);
|
||||||
|
|
||||||
c();
|
c();
|
||||||
|
@ -47,15 +48,37 @@ module.exports = require('./core').extend({
|
||||||
function(c) {
|
function(c) {
|
||||||
self.sendPacket(2,false,function(b) {
|
self.sendPacket(2,false,function(b) {
|
||||||
var reader = self.reader(b);
|
var reader = self.reader(b);
|
||||||
|
|
||||||
while(!reader.done()) {
|
while(!reader.done()) {
|
||||||
var id = reader.uint(4);
|
var player = {};
|
||||||
var name = self.readUnrealString(reader,true);
|
player.id = reader.uint(4);
|
||||||
var ping = reader.uint(4);
|
if(!player.id) break;
|
||||||
var score = reader.uint(4);
|
if(player.id == 0) {
|
||||||
|
// Unreal2XMP Player (ID is always 0)
|
||||||
reader.skip(4);
|
reader.skip(4);
|
||||||
(ping == 0 ? state.bots : state.players).push({
|
}
|
||||||
id: id, name: name, ping: ping, score: score
|
player.name = self.readUnrealString(reader,true);
|
||||||
});
|
player.ping = reader.uint(4);
|
||||||
|
player.score = reader.int(4);
|
||||||
|
reader.skip(4); // stats ID
|
||||||
|
|
||||||
|
// Extra data for Unreal2XMP players
|
||||||
|
if(player.id == 0) {
|
||||||
|
var count = reader.uint(1);
|
||||||
|
for(var iField = 0; iField < count; iField++) {
|
||||||
|
var key = self.readUnrealString(reader,true);
|
||||||
|
var value = self.readUnrealString(reader,true);
|
||||||
|
player[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.id == 0 && player.name == 'Player') {
|
||||||
|
// these show up in ut2004 queries, but aren't real
|
||||||
|
// not even really sure why they're there
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
(player.ping ? state.players : state.bots).push(player);
|
||||||
}
|
}
|
||||||
c();
|
c();
|
||||||
});
|
});
|
||||||
|
@ -79,7 +102,9 @@ module.exports = require('./core').extend({
|
||||||
var length = reader.uint(1);
|
var length = reader.uint(1);
|
||||||
var out;
|
var out;
|
||||||
if(length < 0x80) {
|
if(length < 0x80) {
|
||||||
out = reader.string({length:length});
|
//out = reader.string({length:length});
|
||||||
|
out = '';
|
||||||
|
if(length > 0) out = reader.string();
|
||||||
} else {
|
} else {
|
||||||
length = (length&0x7f)*2;
|
length = (length&0x7f)*2;
|
||||||
out = length+reader.string({encoding:'ucs2',length:length});
|
out = length+reader.string({encoding:'ucs2',length:length});
|
||||||
|
|
|
@ -5,8 +5,8 @@ module.exports = require('./protocols/unreal2').extend({
|
||||||
this.pretty = 'Unreal Tournament 2004';
|
this.pretty = 'Unreal Tournament 2004';
|
||||||
},
|
},
|
||||||
readExtraInfo: function(reader,state) {
|
readExtraInfo: function(reader,state) {
|
||||||
reader.skip(18);
|
state.raw.ping = reader.uint(4);
|
||||||
state.raw.numplayers = reader.uint(4);
|
state.raw.flags = reader.uint(4);
|
||||||
state.maxplayers = reader.uint(4);
|
state.raw.skill = reader.uint(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue