Repository navigation
Scenarios: teams start with the save's techs only - #142
Merged
Merged
Conversation
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>
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-Foreignat 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
startScenariocalledCvGame::setInitialItems, which starts withinitFreeState. That gives each team its free techs and each player the starting gold. The scenario'sCvWBDesc.applyInitialItemsonly callssetHasTech(..., true)on the techs it lists, so it never takes the free techs away. It sets each player's gold itself.What it changes
startScenarionow runssetInitialItems' other steps (assignStartingPlots,normalizeStartingPlots,initFreeUnits,AI_updateFoundValues) in the same order and leaves outinitFreeState. The first three are DllExport.CvPlayerAI::AI_updateFoundValuesisn't, so the host calls it through its Python binding (CyPlayer.AI_updateFoundValues(False)). Note: #63 callsplayer(p).AI_updateFoundValues()directly. When resolving the conflict, use this branch's Python call instead. New games still callsetInitialItemsunchanged.Gold: the scenario sets every player's gold (
StartingGold), so leaving outinitFreeStatechanges 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 thegame.setInitialItems();line inGameSession::startScenario. To resolve, keep #63's version (free state, plots, scenario items, theninitFreeUnits), delete itsgame.initFreeState();line, and use this branch's Python call forAI_updateFoundValues. #63's comment ("the era's free techs and gold") should then say no free techs.Checks
D7D43800at turn 100). New games don't take this path.🤖 Generated with Claude Code