Map icons: RustMaps monument art via RustMapsApi.Assets (runtime SVG raster) - #46
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…h drift guard Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ached, log-once misses Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…null-cache and raster-failure paths Review fixes on MonumentIconSource: GetOrAdd's value factory could race under concurrent first requests, leaking a losing Image and double-firing the rasterization Warning — Lazy (ExecutionAndPublication) now guarantees one Rasterize per (type, size). Two new tests: an assetless mapped type caches null (one TryGetAsset call, one Info log across repeats), and a failing rasterization (bogus MonumentAsset via reflection — its ctor is internal and unvalidated) warns exactly once. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ed PNGs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ards Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR modernizes the #map monument icon pipeline by replacing vendored monument PNGs with RustMapsApi.Assets SVG artwork, rasterized on-demand via Svg.Skia/SkiaSharp and cached for reuse. It also updates DI and tests to reflect the new icon source and adds a targeted Serilog override so “missing icon” signals reach production logs.
Changes:
- Introduces
MonumentTokenMap(Rust+ token →MonumentType, including prefix families) andMonumentIconSource(token → SVG → rasterizedImage<Rgba32>, cached + once-per-token logging). - Updates
MapRendererto consumeMonumentIconSourcevia constructor injection and wires it up inAddMap. - Updates packages/config/tests accordingly (RustMapsApi beta.3 + assets package, Skia/SVG packages, new/updated map tests, Serilog override).
Reviewed changes
Copilot reviewed 14 out of 49 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/RustPlusBot.Features.Map.Tests/MonumentTokenMapTests.cs | Adds mapping + drift-guard tests for token→type and asset coverage. |
| tests/RustPlusBot.Features.Map.Tests/MonumentIconSourceTests.cs | Adds rasterization, caching, and logging behavior tests for the new icon source. |
| tests/RustPlusBot.Features.Map.Tests/MapRendererTests.cs | Updates renderer tests to construct MapRenderer with MonumentIconSource. |
| tests/RustPlusBot.Features.Map.Tests/MapIconsTests.cs | Removes monument/rig assertions now covered by MonumentIconSource tests. |
| tests/RustPlusBot.Features.Map.Tests/MapComposerTests.cs | Updates composer test wiring to provide MapRenderer’s new dependency. |
| src/RustPlusBot.Host/appsettings.json | Adds Serilog per-source override to emit MonumentIconSource Information logs. |
| src/RustPlusBot.Features.Map/RustPlusBot.Features.Map.csproj | Adds references for RustMapsApi.Assets + Skia/SVG raster dependencies. |
| src/RustPlusBot.Features.Map/Rendering/MapRenderer.cs | Switches monument/rig icon retrieval to MonumentIconSource and updates ctor. |
| src/RustPlusBot.Features.Map/MapServiceCollectionExtensions.cs | Registers RustMaps assets + MonumentIconSource singleton for DI. |
| src/RustPlusBot.Features.Map/Assets/MonumentTokenMap.cs | New token→MonumentType mapping (including prefix family rules). |
| src/RustPlusBot.Features.Map/Assets/MonumentIconSource.cs | New runtime SVG rasterizer + cache + “log once” reporting. |
| src/RustPlusBot.Features.Map/Assets/MonumentIconMap.cs | Removes legacy vendored monument icon-key mapping. |
| src/RustPlusBot.Features.Map/Assets/MapIcons.cs | Narrows responsibility to vendored marker/player/vendor icons; removes monument/rig APIs. |
| Directory.Packages.props | Bumps RustMapsApi, adds RustMapsApi.Assets and Skia/SVG package versions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the 35 vendored monument PNGs with SVG artwork from RustMapsApi.Assets 1.0.0-beta.3, rasterized at runtime by Svg.Skia and cached. Monument icons on #map now match the RustMaps red-badge style used by the #info static map, and coverage extends to every monument token Rust+ is known to broadcast.
What changed
MonumentTokenMap(new): 37 exact Rust+ token →MonumentTypeentries plus prefix rules forswamp*/underwater_lab*(Rust+ sends prefab names for those). Sources: previous map + rustplusplus + rustplus.py. Adds previously-missing monuments: radtown, jungle ziggurat, tunnel entrances/links, underwater labs, arctic base B.MonumentIconSource(new DI singleton): resolves token → package SVG → Svg.Skia raster at draw size →Image<Rgba32>, cached per (type, size) in aLazy-wrappedConcurrentDictionary(exactly-once rasterization, race-safe). Serves monuments and the rig strip (same asset family; active red ring unchanged).No monument icon for tokento find gaps. Raster failures log Warning once per (type, size).appsettings.jsongains a Serilog override so these Info lines reach production logs despite the globalWarningfloor.MonumentIconMap+ 35 monument PNGs deleted;MapIconskeeps only the vendored non-monument art (cargo, ch47, patrol, player, vendor).MapRenderertakesMonumentIconSourcevia constructor injection.SkiaSharp.NativeAssets.Linux.NoDependencies(new native dependency, ~9 MB; all Skia use is confined toRasterize's try — a host without the native lib degrades to a monument-less map with greppable Warnings instead of crashing).Verification
-maxcpucount:1, Release, warnings-as-errors clean.jb cleanupcodezero-diff.MonumentAssets.HasAsset; all 39 token routes rasterize to a non-blank 30×30 icon.Live smoke (post-merge or on this branch)
Boot the bot, eyeball the #map render (red-badge icons), and grep logs for
No monument icon for token— any hit is a one-line dictionary addition inMonumentTokenMap.🤖 Generated with Claude Code