Ottermandias / GatherBuddy

Dalamud-based FFXIV addon to simplify gathering.
Apache License 2.0
93 stars 89 forks source link

CRASH: Prefered location is not cleared after swapping item in alarmgroup #234

Closed RyadaProductions closed 1 month ago

RyadaProductions commented 1 month ago

When you swap out a fish with a manually set preferred location for a gathering item with a preferred location by default, the internal data doesn't update to clear out the manual preferred location. This results in a cast exception as the logic of the plugin wants to then convert a Gatherable class into a Fish class. The only way to recover from this crash is to manually edit the PluginConfig alarms.json as the game will lock up upon loading of the GatherBuddy plugin on boot.

Reproduce steps:

Stacktrace:

System.InvalidCastException: Unable to cast object of type 'GatherBuddy.Classes.Gatherable' to type 'GatherBuddy.Classes.Fish'.
   at GatherBuddy.Alarms.AlarmManager.GetUptime(Alarm alarm) in /work/repo/GatherBuddy/Alarms/AlarmManager.cs:line 181
   at GatherBuddy.Gui.Interface.DrawAlarmInfo(Int32& alarmIdx, AlarmGroup group) in /work/repo/GatherBuddy/Gui/Interface.AlarmTab.cs:line 229
   at GatherBuddy.Gui.Interface.DrawAlarmTable(AlarmGroup group, Int32 _) in /work/repo/GatherBuddy/Gui/Interface.AlarmTab.cs:line 284
   at GatherBuddy.Gui.Interface.DrawAlarmInfo(AlarmGroup group, Int32 idx) in /work/repo/GatherBuddy/Gui/Interface.AlarmTab.cs:line 316
   at OtterGui.ItemDetailsWindow.Draw(String label, Action drawHeader, Action drawDetails) in /work/repo/OtterGui/ItemSelector.cs:line 473
   at GatherBuddy.Gui.Interface.DrawAlarmTab() in /work/repo/GatherBuddy/Gui/Interface.AlarmTab.cs:line 363
   at GatherBuddy.Gui.Interface.Draw() in /work/repo/GatherBuddy/Gui/Interface.cs:line 61
   at Dalamud.Interface.Windowing.Window.DrawInternal(DalamudConfiguration configuration) in C:\goatsoft\companysecrets\dalamud\\Interface\Windowing\Window.cs:line 346

Faulty json payload (after reproducing steps):

{
    "Name": "",
    "Id": 12538,
    "SecondOffset": 0,
    "Type": "Gatherable",
    "PreferLocationId": 186,
    "SoundId": 0,
    "Enabled": true,
    "PrintMessage": false
  },

Expected json payload:

{
    "Name": "",
    "Id": 12538,
    "SecondOffset": 0,
    "Type": "Gatherable",
    "PreferLocationId": 0,
    "SoundId": 0,
    "Enabled": true,
    "PrintMessage": false
  },
Ottermandias commented 1 month ago

Yeah, thanks, fixed.