From 12c22bf287068866f691e3c346638d8710b0f3a0 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 24 Apr 2020 04:19:08 -0400 Subject: [PATCH] Show component in error message when sync modification fails because it does not exist --- common/src/sync/packet.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/src/sync/packet.rs b/common/src/sync/packet.rs index 6c0f9c115b..2ab52b53bf 100644 --- a/common/src/sync/packet.rs +++ b/common/src/sync/packet.rs @@ -22,18 +22,18 @@ pub trait CompPacket: Clone + Debug + Send + 'static { /// Useful for implementing CompPacket trait pub fn handle_insert(comp: C, entity: Entity, world: &World) { if let Err(err) = world.write_storage::().insert(entity, comp) { - error!("Error inserting component: {:?}", err); + error!("Error inserting : {:?}", err); } } /// Useful for implementing CompPacket trait -pub fn handle_modify(comp: C, entity: Entity, world: &World) { - if world - .write_storage::() - .get_mut(entity) - .map(|c| *c = comp) - .is_none() - { - error!("Error modifying synced component, it doesn't seem to exist"); +pub fn handle_modify(comp: C, entity: Entity, world: &World) { + if let Some(c) = world.write_storage::().get_mut(entity) { + *c = comp + } else { + error!( + "Error modifying synced component: {:?}, it doesn't seem to exist", + comp + ); } } /// Useful for implementing CompPacket trait