92
92
"""
93
93
94
94
95
+ TILESET_VERSION = 2 # Update this whenever there is a breaking change with tile renders
96
+
95
97
# small but useful
96
98
def iterate_base4 (d ):
97
99
"""Iterates over a base 4 number with d digits"""
@@ -309,6 +311,7 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
309
311
310
312
self .last_rendertime = config .get ('last_rendertime' , 0 )
311
313
self .forcerendertime = config .get ('forcerendertime' , 0 )
314
+ self .lastrenderversion = config .get ('lastrenderversion' , 0 )
312
315
313
316
if "renderchecks" not in self .options :
314
317
# renderchecks was not given, this indicates it was not specified
@@ -318,20 +321,25 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
318
321
# No persistent config?
319
322
if os .path .exists (self .outputdir ):
320
323
# 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
322
325
logging .warning (
323
326
"For render '%s' I couldn't find any persistent config, "
324
327
"but I did find my tile directory already exists. This "
325
328
"shouldn't normally happen, something may be up, but I "
326
329
"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
329
332
else :
330
333
# This is the typical code path for an initial render, make
331
334
# this a "forcerender"
332
335
self .options ['renderchecks' ] = 2
333
336
logging .debug ("This is the first time rendering %s. Doing "
334
337
"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
335
343
elif not os .path .exists (self .outputdir ):
336
344
# Somehow the outputdir got erased but the metadata file is
337
345
# still there. That's strange!
@@ -377,6 +385,11 @@ def __init__(self, worldobj, regionsetobj, assetmanagerobj, texturesobj, options
377
385
self .options ['renderchecks' ] = 2
378
386
os .mkdir (self .outputdir )
379
387
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
+
380
393
# must wait until outputdir exists
381
394
self .fs_caps = get_fs_caps (self .outputdir )
382
395
@@ -591,7 +604,8 @@ def bgcolorformat(color):
591
604
poititle = self .options .get ("poititle" ),
592
605
showlocationmarker = self .options .get ("showlocationmarker" ),
593
606
center = (self .options .get ("center" ) or self .options .get ("spawn" )
594
- or [0 , 64 , 0 ])
607
+ or [0 , 64 , 0 ]),
608
+ lastrenderversion = TILESET_VERSION
595
609
)
596
610
d ['maxZoom' ] = self .options .get ('maxzoom' , self .treedepth )
597
611
if d ['maxZoom' ] < 0 :
@@ -1081,7 +1095,7 @@ def _render_rendertile(self, tile):
1081
1095
max_chunk_mtime = 0
1082
1096
for col , row , chunkx , chunky , chunkz , chunk_mtime in chunks :
1083
1097
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
1085
1099
1086
1100
if chunk_mtime > max_chunk_mtime :
1087
1101
max_chunk_mtime = chunk_mtime
@@ -1324,12 +1338,12 @@ def get_tiles_by_chunk(chunkcol, chunkrow):
1324
1338
colrange = (tilecol ,)
1325
1339
1326
1340
# 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
1328
1342
# rows)
1329
1343
if chunkrow % 4 == 0 :
1330
- rowrange = range (tilerow - 4 , tilerow + 32 + 1 , 4 )
1344
+ rowrange = range (tilerow - 4 , tilerow + 48 + 1 , 4 )
1331
1345
else :
1332
- rowrange = range (tilerow , tilerow + 32 + 1 , 4 )
1346
+ rowrange = range (tilerow , tilerow + 48 + 1 , 4 )
1333
1347
1334
1348
return product (colrange , rowrange )
1335
1349
@@ -1360,12 +1374,12 @@ def get_mtime(x, y):
1360
1374
# First do the odd. For each chunk in the tile's odd column the tile
1361
1375
# "passes through" three chunk sections.
1362
1376
oddcol_sections = []
1363
- for i , y in enumerate (reversed (range (16 ))):
1377
+ for i , y in enumerate (reversed (range (24 ))):
1364
1378
for row in range (tile .row + 3 - i * 2 , tile .row - 2 - i * 2 , - 2 ):
1365
1379
oddcol_sections .append ((tile .col + 1 , row , y ))
1366
1380
1367
1381
evencol_sections = []
1368
- for i , y in enumerate (reversed (range (16 ))):
1382
+ for i , y in enumerate (reversed (range (24 ))):
1369
1383
for row in range (tile .row + 4 - i * 2 , tile .row - 3 - i * 2 , - 2 ):
1370
1384
evencol_sections .append ((tile .col + 2 , row , y ))
1371
1385
evencol_sections .append ((tile .col , row , y ))
0 commit comments