Automatically detect killing floor extended info, don't clobber re-used unreal 2 rule keys, add unreal 2 scoreboard info

This commit is contained in:
mmorrison 2019-10-26 20:20:26 -05:00
parent 34d43720aa
commit 6a0ed624c1
4 changed files with 45 additions and 54 deletions

View file

@ -132,7 +132,7 @@ insurgencysandstorm|Insurgency: Sandstorm (2018)|valve|port=27015,port_query_off
ironstorm|Iron Storm (2002)|gamespy1|port_query=3505 ironstorm|Iron Storm (2002)|gamespy1|port_query=3505
jamesbondnightfire|James Bond 007: Nightfire (2002)|gamespy1|port_query=6550 jamesbondnightfire|James Bond 007: Nightfire (2002)|gamespy1|port_query=6550
jc2mp|Just Cause 2 - Multiplayer (2010)|jc2mp|port=7777 jc2mp|Just Cause 2 - Multiplayer (2010)|jc2mp|port=7777
killingfloor|Killing Floor (2009)|killingfloor|port=7707,port_query_offset=1 killingfloor|Killing Floor (2009)|unreal2|port=7707,port_query_offset=1
killingfloor2|Killing Floor 2 (2016)|valve|port=7777,port_query=27015 killingfloor2|Killing Floor 2 (2016)|valve|port=7777,port_query=27015
kingpin|Kingpin: Life of Crime (1999)|gamespy1|port=31510,port_query_offset=-10 kingpin|Kingpin: Life of Crime (1999)|gamespy1|port=31510,port_query_offset=-10
kisspc|Kiss: Psycho Circus: The Nightmare Child (2000)|gamespy1|port=7777,port_query_offset=1 kisspc|Kiss: Psycho Circus: The Nightmare Child (2000)|gamespy1|port=7777,port_query_offset=1
@ -263,7 +263,7 @@ unreal|Unreal|gamespy1|port=7777,port_query_offset=1
unturned|unturned|valve|port=27015,port_query_offset=1 unturned|unturned|valve|port=27015,port_query_offset=1
ut|Unreal Tournament|gamespy1|port=7777,port_query_offset=1 ut|Unreal Tournament|gamespy1|port=7777,port_query_offset=1
ut2003|Unreal Tournament 2003|unreal2|port=7757,port_query_offset=1 ut2003|Unreal Tournament 2003|unreal2|port=7757,port_query_offset=1
ut2004|Unreal Tournament 2004|ut2004|port=7777,port_query_offset=1 ut2004|Unreal Tournament 2004|unreal2|port=7777,port_query_offset=1
ut3|Unreal Tournament 3|ut3|port=7777,port_query_offset=-1277 ut3|Unreal Tournament 3|ut3|port=7777,port_query_offset=-1277
urbanterror|Urban Terror|quake3|port_query=27960 urbanterror|Urban Terror|quake3|port_query=27960

View file

@ -1,10 +0,0 @@
const Unreal2 = require('./unreal2');
class KillingFloor extends Unreal2 {
readExtraInfo(reader,state) {
state.raw.wavecurrent = reader.uint(4);
state.raw.wavetotal = reader.uint(4);
}
}
module.exports = KillingFloor;

View file

@ -6,6 +6,7 @@ class Unreal2 extends Core {
this.encoding = 'latin1'; this.encoding = 'latin1';
} }
async run(state) { async run(state) {
let extraInfoReader;
{ {
const b = await this.sendPacket(0, true); const b = await this.sendPacket(0, true);
const reader = this.reader(b); const reader = this.reader(b);
@ -18,7 +19,10 @@ class Unreal2 extends Core {
state.raw.gametype = this.readUnrealString(reader, true); state.raw.gametype = this.readUnrealString(reader, true);
state.raw.numplayers = reader.uint(4); state.raw.numplayers = reader.uint(4);
state.maxplayers = reader.uint(4); state.maxplayers = reader.uint(4);
this.readExtraInfo(reader, state); this.logger.debug(log => {
log("UNREAL2 EXTRA INFO", reader.buffer.slice(reader.i));
});
extraInfoReader = reader;
} }
{ {
@ -29,57 +33,65 @@ class Unreal2 extends Core {
while(!reader.done()) { while(!reader.done()) {
const key = this.readUnrealString(reader,true); const key = this.readUnrealString(reader,true);
const value = this.readUnrealString(reader,true); const value = this.readUnrealString(reader,true);
if(key === 'Mutator') state.raw.mutators.push(value); this.logger.debug(key+'='+value);
else if (key || value) state.raw.rules[key] = value; if(key === 'Mutator' || key === 'mutator') {
state.raw.mutators.push(value);
} else if (key || value) {
if (state.raw.rules.hasOwnProperty(key)) {
state.raw.rules[key] += ',' + value;
} else {
state.raw.rules[key] = value;
}
}
} }
if('GamePassword' in state.raw.rules) if('GamePassword' in state.raw.rules)
state.password = state.raw.rules.GamePassword !== 'True'; state.password = state.raw.rules.GamePassword !== 'True';
} }
if (state.raw.mutators.includes('KillingFloorMut')
|| state.raw.rules['Num trader weapons']
|| state.raw.rules['Server Version'] === '1065'
) {
// Killing Floor
state.raw.wavecurrent = extraInfoReader.uint(4);
state.raw.wavetotal = extraInfoReader.uint(4);
state.raw.ping = extraInfoReader.uint(4);
state.raw.flags = extraInfoReader.uint(4);
state.raw.skillLevel = this.readUnrealString(extraInfoReader, true);
} else {
state.raw.ping = extraInfoReader.uint(4);
// These fields were added in later revisions of unreal engine
if (extraInfoReader.remaining() >= 8) {
state.raw.flags = extraInfoReader.uint(4);
state.raw.skill = this.readUnrealString(extraInfoReader, true);
}
}
{ {
const b = await this.sendPacket(2,false); const b = await this.sendPacket(2,false);
const reader = this.reader(b); const reader = this.reader(b);
state.raw.scoreboard = {};
while(!reader.done()) { while(!reader.done()) {
const player = {}; const player = {};
player.id = reader.uint(4); player.id = reader.uint(4);
if(!player.id) break;
if(player.id === 0) {
// Unreal2XMP Player (ID is always 0)
reader.skip(4);
}
player.name = this.readUnrealString(reader,true); player.name = this.readUnrealString(reader,true);
player.ping = reader.uint(4); player.ping = reader.uint(4);
player.score = reader.int(4); player.score = reader.int(4);
reader.skip(4); // stats ID player.statsId = reader.uint(4);
this.logger.debug(player);
// Extra data for Unreal2XMP players if (!player.id) {
if(player.id === 0) { state.raw.scoreboard[player.name] = player.score;
const count = reader.uint(1); } else if (!player.ping) {
for(let iField = 0; iField < count; iField++) { state.bots.push(player);
const key = this.readUnrealString(reader,true); } else {
const value = this.readUnrealString(reader,true); state.players.push(player);
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);
} }
} }
} }
readExtraInfo(reader,state) {
this.debugLog(log => {
log("UNREAL2 EXTRA INFO", reader.buffer.slice(reader.i));
});
}
readUnrealString(reader, stripColor) { readUnrealString(reader, stripColor) {
let length = reader.uint(1), ucs2 = false; let length = reader.uint(1), ucs2 = false;
if(length >= 0x80) { if(length >= 0x80) {

View file

@ -1,11 +0,0 @@
const Unreal2 = require('./unreal2');
class Ut2004 extends Unreal2 {
readExtraInfo(reader,state) {
state.raw.ping = reader.uint(4);
state.raw.flags = reader.uint(4);
state.raw.skill = reader.uint(2);
}
}
module.exports = Ut2004;