Skip to content

Commit

Permalink
Fix duplicate name when same block used twice in one town
Browse files Browse the repository at this point in the history
Potential fix for #2237.
This code was removed by #2100. However, it's necessary to edit then store a *copy* of block data for each block to have a unique name seed from MAPS.BSA, even when starting from same RMB data.
If data is modified in same instance of RMB data then second time block data is read it effectively overwrites first.
@df-ferital Please let me know if this causes any problems with your RMB caching. I'm not sure why this removed and I didn't catch this outcome in my review of your RMB caching PR. Thank you! :)
  • Loading branch information
Interkarma committed Sep 3, 2021
1 parent db0e63a commit a42ca59
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Assets/Scripts/Utility/RMBLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,11 @@ public static DFBlock[] GetLocationBuildingData(in DFLocation location)
if (!contentReader.GetBlock(blockName, out block))
throw new Exception("GetCompleteBuildingData() could not read block " + blockName);

// Make a copy of the building data array for our block copy since we're modifying it
DFLocation.BuildingData[] buildingArray = new DFLocation.BuildingData[block.RmbBlock.FldHeader.BuildingDataList.Length];
Array.Copy(block.RmbBlock.FldHeader.BuildingDataList, buildingArray, block.RmbBlock.FldHeader.BuildingDataList.Length);
block.RmbBlock.FldHeader.BuildingDataList = buildingArray;

// Assign building data for this block
BuildingReplacementData buildingReplacementData;
for (int i = 0; i < block.RmbBlock.SubRecords.Length; i++)
Expand Down

2 comments on commit a42ca59

@df-ferital
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for this mistake on my side! While working on blocks caching, I think I deleted those lines at some point to check the effect in-game and probably did not notice any in the towns I tested. But now that you put the code back, I understand why they are required and this shouldn't affect caching at all.

@Interkarma
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Ferital! :) I was hoping it would be that simple and cause any problems for your changes. Thanks for checking and getting back to me.

Please sign in to comment.