Add battalion 1944 Fixes #84

This commit is contained in:
mmorrison 2018-05-05 03:00:54 -05:00
parent 69614c606c
commit 1b85fda837
3 changed files with 32 additions and 1 deletions

View file

@ -107,6 +107,7 @@ Games List
* ArmA 3 (arma3) [[Separate Query Port](#separate-query-port)]
* Armagetron (armagetron)
* Baldur's Gate (baldursgate) [[Separate Query Port](#separate-query-port)]
* Battalion 1944 (bat1944) [[Separate Query Port](#separate-query-port)]
* Battlefield 1942 (bf1942) [[Separate Query Port](#separate-query-port)]
* Battlefield Vietnam (bfv) [[Separate Query Port](#separate-query-port)]
* Battlefield 2 (bf2) [[Separate Query Port](#separate-query-port)]

View file

@ -49,6 +49,7 @@ arma3|ArmA 3|valve|port=2302,port_query_offset=1
armagetron|Armagetron|armagetron|port=4534
baldursgate|Baldur's Gate|gamespy1|port=6073,port_query=1470
bat1944|Battalion 1944|valve|port=7777,port_query_offset=3
bf1942|Battlefield 1942|gamespy1|port=14567,port_query=23000
bfv|Battlefield Vietnam|gamespy2|port=15567,port_query=23000

View file

@ -37,6 +37,7 @@ class Valve extends require('./core') {
(c) => { this.queryChallenge(state,c); },
(c) => { this.queryPlayers(state,c); },
(c) => { this.queryRules(state,c); },
(c) => { this.cleanup(state,c); },
(c) => { this.finish(state); }
]);
}
@ -203,10 +204,10 @@ class Valve extends require('./core') {
}
queryRules(state,c) {
state.raw.rules = {};
this.sendPacket(0x56,true,false,0x45,(b) => {
const reader = this.reader(b);
const num = reader.uint(2);
state.raw.rules = {};
for(let i = 0; i < num; i++) {
const key = reader.string();
const value = reader.string();
@ -222,6 +223,34 @@ class Valve extends require('./core') {
});
}
cleanup(state,c) {
// Battalion 1944 puts its info into rules fields for some reason
if ('bat_name_s' in state.raw.rules) {
state.name = state.raw.rules.bat_name_s;
delete state.raw.rules.bat_name_s;
if ('bat_player_count_s' in state.raw.rules) {
state.raw.numplayers = parseInt(state.raw.rules.bat_player_count_s);
state.players = [];
for(let i = 0; i < state.raw.numplayers; i++) {
state.players.push({});
}
delete state.raw.rules.bat_player_count_s;
}
if ('bat_max_players_i' in state.raw.rules) {
state.maxplayers = parseInt(state.raw.rules.bat_max_players_i);
delete state.raw.rules.bat_max_players_i;
}
if ('bat_has_password_s' in state.raw.rules) {
state.password = state.raw.rules.bat_has_password_s === 'Y';
delete state.raw.rules.bat_has_password_s;
}
// apparently map is already right, and this var is often wrong
delete state.raw.rules.bat_map_s;
}
c();
}
sendPacket(type,sendChallenge,payload,expect,callback,ontimeout) {
const packetStorage = {};