summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-06 00:04:36 +0100
committerTreeki <treeki@gmail.com>2011-11-06 00:04:36 +0100
commit702ef59574bd7d66c99339d80cb78c55a0456c6d (patch)
tree5545e8cd943c4954bc4ded677ec9da9a0d7dc9f8
parent8136cf1c533aec33ece4765cb3a3feda806450d3 (diff)
downloadkoopatlas-702ef59574bd7d66c99339d80cb78c55a0456c6d.tar.gz
koopatlas-702ef59574bd7d66c99339d80cb78c55a0456c6d.zip
quick fix to Layer cache generation
-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