Skip to content

Biq and SAV enhancements#920

Open
stavrosfa wants to merge 1 commit intoC7-Game:Developmentfrom
stavrosfa:enhancement/biq-game-section
Open

Biq and SAV enhancements#920
stavrosfa wants to merge 1 commit intoC7-Game:Developmentfrom
stavrosfa:enhancement/biq-game-section

Conversation

@stavrosfa
Copy link
Contributor

This PR in short:
Add version info for .biq and .sav files.
Add a few more flags in the GAME structs (both .biq and .sav)
Some comments and observations on the data structures
Fix bug(?) where if the player number is 0 in the biq file, certain dynamic parts have also 0 length

I came across this .sav file, where it was clear that some data had either uninitialized values (usually in the form of -842150451 which is 0xCDCDCDCD in hex), or had plain wrong values, but the save progressed normally in the original civ3 game.

What I tracked it down to was that, even with an unmodified conquests.biq file, if you start a game choosing Quick Start certain values in the binary where "missing", notably the dynamic parts in the .biq GAME struct, which contain a) the ids of the civs in game and b) their alliance statuses.

That caused the whole reading of the binary to be offset by some amount, which I think is constant regardless of settings (4 bytes * 31 players (ids) + 4 bytes * 31 players (alliances)), resulting in junk data after that point in the corresponding GAME struct.

It also seems that the game at this point also assigns some default values, regardless of what it's loading from, so for example, the plague name might be "Plague" in the conquests.biq, or even absent if it's a PTW file, but upon inspection after loading, the plague name has the value "Black Death", which seems to be hadcoded in the game exe itself (found using Ghidra).

Tha flags/comments and the version are bonuses that I came across/added during the investigation.

Ah, almost forgot, Quintillus' editor source code was a big help to be able to identify biq and sav versions, as well as the decompression tool

Add a few more flags in the GAME structs (both .biq and .sav)
Some comments and observations on the data structures
Fix bug(?) where if the player number is 0 in the biq file, certain dynamic parts have also 0 length
Copy link
Contributor

@ajhalme ajhalme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants