-
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
don't rebuild the item drop list #36647
Conversation
But why do they get invalidated? Could this have something to do with how activity resuming became quite inconsistent of late? Good to have this annoyance patched, but the underlying problem seems to still be there |
Co-Authored-By: BevapDin <[email protected]>
I have another candidate for the cause, but my guess needs some verification, and I'm not clear where exactly it goes wrong.
If anything touches any entries in targets between 2a and 2c, that is in fact undefined behaviour, additionally this is an egregiously complicated sequence to run these shared pointers through, alternately copying and moving them across multiple containers. My recommendation is to make sure everything that touches an item_location uses push_back() instead of emplace_back() and see if that clears anything up. |
After this update, dropping large amounts of items hangs the game. |
I agree with Voideka. Fix is no bueno. Large amount of items hangs the game. Even small amout of items take a long time now. The dropping worked in build 10090. SOmething since then fucked shite up. |
What amount of items do you consider "large"? Do you have a savegame and/or reproduction scenario? |
Save attached. Hit shift+D, select any tile, then hit tab for category select, drop all of the Other category. After a couple of items it slows down, then it grinds to a halt. Total items dropped is about 46. I've even tried moving to another map tile without a stack of existing items, same issue. |
I can confirm this bug. My game also hangs. |
This reverts commit 7aad3ab.
Summary
SUMMARY: Bugfixes "instead of rebuilding the item drop list, remove invalid pointers"
Purpose of change
Fixes #36554
Describe the solution
as noted in the attached issue, the push_back function appears to be invalidating the item_locations in the entire item list called
items
. I have noticed thatact.targets
has all valid pointers, and that the pointers do not become invalid until p.moves becomes negative. I couldn't quite find a reasonable solution that involves keeping the way the item list gets rebuilt at the end of this function, so i implemented a for loop that just removes the targets and their associated value when it finds invalid pointers.Describe alternatives you've considered
First I thought copying the item_location was invalidating them, but I couldn't find a specific location at which they were being invalidated.
Testing
Tested with 300 plastic chunks: drop with
d
, drop withD
(directional) and using advanced inventory to drop at my location from my inventory.Additional context
I spent a long time trying to find a way to fix this, so admittedly this is the first solution I found that worked. I have a hunch that there is a more elegant solution out there, but maybe reworking the drop activity even more might be on that particular horizon.