From 702ef59574bd7d66c99339d80cb78c55a0456c6d Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 6 Nov 2011 00:04:36 +0100 Subject: quick fix to Layer cache generation --- src/mapdata.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mapdata.py b/src/mapdata.py index b43ff38..ad0bef2 100644 --- a/src/mapdata.py +++ b/src/mapdata.py @@ -44,21 +44,14 @@ class KPLayer(object): y2 = pos[1] + size[1] - # resize the cache if needed - cache = self.cache + # create the cache + # I was going to just resize it, but setting every tile to -1 + # in Python would probably be slower than creating a new one ... size = (x2 - x1, y2 - y1) width, height = size - oldSize = self.cacheSize - - if oldSize[1] < size[1]: - for i in xrange(size[1] - oldSize[1]): - cache.append([0 for i in xrange(width)]) - elif oldSize[1] > size[1]: - del cache[size[1]:] - - for i, elem in enumerate(cache): - if len(elem) != width: - cache[i] = [0 for i in xrange(width)] + + cache = [[-1 for i in xrange(width)] for j in xrange(height)] + self.cache = cache self.cacheBasePos = (x1, y1) self.cacheSize = size -- cgit v1.2.3