Skip to content

Commit

Permalink
TEMPORARY more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytheway committed May 11, 2020
1 parent 0d6fc16 commit 9e78847
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void Item_factory::finalize_pre( itype &obj )
units::volume total_nonrigid_volume = 0_ml;
for( const pocket_data &pocket : obj.pockets ) {
if( !pocket.rigid ) {
total_nonrigid_volume += pocket.max_contains_volume();
total_nonrigid_volume += pocket.max_contains_volume( true );
}
}
obj.armor->max_encumber = obj.armor->encumber + total_nonrigid_volume / 250_ml;
Expand Down
12 changes: 11 additions & 1 deletion src/item_pocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ void item_pocket::heat_up()
}
}

units::volume pocket_data::max_contains_volume() const
units::volume pocket_data::max_contains_volume( bool debug ) const
{
if( ammo_restriction.empty() ) {
return volume_capacity;
Expand All @@ -1223,9 +1223,19 @@ units::volume pocket_data::max_contains_volume() const
units::volume &max_ammo_volume = max_ammo_volume_by_type[ammo_type->ammo->type];
int stack_size = ammo_type->stack_size ? ammo_type->stack_size : 1;
max_ammo_volume = std::max( max_ammo_volume, ammo_type->volume / stack_size );
if( debug ) {
fprintf( stderr, "Ammo %s (%s) is %d (%d / %d)\n",
ammo_type->get_id().c_str(), ammo_type->ammo->type.c_str(),
to_milliliter( ammo_type->volume / stack_size ),
to_milliliter( ammo_type->volume ), stack_size );
}
}
units::volume max_total_volume = 0_ml;
for( const std::pair<const ammotype, units::volume> &p : max_ammo_volume_by_type ) {
if( debug ) {
fprintf( stderr, "Largest ammo for %s is %d\n",
p.first.c_str(), to_milliliter( p.second ) );
}
max_total_volume = std::max( max_total_volume,
p.second * ammo_restriction.at( p.first ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/item_pocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class pocket_data

bool operator==( const pocket_data &rhs ) const;

units::volume max_contains_volume() const;
units::volume max_contains_volume( bool debug = false ) const;

void load( const JsonObject &jo );
void deserialize( JsonIn &jsin );
Expand Down

0 comments on commit 9e78847

Please sign in to comment.