UnofficialCrusaderPatch / UnofficialCrusaderPatch2

Unofficial balancing patch installer for Stronghold Crusader 1
MIT License
429 stars 59 forks source link

Analyze structure of Crusaders .cfg files #855

Open TheRedDaemon opened 3 years ago

TheRedDaemon commented 3 years ago

Problems with starting the game can sometimes be solved by deleting (or moving) the .cfg files. This might be a sign for a faulty configuration.

However, Crusaders .cfg files (and the two .dat files, both saved in the ./Documents/Stronghold Crusader/ folder) are saved in a non readable, binary format. It might be beneficial to understand the structure. It might help to resolve issues without having to delete the entire configuration. A short search by me at least revealed no documentation on these files somewhere.

gynt commented 3 years ago

@patel-nikhil knows the format quite well

J-T-de commented 3 years ago

There is basically a <1.3 and a >=1.3 version of this file, because in the HD version, they added a new character encoding. Both cfg files are incompatible. I guess there are some setups, where the old format gets written in the new one corrupting the file as result...

NP reversed the HD version of the cfg file (see below). I want to confirm at some point. The skirmishmaster files iirc are also split in an HD and non-Hd version, I reversed the HD version here: https://github.com/sourcehold/sourcehold-data-library/blob/master/stronghold_crusader/structs/skmaster_dat.ksy

CFG file (numbers are offsets) by np

Crusader.cfg format in case it happens to be useful. The file gets loaded when game launches, and written over when game exits. Unknown regions: 0x23A - 0x244 0x27A-0x29A 0x4A6-0x501 (Has the same format as the section for the crusader and warchest trails, space for 20 missions, but seems unused)

settings section

0x46 = player name 0x246 = gamespeed 0x24A = bubble help (0 = off, 1 = on) 0x256 = scroll speed (0 = normal, 1 = fast, 2 = slow) 0x25A = sound (0 = off, 1 = on) 0x25E = music volume 0x262 = FX volume 0x266 = Speech volume

campaign (1 - indexed)

0x26A = The Call to Arms (historical campaign) progress 1-5 0x26E = Saladin's Conquest (historical campaign) progress 6-10 0x272 = The King's Crusade (historical campaign) progress 11-15 0x276 = Crusader States (historical campaign) progress 15-20

setting

0x29E = mouse icon (2 = pointer, 1 = sword)

crusader section

0x342 = farthest mission (0-indexed) 0x346 = shield type (2 = default european lord -> 20 = 2nd blank spot) 0x34A = current mission (0-indexed) 0x34E = 0 if european lord, 1 if arabic 0x352 = year reached 0x356 = array containing # months taken (4bytes) on the mission (value is FFFFFB50 for a chicken)

warchest section

0x422 = farthest mission (0-indexed) 0x42A = year reached 0x426 = current mission (0-indexed)

misc setting

0x41E = genie speech (0 = off 1 = on) 0x52C = resolution on startup (1=800x600, 2=1024x768, 3=1280x720 4 = 1280x1024, 5=1366x768, 6=1440x900, 7=1600x900, 9=1650x1050, 10 = 1920x1080

0x4A6-0x501 (Has the same format as the section for the crusader and warchest trails, space for 20 missions, but seems unused)