Closed Axodouble closed 4 months ago
More than 8 sections isn't supported because their state stored in 1 byte (8 bits) and accessing to Types.SHIFTS[8] cause IndexOutOfRangeException
Sorry about this. As GazziFX mentions it is a limit currently, but the game should at least warn about this rather than breaking. I'll see about adding a warning instead.
(based off your response in #3159) Wouldn't it be possible to allow more segments without messing up states as long as you only add more bytes to the end? Since all states are read as byte arrays and not individual components you should just be able to check the length.
Hmmm I suppose so. I'll take a look at whether it would be a bigger(/more likely to break) change when I see about adding the warning.
Added the warning for the next update.
@DanielWillett sorry to disappoint, but while your proposal is quite reasonable, I am quite hesitant to make that change with the existing object state storage. It would be the change in InteractableObjectRubble.updateState
and some changes in ObjectManager
where it assumes it can just shift the last byte by the section index, but most importantly not only would it need vanilla save and state compatibility but any plugins using that code may easily run into out-of-bounds exceptions. It's a similarly awful situation to item state where any changes are very fragile. Ideally perhaps we can share some sort of "persistent state" and "networked state" code between items, objects, barricades, structures, etc., in the future to eliminate this problem.
After some frustrating headaches assuming I had made a mistake somewhere, I happened to find that that was indeed not the case.
If an object is given more than 8 sections or above, the game client will freeze, this error only occurs when more than 8 sections are added.
Below:
Works fine without any crashing, freezing or similar.
However, an exact same copy of the above prefab which works fine on its own:
Does not work.
Upon loading this the following error appears in the
client.log
file.A fix would be lovely, thanks in advance.