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 upCorrect calculation of count_by_charge items where volume > 1 #15335
Conversation
mugling
added some commits
Feb 10, 2016
kevingranade
merged commit 61ff15b
into
CleverRaven:master
Feb 11, 2016
1 check passed
BevapDin
reviewed
Feb 11, 2016
| @@ -549,7 +549,7 @@ std::string item::info( bool showtext, std::vector<iteminfo> &info ) const | |||
| convert_weight( weight() ), false, "", true, true ) ); | |||
|
|
|||
| if( count_by_charges() ) { | |||
| info.emplace_back( "BASE", _( "Stack size: " ), "", type->stack_size, true ); | |||
| info.emplace_back( "BASE", _( "Stack size: " ), "", type->stack_size / std::min( type->volume, 1U ) , true ); | |||
This comment has been minimized.
This comment has been minimized.
BevapDin
Feb 11, 2016
Contributor
What has the "Stack size" information to do with the volume? Isn't it supposed to show the stack size itself, as in "the number of charges per default stack"? If the calculation is the desired thing to show, the information should be renamed to something like "Charges per 1 volume" or so.
Also: type->volume can be 0, can't it? If so, std::min( type->volume, 1U ) can easily be 0 as well.
Edit: It currently crashes the game when looking at sugar beet seeds in the item wish menu. The seeds have stacks size 40, charges 4 (therefor counted by charges) and volume 0.
This comment has been minimized.
This comment has been minimized.
mugling
Feb 11, 2016
Author
Contributor
What has the "Stack size" information to do with the volume?
Normalized to show charges per unit volume which is what the player needs to know to determine how much an item's volume increases/decreases as the number of charges varies.
type->volumecan be 0, can't it? If so,std::min( type->volume, 1U )can easily be 0 as well.
Might be best to avoid showing that field at all for volume == 0 as it's not relevant if the item has no volume.
Edit: It currently crashes the game when looking at sugar beet seeds in the item wish menu. The seeds have stacks size 40, charges 4 (therefor counted by charges) and volume 0.
In the long term it might be best to avoid specifying volume 0 for AMMO and COMESTIBLE - in the above example seeds should have volume. That said, obviously we need to avoid the crash and I'll look into that.
mugling commentedFeb 10, 2016
Closes #15331