Skip to content

Scenarios: teams start with the save's techs only - #142

Merged
bssth merged 1 commit into
bssth:masterfrom
MortenLyhr:fix/scenario-free-techs
Nov 23, 2026
Merged

bssth merged 1 commit into
bssth:masterfrom
MortenLyhr:fix/scenario-free-techs

Conversation

@MortenLyhr

Copy link
Copy Markdown
Contributor

In a World Builder scenario, OpenCiv4 gave every team its civilization's free techs, the handicap's free techs (AI free techs for the AI) and the techs of eras before the start era. The scenario's own techs were then added on top. The original gives a scenario's teams only the techs the save lists.

Example: TestMap-Foreign at Emperor. The AI teams list no techs. In BtS they start with none. In OpenCiv4, the Vikings had Fishing, Hunting and Archery, China had Agriculture, Mining, Hunting and Archery, and so on. (Hunting and Archery are Emperor's AI free techs.) The human's techs already matched, because the save lists Rome's own techs. The difference showed in BUG's Military Advisor: STRATEGIC ADVANTAGES listed other units.

Why

startScenario called CvGame::setInitialItems, which starts with initFreeState. That gives each team its free techs and each player the starting gold. The scenario's CvWBDesc.applyInitialItems only calls setHasTech(..., true) on the techs it lists, so it never takes the free techs away. It sets each player's gold itself.

What it changes

startScenario now runs setInitialItems' other steps (assignStartingPlots, normalizeStartingPlots, initFreeUnits, AI_updateFoundValues) in the same order and leaves out initFreeState. The first three are DllExport. CvPlayerAI::AI_updateFoundValues isn't, so the host calls it through its Python binding (CyPlayer.AI_updateFoundValues(False)). Note: #63 calls player(p).AI_updateFoundValues() directly. When resolving the conflict, use this branch's Python call instead. New games still call setInitialItems unchanged.

Gold: the scenario sets every player's gold (StartingGold), so leaving out initFreeState changes nothing for them. The barbarians keep 0 gold instead of the handicap's starting gold. OpenCiv4 doesn't load map-only scenarios (WBMapNoPlayers), where the user picks the players and free techs would apply.

Merging with #63

This conflicts with #63 (fix/scenario-free-units): both replace the game.setInitialItems(); line in GameSession::startScenario. To resolve, keep #63's version (free state, plots, scenario items, then initFreeUnits), delete its game.initFreeState(); line, and use this branch's Python call for AI_updateFoundValues. #63's comment ("the era's free techs and gold") should then say no free techs.

Checks

  • ctest 13/13.
  • Sync checksums equal to master's on all 100 turns (D7D43800 at turn 100). New games don't take this path.
  • Kit: the OpenCiv4 tech log for TestMap-Foreign now matches Wine's for every team.

🤖 Generated with Claude Code

startScenario ran CvGame::setInitialItems, whose initFreeState gave every
team its civilization's free techs, the handicap's (AI) free techs and the
techs of eras before the start era, and the scenario's own techs were then
only added on top (CvWBDesc.applyInitialItems sets techs, never clears).
The original gives a World Builder scenario's teams only the techs the save
lists (TestMap-Foreign: the AI teams start with none in BtS, with Fishing,
Hunting, Archery... in OpenCiv4).

Run setInitialItems' other steps one by one and leave initFreeState out
(AI_updateFoundValues isn't exported: through CyPlayer). Its gold is set by
the scenario for each of its players anyway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bssth
bssth merged commit 97b4e5f into bssth:master Nov 23, 2026
3 checks passed
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