Skip to content

Commit

Permalink
increase column count
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Jun 10, 2024
1 parent 98ba88c commit a1bf4c7
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 74 deletions.
15 changes: 8 additions & 7 deletions Autoload/Columnset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]:
Expand All @@ -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]:
Expand Down
2 changes: 1 addition & 1 deletion Autoload/Things.gd
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Autoload/Version.gd
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions Class/ClmClass.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion Scenes/AddCustomSlabWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/CLMGraphics.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions Scenes/ClmControls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func _ready():
"ColumnsetControls":
nodeClm = Columnset
nodeVoxelView = oColumnsetVoxelView


oColumnIndexSpinBox.connect("value_changed", nodeVoxelView, "_on_ColumnIndexSpinBox_value_changed")

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Scenes/ColumnModels.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand Down Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions Scenes/CurrentMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

16 changes: 9 additions & 7 deletions Scenes/DataClm.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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')

Expand All @@ -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)

Expand All @@ -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([])
Expand All @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions Scenes/GenerateTerrainOLD.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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.

Expand All @@ -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


Expand Down
24 changes: 10 additions & 14 deletions Scenes/OpenMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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())
Expand All @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
16 changes: 16 additions & 0 deletions Scenes/OverheadGraphics.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit a1bf4c7

Please sign in to comment.