← Devblog

Painting Terrain at Runtime: The Debug Brush

Debug terrain paint panel open in-game, with rocks painted along a coastline

Until now, sculpting the landscape in Akhenaten meant restarting in the scenario editor, making your changes, saving, and loading back in. That round-trip is gone. A new debug panel — contributed by @cwshields in #542 and extended in #551 — lets you paint terrain directly on a live map: drag the mouse to drop trees, carve a river, sprinkle ore-bearing rocks, or smooth a floodplain into the dunes. No editor mode, no reload.

Opening the Panel

Top Menu → Debug → Terrain paint OFF/ON toggles an ImGui window with the full brush palette. The menu item is wired up from ui_top_menu_widget.js; flipping it sets game.debug_terrain_paint, which the C++ side picks up and opens the panel.

The Brushes

A slider sets the brush size from 1 to 5 tiles. Selecting a regular building from the sidebar automatically cancels the brush, so you can't accidentally have both armed at once.

It's More Than Just Flipping Bits

The hard part of "live terrain editing" isn't drawing — it's everything that has to settle around the stroke afterwards. Pharaoh's terrain isn't a flat grid of tiles; it's a network of interlocking caches and physical rules that the original editor took for granted because nothing painted into a running scenario. The brush fixes that:

Demolishing With the Brush

Painting over an occupied tile demolishes whatever building is there — but it goes through a proper teardown rather than just clearing tile bits. Houses release their population as homeless figures, floodplain farms deplete their soil (when soil-depletion is enabled), and multi-tile buildings walk their prev/next chains so every part is marked deleted in sync. The old brute-force map_building_tiles_remove(0, …) path was leaving zombies of half-removed structures behind.

Why This Matters

Three things change with this in place:

Big thanks to @cwshields for both PRs — the second one came in just hours after the first landed.

← Overlay Menu Goes Script-Driven Road Construction Moves to MuJS →