-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Make copy of item to be thrown - fix throwing bugs #36296
Conversation
Does not close #36271 - Throwing directly from inventory without manually wielding first still segfaults. |
Im throwing from inventory with this PR applied, and its not segfaulting.... you applied this PR yes? and what are the exact repro steps? |
Steps to reproduce are the same. I thought I may had screwed up the merge or build flags somehow so I went ahead and re-ran by doing:
g++ version: g++ (GCC) 9.2.0
This save skips steps 1-3. Are you unable to reproduce the crash with that save? I'm unable to reliably reproduce the issue in the default evacuee start, but wilderness+field starts reproduce the issue reliably. edit: re-running with 78568ae, standby... |
I could've got very lucky with the invalidation and it accessed same memory, but I threw rocks over and over and over again and no crash... but yeah with latest commit that shouldnt be a risk anymore ( hopefully ) How weird that default start dosnt repro, but wilderness does.... |
Yeah after latest commit, your attached save, throwing works ok, no crash, for me. |
Yep, after 78568ae, it no longer crashes! 🎉 |
Summary
SUMMARY: Bugfixes "Make copy of item to be thrown - fix throwing bugs"
Purpose of change
Fixes #36271
Fixes #36239
Fixes #36293
Describe the solution
#36106 changed how throwing works, unfortunately throwing did some sneaky stuff with copies that broke after that PR.
the throw function made a copy, and manipulated charges on that, and deleted the original.
The new function created a reference to the original, and kept the code that set the ( should be copy ) charges to 1, and then deleted it if it was the last charge or not stackable.
What ive done is create a copy again, send that to the ranged.cpp throwing function, and set the copies charges to 1, and subtract the originals charges appropiately. and delete the original if need be. ( but only after a copy has been sent to ranged.cpp )
Describe alternatives you've considered
N/A
Testing
new character, spawn 10 rocks, throw them all, charges reduce properly, thrown drops are the right stack size, and thre last rock is thrown and is deposited on the map, and no rocks left in inventory.
Additional context
N/A