From a1bf4c762e8c54989556f6b63fc2fef394a3d3f4 Mon Sep 17 00:00:00 2001 From: rainlizard <15337628+rainlizard@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:50:48 +1000 Subject: [PATCH] increase column count --- Autoload/Columnset.gd | 15 ++++++++------- Autoload/Things.gd | 2 +- Autoload/Version.gd | 2 +- Class/ClmClass.gd | 18 +++++++++--------- Scenes/AddCustomSlabWindow.gd | 3 ++- Scenes/CLMGraphics.gd | 2 +- Scenes/ClmControls.gd | 9 +++++++++ Scenes/ColumnModels.gd | 8 ++++---- Scenes/CurrentMap.gd | 5 +++++ Scenes/DataClm.gd | 16 +++++++++------- Scenes/GenerateTerrainOLD.gd | 10 +++++----- Scenes/OpenMap.gd | 24 ++++++++++-------------- Scenes/OverheadGraphics.gd | 16 ++++++++++++++++ Scenes/ReadData.gd | 17 ++++++++++------- Scenes/SlabColumnEditor.gd | 2 ++ Scenes/SlabPalette.gd | 2 +- Scenes/SlabsetWindow.gd | 4 +++- Scenes/UniversalDetails.gd | 2 +- Scenes/VoxelGen.gd | 1 - Scenes/VoxelViewer.gd | 15 ++++++++++----- Scenes/WriteData.gd | 12 ++++-------- 21 files changed, 111 insertions(+), 74 deletions(-) diff --git a/Autoload/Columnset.gd b/Autoload/Columnset.gd index 3103fd87..3523685f 100644 --- a/Autoload/Columnset.gd +++ b/Autoload/Columnset.gd @@ -2,6 +2,7 @@ extends 'res://Class/ClmClass.gd' onready var oGame = Nodelist.list["oGame"] onready var oBuffers = Nodelist.list["oBuffers"] +var column_count = 2048 var utilized = [] var orientation = [] var solidMask = [] @@ -17,8 +18,8 @@ var columnsContainingOwnedCubes = {} var columnsContainingRngCubes = {} # Strangely, slabs.clm is missing the second 4 bytes. -# map0000x.clm : 49,160 bytes. first 4 bytes contains 2048, second 4 bytes are ???, then comes the column data. -# slabs.clm : 49,156 bytes. first 4 bytes contains 2048, then comes the column data. +# map0000x.clm : 49,160 bytes. first 4 bytes contains column_count, second 4 bytes are ???, then comes the column data. +# slabs.clm : 49,156 bytes. first 4 bytes contains column_count, then comes the column data. func import_toml_columnset(filePath): @@ -102,10 +103,10 @@ func export_toml_columnset(filePath): #"res://columnset.toml" return textFile.store_line('[common]') - textFile.store_line('ColumnsCount = 2048') + textFile.store_line('ColumnsCount = ' + str(column_count)) textFile.store_line('\r') - for i in 2048: + for i in column_count: # If this is a partial export, then skip this column if it is the same as default. if column_diffs.has(i) == false: continue @@ -126,7 +127,7 @@ func export_toml_columnset(filePath): #"res://columnset.toml" func find_all_different_columns(): var diff_indices = [] - for i in 2048: + for i in column_count: if is_column_different(i): diff_indices.append(i) return diff_indices @@ -160,7 +161,7 @@ func update_list_of_columns_that_contain_rng_cubes(): for cubeID in Cube.rngCube[key]: reverseRngCubeLookup[cubeID] = key - for clmIndex in 2048: + for clmIndex in column_count: var rngCubeTypesInColumn = {} for cubeID in cubes[clmIndex]: @@ -182,7 +183,7 @@ func update_list_of_columns_that_contain_owned_cubes(): for cubeID in Cube.ownedCube[key]: reverseOwnedCubeLookup[cubeID] = key - for clmIndex in 2048: # assuming there are 2048 columns to iterate through + for clmIndex in column_count: var ownedCubeTypesInColumn = {} for cubeID in cubes[clmIndex]: diff --git a/Autoload/Things.gd b/Autoload/Things.gd index 697e1d4c..583269e9 100644 --- a/Autoload/Things.gd +++ b/Autoload/Things.gd @@ -1,6 +1,6 @@ extends Node2D -const THING_LIMIT = -1 #2048 +const THING_LIMIT = -1 const ACTION_POINT_LIMIT = -1 #255 const CREATURE_LIMIT = -1 #255 const LIGHT_LIMIT = -1 diff --git a/Autoload/Version.gd b/Autoload/Version.gd index 7d03e1be..39820a24 100644 --- a/Autoload/Version.gd +++ b/Autoload/Version.gd @@ -1,6 +1,6 @@ extends Node -var major_minor = "0.49" +var major_minor = "0.50" var patch = "0000" var full = "" var unearth_map_format_version:float = 1.06 diff --git a/Class/ClmClass.gd b/Class/ClmClass.gd index 3fe8fdc1..3cdfd3d7 100644 --- a/Class/ClmClass.gd +++ b/Class/ClmClass.gd @@ -51,22 +51,22 @@ func copy_column(indexSrc, indexDest): self.floorTexture[indexDest] = self.floorTexture[indexSrc] func clear_all_column_data(): - self.utilized.resize(2048) + self.utilized.resize(self.column_count) self.utilized.fill(0) - self.orientation.resize(2048) + self.orientation.resize(self.column_count) self.orientation.fill(0) - self.solidMask.resize(2048) + self.solidMask.resize(self.column_count) self.solidMask.fill(0) - self.permanent.resize(2048) + self.permanent.resize(self.column_count) self.permanent.fill(0) - self.lintel.resize(2048) + self.lintel.resize(self.column_count) self.lintel.fill(0) - self.height.resize(2048) + self.height.resize(self.column_count) self.height.fill(0) - self.floorTexture.resize(2048) + self.floorTexture.resize(self.column_count) self.floorTexture.fill(0) - self.cubes.resize(2048) - for i in 2048: + self.cubes.resize(self.column_count) + for i in self.column_count: self.cubes[i] = [0,0,0,0, 0,0,0,0] # Don't use fill(), that doesn't work diff --git a/Scenes/AddCustomSlabWindow.gd b/Scenes/AddCustomSlabWindow.gd index 59a66303..7133cc0a 100644 --- a/Scenes/AddCustomSlabWindow.gd +++ b/Scenes/AddCustomSlabWindow.gd @@ -40,7 +40,8 @@ func _ready(): var spinbox = id.get_node("CustomSpinBox") var shortcut = id.get_node("ButtonShortcut") shortcut.connect("pressed",self,"shortcut_pressed",[id]) - spinbox.max_value = 2047 + spinbox.min_value = 1 + spinbox.max_value = oDataClm.column_count-1 spinbox.value = 1 spinbox.connect("value_changed",oCustomSlabVoxelView,"_on_CustomSlabSpinBox_value_changed") customSlabArrayOfSpinbox.append(spinbox) diff --git a/Scenes/CLMGraphics.gd b/Scenes/CLMGraphics.gd index 9f66999f..37191ef5 100644 --- a/Scenes/CLMGraphics.gd +++ b/Scenes/CLMGraphics.gd @@ -20,7 +20,7 @@ extends TileMap # for y in 255: # var cubeFace # -# # clmIndex is a position inside the 2048 column collection +# # clmIndex is a position inside the column_count column collection # var clmIndex = oDataClmPos.get_cell_clmpos(x,y) # # # clmData is the 24 byte array. diff --git a/Scenes/ClmControls.gd b/Scenes/ClmControls.gd index 3829baeb..73f3c77a 100644 --- a/Scenes/ClmControls.gd +++ b/Scenes/ClmControls.gd @@ -67,6 +67,7 @@ func _ready(): "ColumnsetControls": nodeClm = Columnset nodeVoxelView = oColumnsetVoxelView + oColumnIndexSpinBox.connect("value_changed", nodeVoxelView, "_on_ColumnIndexSpinBox_value_changed") @@ -80,6 +81,14 @@ func _ready(): oGridAdvancedValues.visible = false +func just_opened(): + match name: + "ColumnEditorControls": + oColumnIndexSpinBox.max_value = oDataClm.column_count-1 + "ColumnsetControls": + oColumnIndexSpinBox.max_value = Columnset.column_count-1 + + func establish_maximum_cube_field_values(): for i in cubeSpinBoxArray.size(): cubeSpinBoxArray[i].max_value = Cube.CUBES_COUNT diff --git a/Scenes/ColumnModels.gd b/Scenes/ColumnModels.gd index b380a0f3..5d1e451b 100644 --- a/Scenes/ColumnModels.gd +++ b/Scenes/ColumnModels.gd @@ -17,12 +17,12 @@ extends Node # var CODETIME_START = OS.get_ticks_msec() # # -# #columnModels.resize(2048) -# columnMeshArrays.resize(2048) +# #columnModels.resize(column_count) +# columnMeshArrays.resize(column_count) # # tempArrays.resize(Mesh.ARRAY_MAX) # -# for idx in 2048: +# for idx in column_count: # if oDataClm.solidMask[idx] > 0: # DON'T USE SOLID MASK LIKE THIS!!!!!!!!!!!!!!!!!!!!!!!! # var faceCountPerMesh = 0 # tempArrays[Mesh.ARRAY_INDEX] = [] @@ -171,7 +171,7 @@ extends Node # mmInstance.multimesh = mm # oGame3D.add_child(mmInstance) -# for idx in 2048: +# for idx in column_count: # if columnModels[idx] != null: # pass diff --git a/Scenes/CurrentMap.gd b/Scenes/CurrentMap.gd index cbb8a647..0fe4d7e1 100644 --- a/Scenes/CurrentMap.gd +++ b/Scenes/CurrentMap.gd @@ -24,6 +24,7 @@ onready var oSlabPlacement = Nodelist.list["oSlabPlacement"] onready var oMenu = Nodelist.list["oMenu"] onready var oDataLof = Nodelist.list["oDataLof"] onready var oInstances = Nodelist.list["oInstances"] +onready var oColumnEditor = Nodelist.list["oColumnEditor"] var path = "" var currentFilePaths = {} # [0] = pathString, [1] = modified date @@ -73,5 +74,9 @@ func clear_map(): # "LOF" # Do this last in case other functions rely on the old map size oDataLof.clear_all() + + if oColumnEditor.visible == true: + oColumnEditor.visible = false + print('Cleared map in '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') diff --git a/Scenes/DataClm.gd b/Scenes/DataClm.gd index 21e096d7..ebf69082 100644 --- a/Scenes/DataClm.gd +++ b/Scenes/DataClm.gd @@ -5,6 +5,8 @@ onready var oDataClmPos = Nodelist.list["oDataClmPos"] onready var oOverheadGraphics = Nodelist.list["oOverheadGraphics"] onready var oUniversalDetails = Nodelist.list["oUniversalDetails"] +var column_count = 8192 + # Storing these values outside of main array so I can do array comparisons var utilized = [] var orientation = [] @@ -42,7 +44,7 @@ func clm_data_exists(): func count_filled_clm_entries(): var CODETIME_START = OS.get_ticks_msec() var numberOfFilledEntries = 0 - for entry in 2048: + for entry in column_count: if cubes[entry] != [0,0,0,0, 0,0,0,0]: numberOfFilledEntries += 1 oUniversalDetails.clmEntryCount = numberOfFilledEntries @@ -78,7 +80,7 @@ func update_all_utilized(): a_column_has_changed_since_last_updating_utilized = false var CODETIME_START = OS.get_ticks_msec() - for clearIndex in 2048: + for clearIndex in column_count: utilized[clearIndex] = 0 for y in (M.ySize*3): for x in (M.xSize*3): @@ -89,7 +91,7 @@ func update_all_utilized(): func update_all_solid_mask(): var CODETIME_START = OS.get_ticks_msec() - for index in 2048: + for index in column_count: solidMask[index] = calculate_solid_mask(cubes[index]) print('All CLM solid bitmask updated in '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') @@ -98,7 +100,7 @@ func update_all_solid_mask(): func clear_unused_entries(): update_all_utilized() - for clmIndex in 2048: + for clmIndex in column_count: if utilized[clmIndex] == 0: delete_column(clmIndex) @@ -116,7 +118,7 @@ func sort_columns_by_utilized(): utilized[0] = 999999 # Pretend that the utilized value is maximum for column 0, so it's placed first when sorted. Set it back to 0 afterwards. var CODETIME_START = OS.get_ticks_msec() - for i in 2048: + for i in column_count: # Each column gets its own array which contains all of its column values. array.append([]) @@ -133,12 +135,12 @@ func sort_columns_by_utilized(): # Sort array.sort_custom(self, "sorter_utilized") - for i in 2048: + for i in column_count: var sourceIndex = array[i][0] dictSrcDest[sourceIndex] = i # for swapping the column indexes easier in oDataClmPos # Move to new position - for i in 2048: + for i in column_count: utilized[i] = array[i][1] orientation[i] = array[i][2] solidMask[i] = array[i][3] diff --git a/Scenes/GenerateTerrainOLD.gd b/Scenes/GenerateTerrainOLD.gd index 4ec008c3..39450ebf 100644 --- a/Scenes/GenerateTerrainOLD.gd +++ b/Scenes/GenerateTerrainOLD.gd @@ -142,7 +142,7 @@ func generation(): elif GENERATED_TYPE == GEN_CLM: if x/2 != x/2.0 or z/2 != z/2.0: continue #skips current loop clmIndex = ((z/2) * (TERRAIN_SIZE_X/2)) + (x/2) - if clmIndex >= 2048: clmIndex = 0 + if clmIndex >= column_count: clmIndex = 0 var floorID = oDataClm.floorTexture[clmIndex] add_face(pos, 4, cubeID, floorID, faceCount[slabStyleValue], slabStyleValue) @@ -183,7 +183,7 @@ func generation(): func set_cube_id_with_column_position_data(): - # clmIndex is a position inside the 2048 column collection + # clmIndex is a position inside the column_count column collection # clmData is the 24 byte array. # Get the cubeIDs from that array @@ -199,7 +199,7 @@ func set_cube_id_with_column_position_data(): blockMap[x][z] = oDataClm.cubes[clmIndex] # Warning: this is probably a reference. But it probably doesn't matter. func set_cube_id_to_clm_index(): - # clmIndex is a position inside the 2048 column collection + # clmIndex is a position inside the column_count column collection # clmData is the 24 byte array. # "continue" skips current loop @@ -216,7 +216,7 @@ func set_cube_id_to_clm_index(): if x/2 != x/2.0 or z/2 != z/2.0: continue var clmIndex = ((z/2) * (TERRAIN_SIZE_X/2)) + (x/2) - if clmIndex >= 2048: clmIndex = 0 + if clmIndex >= column_count: clmIndex = 0 blockMap[x][z] = oDataClm.cubes[clmIndex] # Warning: this is probably a reference. But it probably doesn't matter. @@ -225,7 +225,7 @@ func get_clm_index(x, z): # Used by ColumnDetails in clm view if x >= TERRAIN_SIZE_X: return null if z >= TERRAIN_SIZE_Z: return null var clmIndex = ((z/2) * (TERRAIN_SIZE_X/2)) + (x/2) - if clmIndex >= 2048: clmIndex = 0 + if clmIndex >= column_count: clmIndex = 0 return clmIndex diff --git a/Scenes/OpenMap.gd b/Scenes/OpenMap.gd index 83c113ba..6aaa6ee6 100644 --- a/Scenes/OpenMap.gd +++ b/Scenes/OpenMap.gd @@ -124,7 +124,16 @@ func open_map(filePath): oDataLof.use_size(oXSizeLine.text.to_int(), oYSizeLine.text.to_int()) print("NEW MAPSIZE = " + str(M.xSize) + " " + str(M.ySize)) - var formatType = 0 + + # Set map format + if map == "": # If it's a new map, then map format is set to the format you selected on New Map window + oCurrentFormat.selected = oSetNewFormat.selected + else: + if oCurrentMap.currentFilePaths.has("TNGFX") == true: + oCurrentFormat.selected = Constants.KfxFormat + else: + oCurrentFormat.selected = Constants.ClassicFormat + for EXT in oBuffers.FILE_TYPES: if oCurrentMap.currentFilePaths.has(EXT) == true: @@ -137,11 +146,6 @@ func open_map(filePath): continue if EXT == "LIF" and oCurrentMap.currentFilePaths.has("LOF") == true: continue - # Set current format setting to new KFX format, if any new files are detected - - if EXT == "TNGFX": formatType = 1 - if EXT == "APTFX": formatType = 1 - if EXT == "LGTFX": formatType = 1 var readPath = oCurrentMap.currentFilePaths[EXT][oCurrentMap.PATHSTRING] oBuffers.read(readPath, EXT.to_upper()) @@ -163,11 +167,6 @@ func open_map(filePath): for xSlab in M.xSize: var slabID = oDataSlab.get_cell(xSlab, ySlab) oDataLiquid.set_cell(xSlab, ySlab, Slabs.data[slabID][Slabs.REMEMBER_TYPE]) - # Set map format - oCurrentFormat.selected = formatType - # If it's a new map, then map format is set to the format you selected on New Map window - if map == "": - oCurrentFormat.selected = oSetNewFormat.selected continue_load(map) continue_load_openmap(map) @@ -207,9 +206,6 @@ func continue_load(map): oDisplaySlxNumbers.update() - if oColumnEditor.visible == true: - oColumnEditor.visible = false - Utils.popup_centered(oColumnEditor) if oResizeCurrentMapSize.visible == true: oResizeCurrentMapSize._on_ResizeCurrentMapSize_about_to_show() diff --git a/Scenes/OverheadGraphics.gd b/Scenes/OverheadGraphics.gd index 18de397e..f5873d3a 100644 --- a/Scenes/OverheadGraphics.gd +++ b/Scenes/OverheadGraphics.gd @@ -116,3 +116,19 @@ func update_display_fields_size(): displayField.rect_size = Vector2(M.xSize * 96, M.ySize * 96) displayField.material.set_shader_param("fieldSizeInSubtiles", Vector2((M.xSize*3), (M.ySize*3))) + +# var pixDataPerColumn = [] +# pixDataPerColumn.resize(column_count) +# +# for clmIndex in column_count: +# pixDataPerColumn[clmIndex] = oDataClm.get_top_cube_face(clmIndex, 0) +# +# var pixelIndex = 0 +# for y in height: +# for x in width: +# var clmIndex = oDataClmPos.get_cell_clmpos(x, y) +# var rgb = pixDataPerColumn[clmIndex] +# pixData[pixelIndex] = rgb >> 16 & 255 +# pixData[pixelIndex + 1] = rgb >> 8 & 255 +# pixData[pixelIndex + 2] = rgb & 255 +# pixelIndex += 3 diff --git a/Scenes/ReadData.gd b/Scenes/ReadData.gd index 15299da0..52332dbc 100644 --- a/Scenes/ReadData.gd +++ b/Scenes/ReadData.gd @@ -14,6 +14,7 @@ onready var oDataScript = Nodelist.list["oDataScript"] onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oDataLof = Nodelist.list["oDataLof"] onready var oMessage = Nodelist.list["oMessage"] +onready var oCurrentFormat = Nodelist.list["oCurrentFormat"] var value # just so I don't have to initialize the var in every function @@ -172,16 +173,18 @@ func new_dat(): oDataClmPos.initialize((M.xSize*3)+1, (M.ySize*3)+1, 0, Grid.U16) func read_clm(buffer): + if oCurrentFormat.selected == Constants.ClassicFormat: + oDataClm.column_count = 2048 + else: + oDataClm.column_count = 8192 oDataClm.clear_all_column_data() buffer.seek(0) - var numberOfClmEntries = buffer.get_u16() + # Do not read column count from the .clm file, just hardcode it. #buffer.get_32() buffer.seek(4) - oDataClm.unknownData = 65536 - buffer.get_u16() - if oDataClm.unknownData == 65536: oDataClm.unknownData = 0 + oDataClm.unknownData = oDataClm.column_count #buffer.get_32() buffer.seek(8) # For reading maps - for entry in numberOfClmEntries: - + for entry in oDataClm.column_count: oDataClm.utilized[entry] = buffer.get_u16() # 0-1 var specialByte = buffer.get_u8() # 2 @@ -200,11 +203,11 @@ func read_clm(buffer): oDataClm.cubes[entry][cubeNumber] = buffer.get_u16() # 8-23 func new_clm(): + oDataClm.column_count = 8192 oDataClm.clear_all_column_data() - var numberOfClmEntries = 2048 oDataClm.unknownData = 0 - for entry in numberOfClmEntries: + for entry in oDataClm.column_count: oDataClm.utilized[entry] = 0 oDataClm.permanent[entry] = 0 oDataClm.lintel[entry] = 0 diff --git a/Scenes/SlabColumnEditor.gd b/Scenes/SlabColumnEditor.gd index cd3096d5..96758785 100644 --- a/Scenes/SlabColumnEditor.gd +++ b/Scenes/SlabColumnEditor.gd @@ -16,6 +16,7 @@ func _on_ColumnEditor_visibility_changed(): if is_instance_valid(oDataClm) == false: return if visible == true: + oColumnEditorControls.just_opened() oColumnEditorVoxelView.initialize() oPropertiesTabs.set_current_tab(2) @@ -23,6 +24,7 @@ func _on_ColumnEditor_visibility_changed(): # Refresh controls oColumnEditorControls._on_ColumnIndexSpinBox_value_changed(oColumnEditorControls.oColumnIndexSpinBox.value) + else: # Update "Clm entries" in properties window yield(get_tree(),'idle_frame') diff --git a/Scenes/SlabPalette.gd b/Scenes/SlabPalette.gd index da38d2f8..c00c3e8e 100644 --- a/Scenes/SlabPalette.gd +++ b/Scenes/SlabPalette.gd @@ -491,7 +491,7 @@ extends Node # viewDKdat() # #func viewoDkClm(): -# var numberOfClmEntries = 2048 +# var numberOfClmEntries = column_count # for entry in numberOfClmEntries: # var twentyFourByteArray = oAssets.clm[entry] # oDataClm.data.append(twentyFourByteArray) diff --git a/Scenes/SlabsetWindow.gd b/Scenes/SlabsetWindow.gd index 02eba333..33cc9d1f 100644 --- a/Scenes/SlabsetWindow.gd +++ b/Scenes/SlabsetWindow.gd @@ -82,7 +82,8 @@ func _ready(): var spinbox = id.get_node("CustomSpinBox") var shortcut = id.get_node("ButtonShortcut") shortcut.connect("pressed",self,"shortcut_pressed",[id]) - spinbox.max_value = 2047 + spinbox.min_value = 1 + spinbox.max_value = Columnset.column_count-1 spinbox.connect("value_changed",oDkSlabsetVoxelView,"_on_Slabset3x3ColumnSpinBox_value_changed") spinbox.connect("value_changed",self,"_on_Slabset3x3ColumnSpinBox_value_changed") oGridContainerDynamicColumns3x3.add_child(id) @@ -106,6 +107,7 @@ func _on_SlabsetWindow_visibility_changed(): if visible == true: _on_SlabsetTabs_tab_changed(oSlabsetTabs.current_tab) + oColumnsetControls.just_opened() oDkSlabsetVoxelView._on_SlabsetIDSpinBox_value_changed(oSlabsetIDSpinBox.value) _on_SlabsetIDSpinBox_value_changed(oSlabsetIDSpinBox.value) diff --git a/Scenes/UniversalDetails.gd b/Scenes/UniversalDetails.gd index 40ea14bf..fbe7a9e2 100644 --- a/Scenes/UniversalDetails.gd +++ b/Scenes/UniversalDetails.gd @@ -13,7 +13,7 @@ func _process(delta): oUniversalListData.add_item("Tile", str(oSelector.cursorTile).lstrip('(').rstrip(')')) oUniversalListData.add_item("Subtile", str(oSelector.cursorSubtile).lstrip('(').rstrip(')')) - oUniversalListData.add_item("Clm entries", str(clmEntryCount)+' / 2048') + oUniversalListData.add_item("Clm entries", str(clmEntryCount)+' / ' + str(oDataClm.column_count)) func _on_TimerUpdateColumnEntries_timeout(): var newCount = oDataClm.count_filled_clm_entries() diff --git a/Scenes/VoxelGen.gd b/Scenes/VoxelGen.gd index 0d2a7737..8328e85a 100644 --- a/Scenes/VoxelGen.gd +++ b/Scenes/VoxelGen.gd @@ -8,7 +8,6 @@ onready var oGame3D = Nodelist.list["oGame3D"] var blankArray = initalize_blank_array() func column_gen(genArray, x, z, clmIndex, surrClmIndex, generateBottomFace, sourceDataClm): - var cubeArray = sourceDataClm.cubes[clmIndex] for y in 8: var cubeID = cubeArray[y] diff --git a/Scenes/VoxelViewer.gd b/Scenes/VoxelViewer.gd index ac103687..0422d612 100644 --- a/Scenes/VoxelViewer.gd +++ b/Scenes/VoxelViewer.gd @@ -29,7 +29,7 @@ enum { } var viewObject = 0 setget set_object - +var column_count = 2048 var previousObject = 0 func initialize(): @@ -39,6 +39,9 @@ func initialize(): #if visible == true: var CODETIME_START = OS.get_ticks_msec() + if displayingType == MAP_COLUMN: column_count = oDataClm.column_count + if displayingType == DK_COLUMN: column_count = Columnset.column_count + if displayingType == MAP_COLUMN or displayingType == DK_COLUMN: do_all() if displayingType == DK_SLABSET: @@ -47,6 +50,8 @@ func initialize(): if displayingType == MAP_CUSTOM_SLAB: oVoxelCamera.size = 10 + + do_one() print('Columns generated in: ' + str(OS.get_ticks_msec() - CODETIME_START) + 'ms') @@ -101,9 +106,9 @@ func _input(event): func set_object(setVal): if displayingType == DK_SLABSET: - setVal = clamp(setVal,0,27) + setVal = clamp(setVal,0, 27) if displayingType == MAP_COLUMN or displayingType == DK_COLUMN: - setVal = clamp(setVal,0,2047) + setVal = clamp(setVal,0, column_count-1) previousObject = viewObject viewObject = setVal @@ -146,12 +151,12 @@ func do_all(): match displayingType: MAP_COLUMN: - for clmIndex in 2048: + for clmIndex in column_count: var x = clmIndex*2 var y = clmIndex*2 oVoxelGen.column_gen(genArray, x, y, clmIndex, surrClmIndex, true, oDataClm) DK_COLUMN: - for clmIndex in 2048: + for clmIndex in column_count: var x = clmIndex*2 var y = clmIndex*2 oVoxelGen.column_gen(genArray, x, y, clmIndex, surrClmIndex, true, Columnset) diff --git a/Scenes/WriteData.gd b/Scenes/WriteData.gd index 4b970ded..0c4560f1 100644 --- a/Scenes/WriteData.gd +++ b/Scenes/WriteData.gd @@ -349,14 +349,10 @@ func write_dat(): func write_clm(): var buffer = StreamPeerBuffer.new() - var numberOfClmEntries = 2048 - buffer.put_16(numberOfClmEntries) - buffer.put_data([0, 0]) - buffer.put_16(oDataClm.unknownData) - buffer.put_data([0, 0]) - + buffer.put_32(oDataClm.column_count) + buffer.put_32(oDataClm.unknownData) var data = PoolByteArray() - data.resize(numberOfClmEntries * 24) + data.resize(oDataClm.column_count * 24) var utilized = oDataClm.utilized var permanent = oDataClm.permanent @@ -367,7 +363,7 @@ func write_clm(): var orientation = oDataClm.orientation var cubes = oDataClm.cubes - for entry in numberOfClmEntries: + for entry in oDataClm.column_count: var index = entry * 24 data[index] = utilized[entry] & 0xFF