comparison gamelib/gameboard.py @ 405:ae3cee7a1337

Fix crash due to invalid cache
author Neil Muller <drnlmuller@gmail.com>
date Thu, 19 Nov 2009 13:53:00 +0000
parents c7cfa230f5d4
children 02a6de5629d6
comparison
equal deleted inserted replaced
404:e5247ec76f24 405:ae3cee7a1337
819 819
820 def _add_to_pos_cache(self, animal, cache_type): 820 def _add_to_pos_cache(self, animal, cache_type):
821 self._pos_cache[cache_type][animal.pos.x][animal.pos.y][animal.pos.z] = animal 821 self._pos_cache[cache_type][animal.pos.x][animal.pos.y][animal.pos.z] = animal
822 822
823 def _update_pos_cache(self, old_pos, animal, cache_type): 823 def _update_pos_cache(self, old_pos, animal, cache_type):
824 if self.in_bounds(old_pos): 824 if self.in_bounds(old_pos) and self._pos_cache[cache_type]:
825 self._pos_cache[cache_type][old_pos.x][old_pos.y][old_pos.z] = None 825 self._pos_cache[cache_type][old_pos.x][old_pos.y][old_pos.z] = None
826 if animal: 826 if animal:
827 pos = animal.pos 827 pos = animal.pos
828 if self.in_bounds(pos): 828 if self.in_bounds(pos):
829 self._pos_cache[cache_type][pos.x][pos.y][pos.z] = animal 829 self._pos_cache[cache_type][pos.x][pos.y][pos.z] = animal