Repository navigation
Stacks: the plot shows the unit the game core puts at its centre - #152
Open
MortenLyhr wants to merge 1 commit into
Open
MortenLyhr wants to merge 1 commit into
MortenLyhr wants to merge 1 commit into
Conversation
A plot with several units drew the first unit of the plot's own domain, so a selected settler under a warrior, or a selected work boat in a city, stayed hidden behind the other unit. The original draws the plot's centre unit, which CvPlot::updateCenterUnit picks: the first selected unit, else the active player's best defender that can still move, else any of its own, else the best defender against the active player. That function does nothing in the host (the graphics flag is off), so the host now follows the same order with the exported getBestDefender. Checked in Wine with a settler under a warrior (also on a forest hill), a work boat and a warrior in a coastal city, a stack of six, an enemy stack, and a galley with its cargo. The stack's other units now travel with it in the snapshot (UnitView::hidden): a unit that becomes the shown one, say by a click in the unit bar, stands on the plot, fortified if it is, instead of walking in from where it was last shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr
force-pushed
the
fix/stack-center-unit
branch
from
November 23, 2026 08:59
92985bd to
fd5950a
Compare
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.
Summary
A plot with several units drew the first unit of the plot's own domain. So a selected settler standing with a warrior, or a selected work boat in a city, stayed hidden behind the other unit, and only the unit bar showed what was selected.
The original draws the plot's centre unit, which the game core picks in
CvPlot::updateCenterUnit:In OpenCiv4 that function returns at once, because the host keeps the graphics flag off. So
MapCapturenow follows the same order itself, through the exportedCvPlot::getBestDefender. The special cases stay as they were: a unit in a fight, a plane flying a mission, a unit intercepting.The stack's other units now travel with the shown one in the snapshot (
UnitView::hidden: owner, id, resting). When one of them becomes the shown unit (a click in the unit bar, W), it stands on its plot, fortified if it is. Before, it walked in from wherever it was last drawn.The original (Wine)
The kit's
testgames/shots/stacks/scripts (views-stacks.txt) build a small coast with a stack in each case and select one unit per view:Checks
8b7d8557).--turns 100 --map Fractal --size STANDARD --seed 7at turn 100:D7D43800, equal to master's.D7D43800.DllExportcalls from the host (getBestDefender,getHeadSelectedUnitthrough the host's own interface).Not in this PR
Pictures
Each picture is the original (Wine) on the left and OpenCiv4 after this PR on the right. The before | after pictures are OpenCiv4 alone.
The settler is selected under a warrior:


The settler on a forest hill:


A work boat in a coastal city:


The warrior is chosen from the unit bar:

A worker in a stack of six:

Nothing selected:

The galley, and one of its warriors (see Left):


Left
🤖 Generated with Claude Code