TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.06k stars 374 forks source link

Script using `tastudio.onqueryitemtext` gets `IndexOutOfRangeException` after updating from 2.8 #3897

Closed Isotarge closed 1 month ago

Isotarge commented 1 month ago

Summary

TAStudio custom columns appear to be broken shortly after BizHawk 2.8. I have tested this with my own game and Lua script: Knight Shift and ScriptHawk. When running those two together with TAStudio open, I get an exception, a red X where the list view for inputs should be, and the custom columns are not displayed.

I am using the following functions in the TAStudio Lua module:

Repro

  1. Open Knight Shift (Demo Version 1).sms from https://integer-max.itch.io/knight-shift
  2. Open TAStudio
  3. Open Lua Console and ScriptHawk (TAS Safe).lua from https://github.com/Isotarge/ScriptHawk/commit/cd3075f9162bb3211f1d9aec4d306c985567d0ce (requires a full clone of the ScriptHawk repo, it's not a standalone script)
  4. Unpause the emulator

Output

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at BizHawk.Client.EmuHawk.TAStudioLuaLibrary.<>c__DisplayClass40_0.<OnQueryItemText>b__0(Int32 index, String name) in /_/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs:line 516
   at BizHawk.Client.EmuHawk.TAStudio.TasView_QueryItemText(Int32 index, RollColumn column, String& text, Int32& offsetX, Int32& offsetY) in /_/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs:line 310
   at BizHawk.Client.EmuHawk.InputRoll.DrawData(List`1 visibleColumns, Int32 firstVisibleRow, Int32 lastVisibleRow) in /_/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs:line 312
   at BizHawk.Client.EmuHawk.InputRoll.OnPaint(PaintEventArgs e) in /_/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.Drawing.cs:line 60
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Host env.

BizHawk 2.8 or earlier (working) (tested back to 2.2.2)

image

BizHawk 2.9 or later (broken)

image

YoshiRulz commented 1 month ago

The only way https://github.com/TASEmulators/BizHawk/blob/45e2307a7bfd087d3dac38f886b1af349953e7a9/src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs#L510-L520 could give an IooRE would be if the callback is returning 0 values. Add a return nil; here.

I'm guessing the implementation of Call in the old Lua engines was null (or maybe new object?[] { null }) for empty returns, while the new engine has new object?[] {}. (I don't believe the Lua language makes that distinction.)

Isotarge commented 1 month ago

Okie dokie, thank you for the fast response :)