courgette/big-brother-bot — Issue #42: OnPBNewConnection can fail if player left the game
Author: courgette
Created: 2011-11-06 19:59:47+00:00
State: open

## Description
When B3 receive a punkbuster message of type `Player GUID Computed` it tries to save the pbid in the `Client` object.
To fetch the correct `Client` object we just have the player name. If the player left the game just before we try to get the `Client` object, then we fail to obtain an object and end up with `None`.

This particular case is not taken care of and generates an error as in the log below.

```
111106 19:21:19	CONSOLE	"['player.onAuthenticated', 'saimon0007']"
111106 19:21:19	CONSOLE	'[\'punkBuster.onMessage\', \'PunkBuster Server: New Connection (slot #23) 83.53.57.144:3659 [?] "saimon0007" (seq 15212082)\\n\']'
111106 19:21:19	CONSOLE	"['punkBuster.onMessage', 'PunkBuster Server: Player GUID Computed 60473c32d989238426d13453cec313fa(-) (slot #23) 83.53.57.144:3659 saimon0007\\n']"
111106 19:21:19	VERBOSE	u"RCON :\t ('admin.listPlayers', 'player', 'saimon0007')"
111106 19:21:19	CONSOLE	"['player.onLeave', 'saimon0007', '7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '1', 'saimon0007', '', '0', '0', '0', '0', '0']"
111106 19:21:19	CONSOLE	"['punkBuster.onMessage', 'PunkBuster Server: Lost Connection (slot #23) 83.53.57.144:3659 60473c32d989238426d13453cec313fa(-) saimon0007\\n']"
111106 19:21:19	VERBOSE	u"RCON response:\t ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '0']"
111106 19:21:19	DEBUG	'no such client found'
111106 19:21:19	VERBOSE	u"RCON :\t ('admin.listPlayers', 'player', 'saimon0007')"
111106 19:21:19	VERBOSE	u"RCON response:\t ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '0']"
111106 19:21:19	DEBUG	'no such client found'
111106 19:21:19	WARNING	"OnPBNewConnection: we've been unable to get the client"
111106 19:21:19	VERBOSE	u"RCON :\t ('admin.listPlayers', 'player', 'saimon0007')"
111106 19:21:19	VERBOSE	u"RCON response:\t ['7', 'name', 'guid', 'teamId', 'squadId', 'kills', 'deaths', 'score', '0']"
111106 19:21:19	DEBUG	'no such client found'
111106 19:21:19	INFO	'STDOUT \'Error: \\\'NoneType\\\' object has no attribute \\\'ip\\\'\\n File "c:\\\\bf3\\\\b3\\\\__init__.py", line 182, in start\\n console.start()\\n File "c:\\\\bf3\\\\b3\\\\parser.py", line 476, in start\\n self.run()\\n File "c:\\\\bf3\\\\b3\\\\parsers\\\\frostbite2\\\\abstractParser.py", line 121, in run\\n self.routeFrostbitePacket(packet)\\n File "c:\\\\bf3\\\\b3\\\\parsers\\\\frostbite2\\\\abstractParser.py", line 208, in routeFrostbitePacket\\n event = func(eventType, eventData)\\n File "c:\\\\bf3\\\\b3\\\\parsers\\\\frostbite2\\\\abstractParser.py", line 536, in OnPunkbusterMessage\\n event = func(match, data[0])\\n File "c:\\\\bf3\\\\b3\\\\parsers\\\\frostbite2\\\\abstractParser.py", line 615, in OnPBPlayerGuid\\n client.ip = ip\\n\''
111106 19:21:19	INFO	"STDOUT '\\n'"

```

## Proposal
Test if `client` is None right after `client = self.getClient(name)`
If `None` then return