Repository navigation
Add native world-map zoom rendering backend - #6037
Huitzilopochtli-98 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
In addition to the specific issues commented on above, this toolset needs documentation explaining its methodology - the code is virtually devoid of any commentary that explains why it's doing what it's doing. There's a lot of code here and basically no explanation of why it does what it does. AI slop is fine for personal tools, but I have to understand the code I'm being asked to commit to maintain, and if you make it too hard for me to do that, I'm not going to agree to that.
I am also uncomfortable with the way this interacts with the render thread and specifically the way the tool doesn't unload cleanly. I think it should be possible to arrange for a clean unload - suggest the author review our developer-facing documentation on how DF's main and simulation threads interact for more insight.
I also don't find the API documentation sufficient - I read through it twice and I still don't understand how I'm supposed to use it. Basically, I'm not seeing the general use case for this functionality.
| std::lock_guard lock(state_mutex); | ||
| renderer_name = info.name ? info.name : "unknown"; | ||
| } | ||
| texture = sdl.create_texture(sr, 0x16362004, 2, w, h); // ARGB8888 / TARGET |
| } | ||
| } | ||
| if (full || (!valid && started)) { | ||
| if (sdl.set_color(sr, 0, 0, 0, 255) != 0 || sdl.clear(sr) != 0 || |
There was a problem hiding this comment.
i don't like this - while i understand what it's doing, it was considerable work to understand what it is, and thus it's telling an obscure story, and that's bad
| } | ||
| } sdl; | ||
|
|
||
| #include "worldmap-zoom-canvas.h" |
There was a problem hiding this comment.
#includes should be at the top of the file unless there is a compelling reason for them to be somewhere else. please review our contribution standards.
| #include "lauxlib.h" | ||
| #include "lua.h" | ||
|
|
||
| #define WIN32_LEAN_AND_MEAN |
There was a problem hiding this comment.
windows-specific code needs to be gated by an #ifdef and our contribution standards require avoiding including Windows.h whenever possible, thus this include requires a justification
World Map Zoom enlarges the high-level embark Biome map and normal fortress world map at 2x/4x while preserving native text/control size. This PR contributes its native rendering service to DFHack so the backend can be built against each release's own structures and metadata.
Related to #6026. Adapted from the Zlib-licensed World Map Zoom project, retaining the original notices. The released mod has successful Windows in-game testing, including player validation.
Method and scope
The native map is drawn at its original coordinates into an SDL target texture. A cropped region is copied back beneath native-size interface drawing. Dirty-cell batches share the target pass; incomplete new crops receive one native full-map fallback. SDL state is saved/restored explicitly, and camera generations prevent stale crops from being composited.
The plugin documentation now explains the coordinate math, full/incremental rendering sequence, Direct3D motivation, inverse input mapping, thread ownership, and teardown. It includes a concrete centered-2x client sequence and explains the GUI client's responsibilities. The GUI/input helpers remain in the reference project; its released version guards need adaptation for development builds.
Revisions addressing the requested review
Windows.hand module pinning. New core-owned render-task handles support pending cancellation and report completion only after the callback and its captures are destroyed. Renderer cleanup removes hooks/event watches on their owning thread before unload is permitted.stop()plus later polling, and inline render-thread cleanup during process shutdown. A suspended synchronous unload or an incomplete cleanup refuses to unload the module.The core task API, documentation, and independent lifetime tests are isolated in follow-up commit
af4f46e, so that support can be reviewed or split out independently. Renderer refactoring/methodology and graphics tests are inf9b0d85. A third follow-up,2fcb9c9, closes admission before idle unload and fences cleanup queued bystop()even when preparation never happened. Its native regression failed against the old binary and passes with the fix. These append to the reviewed history; no force-push was used.Validation at 2fcb9c9
The initial native build remains enabled on Windows; native Linux compilation/acceptance and full embark/fortress zoom-GUI retesting of the refactored integration remain outstanding. This stays a draft for maintainer review of the integration and core task API. Exact source/structure compatibility checks remain in place and are derived from the build rather than fixed to the standalone mod release.