anegostudios / VintageStory-Issues

Vintage Story's public issue tracker for reporting bugs, crashes and the like
47 stars 16 forks source link

Some `worldconfig.json` DataType options do not render on the Customize screen when creating a new world and crash the client when Applying changes #2636

Open PJ-Mog opened 1 year ago

PJ-Mog commented 1 year ago

Game Version

v1.18.0

Platform

Windows

Modded

Modded

SP/MP

Singleplayer

Description

Several of the DataTypes one can use in a mod's worldconfig.json do not render an input element on the Customize screen. Additionally, if any of these DataTypes are defined and the user tries to click Apply, the client crashes.

In the GuiScreenWorldCustomize class, in InitGui(), there is a switch on attribute.DataType The case statements for EnumDataType.Bool and EnumDataType.DropDown, the two DataTypes that work correctly, both call listElem.Add. The rest of the DataTypes do not call this and may be the source of the issue.

How to reproduce

Create a mod which contains only a modinfo.json and a worldconfig.json which contains the following:

{
  "WorldConfigAttributes": [
    {
      "DataType": "Bool",
      "Category": "worldconfig.json Bug Demo",
      "Code": "Bool Test",
      "Default": "true"
    },
    {
      "DataType": "DropDown",
      "Category": "worldconfig.json Bug Demo",
      "Code": "DropDown Test",
      "Default": "2",
      "Values": [ "1", "2", "3" ],
      "Names": [ "First", "Second", "Third" ]
    },
    {
      "DataType": "IntInput",
      "Category": "worldconfig.json Bug Demo",
      "Code": "IntInput Test",
      "Default": "5"
    },
    {
      "DataType": "DoubleInput",
      "Category": "worldconfig.json Bug Demo",
      "Code": "DoubleInput Test",
      "Default": "123.45"
    },
    {
      "DataType": "IntRange",
      "Category": "worldconfig.json Bug Demo",
      "Code": "IntRange Test",
      "Default": "10",
      "Min": 0,
      "Max": 100,
      "Step": 10
    },
    {
      "DataType": "String",
      "Category": "worldconfig.json Bug Demo",
      "Code": "String Test",
      "Default": "some text here"
    }
  ]
}

Start the game with this mod in the mods folder. Start to create a new single player world Click Customize and scroll all the way to the bottom. The GUI inputs for IntInput, DoubleInput, IntRange, and String DataTypes will be missing. Click Apply Client crashes

Screenshots

image

Logs


Game Version: v1.18.0 (Stable)
4/21/2023 3:38:26 PM: Critical error occurred
Loaded Mods: game@1.18.0, creative@1.18.0, survival@1.18.0, demo@1.3.6
System.InvalidCastException: Specified cast is not valid.
   at Vintagestory.Common.WorldConfig.updateJWorldConfig(Dictionary`2 dict) in VintagestoryLib\Common\Config\WorldConfig.cs:line 183
   at Vintagestory.Common.WorldConfig.updateJWorldConfig() in VintagestoryLib\Common\Config\WorldConfig.cs:line 173
   at Vintagestory.Client.GuiScreenWorldCustomize.OnApply() in VintagestoryLib\Client\MainMenu\Screens\Singleplayer\GuiScreenWorldCustomize.cs:line 594
   at Vintagestory.API.Client.GuiElementTextButton.OnMouseUpOnElement(ICoreClientAPI api, MouseEvent args) in VintagestoryApi\Client\UI\Elements\Impl\Interactive\Controls\GuiElementTextButton.cs:line 304
   at Vintagestory.API.Client.GuiElement.OnMouseUp(ICoreClientAPI api, MouseEvent args) in VintagestoryApi\Client\UI\Elements\Impl\GuiElement.cs:line 677
   at Vintagestory.API.Client.GuiElementTextButton.OnMouseUp(ICoreClientAPI api, MouseEvent args) in VintagestoryApi\Client\UI\Elements\Impl\Interactive\Controls\GuiElementTextButton.cs:line 292
   at Vintagestory.API.Client.GuiComposer.OnMouseUp(MouseEvent mouse) in VintagestoryApi\Client\UI\GuiComposer.cs:line 440
   at GuiScreen.OnMouseUp(MouseEvent e) in VintagestoryLib\Client\MainMenu\Screens\Special\GuiScreen.cs:line 205
   at Vintagestory.Client.NoObf.ClientPlatformWindows.Mouse_ButtonUp(Object sender, MouseButtonEventArgs e) in VintagestoryLib\Client\ClientPlatform\Input.cs:line 229
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at OpenTK.Platform.Windows.WinGLNative.WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) in C:\Users\Nexrem\Desktop\transfer\opentk\src\OpenTK\Platform\Windows\WinGLNative.cs:line 808
   at OpenTK.Platform.Windows.Functions.DispatchMessage(MSG& msg)
   at OpenTK.Platform.Windows.WinGLNative.ProcessEvents() in C:\Users\Nexrem\Desktop\transfer\opentk\src\OpenTK\Platform\Windows\WinGLNative.cs:line 1551
   at OpenTK.GameWindow.Run(Double updates_per_second, Double frames_per_second) in C:\Users\Nexrem\Desktop\transfer\opentk\src\OpenTK\GameWindow.cs:line 369
   at Vintagestory.Client.ClientProgram.Start(ClientProgramArgs args, String[] rawArgs)
   at Vintagestory.ClientNative.CrashReporter.Start(ThreadStart start) in VintagestoryLib\Client\ClientPlatform\ClientNative\CrashReporter.cs:line 104
   at Vintagestory.Client.ClientProgram.Main(String[] rawArgs)```
radfast commented 1 year ago

Thank you for the clear report