Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[CR] Fix clothes dropping #23663
Conversation
RadHazard
added some commits
May 5, 2018
This comment has been minimized.
This comment has been minimized.
|
A revert is definitely the best short term fix, this is definitely a worse
problem than the menu not being totally consistent.
Long term I don't know either, the underlying problem is that the menu
mixes actions that can happen immediately with actions that require time to
pass, and it doesn't have a consistent way of unifying them.
|
RadHazard
changed the title
[WIP][CR] Fix clothes dropping
[CR] Fix clothes dropping
May 5, 2018
This comment has been minimized.
This comment has been minimized.
|
Yeah, makes sense. If you just want to revert for the short term, the branch should be ready to merge. |
This comment has been minimized.
This comment has been minimized.
Kuro-Maii
commented
May 15, 2018
|
is there a way of removing these "none" type items? |
This comment has been minimized.
This comment has been minimized.
|
@Kuro-Maii |
This comment has been minimized.
This comment has been minimized.
|
I got several crashes when the starting NPC burned to death in the burning building scenario and a crash when my player character burned to death, that I suspect are both related to these item dropping bugs. I can't get the source to compile properly on my system (tried both MinGW/MSYS2) so I can't test if this fixes that though. |
This comment has been minimized.
This comment has been minimized.
|
@budg3 DYNAMIC_LINKING=1 reduces the number of dependencies dramatically (you'll only need SDL2 packages). I'd suggest using GIT Bash (MSYS2) when compiling (CMD will cause more problems). Hope this helps. |
This comment has been minimized.
This comment has been minimized.
|
@Wishbringer |
RadHazard commentedMay 5, 2018
Fix for #23524 & #23586. Unfortunately, as it stands this currently reverts the fix to #23242
Marking as CR because the underlying issue is a lot more complex than it looks at first, and I'd appreciate input from people who are more familiar with the codebase.
Explanation of the bugs
Prior to #23242, taking off an item was a synchronous action. The armor layer screen relied on this behavior and expects that once the function returns, the item will have been removed. However, if the item doesn't fit in the player's inventory, the action is changed to the "drop item" activity, which is processed asynchronously starting at the next turn. This caused the bug where the armor screen didn't update correctly, as the item hadn't technically been "removed" yet before the next redraw. This is harmless but annoying.
#23242 fixed the issue by changing the logic to always take off the item, regardless of whether a drop action had been queued. This fixed the armor screen's refresh, but introduced two related bugs, depending on whether it was the player or an NPC that is dropping the item.
If the player is the one dropping the item, they immediately take it off it, which causes said item to tumble to the ground. Then, the queued drop activity fires, but because the item tumbled to the ground it has an invalid index. The game attempts to drop whatever is currently at the index, which causes weird and inconsistent behavior (dropping a None, dropping random articles of clothing, etc.)
However, if it's an NPC that is dropping the item, there's a hack in place (apparently because NPCs don't normally process activities) that causes the drop to be executed synchronously as well. Because the takeoff function hasn't yet taken off the clothing when this happens, the drop activity performs a second takeoff, which completes first (the activity screen uses a separate code path that doesn't check for inventory size, which is why it doesn't recurse infinitely). This invalidates the iterator the original takeoff function was using, causing an immediate CTD when it tries to dereference it.
Potential fixes
At this point, I'm not sure what the best way to proceed is. The simplest fix would be to revert #23242. However, this reintroduces the bug that that PR fixed. This is the fix I've currently implemented, but it's not ideal.
Another option would be to change the drop behavior to just synchronously drop the item. However, that involves code duplication and may cause other issues.
A third option would be to rewrite the way dropping is handled in this scenario. This is probably the best long-term solution, but it requires significant code changes: