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 upFix wielding from inventory #28276
Conversation
ifreund
added
Inventory / AIM / Zones
<Bugfix>
labels
Feb 19, 2019
AMurkin
reviewed
Feb 19, 2019
src/game.cpp Outdated
ZhilkinSerg
added this to the 0.D milestone
Feb 20, 2019
ifreund
force-pushed the
ifreund:fix-wield-from-inventory
branch
from
a14d480
to
4b7e8df
Feb 20, 2019
This comment has been minimized.
This comment has been minimized.
|
now fixes #28281 as well, edited to reflect that. |
ifreund
reviewed
Feb 20, 2019
| // The item_location gets invalidated if wielding an item from the inventory due to updating of | ||
| // the cache, so we have to use u.i_rem() instead to avoid a debug message. | ||
| const item *target = loc.get_item(); | ||
| item to_wield = *target; |
This comment has been minimized.
This comment has been minimized.
ifreund
Feb 20, 2019
Author
Contributor
It seems like there should be a better way to do this but I wasn't thinking of one
ifreund
referenced this pull request
Feb 21, 2019
Closed
Moving item causes intermittent error message #28293
This comment has been minimized.
This comment has been minimized.
Tatterdemalian
commented
Feb 21, 2019
|
Not sure if this bugfix has been implemented in build 0.C-37535-g409acf797d, but the error is no longer intermittent. It now happens consistently whenever I attempt to wield anything from my inventory: DEBUG : item location does not point to valid item FUNCTION : void item_location::remove_item() To Reproduce
Versions and configuration
Additional context debug.log: Tested several times with various combinations of wielding. The error seems to occur when an item is moved to or from the player inventory by the wield action. It does NOT occur when:
It does occur when an item is wielded directly from the worn inventory, but not when an item being un-wielded is worn, which seems to indicate that there is a step where an item being wielded is moved from the worn inventory to the carried inventory as it's wielded, but moved directly to the worn inventory when it's un-wielded. |
This comment has been minimized.
This comment has been minimized.
|
This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there: https://discourse.cataclysmdda.org/t/android-error-android-cdda/18872/3 |
This comment has been minimized.
This comment has been minimized.
|
Merged to 0.D and master. |
ifreund commentedFeb 19, 2019
•
edited
Summary
SUMMARY: NonePurpose of change
Fix debug message on wielding from inventory caused by #28248
Fix #28281
Only consume moves on success.
Describe the solution
Because
player::wield()updates the inventory, theitem_locationis invalidated, causing a debug message on trying to remove the item. This fixes that by usingcharacter::i_rem()instead.This also fixes errant removal of items if the wield was canceled by checking for success before removal.
Additional context
Guess I should've tested more.