9292"""
9393
9494
95+ TILESET_VERSION = 2 # Update this whenever there is a breaking change with tile renders
96+
9597# small but useful
9698def iterate_base4 (d ):
9799 """Iterates over a base 4 number with d digits"""
@@ -309,6 +311,7 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
309311
310312 self .last_rendertime = config .get ('last_rendertime' , 0 )
311313 self .forcerendertime = config .get ('forcerendertime' , 0 )
314+ self .lastrenderversion = config .get ('lastrenderversion' , 0 )
312315
313316 if "renderchecks" not in self .options :
314317 # renderchecks was not given, this indicates it was not specified
@@ -318,20 +321,25 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
318321 # No persistent config?
319322 if os .path .exists (self .outputdir ):
320323 # Somehow there's no config but the output dir DOES exist.
321- # That's strange!
324+ # That's strange! Run forcerender in case of breaking OV version change
322325 logging .warning (
323326 "For render '%s' I couldn't find any persistent config, "
324327 "but I did find my tile directory already exists. This "
325328 "shouldn't normally happen, something may be up, but I "
326329 "think I can continue..." , self .options ['name' ])
327- logging .info ("Switching to --check-tiles mode" )
328- self .options ['renderchecks' ] = 1
330+ logging .info ("Switching to --forcerender mode" )
331+ self .options ['renderchecks' ] = 2
329332 else :
330333 # This is the typical code path for an initial render, make
331334 # this a "forcerender"
332335 self .options ['renderchecks' ] = 2
333336 logging .debug ("This is the first time rendering %s. Doing "
334337 "a full-render" , self .options ['name' ])
338+ elif self .lastrenderversion != TILESET_VERSION :
339+ # Force render in case there is a version change that is breaking
340+ logging .warning ("Re-rendering world due to version change."
341+ "This will avoid any bad rendering between incompatible versions" )
342+ self .options ['renderchecks' ] = 2
335343 elif not os .path .exists (self .outputdir ):
336344 # Somehow the outputdir got erased but the metadata file is
337345 # still there. That's strange!
@@ -377,6 +385,11 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
377385 self .options ['renderchecks' ] = 2
378386 os .mkdir (self .outputdir )
379387
388+ if self .lastrenderversion != TILESET_VERSION and self .options ['renderchecks' ] not in [2 , 3 ]:
389+ logging .warning ("Normally renders from different versions should be"
390+ "overridden or ignored to prevent incompatibilities,"
391+ "but we will honor your decision." )
392+
380393 # must wait until outputdir exists
381394 self .fs_caps = get_fs_caps (self .outputdir )
382395
@@ -591,7 +604,8 @@ def bgcolorformat(color):
591604 poititle = self .options .get ("poititle" ),
592605 showlocationmarker = self .options .get ("showlocationmarker" ),
593606 center = (self .options .get ("center" ) or self .options .get ("spawn" )
594- or [0 , 64 , 0 ])
607+ or [0 , 64 , 0 ]),
608+ lastrenderversion = TILESET_VERSION
595609 )
596610 d ['maxZoom' ] = self .options .get ('maxzoom' , self .treedepth )
597611 if d ['maxZoom' ] < 0 :
@@ -1081,7 +1095,7 @@ def _render_rendertile(self, tile):
10811095 max_chunk_mtime = 0
10821096 for col , row , chunkx , chunky , chunkz , chunk_mtime in chunks :
10831097 xpos = - 192 + (col - colstart ) * 192
1084- ypos = - 96 + (row - rowstart ) * 96 + (16 - 1 - chunky ) * 192
1098+ ypos = - 96 + (row - rowstart ) * 96 + (24 - 1 - chunky ) * 192
10851099
10861100 if chunk_mtime > max_chunk_mtime :
10871101 max_chunk_mtime = chunk_mtime
@@ -1324,12 +1338,12 @@ def get_tiles_by_chunk(chunkcol, chunkrow):
13241338 colrange = (tilecol ,)
13251339
13261340 # If this chunk is in a row divisible by 4, then it touches the
1327- # tile above it as well. Also touches the next 4 tiles down (16
1341+ # tile above it as well. Also touches the next 6 tiles down (24
13281342 # rows)
13291343 if chunkrow % 4 == 0 :
1330- rowrange = range (tilerow - 4 , tilerow + 32 + 1 , 4 )
1344+ rowrange = range (tilerow - 4 , tilerow + 48 + 1 , 4 )
13311345 else :
1332- rowrange = range (tilerow , tilerow + 32 + 1 , 4 )
1346+ rowrange = range (tilerow , tilerow + 48 + 1 , 4 )
13331347
13341348 return product (colrange , rowrange )
13351349
@@ -1360,12 +1374,12 @@ def get_mtime(x, y):
13601374 # First do the odd. For each chunk in the tile's odd column the tile
13611375 # "passes through" three chunk sections.
13621376 oddcol_sections = []
1363- for i , y in enumerate (reversed (range (16 ))):
1377+ for i , y in enumerate (reversed (range (24 ))):
13641378 for row in range (tile .row + 3 - i * 2 , tile .row - 2 - i * 2 , - 2 ):
13651379 oddcol_sections .append ((tile .col + 1 , row , y ))
13661380
13671381 evencol_sections = []
1368- for i , y in enumerate (reversed (range (16 ))):
1382+ for i , y in enumerate (reversed (range (24 ))):
13691383 for row in range (tile .row + 4 - i * 2 , tile .row - 3 - i * 2 , - 2 ):
13701384 evencol_sections .append ((tile .col + 2 , row , y ))
13711385 evencol_sections .append ((tile .col , row , y ))
0 commit comments