From bfd23a982856c21051ba132c46bb864db8853109 Mon Sep 17 00:00:00 2001 From: Enrico Marconi Date: Mon, 12 Apr 2021 16:21:10 +0200 Subject: [PATCH] fix issue #1065: admin bag and other admin items inside a container doesn't disappear when dropped --- assets/common/items/debug/admin_black_hole.ron | 2 +- server/src/events/inventory_manip.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/assets/common/items/debug/admin_black_hole.ron b/assets/common/items/debug/admin_black_hole.ron index ec1ea70993..3b43673794 100644 --- a/assets/common/items/debug/admin_black_hole.ron +++ b/assets/common/items/debug/admin_black_hole.ron @@ -10,7 +10,7 @@ ItemDef( ), ) ), - quality: Artifact, + quality: Debug, tags: [], slots: 900, ) diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index bfabcda89d..dc4809503d 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -613,7 +613,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv }, } // Drop items, Debug items should simply disappear when dropped - for (pos, ori, item) in dropped_items + for (pos, ori, mut item) in dropped_items .into_iter() .filter(|(_, _, i)| !matches!(i.quality(), item::Quality::Debug)) { @@ -622,6 +622,16 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv "common.items.utility.coins" => comp::object::Body::Coins, _ => comp::object::Body::Pouch, }; + + // If item is a container check inside of it for Debug items and remove them + item.slots_mut().iter_mut().for_each(|x| { + if let Some(contained_item) = &x { + if matches!(contained_item.quality(), item::Quality::Debug) { + std::mem::take(x); + } + } + }); + state .create_object(Default::default(), body) .with(comp::Pos(pos.0 + *ori.look_dir() + Vec3::unit_z()))