Fix extension cords falling off when items are turned on #74268
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Fix extension cords falling off when items are turned on"
Purpose of change
Fixes #74246.
Describe the solution
When writing #70475, I incorrectly made
item_contents::combine
rely onpocket.saved_type()
even when it's called during item conversion. I didn't realize thatsaved_type
it only ever useful during deserialization, otherwise it's always LAST. The function already used theconvert
parameter for alternative code that checked againstpocket.get_pocket_data()->type
instead, which is accurate past loading, so simply applying that to the problem code fixes it.The other part of the fixed issue, the cable "duplicating", was because the item wasn't updating its cable length after conversion made the extension cord fall out. The extension cord wasn't duplicating, it was more like there was a phantom extension cord left behind that kept the item connected at its longer length. Calling
update_link_traits()
during item conversion fixes this.Describe alternatives you've considered
Testing
Followed the steps in the issue, no longer reproduces. Followed the steps with only the second commit applied, the lamp immediately updates the cable length and breaks the connection, as intended.
Also spawned and connected some extension cords together and to a battery to make sure nothing unintentionally broke.
Additional context