Skip to content

Bundle 3/6: leaders, flags, units, combat - #147

Merged
bssth merged 125 commits into
bssth:masterfrom
MortenLyhr:train/3-units-combat
Nov 23, 2026
Merged

bssth merged 125 commits into
bssth:masterfrom
MortenLyhr:train/3-units-combat

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge after bundle 2, #146 (this branch holds it; once it is merged, this PR shows only its own changes).

This PR replaces 10 open PRs, merged here one by one with their own commits (each description stays on its PR, which links here once closed); the conflicts between them are resolved as on the branch we play daily. Merging it closes nothing automatically: each replaced PR will be closed with a link here.

PR What
#88 Leaders' hair, brows and beards blended as in the original
#89 Leaders' parts without the leader shader lit as in the original
#73 Civilization flags as the original's: unlit cloth, medallions, health bars, the minimap's banner (builds on #56)
#74 Civilization banner: the flag cloth's shader on Metal/Vulkan, the banner's framing and fringe as the original's
#66 Founding border: the 3x3 plots a new city claims, in the player's colour
#71 New city: its name is asked with the camera on the city
#124 Show the other civilizations' moves one at a time (Show Enemy/Friendly Moves)
#127 Walk a multi-plot move plot by plot, as the original
#130 Combat as the original shows it
#104 Sounds: units' and soundscapes' 3D sounds heard from the camera, as the original's

Commits of this bundle's own (on top of the merges):

  • The generated shaders, regenerated from the merged sources.

  • Fighting units show no flag or health bar while their battle is shown (64ce611a). The game core already holds the battle's end damage when the animation starts, so the health bar (and the flag's health light) gave away the outcome before the blows landed. In the original (seen in Wine, BtS 3.19), neither the attacker nor the defender has a flag or a health bar until the fight is over, with Combat Zoom on or off; the unit panel's ?/5 was already the same. Wine | before | after, mid-fight:

    Wine, OpenCiv4 before, after

    More: combat-healthbar/ (frames of the whole attack, a before/after film, Wine with Combat Zoom on and off).

Checks: macOS build (Release), ctest 14/14 passed; sync checksums --turns 100 --map Fractal --size STANDARD --seed 7 at turn 100 equal master's (D7D43800). Windows: this PR's CI.

🤖 Generated with Claude Code

go140point6 and others added 30 commits November 16, 2026 18:17
Measured in BtS 3.19 (Wine) with CyCamera at 19 zoom levels and the plot
grid at two window sizes:
- Tilt: about CAMERA_LOWER_PITCH + 1.8 (29.8 degrees) up to 1.3 x
  CAMERA_MIN_DISTANCE, then quadratic with the distance to straight down at
  0.86 x CAMERA_SMALLEST_MAX_DISTANCE (within 0.15 degrees). At the start
  distance that is 33.6 degrees, where the straight line gave 42.8.
- FIELD_OF_VIEW is across the screen's diagonal: plots 206 px apart at
  1600x900 and 170 at 1200x900 at the same camera; it was taken as the
  horizontal angle (168 px).
- What the camera looks at is drawn 56.9% of the way up the window
  (CyCamera().GetDefaultViewPortCenter() = (0.5, 0.569)), not in the middle.
  Camera::projection shifts the perspective so the renderer and picking agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The city bar is drawn from the game's CityBar.nif layout and textures:
the banner (CityBar_Base) with the growth and production bars in its
halves, the capital's star or the circle in the population's colour,
the production symbol (what the city builds, else the cancel button,
cut round by ProductionIconMask under ProductionIconBevel) for the
active team's cities, the name and what it builds in the banner's
halves, and buildCityBillboardIconString's icons above it.

It is placed and sized as the original's CITYBILLBOARD faders
(CIV4DetailManager) place it, measured in the original at camera
distances of 12 to 102 plots: out from the city towards the bottom of
the screen and raised, its size levelling off at 0.67. It is no longer
hidden beyond 45 plots, and a click on it is a click on its city (the
city screen opens), over any unit figure under it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LLBOARD_RADIUS

The size came from a fit to zooms from the start view out, which grew
without end closer in. It is now the star's width as measured in the
original at 5 to 102 plots (1.39 points a model unit up close to 0.69 far
out). The bar's top sits on the ground south of the city by
CITYBILLBOARD_RADIUS (90 units up close, no closer than 70), as the
original's plot grid shows, not twice that and raised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onIcon

The host may call only the game core's exports on Windows: the order
queue and GC's info getters are not, so the Windows build did not link.
getCityBillboardProductionIcon is the engine's own call for the symbol:
the player's button for a unit, and INTERFACE_BUTTONS_NOPRODUCTION when
nothing is built (as the original shows), not the cancel button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a settler selected, the original engine draws the plots a city founded
there would claim (its own and the eight next to it, the free culture of
CvCity::init) in the player's primary colour, in its area border style:
rounded corners, a faint hatched fill, following the ground. OpenCiv4 drew a
white outline of the 21-plot city area as straight lines between plot corners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original rounds its borders' corners, outwards and inwards; ours were
sharp, and along rivers the line had steps a texel long.

- In the plots along a border each texel of the border texture takes the
  owner of most of the ground within 0.11 plot of it: a straight edge stays
  where it is, a corner is cut round. Not along a river between owners,
  where the ground is the bank's.
- The texel's distance to the edge is worked out to less than a texel (from
  how much of the ground around it is another owner's), and the shader takes
  the pixel's owner from the distances blended between the four texels
  round it instead of the nearest texel's owner, so the edge runs smoothly
  between the texels.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The border along a river sat a little inside the bank, cut the river's bends
short and was faint there; the original's hugs the near bank through every
bend, and between two owners the water is neither's.

- The border texture is 32 texels a plot side (was 16: a river's bends are a
  texel or two at that), two 8-bit channels (a new RG8 texture format)
  instead of four 16-bit ones, so it takes the same memory.
- It is worked out in the plots along the borders only (the others are their
  plot's owner's, far from an edge): about 70 ms for a 150x104 map with
  17 cities, where the whole map at this size took 450 ms.
- The river is far to cross for an unowned plot's ground too, and its water
  and bed between two grounds are nobody's: each side's ground ends at its
  own bank, round the bends.
- By a river the corners are not rounded, so the bends stay.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The original adds the terrain's detail texture and light to the blended
tiles instead of multiplying them, so flat land keeps its tiles' own
colour: grassland measures as bright as GrassBlend.dds in the original
(RGB 129,144,74 against the texture's 128,139,63), where OpenCiv4 was
about 11% darker (115,126,61) and greener.

- Detail added round its grey, repeated every 2 plots (the landscape's
  4 plots a cell at texture scale 2) instead of 3 times a plot: the
  detail's yellow and dark patches and cracks now have the original's
  size.
- Slopes lighter or darker by how much more or less they face the sun
  than flat land, from the south-east as the original's hills show
  (slopes facing the camera lit, the far side of a ridge dark); flat
  land a little lighter and bluer, as measured.
- No relief on flat land: lit, it made large dark cloud-like patches
  that the original does not have.

Measured on a 1600x900 view (Wine vs this): grassland 129,144,74 vs
130,142,74; plains 189,169,109 vs 186,167,110; plains hills
168,156,121 vs 168,155,123.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the resource layer on, each resource is shown as the original's plot
picker draws it: the resource's button cut to a circle in a black disc with
a light bevelled rim, on a pale pin whose tip is the plot. The bubble keeps
its size at every zoom and stands up and away from the middle of the screen
(left of its plot on the left half, right of it on the right half), so it
moves to the other side as the view passes over it. Farther bubbles are
drawn first, and the layer shows at every camera height, as in the original;
the yield and unit icon layers keep their distance limit.

Measured against Beyond the Sword under Wine at 1600x900: disc 51 px, pin
tip 29 px across and 31 px down from the disc's centre.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The game core asks for the next unit after the settler is gone through
the cycle counter (CvUnit::kill). The host counted it down while the
city's name popup was up, so the next unit was selected and the camera
went to it. The countdown now waits while a popup does, as the core's
own calls to updateSelectionList (not while isDiploOrPopupWaiting).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	apps/oc4core/MapCapture.cpp
#	apps/oc4core/MapCapture.h
TFlagShader takes no light: the player's colours times the cloth's base map.
Lit, the flags came out about a quarter darker and bluer than the original's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ship's damage atlas moves along U by +0.5 to its lightly damaged left half
(unchanged); a flag's medallions move along V by -0.2 a row, up their strip
from its empty bottom row, which only works with V flipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Over each flag, a medallion for each unit on the plot (Art/Units/Flag/
  Medallions.kfm, up to 7): white, green/yellow/red for selected units by how
  they can move. The promotion coin in the same model stays hidden.
- Health bars as the original's billboards: HEALTH_BAR_WIDTH over the
  UNIT_HEALTH_BILLBOARD_SCALE fader long, behind the unit and above the ground
  (..._RADIUS, ..._Z), drawn in the scene so the figures hide part of it.
- The flag by the minimap is the player's era flag model, waving, its cloth
  in the player's two colours, instead of a flat picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured in the original with hurt units (Swordsmen at 100 % to 10 %, units
from Strength 2 to 40): the bar's length is what the engine gets from the DLL,
the unit's current strength times CvUnit::getHealthBarModifier
(HEALTH_BAR_WIDTH over twice the best land unit's strength), so units without
strength have none. Green from two thirds of the hit points, yellow from a
third, red below; as thick at every length. It is a billboard: the _Z fader
moves it up the screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flag cloth's colours times its base map (flags bit 4096, from bssth#56) was only
in the HLSL; Metal and Vulkan still laid the composed decal over the cloth, so
every flag there was one flat colour, without the cloth's folds and its cut
edge. Regenerated with tools/shaders/gen_msl.py and gen_spirv.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The main interface's flag is seen from the front with its pole in the middle,
1.06 of the model's height filling the 250 px picture, centred 0.53 of it up
(was fitted to the model's box: some 4% smaller, 4 px higher and 5 px left of
the original's at 1600x900). Its blended parts cover the panel with their
alpha counted twice, as the original's widget pictures do: the fringe comes
out faint over the panel instead of bright gold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flag's cloth (the civilization's decal in the player's colours) was one
level only, so a small flag sampled its 128 px emblem texel by texel; the
original's decals are DDS files with all their mips, sampled trilinearly
(Civ4FlagDecal.fx). Both the map's flags and the banner by the minimap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The model shader's flag branch (from bssth#56) was not yet in the generated
shaders: tools/shaders/gen_msl.py and gen_spirv.py (glslang 16.6.0,
SPIRV-Tools v2026.4, as CI's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CvGame::getBestLandUnitCombat is not exported from the Windows DLL. The
exported CvUnit::getHealthBarModifier already divides by it: a modifier that
is not finite means there is no best land unit yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	src/render/MslShaders.inc
#	src/render/SpirvShaders.inc
The original draws the grid (CONTROL_GRID) by swapping each terrain's blend
atlas for its grid texture (<Grid> in CIV4ArtDefines_Terrain.xml, e.g.
GrassGrids.dds): the same tiles with a line painted through their middles,
where the plot edges run. So the grid lies in the ground: over hills, down
to the sea floor, under water, rivers, forests and improvements, and it
fades out far away as the atlas mips average the line away.

Measured from the textures: on land the ground under the line goes half way
to black, 1/128 of a plot wide; on coast half way and on ocean 30% to
white, 2/128 wide (so lines over water are light, not dark).

The terrain shader now does the same: each terrain's line (grey, amount,
width) is measured from its grid texture against its blend texture when the
atlas is built, blended through the tile's layers as their colours are, and
drawn on the plot edges before detail and light. Its width is in plots (it
widens up close) and it spreads and fades with the pixel's footprint as a
mipmapped texel would. Before, it was a fixed one-pixel darkening by 35%
over everything, water included. Metal/SPIR-V translations regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The grid textures' mips are drawn by hand: down to 16 texels a plot each
draws the line again, as many texels wide and as dark as the full texture
(so the original's grid stays a crisp pixel or two wide and half dark at
every middle zoom), and the smaller mips have none. Measured in Wine at
nine zooms (views-grid-zoom.txt). The line was fading with distance as an
averaged mip would; now it is drawn per mip as the original's are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws water as its own plane over the ground (Shaders/FX/Water.fx,
CIV4WaterPlaneInfos.xml), unlit: Water.dds twice, scrolling apart, half and half,
their alphas multiplied added as sparkles, laid over the sea floor (the coast
and ocean terrains' own tiles) at the plane's material alpha (0.5), faded out
at the shore, darkened by the fog of war. OpenCiv4 tinted the sea floor a dark
blue and added a sun glint instead.

- New water pass (kWaterHlsl: VSWater/PSWater) after the terrain: a flat grid
  at the water's level over every tile with water at a corner, blended, writing
  depth. The plane's texture, scale, scroll rates and alpha come from the game's
  CvWaterPlaneInfo (MapCapture).
- Scroll rates are per frame at 30 a second; the second layer scrolls the other
  way (measured from a Wine film: two patterns drifting east and west at about
  0.0048 texture units a second each).
- The shore: the water ends where the land/water levels blended between plot
  centres are 0.042 of a plot deep, a little in or out by smooth noise: on a
  straight coast about a quarter of a plot inside the water plot, a one-plot lake
  about 0.56 of a plot across, as in the original.
- The terrain shader's tint and glint are gone; the sea floor is the terrain's.

Measured against the original (Wine, same views): coast 57,121,156 vs
49,121,156, ocean 40,102,143 vs 32,103,143.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws most improvements from CIV4PlotLSystem.xml, not from
CIV4ArtDefines_Improvement.xml's single model; only farms were laid out
that way. Now:

- Mine, quarry, pasture, windmill, fort and whaling boats take their goal
  art from Leaf_LandImprovement_4x4 / Leaf_Water_Improvement_4x4 by era
  (modern mine, quarry, pasture, windmill; the three forts; modern whaling
  boats), turned by the goal's fTwist; a goal without a NIF (an early
  pasture) keeps the art define's model.
- Cottage, hamlet, village and town are houses of the owner's era and art
  style (art:building on the BLeaf leaves) over the goal's iCropArea cells
  (5, 10, 15, 25) round a lot near the plot's middle, turned 45 degrees;
  the goal itself (bPlace:0) draws nothing. Before, each was one small
  model of thatched huts in every era.
- Plantations and the winery: their goal by era and resource on a leaf
  near the middle, the goal's szExtra and its crops round it.
- An unowned plot is drawn in the era and art style of the player looking
  at it (the game's era is the average of all players, which drew an
  industrial player's improvements as classical ones).

House pieces of the city files stand on the ground (PlotPiece::standing)
as the city's own houses do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plot LSystem marks crops, extras and some goals bCutTrees (the trees
on their leaf go) and gives cottages, towns and forts an fCenterCut (a
clearing round the goal, in world units). OpenCiv4 cut trees only at the
models' own TreeCut nodes, so a plantation's crops, racks and grinders
stood hidden in the jungle the original clears for them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fort goals' fTwist (-45 degrees) turned the fort to a diamond; the
original draws it square to the plot in every era (Wine, Ancient,
Classical and Industrial test maps). fTwist turns a layout's lots, and
a goal the plot root places straight has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr and others added 15 commits November 21, 2026 17:53
bssth#81 adds a call drawMesh(..., d.onGround); bssth#82 gives drawMesh a sixth parameter. Each builds
alone and they merge without a conflict, but together the call needs the new argument
(docs/pr-merge-order.md, issue bssth#105).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the bundle's sources

Generated with tools/shaders/gen_msl.py and gen_spirv.py: where two PRs' generated files
conflicted, one side was taken and both regenerated from the merged sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the bundle's sources

Generated with tools/shaders/gen_msl.py and gen_spirv.py: where two PRs' generated files
conflicted, one side was taken and both regenerated from the merged sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ring (Art/Units/Selection Effect/selection_ground.nif) tests no depth
(zMode00, NiZBufferProperty flags 12) and its alpha property says no sorter:
Gamebryo draws it where the scene has it. In the original (Wine, a stack of
two workers at three zooms) the workers' legs hide the ring and its dots.
OpenCiv4 drew it after the units, sorted with the blended items at the
frame's end, so it lay over the figures. Now it is drawn before the units,
unsorted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr and others added 10 commits November 21, 2026 20:34
The rivers' pieces (blended, depth written, drawn with the frame's blended
things after the ring) covered the ring where it crosses a river and its
banks. The ring now lies 1.5 over the ground, tests depth and writes it where
it shows (alpha test): the river and road pieces, laid lower, cannot cover it,
and what stands in front of it (figures, a hut) still does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As the original (checked in Wine, BtS 3.19; the rules are the game core's
CvPlot::getVisibleBonusState/getVisibleImprovementState and the display form of
calculateYield):
- A resource shows only with the tech that reveals it, in anyone's land; an
  improvement on it shows anyway (a mine on flat land, a pasture).
- Under the fog the owner, improvement and road are the ones last seen
  (getRevealedOwner/ImprovementType/RouteType): the host drew the plot's real
  owner and road.
- The yield symbols are the display yields (CvPlot::calculateYield(y, true),
  read through Python where they can differ from getYield, cached): under the
  fog the last seen improvement's; on an unowned plot by the player's techs.
- In the WorldBuilder (and the debug mode) every resource, improvement, road
  and border is shown as it is, hidden techs or not.

CvImprovementInfo::isImprovementBonusTrade (an improved resource's look) is
read once through Python: it is not exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…knows them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	apps/oc4core/MapCapture.h
A resource's bubble stands left of its plot on the left half of the screen and
right of it on the right half. A plot at the very middle of the screen (the
camera centred on it, as when it glides into or out of a city's screen on that
city) is within a thousandth of a pixel of the middle in every frame, on
either side by rounding: its bubble jumped from side to side with each frame
of the glide (84 times in one test run: Roma with stone, its screen opened and
closed).

Each plot's bubble now keeps the side it stands on from frame to frame and
goes over only when its plot is clearly past the middle: 2% of the screen's
width (32 px at 1600). Elsewhere the bubbles stand as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two lines and where and how long they show were checked in the original
under Wine (2026-11-22): Alt+F pressed on and off, filmed; the line is an
event message at the top for about 10 s (EVENT_MESSAGE_TIME). No TXT_KEY in
the game's text has it. The code was right; its comment named the wrong source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… running game

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The game core has the battle's end damage before the animation starts, so the
health bar (and the flag's health light) told the outcome while the units still
fought. The original shows neither on the attacker or the defender until the
fight is over, Combat Zoom on or off (seen in Wine, the bssth#50 combat films).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bssth
bssth merged commit 1323402 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.

3 participants