Skip to content

Fix duplicate room prevention for shape-first palaces#415

Merged
Ellendar merged 3 commits into
mainfrom
roompool-fix
Apr 28, 2026
Merged

Fix duplicate room prevention for shape-first palaces#415
Ellendar merged 3 commits into
mainfrom
roompool-fix

Conversation

@initsu
Copy link
Copy Markdown
Collaborator

@initsu initsu commented Apr 25, 2026

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.)

initsu added 3 commits April 25, 2026 20:35
- 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.
@initsu initsu added this to the 5.1.X milestone Apr 25, 2026
@Ellendar Ellendar merged commit 4d57272 into main Apr 28, 2026
2 checks passed
@initsu initsu deleted the roompool-fix branch April 28, 2026 23:25
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