From 75605ae59455dfd40f48a9668c910da2cabb9b83 Mon Sep 17 00:00:00 2001 From: Vitaliy Andrianov Date: Tue, 21 Jan 2025 17:56:10 +0400 Subject: [PATCH 1/3] Loot sorting: stop moving crafts in progress Prevent sorting activity from moving items that somebody works on fixes #74170 --- src/activity_item_handling.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 293b02e2da517..8c0881ae96311 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -2021,6 +2021,20 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) map &here = get_map(); const tripoint_abs_ms abspos = you.pos_abs(); zone_manager &mgr = zone_manager::get_manager(); + + std::vector crafting_items; + + for( const npc &guy : g->all_npcs() ) { + if( !guy.activity.targets.empty() ) { + for( const item_location &target : guy.activity.targets ) { + crafting_items.push_back( target.get_item() ); + } + } + } + for( const item_location &target : get_player_character().activity.targets ) { + crafting_items.push_back( target.get_item() ); + } + if( here.check_vehicle_zones( here.get_abs_sub().z() ) ) { mgr.cache_vzones(); } @@ -2155,6 +2169,16 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) break; } + // don't steal disassembly in progress + if( it->has_var( "activity_var" ) ) { + continue; + } + + // don't steal crafts in progress + if( std::find( crafting_items.begin(), crafting_items.end(), it ) != crafting_items.end() ) { + continue; + } + // skip items that allready sorted if( zone_type_id != zone_type_LOOT_CUSTOM && mgr.has( zone_type_id, src, _fac_id( you ) ) ) { continue; @@ -2328,6 +2352,16 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) continue; } + // don't steal disassembly in progress + if( thisitem.has_var( "activity_var" ) ){ + continue; + } + // don't steal crafts in progress + if( std::find(crafting_items.begin(), crafting_items.end(), it->first) !=crafting_items.end() ) { + continue; + } + + // Only if it's from a vehicle do we use the vehicle source location information. const std::optional vpr_src = it->second ? vpr : std::nullopt; const zone_type_id id = mgr.get_near_zone_type_for_item( thisitem, abspos, From 1fa167dd0224372e8a4ca4a711f1847147275fdc Mon Sep 17 00:00:00 2001 From: o175 Date: Tue, 21 Jan 2025 18:15:10 +0400 Subject: [PATCH 2/3] Update src/activity_item_handling.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/activity_item_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 8c0881ae96311..d0952050a7512 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -2353,7 +2353,7 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) } // don't steal disassembly in progress - if( thisitem.has_var( "activity_var" ) ){ + if( thisitem.has_var( "activity_var" ) ) { continue; } // don't steal crafts in progress From d3e5249921ee2fccd575a7105c8043eef99edf01 Mon Sep 17 00:00:00 2001 From: o175 Date: Tue, 21 Jan 2025 18:15:18 +0400 Subject: [PATCH 3/3] Update src/activity_item_handling.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/activity_item_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index d0952050a7512..2b1ca60ed3665 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -2357,8 +2357,8 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) continue; } // don't steal crafts in progress - if( std::find(crafting_items.begin(), crafting_items.end(), it->first) !=crafting_items.end() ) { - continue; + if( std::find( crafting_items.begin(), crafting_items.end(), it->first ) != crafting_items.end() ) { + continue; }