From d13302f256d2bb89f24232a58ac5eae01b42c3e4 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 3 Feb 2021 00:41:19 -0500 Subject: [PATCH] Fixed bombs panicing the server. --- server/src/events/entity_manipulation.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index eafae8edca..9ff9c8fbe6 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -734,20 +734,20 @@ pub fn handle_explosion( } }, RadiusEffect::Entity(mut effect) => { - for (entity_b, pos_b, _health_b) in ( - &ecs.entities(), - &ecs.read_storage::(), - &ecs.read_storage::(), - ) - .join() - .filter(|(_, _, h)| !h.is_dead) + for (entity_b, pos_b) in (&ecs.entities(), &ecs.read_storage::()).join() { let distance_squared = pos.distance_squared(pos_b.0); let strength = 1.0 - distance_squared / explosion.radius.powi(2); if strength > 0.0 { - effect.modify_strength(strength); - server.state().apply_effect(entity_b, effect.clone(), owner); + let is_alive = ecs + .read_storage::() + .get(entity_b) + .map_or(true, |h| !h.is_dead); + if is_alive { + effect.modify_strength(strength); + server.state().apply_effect(entity_b, effect.clone(), owner); + } } } },