From 66e2d5cc1dc4a88b72128d5aba97b786dd5b3f1f Mon Sep 17 00:00:00 2001 From: drcarademono <73616371+drcarademono@users.noreply.github.com> Date: Wed, 25 Sep 2024 20:23:34 -0700 Subject: [PATCH] Use replacement building data in replaced RMBs --- Assets/Scripts/Utility/RMBLayout.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Assets/Scripts/Utility/RMBLayout.cs b/Assets/Scripts/Utility/RMBLayout.cs index d5a21913e7..bce2a22368 100644 --- a/Assets/Scripts/Utility/RMBLayout.cs +++ b/Assets/Scripts/Utility/RMBLayout.cs @@ -642,6 +642,28 @@ public static DFBlock[] GetLocationBuildingData(in DFLocation location) for (int i = 0; i < block.RmbBlock.SubRecords.Length; i++) { ref DFLocation.BuildingData building = ref block.RmbBlock.FldHeader.BuildingDataList[i]; + + // Check for replacement building data and use it if found + if (WorldDataReplacement.GetBuildingReplacementData(blockName, block.Index, i, out buildingReplacementData)) + { + // Replace the entire SubRecord (contains both exterior and interior data) + block.RmbBlock.SubRecords[i] = buildingReplacementData.RmbSubRecord; + + // Use replacement metadata (FactionId, NameSeed, Quality, etc.) + if (buildingReplacementData.FactionId > 0) + building.FactionId = buildingReplacementData.FactionId; + if (buildingReplacementData.Quality > 0) + building.Quality = buildingReplacementData.Quality; + building.NameSeed = buildingReplacementData.NameSeed; + building.BuildingType = (DFLocation.BuildingTypes)buildingReplacementData.BuildingType; + + // Check for and replace AutoMap data + if (buildingReplacementData.AutoMapData != null && buildingReplacementData.AutoMapData.Length == 64 * 64) + { + block.RmbBlock.FldHeader.AutoMapData = buildingReplacementData.AutoMapData; + } + } + if (IsNamedBuilding(building.BuildingType)) { // Try to find next building and merge data