Skip to content

Commit fdbb0af

Browse files
committed
Check if entity was destroyed in EntitySendSystem
This fixes an issue where the server would panic when an entity was spawned directly before it was destroyed.
1 parent 8187341 commit fdbb0af

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

server/src/entity/broadcast.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use feather_core::network::packet::implementation::SpawnObject;
2121
use feather_core::network::packet::implementation::{PacketEntityMetadata, SpawnPlayer};
2222
use feather_core::Packet;
2323
use shrev::EventChannel;
24-
use specs::{Entity, Read, ReadStorage, ReaderId, System, Write, WriteStorage};
24+
use specs::{Entities, Entity, Read, ReadStorage, ReaderId, System, Write, WriteStorage};
2525
use uuid::Uuid;
2626

2727
/// Handles lazy sending of entities to a client.
@@ -74,6 +74,7 @@ impl<'a> System<'a> for EntitySendSystem {
7474
Write<'a, EventChannel<EntitySendEvent>>,
7575
Read<'a, EntitySender>,
7676
ReadStorage<'a, FallingBlockComponent>,
77+
Entities<'a>,
7778
);
7879

7980
fn run(&mut self, data: Self::SystemData) {
@@ -87,9 +88,14 @@ impl<'a> System<'a> for EntitySendSystem {
8788
mut send_events,
8889
entity_sender,
8990
falling_blocks,
91+
entities,
9092
) = data;
9193

9294
while let Ok(request) = entity_sender.queue.pop() {
95+
if !entities.is_alive(request.entity) {
96+
continue; // Entity was destroyed
97+
}
98+
9399
let ty = types.get(request.entity).unwrap();
94100
let metadata = metadatas.get_mut(request.entity).unwrap();
95101
let position = positions.get(request.entity).unwrap();

0 commit comments

Comments
 (0)