SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
88 stars 18 forks source link

[Bug Report / Feature Request] More than 8 sections on a rubble object causes an IndexOutOfRangeException from InteractableObjectRubble.updateState. #3159

Closed DanielWillett closed 2 years ago

DanielWillett commented 2 years ago

If you create an object with more than 8 sections, an error is thrown when the object is loaded (editor or in-game):

[2022-05-03 15:16:03] IndexOutOfRangeException: Index was outside the bounds of the array.
[2022-05-03 15:16:03] SDG.Unturned.InteractableObjectRubble.updateState (SDG.Unturned.Asset asset, System.Byte[] state) (at <e722b749a4ba496696325f210b77d83c>:0)
SDG.Unturned.LevelObject..ctor (UnityEngine.Vector3 newPoint, UnityEngine.Quaternion newRotation, UnityEngine.Vector3 newScale, System.UInt16 newID, System.Guid newGUID, SDG.Unturned.ELevelObjectPlacementOrigin newPlacementOrigin, System.UInt32 newInstanceID, SDG.Unturned.AssetReference`1[T] customMaterialOverride, System.Int32 materialIndexOverride, System.Boolean newIsHierarchyItem, SDG.Unturned.NetId netId) (at <e722b749a4ba496696325f210b77d83c>:0)
SDG.Framework.Devkit.DevkitHierarchyWorldObject.Start () (at <e722b749a4ba496696325f210b77d83c>:0)

It's caused by how isAlive is stored in the state and how it's read by accessing Types.SHIFTS with the section number as the index. Is there any chance we could see support for more than 8 sections? From what I can see the state format is the only thing that would need to be changed.

Thanks

SDGNelson commented 2 years ago

Sorry to say that this is unlikely to change until (when/if) savedata rewrite because the state arrays do not have a good versioning system at the moment.