Skip to content

Add support for impassable terrain - #992

Merged
ajhalme merged 1 commit into
C7-Game:Developmentfrom
Billytifft:billy/impassable-terrain
Sep 14, 2026
Merged

ajhalme merged 1 commit into
C7-Game:Developmentfrom
Billytifft:billy/impassable-terrain

Conversation

@Billytifft

@Billytifft Billytifft commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Closes #362

Summary

Adds the Impassable terrain flag from the BIQ TERR section to the terrain model and makes unit movement respect it. This fixes terrains like the WWII Pacific scenario's desert, which has a movement cost of 0 but must block entry entirely.

ImpassableByWheeled is deliberately left for a follow-up, as scoped in the issue.

Changes

  • TerrainType: new impassable property, imported from civ3Terrain.Impassable
  • Tile: IsImpassable() helper, reading the overlay terrain (consistent with MovementCost())
  • MapUnit.ResolveIntent: returns Disabled on impassable tiles, which gates every entry path:
    • manual movement (MapUnit.Move)
    • go-to pathing (A* CanEnterPeacefully/CanEnterForcefully)
    • go-to execution (MoveAlongPath)
    • go-to UI (goto cursor / hover cost)
  • Tests: MakeImpassableDesertTile() helper plus two tests — a land unit can't enter an impassable tile (even forcefully) and can't path through one

Verification

  • dotnet build C7/C7.sln — 0 errors
  • dotnet test C7/C7.sln with CIV3_HOME set — 69/69 pass, 0 skipped (real Civ3 scenario/save tests included)
  • dotnet format C7/C7.sln whitespace --verify-no-changes — clean

Standard BIQs have no impassable terrain, so this is a no-op for normal games; it only affects mods that flag terrain impassable.

protected Tile MakeImpassableDesertTile() {
return new(ID.None("")) {
baseTerrainType = new() { Key = "desert" },
overlayTerrainType = new() { Key = "desert", movementCost = 1, impassable = true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#362 explicitly mentions 0 movementCost. That could be a good test case to check.

@ajhalme

ajhalme commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

LGTM, test is fine as is

@ajhalme
ajhalme merged commit 7cd0d45 into C7-Game:Development Sep 14, 2026
3 checks passed
@stavrosfa

Copy link
Copy Markdown
Contributor

I think barbarians spawn on these impassable tiles, if I remember correctly from the ww2 map.
So perhaps only human units are unable to move there, or, it's just barbarians that can move on them.
Obviously this got merged, so perhaps an issue could be opened and linked to this PR as reference, so we dont miss it in the future?

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.

Add support for "Impassable" flag

3 participants