JavidPack / RecipeBrowser

RecipeBrowser mod for tModLoader
https://forums.terraria.org/index.php?threads/recipe-browser.62462/
79 stars 50 forks source link

Prevent IndexOutOfRangeException when Recipe.maxRequirements is modified #62

Closed ExterminatorX99 closed 1 year ago

ExterminatorX99 commented 3 years ago

@JavidPack

JavidPack commented 3 years ago

Yeah, I saw this, it'll have to wait until I have time to look at everything. From what I remember changing Recipe.maxRequirements was supposed to have other unintended consequences, so it was intentional not to assume it would change. I'll have to find time to double check

dougbenham commented 2 years ago

Without this fix, the game freezes if you are using Magic Storage + Recipe Browser + Recursive Craft and you open the crafting interface of Magic Storage and then simultaneously click on an item in the Recipe Browser. Thanks for your hard work @ExterminatorX99.

Shadowex3 commented 2 years ago

Without this fix, the game freezes if you are using Magic Storage + Recipe Browser + Recursive Craft and you open the crafting interface of Magic Storage and then simultaneously click on an item in the Recipe Browser. Thanks for your hard work @ExterminatorX99.

Magic Storage definitely makes it easier to trigger the crash however it's not a necessary component. I haven't tried to reproduce it in 1.4 yet but in 1.3 I was able to fairly reliably hang the game's process by viewing the recipe for an item and doubleclicking on the next step it's used to build. There also seemed to be certain items particularly prone to causing the issue by viewing them in recipe browser like the cell phone.

This was the error I got. it's an out of range exception but doesn't seem to reference maxrequirements, unless that's something under the hood not visible in the logs.

It's a real tragedy this and Recursive Crafting seem incompatible, they're both gamechanging QoL additions that frankly deserve to be in the base game.

[18:57:26] [1/ERROR] [Terraria]: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at RecipeBrowser.RecipeCatalogueUI.SetRecipe(Int32 index) in RecipeBrowser\RecipeCatalogueUI.cs:line 747
at RecipeBrowser.UIElements.UIRecipeSlot.Click(UIMouseEvent evt) in RecipeBrowser\UIElements\UIRecipeSlot.cs:line 67
at Terraria.UI.UserInterface.Update(GameTime time)
at Terraria.ModLoader.ModHooks.UpdateUI(GameTime gameTime)
at Terraria.Main.DoUpdate(GameTime gameTime)
at DMD<Terraria.Main::Update>(Main , GameTime ) 
JavidPack commented 2 years ago

well, at this point I won't be changing 1.3 anymore, and it should be fixed in 1.4.