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

Fix encumbrance and comfort updating after tailoring and wielding worn items #57077

Merged
merged 4 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5751,8 +5751,9 @@ void item::on_wield( Character &you )
you.martial_arts_data->martialart_use_message( you );
}

// Update encumbrance in case we were wearing it
// Update encumbrance and discomfort in case we were wearing it
you.flag_encumbrance();
you.calc_discomfort();
you.on_item_acquire( *this );
}

Expand Down
13 changes: 13 additions & 0 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,9 @@ static bool damage_item( Character &pl, item_location &fix )
fix.remove_item();
}

pl.calc_encumbrance();
pl.calc_discomfort();

return true;
}

Expand Down Expand Up @@ -3242,6 +3245,8 @@ repair_item_actor::attempt_hint repair_item_actor::repair( Character &pl, item &
pl.add_msg_if_player( m_good, _( "You take your %s in, improving the fit." ),
fix->tname() );
fix->set_flag( flag_FIT );

pl.calc_encumbrance();
}
handle_components( pl, *fix, false, false );
return AS_SUCCESS;
Expand All @@ -3256,6 +3261,7 @@ repair_item_actor::attempt_hint repair_item_actor::repair( Character &pl, item &
pl.add_msg_if_player( m_good, _( "You resize the %s to accommodate your tiny build." ),
fix->tname().c_str() );
fix->set_flag( flag_UNDERSIZE );
pl.calc_encumbrance();
handle_components( pl, *fix, false, false );
return AS_SUCCESS;
}
Expand All @@ -3268,6 +3274,7 @@ repair_item_actor::attempt_hint repair_item_actor::repair( Character &pl, item &
pl.add_msg_if_player( m_good, _( "You adjust the %s back to its normal size." ),
fix->tname().c_str() );
fix->unset_flag( flag_UNDERSIZE );
pl.calc_encumbrance();
handle_components( pl, *fix, false, false );
return AS_SUCCESS;
}
Expand Down Expand Up @@ -4708,6 +4715,8 @@ cata::optional<int> sew_advanced_actor::use( Character &p, item &it, bool, const
if( destroyed ) {
p.add_msg_if_player( m_bad, _( "You destroy it!" ) );
p.i_rem_keep_contents( &mod );
p.calc_encumbrance();
p.calc_discomfort();
}
return thread_needed / 2;
} else if( rn <= 10 ) {
Expand All @@ -4721,13 +4730,17 @@ cata::optional<int> sew_advanced_actor::use( Character &p, item &it, bool, const
p.consume_items( comps, 1, is_crafting_component );
mod.set_flag( the_mod );
mod.update_clothing_mod_val();
p.calc_encumbrance();
p.calc_discomfort();
return thread_needed;
}

p.add_msg_if_player( m_good, _( "You modify your %s!" ), mod.tname() );
mod.set_flag( the_mod );
mod.update_clothing_mod_val();
p.consume_items( comps, 1, is_crafting_component );
p.calc_encumbrance();
p.calc_discomfort();
return thread_needed / 2;
}

Expand Down