Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct calculation of count_by_charge items where volume > 1 #15335

Merged
merged 2 commits into from Feb 11, 2016

Conversation

Projects
None yet
3 participants
@mugling
Copy link
Contributor

commented Feb 10, 2016

Closes #15331

@kevingranade kevingranade merged commit 61ff15b into CleverRaven:master Feb 11, 2016

1 check passed

default
Details
@@ -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.

Copy link
@BevapDin

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.

Copy link
@mugling

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->volume can 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.