Skip to content

Commit

Permalink
Don't crash in case of missing geplayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Herne committed Nov 23, 2014
1 parent 65de1c9 commit 3d15d41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion HUD.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def __init__(self, player, window):

def draw(self, region, scrollpos):
"""Draw the heads-up display"""
geplayer = self.player.geplayer
with self.player.statelock:
geplayer = self.player.geplayer
if geplayer is None:
return False
region = pygame.Rect(region)
pygame.draw.rect(self.window, BLACK, region)
framewidth = self.frame.thickness[Frame.VERTICAL]
Expand Down
7 changes: 5 additions & 2 deletions MessageBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def update(self):
highestpriority = 0
highestprioritymgo = None
self.string = None
mgolist = self.player.geplayer.world.gemgos #FIXME
with self.player.statelock:
if self.player.geplayer is None:
return False
mgolist = self.player.geplayer.world.gemgos
if len(mgolist) > 0:
for mgo in mgolist:
if mgo.message[1] > highestpriority:
Expand All @@ -44,4 +47,4 @@ def update(self):
self.string = highestprioritymgo.message[0]
highestprioritymgo.mdnotify()
else:
self.string = None
self.string = None

0 comments on commit 3d15d41

Please sign in to comment.