From b6c32eff99b2a7f585f7871c40fc46b238180679 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Tue, 11 Feb 2020 18:56:55 +0300 Subject: [PATCH 1/2] Handle FILTHY tag when unloading/reloading items --- src/activity_handlers.cpp | 7 +++++++ src/player.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 506bc1952fdaf..d73b0f83126c8 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1879,6 +1879,8 @@ 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() ); @@ -1886,6 +1888,11 @@ void activity_handlers::reload_finish( player_activity *act, player *p ) } std::string msg = _( "You reload the %s." ); + + if( ammo_is_filthy && !reloadable_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." ); diff --git a/src/player.cpp b/src/player.cpp index e10911b915fd5..0c3d27753d6ad 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -3774,6 +3774,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 ) ) { From 561c6cde519715c36899b7ea4c46547e42bba823 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Fri, 21 Feb 2020 07:19:42 +0000 Subject: [PATCH 2/2] Update src/activity_handlers.cpp --- src/activity_handlers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index d73b0f83126c8..afbb115ece6b2 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1889,7 +1889,7 @@ void activity_handlers::reload_finish( player_activity *act, player *p ) std::string msg = _( "You reload the %s." ); - if( ammo_is_filthy && !reloadable_is_filthy ) { + if( ammo_is_filthy ) { reloadable.set_flag( "FILTHY" ); }