Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grenade related crashes #1220

Merged
merged 1 commit into from
May 28, 2023
Merged

Conversation

Kurtsley
Copy link
Contributor

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.

@FilmBoy84 FilmBoy84 merged commit 7aaad34 into OpenApoc:master May 28, 2023
3 checks passed
@FilmBoy84
Copy link
Collaborator

Nice catch 🍻

@XCOM-HUB
Copy link

XCOM-HUB commented May 28, 2023

Nice catch 🍻

That was my catch. You are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants