Skip to content

Documenting base ruleset drift#937

Draft
ajhalme wants to merge 1 commit into
C7-Game:Developmentfrom
ajhalme:base-ruleset-drift
Draft

Documenting base ruleset drift#937
ajhalme wants to merge 1 commit into
C7-Game:Developmentfrom
ajhalme:base-ruleset-drift

Conversation

@ajhalme
Copy link
Copy Markdown
Contributor

@ajhalme ajhalme commented May 24, 2026

Made a script for applying changes in saved game unitPrototype to the matching base ruleset field.

This draft PR is not intended to be merged as is, just a way to document "drift" between what the save files are given and what the base ruleset provides. The diff/drift here is based on latest Development branch as of this writing.

Issues

Notable issues when reading a Civ3 save in OC3, saving the game in standard OC3 json save file format, and then applying unitPrototype on top of the OC3 base ruleset:

  • Unique units replacing upgradeTo paths
  • flag placement (rotateBeforeAttack): the field order in code doesn't match current ruleset order, resulting in this add/remove noise
  • blank producibleBy getting removed
  • Unicode encoding of city names, etc.
  • Whitespace

@ajhalme
Copy link
Copy Markdown
Contributor Author

ajhalme commented May 24, 2026

The ruleset-save patch/compare script below. (note -n flag for a dry-run)

I run it like so:

./merge.sh <OpenCiv>/C7/Lua/game_modes/base-ruleset.json <Civ3>/Conquests/Saves/curragh5.SAV.json

#!/usr/bin/bash

# Usage: ./merge.sh [-n] <A.json> <B.json>
# -n  Dry run: show diff without modifying A.json

DRY_RUN=false

if [ "$1" = "-n" ]; then
    DRY_RUN=true
    shift
fi

if [ $# -ne 2 ]; then
    echo "Usage: $0 [-n] <target.json> <source.json>"
    exit 1
fi

A="$1"
B="$2"
UPDATED="${A%.json}_updated.json"

if [ ! -f "$A" ]; then
    echo "Error: '$A' not found"
    exit 1
fi

if [ ! -f "$B" ]; then
    echo "Error: '$B' not found"
    exit 1
fi

jq --slurpfile b "$B" '.unitPrototypes = $b[0].unitPrototypes' "$A" > "$UPDATED"

if [ "$DRY_RUN" = true ]; then
    echo "Dry run — diff of '$A' vs proposed changes:"
    diff "$A" "$UPDATED"
    rm "$UPDATED"
else
    mv "$UPDATED" "$A"
    echo "Done"
fi

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.

1 participant