summaryrefslogtreecommitdiff
path: root/src/mapdata.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapdata.py')
-rw-r--r--src/mapdata.py19
1 files changed, 6 insertions, 13 deletions
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