0

Store north-direction in overviewer.dat

Check stored value at render time and abort if direction has changed and
--forcerender not specified.
Addresses concerns from pull request #458
This commit is contained in:
Thomas Lake
2011-08-17 17:49:22 -04:00
committed by Aaron Griffith
parent 087d597ed0
commit 3e1ae9dd17
3 changed files with 12 additions and 2 deletions

View File

@@ -117,7 +117,7 @@ def main():
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, helptext="Print more output. You can specify this option multiple times.") parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, helptext="Print more output. You can specify this option multiple times.")
parser.add_option("--skip-js", dest="skipjs", action="store_true", helptext="Don't output marker.js or regions.js") parser.add_option("--skip-js", dest="skipjs", action="store_true", helptext="Don't output marker.js or regions.js")
parser.add_option("--no-signs", dest="nosigns", action="store_true", helptext="Don't output signs to markers.js") parser.add_option("--no-signs", dest="nosigns", action="store_true", helptext="Don't output signs to markers.js")
parser.add_option("--north-direction", dest="north_direction", helptext="Specifies which corner of the screen north will point to. Valid options are: " + ", ".join(avail_north_dirs) + ".", type="choice", default=avail_north_dirs[0], choices=avail_north_dirs) parser.add_option("--north-direction", dest="north_direction", action="store", helptext="Specifies which corner of the screen north will point to. Valid options are: " + ", ".join(avail_north_dirs) + ".", type="choice", default=avail_north_dirs[0], choices=avail_north_dirs)
parser.add_option("--display-config", dest="display_config", action="store_true", helptext="Display the configuration parameters, but don't render the map. Requires all required options to be specified", commandLineOnly=True) parser.add_option("--display-config", dest="display_config", action="store_true", helptext="Display the configuration parameters, but don't render the map. Requires all required options to be specified", commandLineOnly=True)
#parser.add_option("--write-config", dest="write_config", action="store_true", helptext="Writes out a sample config file", commandLineOnly=True) #parser.add_option("--write-config", dest="write_config", action="store_true", helptext="Writes out a sample config file", commandLineOnly=True)
@@ -241,6 +241,13 @@ def main():
# First do world-level preprocessing # First do world-level preprocessing
w = world.World(worlddir, destdir, useBiomeData=useBiomeData, regionlist=regionlist, north_direction=north_direction) w = world.World(worlddir, destdir, useBiomeData=useBiomeData, regionlist=regionlist, north_direction=north_direction)
if not (w.persistentData['north_direction'] == north_direction) and not options.forcerender:
logging.error("Conflicting north-direction setting!")
logging.error("Overviewer.dat gives previous north-direction as "+w.persistentData['north_direction'])
logging.error("Requested north-direction was "+north_direction)
logging.error("To change north-direction of an existing render, --forcerender must be specified")
sys.exit(1)
w.go(options.procs) w.go(options.procs)
logging.info("Rending the following tilesets: %s", ",".join(options.rendermode)) logging.info("Rending the following tilesets: %s", ",".join(options.rendermode))

View File

@@ -187,6 +187,7 @@ class MapGen(object):
# save persistent data # save persistent data
self.world.persistentData['POI'] = self.world.POI self.world.persistentData['POI'] = self.world.POI
self.world.persistentData['north_direction'] = self.world.north_direction
with open(self.world.pickleFile,"wb") as f: with open(self.world.pickleFile,"wb") as f:
cPickle.dump(self.world.persistentData,f) cPickle.dump(self.world.persistentData,f)

View File

@@ -135,9 +135,11 @@ class World(object):
if os.path.exists(self.pickleFile): if os.path.exists(self.pickleFile):
with open(self.pickleFile,"rb") as p: with open(self.pickleFile,"rb") as p:
self.persistentData = cPickle.load(p) self.persistentData = cPickle.load(p)
if not self.persistentData.get('north_direction', False):
self.persistentData['north_direction']=='lower-left'
else: else:
# some defaults # some defaults
self.persistentData = dict(POI=[]) self.persistentData = dict(POI=[], north_direction=self.north_direction)
def get_region_path(self, chunkX, chunkY): def get_region_path(self, chunkX, chunkY):