Merge pull request #89758 from GuardianDll/seasoning_from_fridge
This commit is contained in:
+1
-1
@@ -1271,7 +1271,7 @@ static bool eat( item &food, Character &you, bool force )
|
||||
};
|
||||
|
||||
std::unordered_set<item_location> all_valid_seasonings = get_map().all_items( legal_to_consume,
|
||||
you, Access_Inventory | Access_Map_Around );
|
||||
you, Access_Inventory | Access_Map_Around | Access_Vehicle_Around );
|
||||
|
||||
for( const item_location &checked : all_valid_seasonings ) {
|
||||
// Always pick the best(highest fun) valid seasoning we find.
|
||||
|
||||
@@ -183,6 +183,7 @@ enum accessor_flags_ {
|
||||
Access_Map_Current_Z = 1 << 2, // Everything on the current z-level (ignores reachability)
|
||||
Access_Map_All = 1 << 3, // Everything on the map, all z-levels (ignores reachability)
|
||||
Access_Vehicle = 1 << 4, // Everything on vehicles in the bubble *owned by that guy's faction* (ignores reachability)
|
||||
Access_Vehicle_Around = 1 << 5, // Cargo from vehicles *owned by that guy's faction* (only reachable)
|
||||
Access_EVERYTHING = Access_Inventory | Access_Map_All | Access_Vehicle // All of the above
|
||||
};
|
||||
|
||||
|
||||
+18
-1
@@ -254,7 +254,7 @@ std::unordered_set<item_location> map::all_items( const std::function<bool( cons
|
||||
}
|
||||
}
|
||||
|
||||
if( flags & Access_Vehicle ) {
|
||||
if( flags & Access_Vehicle ) {
|
||||
for( wrapped_vehicle &v : get_vehicles() ) {
|
||||
vehicle *veh = v.v;
|
||||
if( veh ) {
|
||||
@@ -272,6 +272,23 @@ std::unordered_set<item_location> map::all_items( const std::function<bool( cons
|
||||
}
|
||||
}
|
||||
|
||||
if( flags & Access_Vehicle_Around ) {
|
||||
for( const tripoint_bub_ms &pt : reachable_flood_steps( who.pos_bub(), PICKUP_RANGE ) ) {
|
||||
if( const optional_vpart_position vp = veh_at( pt ) ) {
|
||||
if( std::optional<vpart_reference> cargo = vp.cargo() ) {
|
||||
for( item &it : cargo->items() ) {
|
||||
// We always want to recurse even if the top-level item doesn't pass our filter - the contained items still might!
|
||||
item_location there( vehicle_cursor( vp->vehicle(), cargo->part_index() ), &it );
|
||||
recursive_add_contained_items( filter, there );
|
||||
if( filter( it ) ) {
|
||||
ret.emplace( there );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user