Improved handling of signposts
This commit is contained in:
50
chunk.py
50
chunk.py
@@ -520,32 +520,6 @@ class ChunkRenderer(object):
|
|||||||
else:
|
else:
|
||||||
t = textures.blockmap[blockid]
|
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:
|
if not t:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -644,6 +618,30 @@ class ChunkRenderer(object):
|
|||||||
if y != 0 and blocks[x,y-1,z] == 0:
|
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)
|
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
|
return img
|
||||||
|
|
||||||
# Render 3 blending masks for lighting
|
# Render 3 blending masks for lighting
|
||||||
|
|||||||
10
quadtree.py
10
quadtree.py
@@ -153,15 +153,7 @@ class QuadtreeGen(object):
|
|||||||
# in self.world.POI. To make sure we don't remove these from markers.js
|
# 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
|
# we need to merge self.world.POI with the persistant data in world.PersistentData
|
||||||
|
|
||||||
#
|
self.world.POI += filter(lambda x: x['type'] != 'spawn', self.world.persistentData['POI'])
|
||||||
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)
|
|
||||||
|
|
||||||
# write out the default marker table
|
# write out the default marker table
|
||||||
with open(os.path.join(self.destdir, "markers.js"), 'w') as output:
|
with open(os.path.join(self.destdir, "markers.js"), 'w') as output:
|
||||||
|
|||||||
9
world.py
9
world.py
@@ -17,6 +17,7 @@ import functools
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import Queue
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import cPickle
|
import cPickle
|
||||||
@@ -280,7 +281,9 @@ class WorldRenderer(object):
|
|||||||
item = q.get(block=False)
|
item = q.get(block=False)
|
||||||
if item[0] == "newpoi":
|
if item[0] == "newpoi":
|
||||||
self.POI.append(item[1])
|
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
|
pass
|
||||||
if 1000 % i == 0 or i % 1000 == 0:
|
if 1000 % i == 0 or i % 1000 == 0:
|
||||||
logging.info("{0}/{1} chunks rendered".format(i, len(chunks)))
|
logging.info("{0}/{1} chunks rendered".format(i, len(chunks)))
|
||||||
@@ -310,8 +313,10 @@ class WorldRenderer(object):
|
|||||||
item = q.get(block=False)
|
item = q.get(block=False)
|
||||||
if item[0] == "newpoi":
|
if item[0] == "newpoi":
|
||||||
self.POI.append(item[1])
|
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
|
pass
|
||||||
if i > 0:
|
if i > 0:
|
||||||
if 1000 % i == 0 or i % 1000 == 0:
|
if 1000 % i == 0 or i % 1000 == 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user