Skip to content

Commit db6ba3d

Browse files
committed
renames
1 parent 687ea81 commit db6ba3d

File tree

6 files changed

+188
-218
lines changed

6 files changed

+188
-218
lines changed

Autoload/Slabset.gd

+112-142
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ enum dir {
2525

2626

2727
func load_slabset():
28+
var CODETIME_START = OS.get_ticks_msec()
2829
var oGame = Nodelist.list["oGame"]
29-
30-
CODETIME_START = OS.get_ticks_msec()
31-
32-
var filePath = oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.DAT")
33-
var buffer = Filetypes.file_path_to_buffer(filePath)
34-
buffer.seek(2)
30+
var dat_buffer = Filetypes.file_path_to_buffer(oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.DAT"))
31+
dat_buffer.seek(2)
3532

3633
var totalSlabs = 42 + 16
3734
dat.resize(totalSlabs)
@@ -43,7 +40,7 @@ func load_slabset():
4340
dat[slabID][variation].resize(9)
4441
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
4542
for subtile in 9:
46-
var value = 65536 - buffer.get_u16()
43+
var value = 65536 - dat_buffer.get_u16()
4744
dat[slabID][variation][subtile] = value
4845
else:
4946
for subtile in 9:
@@ -59,111 +56,8 @@ func load_slabset():
5956

6057
print('Created Slabset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')
6158

62-
func fetch_slab(slabID, variation, subtile):
63-
if dat.size() > slabID:
64-
return dat[slabID][variation][subtile]
65-
else:
66-
return blank_dat_entry[variation][subtile]
67-
68-
69-
func create_cfg_slabset(filePath): #"res://slabset.cfg"
70-
var oMessage = Nodelist.list["oMessage"]
71-
var textFile = File.new()
72-
if textFile.open(filePath, File.WRITE) == OK:
73-
var slabSection = 0
74-
75-
for slabID in 58:
76-
#textFile.store_line('[[slab' + str(slabSection) + '.columns]]')
77-
78-
var variationStart = (slabID * 28)
79-
if slabID >= 42:
80-
variationStart = (42 * 28) + (8 * (slabID - 42))
81-
82-
var variationCount = 28
83-
if slabID >= 42:
84-
variationCount = 8
85-
86-
textFile.store_line('[slab' + str(slabID) + ']')
87-
88-
for variationNumber in variationCount:
89-
if variationStart + variationNumber < Slabset.dat.size():
90-
#var beginLine = get_dir_text(variationNumber) + ' = '
91-
textFile.store_line('[slab' + str(slabSection) + '.' + get_dir_text(variationNumber) + ']')
92-
textFile.store_line('columns = ' + String(Slabset.dat[variationStart + variationNumber])) #.replace(',','').replace('[','').replace(']','')
93-
94-
#var objectNumber = 0
95-
var hasObjects = false
96-
for i in tngObject.size():
97-
if tngObject[i][1] == variationStart + variationNumber: #VariationIndex
98-
textFile.store_line("\r")
99-
hasObjects = true
100-
textFile.store_line('[[slab' + str(slabSection) + '.' + get_dir_text(variationNumber) + '_objects' + ']]')
101-
for z in 9:
102-
var val = tngObject[i][z]
103-
var beginLine = ''
104-
match z:
105-
0: beginLine = 'IsLight'
106-
1: beginLine = 'VariationIndex'
107-
2: beginLine = 'Subtile'
108-
3: beginLine = 'RelativeX'
109-
4: beginLine = 'RelativeY'
110-
5: beginLine = 'RelativeZ'
111-
6: beginLine = 'ThingType'
112-
7: beginLine = 'Subtype'
113-
8: beginLine = 'EffectRange'
114-
if z == 1: continue # skip "VariationIndex"
115-
116-
beginLine += ' = '
117-
118-
textFile.store_line(beginLine + String(val))
119-
#objectNumber += 1
120-
121-
if hasObjects == false:
122-
textFile.store_line('objects = []')
123-
124-
textFile.store_line("\r")
125-
126-
textFile.store_line("\r")
127-
128-
slabSection += 1
129-
130-
textFile.close()
131-
oMessage.quick("aaaaa Saved: " + filePath)
132-
else:
133-
oMessage.big("Error", "Couldn't save file, maybe try saving to another directory.")
134-
135-
func get_dir_text(variationNumber):
136-
match variationNumber:
137-
00: return 'S'
138-
01: return 'W'
139-
02: return 'N'
140-
03: return 'E'
141-
04: return 'SW'
142-
05: return 'NW'
143-
06: return 'NE'
144-
07: return 'SE'
145-
08: return 'ALL' #SWNE
146-
09: return 'S_LAVA'
147-
10: return 'W_LAVA'
148-
11: return 'N_LAVA'
149-
12: return 'E_LAVA'
150-
13: return 'SW_LAVA'
151-
14: return 'NW_LAVA'
152-
15: return 'NE_LAVA'
153-
16: return 'SE_LAVA'
154-
17: return 'ALL_LAVA' #SWNE_LAVA
155-
18: return 'S_WATER'
156-
19: return 'W_WATER'
157-
20: return 'N_WATER'
158-
21: return 'E_WATER'
159-
22: return 'SW_WATER'
160-
23: return 'NW_WATER'
161-
24: return 'NE_WATER'
162-
25: return 'SE_WATER'
163-
26: return 'ALL_WATER' #SWNE_WATER
164-
27: return 'CENTER'
165-
16659
func load_slabset_things():
60+
CODETIME_START = OS.get_ticks_msec()
16761
var oGame = Nodelist.list["oGame"]
16862
var filePath = oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.TNG")
16963
var buffer = Filetypes.file_path_to_buffer(filePath)
@@ -172,38 +66,16 @@ func load_slabset_things():
17266
numberOfThings = buffer.get_u16() # It says 359, however there are actually 362 entries in the file.
17367
print('Number of Things: '+str(numberOfThings))
17468

175-
slabtng_index_asset(buffer)
176-
slabtng_object_entry_asset(buffer)
177-
178-
#test_creation_of_object()
179-
180-
func slabtng_index_asset(buffer):
181-
CODETIME_START = OS.get_ticks_msec()
182-
183-
# var textFile = File.new()
184-
# textFile.open("res://slabtng_index_asset.txt", File.WRITE)
185-
18669
buffer.seek(2)
18770
var numberOfSets = 1304
18871
tngIndex.resize(numberOfSets)
18972

19073
for i in tngIndex.size():
19174
var value = buffer.get_u16()
19275
tngIndex[i] = value
193-
#var lineOfText = str(value)
194-
#textFile.store_line(lineOfText)
195-
196-
#textFile.close()
197-
#print('slabtng_index_asset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')
198-
199-
func slabtng_object_entry_asset(buffer):
200-
CODETIME_START = OS.get_ticks_msec()
20176

20277
buffer.seek(2 + (1304*2))
20378

204-
#var textFile = File.new()
205-
#textFile.open("res://slabtng_object_entry_asset.txt", File.WRITE)
206-
20779
tngObject.resize(numberOfThings)
20880
for i in tngObject.size():
20981

@@ -231,18 +103,116 @@ func slabtng_object_entry_asset(buffer):
231103
tngObject[i][6] = buffer.get_u8() # Thing type
232104
tngObject[i][7] = buffer.get_u8() # Thing subtype
233105
tngObject[i][8] = buffer.get_u8() # Effect range
234-
235-
# textFile.store_line(str(i)+'---------------------')
236-
# for blah in 9:
237-
# textFile.store_line(str(tngObject[i][blah]))
238-
239-
#textFile.close()
240106

241107
print('slabtng_object_entry_asset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')
242108

243-
# tngObject[i][3] = wrapi(file.get_u16(), -511, 65025) / 256.0
244-
# tngObject[i][4] = wrapi(file.get_u16(), -511, 65025) / 256.0
245-
# tngObject[i][5] = wrapi(file.get_u16(), -511, 65025) / 256.0
109+
110+
111+
112+
func fetch_column_index(slabID, variation, subtile):
113+
if dat.size() > slabID:
114+
return dat[slabID][variation][subtile]
115+
else:
116+
return blank_dat_entry[variation][subtile]
117+
118+
119+
#func create_cfg_slabset(filePath): #"res://slabset.cfg"
120+
# var oMessage = Nodelist.list["oMessage"]
121+
# var textFile = File.new()
122+
# if textFile.open(filePath, File.WRITE) == OK:
123+
# var slabSection = 0
124+
#
125+
# for slabID in 58:
126+
# #textFile.store_line('[[slab' + str(slabSection) + '.columns]]')
127+
#
128+
# var variationStart = (slabID * 28)
129+
# if slabID >= 42:
130+
# variationStart = (42 * 28) + (8 * (slabID - 42))
131+
#
132+
# var variationCount = 28
133+
# if slabID >= 42:
134+
# variationCount = 8
135+
#
136+
# textFile.store_line('[slab' + str(slabID) + ']')
137+
#
138+
# for variationNumber in variationCount:
139+
# if variationStart + variationNumber < Slabset.dat.size():
140+
# #var beginLine = get_dir_text(variationNumber) + ' = '
141+
# textFile.store_line('[slab' + str(slabSection) + '.' + get_dir_text(variationNumber) + ']')
142+
# textFile.store_line('columns = ' + String(Slabset.dat[variationStart + variationNumber])) #.replace(',','').replace('[','').replace(']','')
143+
#
144+
# #var objectNumber = 0
145+
# var hasObjects = false
146+
# for i in tngObject.size():
147+
# if tngObject[i][1] == variationStart + variationNumber: #VariationIndex
148+
# textFile.store_line("\r")
149+
# hasObjects = true
150+
# textFile.store_line('[[slab' + str(slabSection) + '.' + get_dir_text(variationNumber) + '_objects' + ']]')
151+
# for z in 9:
152+
# var val = tngObject[i][z]
153+
# var beginLine = ''
154+
# match z:
155+
# 0: beginLine = 'IsLight'
156+
# 1: beginLine = 'VariationIndex'
157+
# 2: beginLine = 'Subtile'
158+
# 3: beginLine = 'RelativeX'
159+
# 4: beginLine = 'RelativeY'
160+
# 5: beginLine = 'RelativeZ'
161+
# 6: beginLine = 'ThingType'
162+
# 7: beginLine = 'Subtype'
163+
# 8: beginLine = 'EffectRange'
164+
# if z == 1: continue # skip "VariationIndex"
165+
#
166+
# beginLine += ' = '
167+
#
168+
# textFile.store_line(beginLine + String(val))
169+
# #objectNumber += 1
170+
#
171+
# if hasObjects == false:
172+
# textFile.store_line('objects = []')
173+
#
174+
# textFile.store_line("\r")
175+
#
176+
# textFile.store_line("\r")
177+
#
178+
# slabSection += 1
179+
#
180+
# textFile.close()
181+
# oMessage.quick("aaaaa Saved: " + filePath)
182+
# else:
183+
# oMessage.big("Error", "Couldn't save file, maybe try saving to another directory.")
184+
185+
func get_dir_text(variationNumber):
186+
match variationNumber:
187+
00: return 'S'
188+
01: return 'W'
189+
02: return 'N'
190+
03: return 'E'
191+
04: return 'SW'
192+
05: return 'NW'
193+
06: return 'NE'
194+
07: return 'SE'
195+
08: return 'ALL' #SWNE
196+
09: return 'S_LAVA'
197+
10: return 'W_LAVA'
198+
11: return 'N_LAVA'
199+
12: return 'E_LAVA'
200+
13: return 'SW_LAVA'
201+
14: return 'NW_LAVA'
202+
15: return 'NE_LAVA'
203+
16: return 'SE_LAVA'
204+
17: return 'ALL_LAVA' #SWNE_LAVA
205+
18: return 'S_WATER'
206+
19: return 'W_WATER'
207+
20: return 'N_WATER'
208+
21: return 'E_WATER'
209+
22: return 'SW_WATER'
210+
23: return 'NW_WATER'
211+
24: return 'NE_WATER'
212+
25: return 'SE_WATER'
213+
26: return 'ALL_WATER' #SWNE_WATER
214+
27: return 'CENTER'
215+
246216

247217

248218
#

Scenes/PickSlabWindow.gd

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ func add_slabs():
9191
match slabID:
9292
Slabs.PORTAL:
9393
for i in 9:
94-
columnArray[i] = Slabset.fetch_slab(slabID, 8, i)
94+
columnArray[i] = Slabset.fetch_column_index(slabID, 8, i)
9595
Slabs.WALL_AUTOMATIC:
9696
for i in 9:
97-
columnArray[i] = Slabset.fetch_slab(Slabs.WALL_WITH_BANNER, slabVariation, i)
97+
columnArray[i] = Slabset.fetch_column_index(Slabs.WALL_WITH_BANNER, slabVariation, i)
9898
_:
9999
if slabID < 1000:
100100
for i in 9:
101-
columnArray[i] = Slabset.fetch_slab(slabID, slabVariation, i)
101+
columnArray[i] = Slabset.fetch_column_index(slabID, slabVariation, i)
102102
else:
103103
# Custom slab
104104
pass

Scenes/PlaceThingWithSlab.gd

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ onready var oSelector = Nodelist.list["oSelector"]
88

99
onready var dir = oSlabPlacement.dir
1010

11-
# The way things placed from slabs.tng works, is that we use the same coordinates (via bitmask and slabVariation) as what's in slabs.dat/clm (level 1000)
11+
# The way things placed from slabs.tng works, is that we use the same coordinates (via bitmask and fullVariationIndex) as what's in slabs.dat/clm (level 1000)
1212
# Except we change the positions based on some placement rules.
1313
# For example the Prison bars need extra rules for detecting nearby walls, but the original slab cubes did not need these rules.
14-
# So objects have their own placement rules, though we use the original bitmask/slabvariation (from oSlabPlacement) as a basis to work from.
14+
# So objects have their own placement rules, though we use the original bitmask/fullVariationIndex (from oSlabPlacement) as a basis to work from.
1515

16-
func place_slab_objects(xSlab, ySlab, slabID, ownership, slabVariation, bitmask, surrID, surrOwner):
16+
func place_slab_objects(xSlab, ySlab, slabID, ownership, fullVariationIndex, bitmask, surrID, surrOwner):
1717
oInstances.delete_attached_objects_on_slab(xSlab, ySlab)
1818

1919
if slabID == Slabs.PRISON:
@@ -42,9 +42,9 @@ func place_slab_objects(xSlab, ySlab, slabID, ownership, slabVariation, bitmask,
4242
var isMiddle = determine_if_middle(slabID, ownership, bitmask, surrID, surrOwner)
4343
if isMiddle == false:
4444
constructedSlab = oSlabPlacement.slab_all
45-
#print(slabVariation + constructedSlab[0])
45+
#print(fullVariationIndex + constructedSlab[0])
4646
for subtile in 9:
47-
var idx = get_obj_idx(slabVariation + constructedSlab[subtile], subtile)
47+
var idx = get_obj_idx(fullVariationIndex + constructedSlab[subtile], subtile)
4848
if idx != -1:
4949
oInstances.spawn(xSlab, ySlab, slabID, ownership, subtile, Slabset.tngObject[idx])
5050

@@ -88,8 +88,8 @@ func get_obj_idx(newSlabVar, subtile):
8888

8989
var idx = Slabset.tngIndex[newSlabVar]
9090
if idx >= Slabset.numberOfThings: return -1
91-
# "tngIndex" has one index per slabVariation.
92-
# But there are actually multiple entries inside "tngObject" with the same slabVariation value. Their index is grouped up, that's why I do idx+=1.
91+
# "tngIndex" has one index per fullVariationIndex.
92+
# But there are actually multiple entries inside "tngObject" with the same fullVariationIndex value. Their index is grouped up, that's why I do idx+=1.
9393
while true:
9494
if subtile == Slabset.tngObject[idx][2]:
9595
return idx

0 commit comments

Comments
 (0)