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.
Addresses #1218.
There are two problems happening here. If you prime a grenade for any amount of time, drop it, then pick it up the game will crash when the timer runs out. If you pick up the grenade before it explodes and then end the mission, it will crash the game at the beginning of the next mission unless unequipped. The main problem stems from a unit update function in battleunit.cpp and the explode function in aequipment.cpp. It appears the update function is called every tick and iterates through each units inventory as part of the update process. The explode function will remove the grenade once it has exploded. When the grenade is place back into the inventory and explodes, the explode function will remove the equipment from the inventory and cause the crash.
The update function now iterates over a copy of the inventory instead of the actual inventory. This is a pretty broad change and could possibly lead to a slight performance hit or unintended results. Feedback appreciated.
The second fix was to simply unprime all grenades when the battle ends.