Skip to content

Commit

Permalink
Don't set ammo type of empty vehicle tanks
Browse files Browse the repository at this point in the history
  • Loading branch information
ifreund authored and kevingranade committed Feb 8, 2019
1 parent 97a58b6 commit 0da5ab6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/vehicle_part.cpp
Expand Up @@ -217,11 +217,13 @@ long vehicle_part::ammo_remaining() const
int vehicle_part::ammo_set( const itype_id &ammo, long qty )
{
const itype *liquid = item::find_type( ammo );
if( is_tank() && liquid->phase >= LIQUID ) {

// We often check if ammo is set to see if tank is empty, if qty == 0 don't set ammo
if( is_tank() && liquid->phase >= LIQUID && qty != 0 ) {
base.contents.clear();
auto stack = units::legacy_volume_factor / std::max( liquid->stack_size, 1 );
long limit = units::from_milliliter( ammo_capacity() ) / stack;
base.emplace_back( ammo, calendar::turn, qty >= 0 ? std::min( qty, limit ) : limit );
base.emplace_back( ammo, calendar::turn, qty > 0 ? std::min( qty, limit ) : limit );
return qty;
}

Expand Down

0 comments on commit 0da5ab6

Please sign in to comment.