Fix duplicate room prevention for shape-first palaces#415
Merged
Conversation
- Moved it after original constructor - Added a few lines of documentation - ItemRoomsByDirection is now also cloned for consistency
1st problem: roomsByExitType was set outside of the shape for-loop. Then roomPool.RemoveDuplicates was called inside the loop, which modified roomPool. However, that didn't matter since roomsByExitType was never re-created from the roomPool. 2nd problem: The code used to rely on roomPool.NormalRooms to refill the rooms-by-shape list. Since roomPool.RemoveDuplicates now mutates this field, it was just going to return an empty list at that point.
Ellendar
approved these changes
Apr 28, 2026
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.
Chadbert pointed out to me that he got a Tower palace with unreasonbly many duplicate rooms. After investigating, it turns out the code no longer actually avoids duplicate rooms for shape-first palaces.
1st problem:
roomsByExitType was set outside of the shape for-loop. Then roomPool.RemoveDuplicates was called inside the loop, which modified roomPool. However, that didn't matter since roomsByExitType was never re-created from the roomPool.
2nd problem:
The code used to rely on roomPool.NormalRooms to refill the rooms-by-shape list. Since roomPool.RemoveDuplicates now mutates this field, it was just going to return an empty list at that point.
Because the RoomPool code was messy, I also had to do some refactoring.
I think it should be merged before the tournament because it's a bug that impacts a lot of the palace styles used.
(I'd recommend reviewing commit-by-commit.)