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

Handle FILTHY tag when unloading/reloading items #37927

Merged
merged 2 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_is_filthy ) {
kevingranade marked this conversation as resolved.
Show resolved Hide resolved
reloadable.set_flag( "FILTHY" );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for !reloadable_is_filthy is redundant. If it's already filthy, nothing changes.


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 @@ -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 ) ) {
Expand Down