Skip to content

Commit 3279f3b

Browse files
committed
fixed loading cfgs
1 parent 9f6d735 commit 3279f3b

File tree

7 files changed

+30
-49
lines changed

7 files changed

+30
-49
lines changed

Autoload/Slabset.gd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func load_default_original_slabset():
122122

123123
var object_info = create_object_list(tng_buffer)
124124
if object_info.size() == 0:
125-
oMessage.quick("Failed to load objects")
126125
return
127126

128127
var totalSlabs = 42 + 16

Autoload/Version.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extends Node
22

3-
var major_minor = "0.61"
3+
var major_minor = "0.60"
44
var patch = "0000"
55
var full = ""
66
var unearth_map_format_version:float = 1.06

Scenes/CfgLoader.gd

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,59 +22,30 @@ var file_exists_checker = File.new()
2222

2323
func start(mapPath):
2424
var CODETIME_LOADCFG_START = OS.get_ticks_msec()
25-
clear_stuff()
26-
load_classic_or_kfx_format(mapPath)
27-
print('Loaded all .cfg and .toml files: ' + str(OS.get_ticks_msec() - CODETIME_LOADCFG_START) + 'ms')
28-
if oConfigFilesListWindow.visible:
29-
Utils.popup_centered(oConfigFilesListWindow)
30-
oCustomSlabSystem.load_unearth_custom_slabs_file()
31-
32-
33-
func clear_stuff():
3425
Things.clear_dynamic_lists()
3526
Things.reset_thing_data_to_default()
3627
Slabs.reset_slab_data_to_default()
3728
Slabset.clear_all_slabset_data()
3829
Columnset.clear_all_column_data()
3930
Cube.clear_all_cube_data()
40-
41-
42-
func load_classic_or_kfx_format(mapPath):
43-
if oCurrentFormat.selected == Constants.ClassicFormat or oGame.keeperfx_is_installed() == false:
44-
load_classic_format()
45-
else:
46-
load_kfx_format(mapPath)
47-
48-
49-
func load_classic_format():
50-
# Load configuration for classic Dungeon Keeper format
51-
# Uses Unearth defaults and scans DATA directory for TMAP files
52-
Cube.load_dk_original_cubes()
53-
Slabset.load_default_original_slabset()
54-
Columnset.load_default_original_columnset()
5531

56-
# Populate default spellbooks for Classic format
57-
for subtype in [11,12,13,14,15,16,17,18,19,20,21,22,23,45,46,47,48,134,135]:
58-
Things.LIST_OF_SPELLBOOKS.append(subtype)
32+
if oCurrentFormat.selected == Constants.ClassicFormat or oGame.keeperfx_is_installed() == false:
33+
Cube.load_dk_original_cubes()
34+
Slabset.load_default_original_slabset()
35+
Columnset.load_default_original_columnset()
36+
load_classic_tmap_files()
37+
Things.LIST_OF_SPELLBOOKS = [11,12,13,14,15,16,17,18,19,20,21,22,23,45,46,47,48,134,135]
38+
Things.LIST_OF_HEROGATES = [49]
5939

60-
# Populate default Hero Gate for Classic format
61-
Things.LIST_OF_HEROGATES.append(49)
40+
load_cfgs(mapPath)
6241

63-
# Load TMAP files for classic format
64-
load_classic_tmap_files()
65-
66-
67-
func load_classic_tmap_files():
68-
oConfigFileManager.clear_paths()
69-
# Scan DATA directory for TMAP files
70-
var data_directory = oGame.DK_DATA_DIRECTORY
71-
var tmap_files = Utils.get_filetype_in_directory(data_directory, "dat")
72-
for fullPath in tmap_files:
73-
if "tmap" in fullPath.to_lower():
74-
oConfigFileManager.paths_loaded[oConfigFileManager.LOAD_CFG_DATA].append(fullPath)
42+
print('Loaded all .cfg and .toml files: ' + str(OS.get_ticks_msec() - CODETIME_LOADCFG_START) + 'ms')
43+
if oConfigFilesListWindow.visible:
44+
Utils.popup_centered(oConfigFilesListWindow)
45+
oCustomSlabSystem.load_unearth_custom_slabs_file()
7546

7647

77-
func load_kfx_format(mapPath):
48+
func load_cfgs(mapPath):
7849
# Load configuration for KeeperFX format
7950
# Processes .cfg and .toml files from multiple directories
8051
oConfigFileManager.clear_paths()
@@ -317,7 +288,7 @@ func load_campaign_boss_file(mapPath):
317288
return {}
318289
var list_of_main_campaign_files = Utils.get_filetype_in_directory(levelsDirPath, "cfg")
319290
for campaignPath in list_of_main_campaign_files:
320-
var cfgDictionary = oReadCfg.read_dkcfg_file(campaignPath)
291+
var cfgDictionary = oReadCfg.read_dkcfg_file(campaignPath)["config"]
321292
var levelsLocation = cfgDictionary.get("common", {}).get("LEVELS_LOCATION", null)
322293
if levelsLocation and oGame.GAME_DIRECTORY.plus_file(levelsLocation).to_lower() == mapPath.get_base_dir().to_lower():
323294
#print(oGame.GAME_DIRECTORY.plus_file(levelsLocation).to_lower())
@@ -366,3 +337,12 @@ func remove_path_from_loaded(file_path):
366337
if oConfigFileManager.paths_loaded[load_cfg_type].has(file_path):
367338
oConfigFileManager.paths_loaded[load_cfg_type].erase(file_path)
368339
break
340+
341+
func load_classic_tmap_files():
342+
oConfigFileManager.clear_paths()
343+
# Scan DATA directory for TMAP files
344+
var data_directory = oGame.DK_DATA_DIRECTORY
345+
var tmap_files = Utils.get_filetype_in_directory(data_directory, "dat")
346+
for fullPath in tmap_files:
347+
if "tmap" in fullPath.to_lower():
348+
oConfigFileManager.paths_loaded[oConfigFileManager.LOAD_CFG_DATA].append(fullPath)

Scenes/ConfigFilesListWindow.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func get_campaign_main_data(mapPathArgument):
5959
return {}
6060
var listOfCampaignFiles = Utils.get_filetype_in_directory(levelsDirectoryPath, "cfg")
6161
for campaignFilePath in listOfCampaignFiles:
62-
var configData = oReadCfg.read_dkcfg_file(campaignFilePath)
62+
var configData = oReadCfg.read_dkcfg_file(campaignFilePath)["config"]
6363
var levelsLocation = configData.get("common", {}).get("LEVELS_LOCATION", null)
6464
if levelsLocation and oGame.GAME_DIRECTORY.plus_file(levelsLocation).to_lower() == mapPathArgument.get_base_dir().to_lower():
6565
return configData

Scenes/OpenMap.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func start():
7676
#oCurrentMap.clear_map()
7777
#open_map("C:/Games/Dungeon Keeper GOG/levels/MAP00001.SLB")
7878
#open_map("C:/Games/Dungeon Keeper/levels/deepdngn/map00084.slb")
79-
open_map("C:/Games/Dungeon Keeper/levels/personal/map00001.slb")
80-
#open_map("C:/Games/Dungeon Keeper/campgns/dk2/map00200.slb")
79+
#open_map("C:/Games/Dungeon Keeper/levels/personal/map00001.slb")
80+
open_map("C:/Games/Dungeon Keeper/levels/dk2/map00001.slb")
8181
else:
8282
# initialize a cleared map
8383
oCurrentMap.clear_map()

Scenes/SortCreatureStats.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func _on_SortCreatureStats_visibility_changed():
1717
func start():
1818
var listOfCfgs = Utils.get_filetype_in_directory(oGame.GAME_DIRECTORY.plus_file("creatrs"), "CFG")
1919
for path in listOfCfgs:
20-
var aaa = oReadCfg.read_dkcfg_file(path)
20+
var aaa = oReadCfg.read_dkcfg_file(path)["config"]
2121
all_creature_data[path.get_file()] = aaa
2222

2323
populate_optionbutton()

changelog.gd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ extends Node
33
const string = """
44
<version> - <date>
55
- All custom specials now have access to the CustomBox field
6+
- Fixed loading classic format
7+
- Fixed loading campaign CFGs
68
0.60.804 - 24/7/2025
79
- Attempt to auto-detect keeperfx.exe or keeper.exe in current folder and parent folder
810
- Added link to keeperfx.net/workshop in File menu

0 commit comments

Comments
 (0)