Jump to content

[Vanilla/DLC] Use of Action.NumActions in DLC causes obscure crash with non-DLC version


Hexicube
  • Branch: Live Branch Version: Windows Pending

In advance: I know I should be building two separate mod DLLs, however my mod has nothing to do with anything DLC-specific and works fine outside of this issue.

Use of particular enums, in this case Action, can cause obscure bugs due to the fact the enum will have a different list of values (and therefore a different int mapping).

For my particular mod I was using Action.NumActions, which is the "there's no bind for this" Action, and it has a value of 266 with DLC; however, non-DLC values don't even go to 266 (probably due to radiation overlay), and thus crash.

Stack trace:

ArgumentException: 266 is not bound in GameInputBindings
  at GameUtil.ActionToBinding (Action action) [0x0003e] in <f834fb9792e545c0aa06cca79073875a>:0 
  at GameUtil.GetActionString (Action action) [0x00010] in <f834fb9792e545c0aa06cca79073875a>:0 
  at GameUtil.ReplaceHotkeyString (System.String template, Action action) [0x00000] in <f834fb9792e545c0aa06cca79073875a>:0 
  at KIconButtonMenu+ButtonInfo.GetTooltipText () [0x0002e] in <f834fb9792e545c0aa06cca79073875a>:0 
  at KIconButtonMenu.RefreshButtons () [0x00232] in <f834fb9792e545c0aa06cca79073875a>:0 
  at KIconButtonMenu.SetButtons (System.Collections.Generic.IList`1[T] buttons) [0x0000f] in <f834fb9792e545c0aa06cca79073875a>:0 
  at UserMenuScreen.Refresh (UnityEngine.GameObject go) [0x00036] in <f834fb9792e545c0aa06cca79073875a>:0 
  at RootMenu.OnSelectObject (System.Object data) [0x000b4] in <f834fb9792e545c0aa06cca79073875a>:0 
  at EventSystem.Trigger (UnityEngine.GameObject go, System.Int32 hash, System.Object data) [0x000fe] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KMonoBehaviour.Trigger (System.Int32 hash, System.Object data) [0x00026] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at SelectTool.Select (KSelectable new_selected, System.Boolean skipSound) [0x00130] in <f834fb9792e545c0aa06cca79073875a>:0 
  at SelectTool.OnLeftClickDown (UnityEngine.Vector3 cursor_pos) [0x00039] in <f834fb9792e545c0aa06cca79073875a>:0 
  at PlayerController.OnKeyDown (KButtonEvent e) [0x000ac] in <f834fb9792e545c0aa06cca79073875a>:0 
  at KInputHandler.HandleKeyDown (KButtonEvent e) [0x0001c] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KInputHandler.HandleKeyDown (KButtonEvent e) [0x0006f] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KInputHandler.HandleEvent (KInputEvent e) [0x00008] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KInputController.Dispatch () [0x0001c] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KInputManager.Dispatch () [0x00017] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at KInputManager.Update () [0x0002e] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at GameInputManager.Update () [0x00007] in <4c2b2fae6abe493697de2dfee51c79b6>:0 
  at Global.Update () [0x00000] in <f834fb9792e545c0aa06cca79073875a>:0 

This stack trace points literally no fingers, the reporting user only suspected mine as it was the only one that updated and the in-game action was closely tied to what mine is for. Had it been another enum, this could happen on world load or even game load.

I've temporarily worked around the issue with:

System.Enum.TryParse(typeof(Action), out numAct);

This is a band-aid solution, and the real solution would be to explicitly specify enum values for any enum expected to have differences between the two versions.


Steps to Reproduce

See above




User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...