Make building replacements compatible with RMB replacements #2699
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.
Currently modded building replacements and modded RMB replacements are incompatible. Whenever a mod tries to change a building in a modded RMB, the building's metadata is changed but the exterior and interior remains unchanged. This is an especially big problem for unmaintained building replacement mods like Tavern's Redone and Soldier's Luxury, which are incompatible with newer RMB replacement mods like Cities Overhauled and Beautiful Cities.
This PR fixes these incompatibilities by applying building replacements in RMBLayout, after applying RMB replacements. It modifies the method GetLocationBuildingData, in which building replacements change metadata, so that it also changes RMBSubRecords.
Everything appears to be working as intended upon testing. Buildings are replaced in modded RMBs exactly as they would be were the building replacement affecting a vanilla block. Both interior and exterior data (as with Lively Cities) works correctly. Factions (like Archaeologists Guild) work correctly and appear in blue on the automap. Named buildings like taverns still get their metadata from the location data after the building replacements are applied, so their nameseeds and quality etc are correct. This PR also appears to be robust to modded RMBs with many buildings deleted (ie Beautiful Villages); no NullReferences or Index out of range occurred.