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

Refactor salvage_actor::cut_up #58414

Merged
merged 27 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
086ca2c
Refactor cut_up
Willenbrink Jun 13, 2022
8bf062d
Move uniform distribution into own function
Willenbrink Jun 13, 2022
1fa1df3
Refactor into lambdas
Willenbrink Jun 13, 2022
fe1efab
Move find_recipe into own function
Willenbrink Jun 13, 2022
dd29378
Commenting + renaming
Willenbrink Jun 14, 2022
2f7dbd0
Hide cut_up and unify try_to_cut and valid_to_cut
Willenbrink Jun 14, 2022
4361af8
Remove cutter item from cut_up
Willenbrink Jun 14, 2022
831c19d
Remove one const from function declaration
Willenbrink Jun 14, 2022
094734a
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jun 20, 2022
b48ee4d
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jun 26, 2022
abb256d
Rebalance fab skill, update comments
Willenbrink Jun 24, 2022
cc7e412
Unsalvageable or count_by_charges items unsalavgeable
Willenbrink Jun 24, 2022
b4c3cca
Check uncraft before crafting recipes
Willenbrink Jun 24, 2022
a2e21f6
Limit mass returned from cut up
Willenbrink Jun 27, 2022
954b4f9
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jun 27, 2022
29c50e7
Combine num, efficiency into num_adjusted
Willenbrink Jul 1, 2022
ad99d45
cut_up_comp handles eff, remove extra loop
Willenbrink Jul 1, 2022
f83f362
Add chance to always salvage smth
Willenbrink Jul 1, 2022
d187990
Use items count_by_charges instead of discarding
Willenbrink Jul 1, 2022
6fec4a3
Formatting
Willenbrink Jul 1, 2022
c5f49a3
Check for salvageable before count_by_charges
Willenbrink Jul 1, 2022
86904f5
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jul 1, 2022
9b9e2ef
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jul 4, 2022
de2db8b
Fix error and always round yields down
Willenbrink Jul 5, 2022
f89914e
Merge branch 'master' into refactor_cut_up
Willenbrink Jul 11, 2022
395f133
Fix usage of get_wielded_item
Willenbrink Jul 11, 2022
d8a6465
Merge branch 'CleverRaven:master' into refactor_cut_up
Willenbrink Jul 17, 2022
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
6 changes: 4 additions & 2 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5941,9 +5941,11 @@ void longsalvage_activity_actor::finish( player_activity &act, Character &who )
}

for( item &it : items ) {
if( actor->valid_to_cut_up( it ) ) {
// Check first and only if possible attempt it with player char
// This suppresses warnings unless it is an item the player wears
if( actor->valid_to_cut_up( nullptr, it ) ) {
item_location item_loc( map_cursor( who.pos() ), &it );
actor->cut_up( who, *salvage_tool, item_loc );
actor->try_to_cut_up( who, *salvage_tool, item_loc );
return;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8830,7 +8830,7 @@ void game::butcher()
if( it->is_corpse() ) {
corpses.push_back( it );
} else {
if( ( salvage_tool_index != INT_MIN ) && salvage_iuse->valid_to_cut_up( *it ) ) {
if( ( salvage_tool_index != INT_MIN ) && salvage_iuse->valid_to_cut_up( nullptr, *it ) ) {
salvageables.push_back( it );
}
if( u.can_disassemble( *it, crafting_inv ).success() ) {
Expand Down Expand Up @@ -9027,12 +9027,12 @@ void game::butcher()
break;
case BUTCHER_SALVAGE: {
if( !salvage_iuse || !salvage_tool ) {
debugmsg( "null salve_iuse or salvage_tool" );
debugmsg( "null salvage_iuse or salvage_tool" );
} else {
// Pick index of first item in the salvage stack
item *const target = &*salvage_stacks[indexer_index].first;
item_location item_loc( map_cursor( u.pos() ), target );
salvage_iuse->cut_up( u, *salvage_tool, item_loc );
salvage_iuse->try_to_cut_up( u, *salvage_tool, item_loc );
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,7 @@ class salvage_inventory_preset: public inventory_selector_preset
}

bool is_shown( const item_location &loc ) const override {
return actor->valid_to_cut_up( *loc.get_item() );
return actor->valid_to_cut_up( nullptr, *loc.get_item() );
}

private:
Expand Down
1 change: 1 addition & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9928,6 +9928,7 @@ bool item::is_salvageable() const
if( is_null() ) {
return false;
}
// None of the materials are salvageable or they turn into the original item
const std::map<material_id, int> &mats = made_of();
if( std::none_of( mats.begin(), mats.end(), [this]( const std::pair<material_id, int> &m ) {
return m.first->salvaged_into().has_value() && m.first->salvaged_into().value() != type->get_id();
Expand Down
Loading