Repository navigation
Conversation
CreateItemToCraft() empties a material container by calling the virtual RemoveSecondaryMaterial(). banana overrides it with the eating logic: the banana turns into banana peels, drops its main material and sends itself to hell. The crafting code then builds the "You never learned how to cook" message from an item whose main material is null and crashes in object::AddRustLevelDescription(). Call materialcontainer::RemoveSecondaryMaterial() directly. The prototype then keeps its main material and only loses its contents. Fixes Attnam#570
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #570.
Typing "banana" at "What do you want to try to create?" crashes the game instead of printing "You never learned how to cook a banana!".
CreateItemToCraft()spawns a prototype and callsEmptyContainer(), which calls the virtualRemoveSecondaryMaterial().bananaoverrides that method with the eating logic. It moves its main material into a newbananapeels, sets its own main material to null and callsSendToHell(). Back insrpForgeItem::work(),GetName(INDEFINITE)reachesobject::AddRustLevelDescription()and dereferences the null main material.The fix calls
materialcontainer::RemoveSecondaryMaterial()directly. The prototype then loses its contents and keeps its main material.holybananaderives frombanana, inherits the override and crashed the same way. No other class in thematerialcontainerhierarchy overridesRemoveSecondaryMaterial().CreateItem()callsEmptyContainer()for wishes that contain "empty", so a wish for an empty banana probably takes the same path. I did not test that one.I tested on a Linux build of the v060 source with AddressSanitizer.
proto.cppis the same on master.bananaorholy bananain the craft menu (f, then "create an item"). The backtrace goes throughsrpForgeItem::work()toobject::AddRustLevelDescription().