Skip to content

Commit

Permalink
Handle FILTHY tag when unloading/reloading items (#37927)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg authored Feb 21, 2020
1 parent 50653f7 commit 955132f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1879,13 +1879,20 @@ void activity_handlers::reload_finish( player_activity *act, player *p )
const int qty = act->index;
const bool is_speedloader = ammo.has_flag( flag_SPEEDLOADER );
const bool is_bolt = ammo.ammo_type() == ammo_bolt;
const bool reloadable_is_filthy = reloadable.is_filthy();
const bool ammo_is_filthy = ammo.is_filthy();

if( !reloadable.reload( *p, std::move( act->targets[ 1 ] ), qty ) ) {
add_msg( m_info, _( "Can't reload the %s." ), reloadable.tname() );
return;
}

std::string msg = _( "You reload the %s." );

if( ammo_is_filthy ) {
reloadable.set_flag( "FILTHY" );
}

if( reloadable.get_var( "dirt", 0 ) > 7800 ) {
msg =
_( "You manage to loosen some debris and make your %s somewhat operational." );
Expand Down
3 changes: 3 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3773,6 +3773,9 @@ bool player::unload( item &it )

// Construct a new ammo item and try to drop it
item ammo( target->ammo_current(), calendar::turn, qty );
if( target->is_filthy() ) {
ammo.set_flag( "FILTHY" );
}

if( ammo.made_of_from_type( LIQUID ) ) {
if( !this->add_or_drop_with_msg( ammo ) ) {
Expand Down

0 comments on commit 955132f

Please sign in to comment.