Skip to content

Commit

Permalink
Loot sorting: stop moving crafts in progress (#79279)
Browse files Browse the repository at this point in the history
* Loot sorting: stop moving crafts in progress

Prevent sorting activity from moving items that somebody works on

fixes #74170

* Update src/activity_item_handling.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/activity_item_handling.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Vitaliy Andrianov <o1783783@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent 3e142e5 commit 56b4c66
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const item *> 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();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<vpart_reference> vpr_src = it->second ? vpr : std::nullopt;
const zone_type_id id = mgr.get_near_zone_type_for_item( thisitem, abspos,
Expand Down

0 comments on commit 56b4c66

Please sign in to comment.