Skip to content

Commit e88976f

Browse files
authored
Ignore unknown item event types instead of throwing exception. (#848)
1 parent 105001e commit e88976f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

NWN.Anvil/src/main/API/Events/Native/ItemEvents/ItemEventHandlerEventFactory.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ private static void OnEventHandler(void* pItem, uint nEventId, uint nCallerObjec
2222
{
2323
CNWSItem item = CNWSItem.FromPointer(pItem);
2424

25-
ItemHandlerEvent eventData = nEventId switch
25+
ItemHandlerEvent? eventData = nEventId switch
2626
{
2727
11 => HandleEvent<OnItemDestroy>(item),
2828
16 => HandleEvent<OnItemDecrementStackSize>(item),
29-
_ => throw new ArgumentOutOfRangeException(nameof(nEventId), nEventId, null),
29+
_ => null,
3030
};
3131

32+
if (eventData == null)
33+
{
34+
Hook.CallOriginal(pItem, nEventId, nCallerObjectId, pScript, nCalendarDay, nTimeOfDay);
35+
return;
36+
}
37+
3238
if (!eventData.Skip)
3339
{
3440
Hook.CallOriginal(pItem, nEventId, nCallerObjectId, pScript, nCalendarDay, nTimeOfDay);

0 commit comments

Comments
 (0)