diff --git a/Autoload/Slabset.gd b/Autoload/Slabset.gd index 94d39b3d..97868d4f 100644 --- a/Autoload/Slabset.gd +++ b/Autoload/Slabset.gd @@ -31,28 +31,19 @@ func load_slabset(): dat_buffer.seek(2) var totalSlabs = 42 + 16 - dat.resize(totalSlabs) - for slabID in totalSlabs: - dat[slabID] = [] - dat[slabID].resize(28) # Ensure each slab has space for 28 variations - for variation in 28: - dat[slabID][variation] = [] - dat[slabID][variation].resize(9) - if slabID < 42 or variation < 8: # Only fill the data for the first 42 slabs and the first 8 variations of the next 16 slabs - for subtile in 9: - var value = 65536 - dat_buffer.get_u16() - dat[slabID][variation][subtile] = value - else: - for subtile in 9: - dat[slabID][variation][subtile] = 0 - - blank_dat_entry = [] - blank_dat_entry.resize(28) - for variation in 28: - blank_dat_entry[variation] = [] - blank_dat_entry[variation].resize(9) - for subtile in 9: - blank_dat_entry[variation][subtile] = 0 + dat = [] + dat.resize(28*totalSlabs) # Ensure each slab has space for 28 variations + for variation in dat.size(): + dat[variation] = [] + dat[variation].resize(9) + if variation < 42*28 or (variation % 28) < 8: # Handle the longslabs and the shortslabs + #if variation < 42*28 or (variation >= 42*28 and (variation % 28) < 8): + for subtile in 9: + var value = 65536 - dat_buffer.get_u16() + dat[variation][subtile] = value + else: # Fill the extra space at the end of the shortslabs + for subtile in 9: + dat[variation][subtile] = 0 print('Created Slabset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') @@ -107,13 +98,11 @@ func load_slabset_things(): print('slabtng_object_entry_asset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') - - -func fetch_column_index(slabID, variation, subtile): - if dat.size() > slabID: - return dat[slabID][variation][subtile] +func fetch_column_index(variation, subtile): + if variation < dat.size(): + return dat[variation][subtile] else: - return blank_dat_entry[variation][subtile] + return 0 #func create_cfg_slabset(filePath): #"res://slabset.cfg" diff --git a/Scenes/PickSlabWindow.gd b/Scenes/PickSlabWindow.gd index bb598e5c..be38da5f 100644 --- a/Scenes/PickSlabWindow.gd +++ b/Scenes/PickSlabWindow.gd @@ -85,20 +85,24 @@ func add_slabs(): if putIntoTab != Slabs.TAB_NONE: var scene = load("res://Scenes/SlabDisplay.tscn") var id = scene.instance() - var slabVariation = 0 + var slabVariation var columnArray = [0,0,0, 0,0,0, 0,0,0] match slabID: Slabs.PORTAL: + slabVariation = (Slabs.PORTAL*28) + 8 for i in 9: - columnArray[i] = Slabset.fetch_column_index(slabID, 8, i) + columnArray[i] = Slabset.fetch_column_index(slabVariation, i) Slabs.WALL_AUTOMATIC: + slabVariation = Slabs.WALL_WITH_BANNER*28 for i in 9: - columnArray[i] = Slabset.fetch_column_index(Slabs.WALL_WITH_BANNER, slabVariation, i) + columnArray[i] = Slabset.fetch_column_index(slabVariation, i) _: if slabID < 1000: + # Normal slab + slabVariation = slabID*28 for i in 9: - columnArray[i] = Slabset.fetch_column_index(slabID, slabVariation, i) + columnArray[i] = Slabset.fetch_column_index(slabVariation, i) else: # Custom slab pass diff --git a/Scenes/PlaceThingWithSlab.gd b/Scenes/PlaceThingWithSlab.gd index e0f2c814..73dab1a0 100644 --- a/Scenes/PlaceThingWithSlab.gd +++ b/Scenes/PlaceThingWithSlab.gd @@ -84,7 +84,7 @@ func determine_if_middle(slabID, ownership, bitmask, surrID, surrOwner): return false func get_obj_idx(newSlabVar, subtile): - if newSlabVar >= 1304: return -1 # Out of bounds, causes crash + if newSlabVar >= Slabset.tngIndex.size(): return -1 # Out of bounds, causes crash var idx = Slabset.tngIndex[newSlabVar] if idx >= Slabset.numberOfThings: return -1 diff --git a/Scenes/SlabPlacement.gd b/Scenes/SlabPlacement.gd index 1607eeef..4fe15852 100644 --- a/Scenes/SlabPlacement.gd +++ b/Scenes/SlabPlacement.gd @@ -752,10 +752,8 @@ func dkdat_position_to_column_data(clmIndexGroup): #print(clmIndexGroup) for subtile in 9: - var index = clmIndexGroup[subtile] / 9 - var slabID = index / 28 - var variation = index % 28 - var dkClmIndex = Slabset.fetch_column_index(slabID, variation, subtile) + var variation = clmIndexGroup[subtile] / 9 + var dkClmIndex = Slabset.fetch_column_index(variation, subtile) # Get the cube data from oDkClm slabCubes.append(Columnset.cubes[dkClmIndex]) diff --git a/Scenes/SlabsetWindow.gd b/Scenes/SlabsetWindow.gd index f0192c66..7424b0e8 100644 --- a/Scenes/SlabsetWindow.gd +++ b/Scenes/SlabsetWindow.gd @@ -154,20 +154,19 @@ func _on_VariationNumberSpinBox_value_changed(value): update_columns_ui() func update_columns_ui(): - - var variation = int(oVariationNumberSpinBox.value) var slabID = int(oSlabsetIDSpinBox.value) + var variation = (slabID * 28) + int(oVariationNumberSpinBox.value) for subtile in columnSettersArray.size(): var spinbox = columnSettersArray[subtile].get_node("CustomSpinBox") spinbox.disconnect("value_changed",self,"_on_Slabset3x3ColumnSpinBox_value_changed") - var clmIndex = Slabset.fetch_column_index(slabID, variation, subtile) + var clmIndex = Slabset.fetch_column_index(variation, subtile) spinbox.value = clmIndex spinbox.connect("value_changed",self,"_on_Slabset3x3ColumnSpinBox_value_changed") func _on_Slabset3x3ColumnSpinBox_value_changed(value): - var variation = int(oVariationNumberSpinBox.value) var slabID = int(oSlabsetIDSpinBox.value) + var variation = (slabID * 28) + int(oVariationNumberSpinBox.value) for y in 3: for x in 3: @@ -176,7 +175,7 @@ func _on_Slabset3x3ColumnSpinBox_value_changed(value): var spinbox = id.get_node("CustomSpinBox") var clmIndex = spinbox.value - Slabset.dat[slabID][variation][i] = clmIndex + Slabset.dat[variation][i] = clmIndex #oSlabPalette.slabPal[variation][i] = clmIndex # This may not be working diff --git a/Scenes/VoxelViewer.gd b/Scenes/VoxelViewer.gd index 9b2733b8..c4f27271 100644 --- a/Scenes/VoxelViewer.gd +++ b/Scenes/VoxelViewer.gd @@ -128,10 +128,12 @@ func do_all(): oAllVoxelObjects.translation.x = -0.5 var CODETIME_START = OS.get_ticks_msec() + + if displayingType == DK_SLABSET: # This is not for custom slab, this is for dynamic slabs var slabID = oSlabsetIDSpinBox.value var separation = 0 - + var variationStart = slabID * 28 for variation in 28: var surrClmIndex = [-1,-1,-1,-1] for ySubtile in 3: @@ -141,7 +143,7 @@ func do_all(): var x = (variation*3) + xSubtile + separation var z = (variation*3) + ySubtile + separation - var clmIndex = Slabset.fetch_column_index(slabID, variation, subtile) + var clmIndex = Slabset.fetch_column_index(variationStart+variation, subtile) oVoxelGen.column_gen(genArray, x-1.5, z-1.5, clmIndex, surrClmIndex, true, Columnset)