[ModAPI] IMySurvivalBuff Level property has no safety, crashes game if set out of bounds

gruzzob shared this bug 10 hours ago
Investigating

This one is one bug and one... lack of access that interact in an unfortunate way.

The first:

The .Level property of the IMySurvivalBuff interface can be set higher than the maximum level available from the defined buff, or lower than 0. This will cause a IndexOutOfBoundsException as the .Level property is used to directly index in to the array containing the buff values in .ApplyBuff() on the object backing the IMySurvivalBuff interface... on all the backing types.


Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SpaceEngineers.Game.EntityComponents.GameLogic.Buffs.MyMaxHealthBuff.ApplyBuff()

The second:

We don't have an apparent way of getting the maximum level a buff can get to. The Definitions aren't whitelisted for the ModAPI, and we don't have an easy or apparent way to get from the IMySurvivalBuff interface to the Definition used to provide it with data even if we could read those definitions.

The implications of that is that we can't check for trying to set an out of bounds value on the survival buff ourselves.

Leave a Comment
 
Attach a file