Skip to content

Commit

Permalink
[BFH] fix map recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleveil committed Apr 13, 2015
1 parent 3416ec5 commit 10c3310
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions b3/parsers/bfh.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# - removed commander: BFH seems not to have commander feature
# - removed EVT_CLIENT_COMROSE and EVT_CLIENT_DISCONNECT_REASON
# 2015-04-13 - 0.2 - Thomas LEVEIL - adjust BFH_REQUIRED_VERSION
# - fix map recognition

import b3
import b3.clients
Expand Down Expand Up @@ -148,12 +149,12 @@
"""

# game maps: dict('Engine name'='Human-readable name')
MAP_NAME_BY_ID = dict([(x['Engine name'], x['Human-readable name']) for x in
MAP_NAME_BY_ID = dict([(x['Engine name'].lower(), x['Human-readable name']) for x in
csv.DictReader(maps_csv.splitlines(), dialect='dice')])

MAP_ID_BY_NAME = {name.lower(): x for x, name in MAP_NAME_BY_ID.items()}

GAME_MODES_BY_MAP_ID = dict([(x['Engine name'], x['Game modes,,,,,,,,,'].split(',')) for x in
GAME_MODES_BY_MAP_ID = dict([(x['Engine name'].lower(), x['Game modes,,,,,,,,,'].split(',')) for x in
csv.DictReader(maps_csv.splitlines(), dialect='dice')])


Expand Down Expand Up @@ -322,8 +323,8 @@ def OnPlayerTeamchange(self, action, data):

def OnPlayerSquadchange(self, action, data):
"""
player.onSquadChange <soldier name: player name> <team: Team ID> <squad: Squad ID>
player.onSquadChange <soldier name: player name> <team: Team ID> <squad: Squad ID>
Effect: Player might have changed squad
NOTE: this event also happens after a player left the game
"""
Expand Down Expand Up @@ -461,7 +462,7 @@ def getEasyName(self, mapname):
Change level name to real name.
"""
try:
return MAP_NAME_BY_ID[mapname]
return MAP_NAME_BY_ID[mapname.lower()]
except KeyError:
self.warning('unknown level name \'%s\': please report this on B3 forums' % mapname)
return mapname
Expand Down
4 changes: 3 additions & 1 deletion tests/parsers/test_bfh.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ def test_server_onLevelLoaded(self):
'', 'true', 'true', 'false', '428710', '6019', '108.61.98.177:40000', '', 'true', 'EU', 'ams', 'NL', '0',
'IN_GAME'])
# WHEN
self.parser.routeFrostbitePacket(['server.onLevelLoaded', 'MP_Glades', 'TeamDeathMatch0', '0', '1'])
with patch.object(self.parser, "warning") as warning_mock:
self.parser.routeFrostbitePacket(['server.onLevelLoaded', 'MP_Glades', 'TeamDeathMatch0', '0', '1'])
# THEN
event = self.parser.queueEvent.call_args[0][0]
self.assertEqual('Game Warmup', self.parser.getEventName(event.type))
self.assertEquals('MP_Glades', event.data)
self.assertListEqual([], warning_mock.mock_calls)


class Test_punkbuster_events(BFHTestCase):
Expand Down

0 comments on commit 10c3310

Please sign in to comment.