0

Use a more efficient checker for cached images

This commit is contained in:
Ryan McCue
2010-12-11 21:10:59 +10:00
parent 9bc7c10bd1
commit e7c19f9309
2 changed files with 21 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ import Queue
import sys
import logging
import cPickle
import collections
import numpy
@@ -107,6 +108,20 @@ class WorldRenderer(object):
textures.prepareBiomeData(worlddir)
self.chunklist = chunklist
self.cached = collections.defaultdict(dict)
# In order to avoid having to look up the cache file names in
# ChunkRenderer, get them all and store them here
for root, dirnames, filenames in os.walk('.'):
for filename in filenames:
if not filename.endswith('.png'):
continue
dirname, dir_b = os.path.split(root)
_, dir_a = os.path.split(dirname)
_, x, z, cave, _ = filename.split('.', 4)
bits = '.'.join((dir_a, dir_b, x, z, cave))
self.cached[bits] = os.path.join(root, filename)
# stores Points Of Interest to be mapped with markers
# a list of dictionaries, see below for an example