From 06363e3604d1736e052a2fd258be1c6d6c59a9f4 Mon Sep 17 00:00:00 2001 From: Patrick Owen Date: Sat, 9 Sep 2023 17:03:36 -0400 Subject: [PATCH] Fix server crash on client disconnect due to incomplete entity removal --- server/src/sim.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/src/sim.rs b/server/src/sim.rs index ba5f7ecd..6f87c300 100644 --- a/server/src/sim.rs +++ b/server/src/sim.rs @@ -163,6 +163,9 @@ impl Sim { pub fn destroy(&mut self, entity: Entity) { let id = *self.world.get::<&EntityId>(entity).unwrap(); self.entity_ids.remove(&id); + if let Ok(position) = self.world.get::<&Position>(entity) { + self.graph_entities.remove(position.node, entity); + } self.world.despawn(entity).unwrap(); self.despawns.push(id); }