-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for intended precedence of building overrides when RMB block overrides also present #2714
Open
ajrb
wants to merge
2
commits into
Interkarma:master
Choose a base branch
from
ajrb:fixBuildingReplacement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
…rides also present If an RMB block was overridden, the block reading was shortcut and building overrides never applied correctly. This addition applies any applicable building overrides after loading the RMB override data.
Wait on cara to test this, to know if it properly addresses his issue |
I generally view these issues as mod incompatibilities, but I'll add some
protection to avoid the exception as you suggested.
Regarding the position of buildings, like everything else the building file
takes precedence if it's present. If this is altered then building
replacements will be unable to move the building. I could look at making a
special case if the RMB is overridden, but this does add complexity that
will need explaining somewhere.
…On Sat, 4 Jan 2025 at 00:33, drcarademono ***@***.***> wrote:
I did lots of testing and by and large this PR successfully does
everything it's supposed to do. However, it still needs fixes for two
issues: *building index outside the bounds of the RMB array* and *misplaced
buildings*.
*Building index outside the bounds of the RMB array*
This is an edge case we discussed on Discord earlier: a modded RMB can
sometimes have fewer buildings in its buildings array than a building
file's index. This issue crops up when Beautiful Villages and Lively Cities
are combined, since Beautiful Villages removes lots of buildings (to make
villages seem more rural) and Lively Cities then tries to modify buildings
that are missing. The result is this error:
DaggerfallWorkshop.Utility.AssetInjection.WorldDataReplacement.ReplaceRmbBlockBuildingData (System.String blockName, System.Int32 blockIndex, DaggerfallConnect.DFBlock& dfBlock) (at Assets/Scripts/Utility/AssetInjection/WorldDataReplacement.cs:408)
DaggerfallWorkshop.Utility.AssetInjection.WorldDataReplacement.GetDFBlockReplacementData (System.Int32 block, System.String blockName, DaggerfallConnect.DFBlock& dfBlock) (at Assets/Scripts/Utility/AssetInjection/WorldDataReplacement.cs:381)
DaggerfallConnect.Arena2.BlocksFile.GetBlock (System.Int32 block) (at Assets/Scripts/API/BlocksFile.cs:385)
DaggerfallConnect.Arena2.BlocksFile.GetBlock (System.String name) (at Assets/Scripts/API/BlocksFile.cs:416)
DaggerfallWorkshop.Utility.ContentReader.GetBlock (System.String name, DaggerfallConnect.DFBlock& blockOut) (at Assets/Scripts/Utility/ContentReader.cs:116)
DaggerfallWorkshop.TerrainHelper.SetLocationTiles (DaggerfallWorkshop.MapPixelData& mapPixel) (at Assets/Scripts/Terrain/TerrainHelper.cs:149)
DaggerfallWorkshop.DaggerfallTerrain.BeginMapPixelDataUpdate (DaggerfallWorkshop.ITerrainTexturing terrainTexturing) (at Assets/Scripts/Terrain/DaggerfallTerrain.cs:180)
DaggerfallWorkshop.StreamingWorld.UpdateTerrainData (DaggerfallWorkshop.StreamingWorld+TerrainDesc terrainDesc) (at Assets/Scripts/Terrain/StreamingWorld.cs:1216)
DaggerfallWorkshop.StreamingWorld+<UpdateTerrains>d__79.MoveNext () (at Assets/Scripts/Terrain/StreamingWorld.cs:662)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /home/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
DaggerfallWorkshop.StreamingWorld:Update() (at Assets/Scripts/Terrain/StreamingWorld.cs:253)```
Interestingly, when this occurs it breaks not only the DFLocation data of the affected village but that of all currently loaded locations in the map pixels surrounding the village. No buildings can be entered, and all buildings return an error (with World Tooltips) consistent with not finding any building data in the location:
![image](https://github.com/user-attachments/assets/c2a5fb2e-a484-4c32-98b0-b3ef2a47b118)
As we discussed on Discord, my recommendation for this edge case is to simply check if the building file's index is outside the bounds of the modded RMB's BuildingDataList array and, if so, skip the replacement.
**Misplaced buildings**
I also noticed that some buildings with building replacements are misplaced. Here's an example of one (from a TVRNAL01.RMB block in the north of Gothcroft in Northmoor) where the house moves positions depending on whether or not Lively Cities is enabled.
With Beautiful Cities only:
![2025-01-03_16-10](https://github.com/user-attachments/assets/1f3b061f-4ae7-45f4-82a4-4401bcb2fe29)
With Beautiful Cities + Lively Cities:
![2025-01-03_16-13](https://github.com/user-attachments/assets/eb1cf563-df71-44b6-806a-91b40ab9850d)
I am almost certain this is because replaced buildings are taking their XPos, YPos, ZPos, and YRotation from the building file instead of from the modded RMB. So for example, this particular building file (TVRNAL01.RMB-559-building15.json in Lively Cities) begins:
```{
"FactionId": 0,
"BuildingType": 18,
"Quality": 5,
"NameSeed": 0,
"RmbSubRecord": {
"XPos": 1280,
"ZPos": 2176,
"YRotation": 1536,
"Exterior": {```
This building has the following position in Beautiful Cities' TVRNAL01.RMB:
``` "XPos": 1280,
"ZPos": 2432,
"YRotation": -512,```
Because RMBs (sometimes dramatically) change block layouts, the RMBs should always supply the building's position (ie, XPos, YPos, ZPos, and YRotation) while the building file replaces everything else. This will allow building files to be compatible with any RMB replacer, which is the consistent with the goal of this PR.
(Please note that modded buildings often have YPos, not just XPos and ZPos, as they sometimes are placed on hills)
—
Reply to this email directly, view it on GitHub
<#2714 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARMLLWLL7DHSVLO4EJLL7D2I4T6TAVCNFSM6AAAAABUDOC6RKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRZHE3DINJWGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Making a special case if the RMB is overridden seems like a great "best of both worlds" solution here. Building files will still be able to change the building's position in a vanilla RMB, and RMB files won't have their layouts overridden by building files. That makes different types of mods as compatible with each other as possible. |
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.
When an RMB block is overridden, the block reading is shortcut and building overrides should be applied correctly. This was not happening, and this addition applies any applicable building overrides after loading the RMB override data.
This PR replaces #2699 submitted by carademono. That PR was a very good effort but it would only fixe it for a specific scenario and also breaks the block construction encapsulation.
This should be rigorously tested that it doesn't break any existing mods.
One issue that has never been addressed is the automap data which is at the RMB block level but can be overridden by a building override. I intend to take a look at a way to have building overrides map data to be merged.