0

Improved handling of signposts

This commit is contained in:
Andrew Chin
2010-10-24 00:19:27 -04:00
parent cb363df3cd
commit f2b34dff7a
3 changed files with 32 additions and 37 deletions

View File

@@ -520,32 +520,6 @@ class ChunkRenderer(object):
else:
t = textures.blockmap[blockid]
# see if we want to do anything else with this chunk
if blockid in (63, 68): # signs
# find the sign text from the TileEntities list
print "Found a sign!"
for entity in tileEntities:
if entity['id'] == 'Sign':
print "adding to POI list"
# TODO assert that the x,y,z of this entity matches
# the x,y,z of this block
# convert the blockID coordinates from local chunk
# coordinates to global world coordinates
newPOI = dict(type="sign",
x= x+(self.chunkX*16),
y= z,
z= y+(self.chunkY*16),
msg="%s\n%s\n%s\n%s" %
(entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']),
chunk= (self.chunkX, self.chunkY),
)
print "new POI: %s" % newPOI
self.queue.put(["newpoi", newPOI])
break
if not t:
continue
@@ -644,6 +618,30 @@ class ChunkRenderer(object):
if y != 0 and blocks[x,y-1,z] == 0:
draw.line(((imgx,imgy+6+increment), (imgx+12,imgy+increment)), fill=(0,0,0), width=1)
for entity in tileEntities:
if entity['id'] == 'Sign':
# convert the blockID coordinates from local chunk
# coordinates to global world coordinates
newPOI = dict(type="sign",
x= entity['x'],
y= entity['z'],
z= entity['y'],
msg="%s\n%s\n%s\n%s" %
(entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']),
chunk= (self.chunkX, self.chunkY),
)
self.queue.put(["newpoi", newPOI])
# check to see if there are any signs in the persistentData list that are from this chunk.
# if so, remove them from the persistentData list (since they're have been added to the world.POI
# list above.
self.queue.put(['removePOI', (self.chunkX, self.chunkY)])
return img
# Render 3 blending masks for lighting

View File

@@ -153,15 +153,7 @@ class QuadtreeGen(object):
# in self.world.POI. To make sure we don't remove these from markers.js
# we need to merge self.world.POI with the persistant data in world.PersistentData
#
modifiedChunks = map(lambda x: x['chunk'], filter(lambda x: x['type'] != 'spawn', self.world.POI))
for item in self.world.persistentData['POI']:
# if this previously discovered POI isn't in a modified chunk, keep it
if item['chunk'] not in modifiedChunks and item['type'] != 'spawn':
self.world.POI.append(item)
# else discard it, because self.world.POI will contain it (or not if it
# was deleted)
self.world.POI += filter(lambda x: x['type'] != 'spawn', self.world.persistentData['POI'])
# write out the default marker table
with open(os.path.join(self.destdir, "markers.js"), 'w') as output:

View File

@@ -17,6 +17,7 @@ import functools
import os
import os.path
import multiprocessing
import Queue
import sys
import logging
import cPickle
@@ -280,7 +281,9 @@ class WorldRenderer(object):
item = q.get(block=False)
if item[0] == "newpoi":
self.POI.append(item[1])
except:
elif item[0] == "removePOI":
self.persistentData['POI'] = filter(lambda x: x['chunk'] != item[1], self.persistentData['POI'])
except Queue.Empty:
pass
if 1000 % i == 0 or i % 1000 == 0:
logging.info("{0}/{1} chunks rendered".format(i, len(chunks)))
@@ -310,8 +313,10 @@ class WorldRenderer(object):
item = q.get(block=False)
if item[0] == "newpoi":
self.POI.append(item[1])
elif item[0] == "removePOI":
self.persistentData['POI'] = filter(lambda x: x['chunk'] != item[1], self.persistentData['POI'])
except:
except Queue.Empty:
pass
if i > 0:
if 1000 % i == 0 or i % 1000 == 0: