Skip to content

Cities as the original: smoke and fumes, houses on their paving, walls, trees cleared - #91

Open
MortenLyhr wants to merge 2 commits into
bssth:masterfrom
MortenLyhr:fix/city-art
Open

MortenLyhr wants to merge 2 commits into
bssth:masterfrom
MortenLyhr:fix/city-art

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What it changes

Cities now look like the original's from the map:

  • Effects. The game core says which effects a city shows (CvCity::getVisibleEffects, a DllExport the original engine calls): black smoke over a city with angry citizens, green fumes over an unhealthy one, a large plume and fire over an occupied one, fireworks on "We love the King" day. OpenCiv4 never asked, so cities showed none. Each effect is now drawn at the city's middle as its CIV4EffectInfos model at the effect's scale (the detail zoom's list while the city screen is up).
  • Houses and paving. The LSystem's art is 33.4 units a lot: its 1x1 houses are 30–35 across and the paving pieces (mod_city_lot.nif's 4x4 is 133.6) tile at that. OpenCiv4 took a house as 50 units a lot, so houses stood a third smaller than their lots with grass between them. They are now scaled to the lot (the lot itself unchanged: CITY_LAYOUT_SIZE), laid as a tight square block, on the paving the LSystem lays under its 2x2 lots in the city's era (all_city_lot_2x2.nif to the middle ages, ren_city_lot.nif, mod_city_lot.nif from the industrial era). Measured on a size 16 city: the paving is 0.39 of its 5-plot border across in the original, 0.37 now (the houses were 0.27).
  • Walls stand on the paving's edge, close round the houses as in the original (they were a lot out).
  • Trees. A city clears the forest round it, a circle CITY_TREECUT_SCALE (1.0) plots across, as measured in the original; before, trees stood up to the houses.

Host code only (apps/oc4core/MapCapture.*, src/render/MapView.cpp, MapSnapshot.h); the one new game core call is CvCity::getVisibleEffects (DllExport). No shader changes.

Original · before · after
Angry city (smoke)
Unhealthy city (fumes)
Occupied city
Walls
Size 16 in a forest
Size 24

Not the same yet: the original lays its houses out with the LSystem's productions (so a city's outline steps where its nodes end), OpenCiv4 fills lots nearest the middle; the angry smoke is fainter than the original's.

How it was checked

  • ctest passes: 15/15 (macOS, Release; rebased on master 8b7d8557).
  • Game results unchanged: --turns 100 --map Fractal --size STANDARD --seed 7 gives the same checksum as master on all 100 turns, ending at D7D43800 (drawing only).
  • Original saves still load: not affected, not tested.
  • Compared with the original under Wine on the test map, industrial era: angry, unhealthy, calm and occupied cities; sizes 1, 4, 8, 12, 16, 24; walls and a castle (the castle draws no walls in either); Greco-Roman, European, Asian, Middle East, South American and barbarian art styles.

🤖 Generated with Claude Code

@bssth

bssth commented Nov 23, 2026

Copy link
Copy Markdown
Owner

src/render/MapView.cpp:3710: featureKey[at] |= 1 << 30 changes nothing on a city plot: with no feature feature == -1, and int32_t(-1) << 8 already has bit 30 set. Founding a city next to a forest leaves the trees up until some other feature changes; same on razing. Build the key from the unsigned feature, e.g. int32_t(uint16_t(p.feature)) << 8 | p.featureVariety.

MortenLyhr and others added 2 commits November 23, 2026 09:12
… cut

- The effects the game core shows over a city (CvCity::getVisibleEffects:
  an occupied city's smoke and fire, an angry one's smoke, an unhealthy
  one's fumes, fireworks) are drawn at its middle, at the effect's scale.
- Houses are scaled to the lot (the LSystem's art is 33.4 units a lot),
  laid as a tight square block, on the paving the LSystem lays under its
  2x2 lots in the city's era (all_city_lot / ren_city_lot / mod_city_lot).
- Walls stand on the paving's edge (were a lot out).
- A city clears the trees in a circle CITY_TREECUT_SCALE plots across.

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

A plot with no feature has feature -1, and int32_t(-1) << 8 already has
bit 30 set, so the city's mark changed nothing on its plot: the trees by a
new or razed city stayed until some other feature changed. The key now
takes the feature as unsigned (bssth's review of bssth#91).

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

Copy link
Copy Markdown
Contributor Author

Thanks, you're right. A plot with no feature has feature == -1, and int32_t(-1) << 8 already has bit 30 set, so |= 1 << 30 changed nothing on a featureless plot. A new city there, or a razed one, didn't count as a feature change, and the trees it should cut stayed until something else changed a feature.

Fixed in 2b7d2d16, as you suggested: the key takes the feature as unsigned, int32_t(uint16_t(p.feature)) << 8 | p.featureVariety. The feature (16 bits) and variety (8 bits) now fill bits 0–23 only, so bit 30 is the city's own.

I also rebased the PR on master (it conflicted with the plot yields in MapCapture.cpp; I kept both sides).

Checked:

  • Founded a city on bare grass in a forest with oc4core --keys (settler at 81,71 on the test map, forest all round; B). With a temporary log of the keys: before the fix the feature key did not change when the city came; with it, it does.
  • In this case the trees were cut at once even before the fix. A new city always gets a road on its plot (INITIAL_CITY_ROUTE_TYPE = ROUTE_ROAD in GlobalDefines.xml, CvPlot::updateCityRoute), so the decor key changed too, and that also re-cuts the trees. The pictures with and without the fix are the same. Without the fix, the missed change would show when only the city changes and the road doesn't, for example when a city is razed, since the road stays.
  • ctest passes (15/15), and the checksums at all 100 turns are the same as master's, ending at D7D43800.

🤖 Generated with Claude Code

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