Character::i_add
returns an item_location
#58191
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
Infrastructure "
Character::i_add
returns anitem_location
"Purpose of change
Initiated as a fix for the errors that popped up in #58093
Handling this with
item_location
is also generally preferable to item pointers or references.Describe the solution
Character::i_add
and everything around itCharacter::best_pocket
that popped up with this (parent of returneditem_location
is::item_in_container
when it should be::item_on_person
While I was there I also did some minor adjustments in the tests, but only in lines I had to change anyway or lines next to them. Mostly stuff like changing
CHECK( x == true )
toCHECK( x )
.Describe alternatives you've considered
Maybe also have
map::add_item
return anitem_location
, but this turned out bigger than expected already, so maybe another time.Testing
Picking stuff up and spawning it with debug menu seems to work properly. Had no test issues either.
Making an ammo belt from linkage on the ground works, although that always only loads one bullet. Probably linkage on the ground isn't properly registered as available for reloading, but that's a different bug in a different place and doesn't break anything either.
Additional context
Going through the tests showed me there are tons of methods that should also should be changed to accept
item_location
s as parameters instead ofitem *
oritem &
. Basically everything that handles real, existing items. Wield, wear, reload, that kind of stuff. But that's not a project I'm going to tackle any time soon.