From b5ae623a69f071d2101f160db833b09cb080243c Mon Sep 17 00:00:00 2001 From: Michael Morrison Date: Wed, 10 Jul 2013 11:41:49 -0500 Subject: [PATCH] fix ut3 servers timing out --- protocols/gamespy3.js | 6 +++--- protocols/ut3.js | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/protocols/gamespy3.js b/protocols/gamespy3.js index f624ab4..4ce6121 100644 --- a/protocols/gamespy3.js +++ b/protocols/gamespy3.js @@ -11,9 +11,9 @@ module.exports = require('./core').extend({ this.sendPacket(9,false,false,false,function(buffer) { var reader = self.reader(buffer); reader.skip(5); - var challenge = reader.string(); + var challenge = parseInt(reader.string()); - self.sendPacket(0,challenge,new Buffer([0,0,0,0]),true,function(buffer) { + self.sendPacket(0,challenge,new Buffer([0xff,0xff,0xff,0x01]),true,function(buffer) { var reader = self.reader(buffer); var state = { @@ -59,7 +59,7 @@ module.exports = require('./core').extend({ b.writeUInt8(0xFD, 1); b.writeUInt8(type, 2); b.writeUInt32BE(this.sessionId, 3); - if(challengeLength) b.writeUInt32BE(challenge, 7); + if(challengeLength) b.writeInt32BE(challenge, 7); if(payloadLength) payload.copy(b, 7+challengeLength); var numPackets = 0; diff --git a/protocols/ut3.js b/protocols/ut3.js index 6660648..7276a88 100644 --- a/protocols/ut3.js +++ b/protocols/ut3.js @@ -7,12 +7,13 @@ module.exports = require('./gamespy3').extend({ this._super(state); this.translateState(state,{ - 'OwningPlayerName': 'hostname', - 'p1073741825': 'mapname', + //'OwningPlayerName': 'hostname', + 'mapname': false, + 'p1073741825': 'map', 'p1073741826': 'gametype', 'p1073741827': 'servername', 'p1073741828': 'custom_mutators', - 'gamemode': 'open', + 'gamemode': 'joininprogress', 's32779': 'gamemode', 's0': 'bot_skill', 's6': 'pure_server', @@ -23,13 +24,24 @@ module.exports = require('./gamespy3').extend({ 'p268435705': 'time_limit', 'p268435703': 'numbots', 'p268435717': 'stock_mutators', + 'p1073741829': 'stock_mutators', 's1': false, 's9': false, 's11': false, 's12': false, 's13': false, - 's14': false + 's14': false, + 'p268435706': false, + 'p268435968': false, + 'p268435969': false }); - state['custom_mutators'] = state['custom_mutators'].split('\x1c'); + + function split(a) { + var s = a.split('\x1c'); + s = s.filter(function(e) { return e }); + return s; + } + if('custom_mutators' in state) state['custom_mutators'] = split(state['custom_mutators']); + if('stock_mutators' in state) state['stock_mutators'] = split(state['stock_mutators']); } });