Skip to content

Fix colony radar minimap staying stale after construction and other building changes - #1281

Merged
akarnokd merged 1 commit into
akarnokd:masterfrom
janosgy:fix/colony-radar-cache-invalidation
Aug 5, 2026
Merged

akarnokd merged 1 commit into
akarnokd:masterfrom
janosgy:fix/colony-radar-cache-invalidation

Conversation

@janosgy

@janosgy janosgy commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • After Fix colony radar minimap redrawing every frame #1259 / Lazy-cache colony radar minimap by day/night alpha #1261, the colony radar could keep a stale image when a building’s look changed at an already-cached day/night alpha (e.g. construction finished, still showing scaffolding).
  • Keep the full per-alpha minimap cache, and rebuild it when building minimap content actually changes.
  • Each radar draw collects a reusable snapshot of (buildingId, tileKind) pairs (constructing / damaged / normal / inoperable / …), compares it to the previous snapshot, and rebuilds only on a difference. Pavement / planet switch / place / demolish still call invalidate() explicitly.

How the bug happened

#1259 stopped redrawing the radar every frame. #1261 cached one image per lighting alpha and stopped treating day/night as a full dirty. Simulator-driven look changes (construction done, damage/repair, power) did not clear that cache for the current alpha, so the radar could stay wrong until lighting moved on.

How we fixed it

  • Keep the lazy full-image cache (terrain + buildings) keyed by alpha.
  • Detect content changes via a building-state snapshot compare: planet id, building knowledge, and each building’s symbolic minimap tile kind - this was the fastest solution I found.
  • Rebuild only when that snapshot differs; otherwise blit the cached image.
  • Structural/non-building edits (pave, planet switch, place/demolish for roads) still force radar.invalidate().

Note

I finished the main campaign. This was the only bug I found related to my recent changes, so I don’t expect further follow-ups from me.

Tested

  • Radar open, start build/upgrade, keep lighting stable → minimap updates when construction finishes
  • Offline / no energy / damaged / repaired buildings show the right tiles without needing a day/night step
  • Pave, place, demolish → pavement/roads/buildings update correctly
  • Switch planets → correct minimap
  • Busy planet with radar open: stays near cached-radar performance when building states are stable
  • Day/night: per-alpha cache still reuses; building changes invalidate and rebuild as needed

Cache the full radar image per lighting alpha again, and rebuild when a building-state snapshot (id + minimap tile kind) changes, so construction and related updates stay correct without redrawing every frame.
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🐷 TruffleHog + Entropy Beauty Scan

Average entropy of changed code: 4.416 bits/char
Verdict: ✅ Mid-4 beauty detected (thoughtful human code!)

Changed files entropy:

src/hu/openig/model/Tile.java: 4.499
src/hu/openig/model/TileCached.java: 4.503
src/hu/openig/screen/items/PlanetScreen.java: 4.245

✅ No secrets or suspicious high-entropy strings found.

Mid-4 beauty heuristic in action — powered by our entropy chats! 😊

@akarnokd
akarnokd merged commit 0686505 into akarnokd:master Aug 5, 2026
2 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.

2 participants