Skwizzy / SPT-LootingBots

AI Looting mod for Singleplayer Tarkov
https://hub.sp-tarkov.com/files/file/1096-looting-bots/#overview
31 stars 10 forks source link

Exception when appraising items from corpse #62

Closed Skwizzy closed 1 year ago

Skwizzy commented 1 year ago

Reported by TinyTeeth: [Error : Unity Log] KeyNotFoundException: The given key was not present in the dictionary. Stack trace: System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <eae584ce26bc40229c1b1aa476bfa589>:0) LootingBots.Patch.Components.ItemAppraiser.GetItemHandbookPrice (EFT.InventoryLogic.Item lootItem) (at <5e79707d2d954cccbf7c693400a0b10a>:0) LootingBots.Patch.Components.ItemAppraiser.GetItemPrice (EFT.InventoryLogic.Item lootItem) (at <5e79707d2d954cccbf7c693400a0b10a>:0) LootingBots.Patch.Components.ItemAdder.IsValuableEnough (EFT.InventoryLogic.Item lootItem) (at <5e79707d2d954cccbf7c693400a0b10a>:0) LootingBots.Patch.Components.ItemAdder+<TryAddItemsToBot>d__15.MoveNext () (at <5e79707d2d954cccbf7c693400a0b10a>:0) Rethrow as AggregateException: One or more errors occurred. System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Threading.Tasks.Task`1[TResult].GetResultCore (System.Boolean waitCompletionNotification) (at <eae584ce26bc40229c1b1aa476bfa589>:0) System.Threading.Tasks.Task`1[TResult].get_Result () (at <eae584ce26bc40229c1b1aa476bfa589>:0) LootingBots.Patch.Components.LootFinder+<LootCorpse>d__15.MoveNext () (at <5e79707d2d954cccbf7c693400a0b10a>:0) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <85d1d3e7744a4a47b5f51883bf40bba2>:0) UnityEngine.DebugLogHandler:LogException(Exception, Object) Class311:UnityEngine.ILogHandler.LogException(Exception, Object) UnityEngine.Debug:CallOverridenDebugHandler(Exception, Object)

Skwizzy commented 1 year ago

Should be fixed by using the TryGetValue to read from the dictionary. If an item template cannot be found in the dictionary, the value will default to 0 84a25a7