Skip to content

Commit

Permalink
fix bitmask issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 28, 2024
1 parent 991e630 commit d711f30
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
45 changes: 23 additions & 22 deletions Autoload/Slabs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ const OWNABLE = true
const FLOOR_SLAB = false
const BLOCK_SLAB = true
enum {
BITMASK_GENERAL
BITMASK_FLOOR
BITMASK_BLOCK
BITMASK_SIMPLE
BITMASK_CLAIMED
BITMASK_REINFORCED
Expand Down Expand Up @@ -198,47 +199,47 @@ func fetch_name(slabID):


var data = {
00: ["HARD", BLOCK_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 0
01: ["GOLD", BLOCK_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 1
02: ["DIRT", BLOCK_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 2
03: ["TORCH_DIRT", BLOCK_SLAB, BITMASK_GENERAL, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 3
00: ["HARD", BLOCK_SLAB, BITMASK_BLOCK, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 0
01: ["GOLD", BLOCK_SLAB, BITMASK_BLOCK, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 1
02: ["DIRT", BLOCK_SLAB, BITMASK_BLOCK, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 2
03: ["TORCH_DIRT", BLOCK_SLAB, BITMASK_BLOCK, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 3
04: ["DRAPE_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 4
05: ["TORCH_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 5
06: ["TWINS_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 6
07: ["WOMAN_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 7
08: ["PAIR_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 8
09: ["DAMAGED_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 9
10: ["PATH", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 10
10: ["PATH", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 10
11: ["PRETTY_PATH", FLOOR_SLAB, BITMASK_CLAIMED, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 11
12: ["LAVA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_LAVA, NOT_OWNABLE], # 12
13: ["WATER", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_WATER, NOT_OWNABLE], # 13
14: ["ENTRANCE_ZONE", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 14
12: ["LAVA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_LAVA, NOT_OWNABLE], # 12
13: ["WATER", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_WATER, NOT_OWNABLE], # 13
14: ["ENTRANCE_ZONE", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 14
15: ["ENTRANCE_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 15
16: ["TREASURY_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 16
16: ["TREASURY_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 16
17: ["TREASURY_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 17
18: ["BOOK_SHELVES", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 18
18: ["BOOK_SHELVES", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 18
19: ["LIBRARY_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 19
20: ["PRISON_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 20
20: ["PRISON_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 20
21: ["PRISON_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 21
22: ["TORTURE_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 22
22: ["TORTURE_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 22
23: ["TORTURE_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 23
24: ["TRAINING_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 24
24: ["TRAINING_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 24
25: ["TRAINING_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 25
26: ["HEART_PEDESTAL", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 26
26: ["HEART_PEDESTAL", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 26
27: ["HEART_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 27
28: ["WORKSHOP_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 28
28: ["WORKSHOP_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 28
29: ["WORKSHOP_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 29
30: ["SCAVENGE_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 30
30: ["SCAVENGE_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 30
31: ["SCAVENGER_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 31
32: ["TEMPLE_POOL", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 32
32: ["TEMPLE_POOL", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 32
33: ["TEMPLE_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 33
34: ["GRAVE_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 34
34: ["GRAVE_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 34
35: ["GRAVE_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 35
36: ["HATCHERY", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 36
36: ["HATCHERY", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 36
37: ["HATCHERY_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 37
38: ["LAIR_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 38
38: ["LAIR_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 38
39: ["LAIR_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 39
40: ["BARRACK_AREA", FLOOR_SLAB, BITMASK_GENERAL, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 40
40: ["BARRACK_AREA", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 40
41: ["BARRACK_WALL", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 41
42: ["DOOR_WOODEN", FLOOR_SLAB, BITMASK_DOOR1, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 42
43: ["DOOR_WOODEN2", FLOOR_SLAB, BITMASK_DOOR2, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 43
Expand Down
13 changes: 8 additions & 5 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func load_terrain_data(path): # 4ms
setIsOwnable = Slabs.OWNABLE


var setBitmask = Slabs.BITMASK_GENERAL
var setBitmask = Slabs.BITMASK_BLOCK

if slabSection.get("Animated", 0) == 1:
setBitmask = Slabs.BITMASK_SIMPLE
Expand All @@ -137,15 +137,18 @@ func load_terrain_data(path): # 4ms
else:
match slabSection.get("Category", 0):
0: # Unclaimed
setBitmask = Slabs.BITMASK_GENERAL
if setBlockType == Slabs.BLOCK_SLAB:
setBitmask = Slabs.BITMASK_BLOCK
elif setBlockType == Slabs.FLOOR_SLAB:
setBitmask = Slabs.BITMASK_FLOOR
1: # Diggable dirt
setBitmask = Slabs.BITMASK_GENERAL
setBitmask = Slabs.BITMASK_BLOCK
2: # Claimed path
setBitmask = Slabs.BITMASK_CLAIMED
3: # Fortified wall
setBitmask = Slabs.BITMASK_REINFORCED
4: # Room interior
setBitmask = Slabs.BITMASK_GENERAL
4: # Room
setBitmask = Slabs.BITMASK_FLOOR
5: # Obstacle
setBitmask = Slabs.BITMASK_SIMPLE

Expand Down
2 changes: 1 addition & 1 deletion Scenes/CustomSlabSystem.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func load_unearth_custom_slabs_file():
"wibble_edges": cfg.get_value(section, "wibble_edges", false),
"cube_data": slabCubeData,
"floor_data": slabFloorData,
"bitmask": cfg.get_value(section, "bitmask", Slabs.BITMASK_GENERAL),
"bitmask": cfg.get_value(section, "bitmask", Slabs.BITMASK_FLOOR),
"is_solid": cfg.get_value(section, "is_solid", Slabs.FLOOR_SLAB),
"ownable": cfg.get_value(section, "ownable", Slabs.OWNABLE),
}
Expand Down
22 changes: 12 additions & 10 deletions Scenes/SlabPlacement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,14 @@ func place_general(xSlab, ySlab, slabID, ownership, surrID, surrOwner, bitmaskTy

var bitmask
match bitmaskType:
Slabs.BITMASK_REINFORCED:
bitmask = get_wall_bitmask(xSlab, ySlab, surrID, ownership)
Slabs.BITMASK_GENERAL:
Slabs.BITMASK_BLOCK:
bitmask = get_tall_bitmask(surrID)
Slabs.BITMASK_FLOOR:
bitmask = get_general_bitmask(slabID, ownership, surrID, surrOwner)
Slabs.BITMASK_CLAIMED:
bitmask = get_claimed_bitmask(slabID, ownership, surrID, surrOwner)
Slabs.BITMASK_REINFORCED:
bitmask = get_wall_bitmask(xSlab, ySlab, surrID, ownership)
Slabs.BITMASK_SIMPLE:
bitmask = 1 # Always use south variation
modifyForLiquid = false
Expand Down Expand Up @@ -753,13 +755,13 @@ func set_columns(xSlab, ySlab, constructedColumns, constructedFloor):
var xSubtile = i - (ySubtile*3)
oDataClmPos.set_cell_clmpos((xSlab*3)+xSubtile, (ySlab*3)+ySubtile, clmIndex)

#func get_tall_bitmask(surrID):
# var bitmask = 0
# if Slabs.data[ surrID[dir.s] ][Slabs.IS_SOLID] == false: bitmask += 1
# if Slabs.data[ surrID[dir.w] ][Slabs.IS_SOLID] == false: bitmask += 2
# if Slabs.data[ surrID[dir.n] ][Slabs.IS_SOLID] == false: bitmask += 4
# if Slabs.data[ surrID[dir.e] ][Slabs.IS_SOLID] == false: bitmask += 8
# return bitmask
func get_tall_bitmask(surrID):
var bitmask = 0
if Slabs.data[ surrID[dir.s] ][Slabs.IS_SOLID] == false: bitmask += 1
if Slabs.data[ surrID[dir.w] ][Slabs.IS_SOLID] == false: bitmask += 2
if Slabs.data[ surrID[dir.n] ][Slabs.IS_SOLID] == false: bitmask += 4
if Slabs.data[ surrID[dir.e] ][Slabs.IS_SOLID] == false: bitmask += 8
return bitmask

func get_general_bitmask(slabID, ownership, surrID, surrOwner):
var bitmask = 0 # Center
Expand Down
5 changes: 0 additions & 5 deletions Scenes/UndoStates.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,13 @@ func _process(delta):
if undo_save_queued == true:
set_process(false)
while true:
print("a")
if Input.is_mouse_button_pressed(BUTTON_LEFT) or \
oLoadingBar.visible == true or \
oNewMapWindow.currently_creating_new_map == true or \
performing_undo == true:
print("b")
yield(get_tree(), "idle_frame")
print("c")
else:
print("d")
break
print("oThreadedSaveUndo.semaphore.post()")
oThreadedSaveUndo.semaphore.post()

undo_save_queued = false
Expand Down

0 comments on commit d711f30

Please sign in to comment.