From ec1427d6693672a40220e6043a34f69ed7afd46f Mon Sep 17 00:00:00 2001 From: Ben Wallis Date: Tue, 31 May 2022 13:37:56 +0100 Subject: [PATCH] Added temporary fix to prevent loot drops causing a server crash in some (currently unknown) circumstances --- server/src/events/entity_manipulation.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 3f84761385..0e1c620910 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -447,6 +447,10 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt let pos = state.ecs().read_storage::().get(entity).cloned(); let vel = state.ecs().read_storage::().get(entity).cloned(); if let Some(pos) = pos { + // TODO: Figure out how damage contributions of 0% are being awarded - for now + // just remove them to avoid a crash when creating the WeightedIndex + let _ = exp_awards.drain_filter(|(_, exp)| *exp < f32::EPSILON); + let winner_uid = if exp_awards.is_empty() { None } else {