Fix wall lights/torches dropped when pasting a blueprint - #44
Open
IonatanPerez wants to merge 1 commit into
Open
Fix wall lights/torches dropped when pasting a blueprint#44IonatanPerez wants to merge 1 commit into
IonatanPerez wants to merge 1 commit into
Conversation
DesignateSingleCell placed items in a single pass, designating each only if CanPlace succeeded at that moment. Wall attachments (wall lamps, torches) require their supporting wall to already exist, so any attachment stored before its wall in the blueprint was silently skipped and never queued. Pasted copies came out missing lights, depending on item ordering/orientation. Repeat placement passes until a full pass places nothing new, so walls are designated before the attachments that depend on them. Planning (shift) mode keeps its original single-pass behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
When pasting a saved blueprint, wall-mounted lights and torches are sometimes missing from the built copy — and which ones go missing depends on their orientation/position, so a symmetric room comes out lopsided. The blueprint saves the lamps correctly; they are dropped at paste time.
Root cause
Designator_Blueprint.DesignateSingleCelliterates the blueprint contents in a single pass, designating each item only ifCanPlace(origin)succeeds at that moment:Wall lamps / torches are wall attachments (
isAttachment,PlaceWorker_AttachedToWall): they occupy a floor cell next to a wall and require the supporting wall to already exist to be placeable. Because everything is placed in one unordered pass, any attachment stored before its supporting wall failsCanPlace(the wall's blueprint isn't down yet) and is silently skipped — never queued.An attachment stored after its wall places fine, which is why the loss looks orientation-dependent.
Concrete repro (RimWorld 1.6 fork, but same code path here)
A 4-bedroom blueprint with 8 wall lamps on the central wall — 4 facing north (below the wall), 4 facing south (above it):
The north lamps come before their wall in the stored order → dropped. Verified against the saved blueprint data and the resulting map.
Fix
Repeat the placement pass until a full pass places nothing new. Walls/edifices get designated first, then a subsequent pass places the attachments that depend on them. Planning (shift) mode keeps its original single-pass behaviour.
Terminates because every placed/already-placed item is removed from the pending list each pass (worst case O(n²), n = item count — trivial in practice).
Testing
The equivalent change compiles cleanly and was tested in-game on RimWorld 1.6 (via the community fork that shares this code): re-pasting the repro blueprint now places all 8 lamps. Since the master/1.x branches have the identical single-pass logic, the fix applies unchanged aside from the
AvailableContentsaccessor name.Also usable as a workaround without this patch: stamping the same blueprint twice places the previously-dropped attachments on the second stamp (their walls exist by then) — which is exactly what this change does automatically in one stamp.