diff --git a/server/src/lib.rs b/server/src/lib.rs index 5dce360972..b467289571 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -846,84 +846,71 @@ impl Server { let mut last_ori = ecs.write_storage::>(); let mut last_action_state = ecs.write_storage::>(); - if let ( - Some(client_pos), - Some(client_vel), - Some(client_ori), - Some(client_action_state), - ) = ( - ecs.read_storage::().get(entity), - ecs.read_storage::().get(entity), - ecs.read_storage::().get(entity), - ecs.read_storage::().get(entity), - ) { - // If nothing changed... + if let Some(client_pos) = ecs.read_storage::().get(entity) { if last_pos .get(entity) .map(|&l| l != *client_pos) .unwrap_or(true) { let _ = last_pos.insert(entity, comp::Last(*client_pos)); - let msg = ServerMsg::EntityPos { entity: uid.into(), pos: *client_pos, }; - match force_update { Some(_) => clients.notify_ingame_if(msg, in_vd), None => clients.notify_ingame_if_except(entity, msg, in_vd), } } + } + if let Some(client_vel) = ecs.read_storage::().get(entity) { if last_vel .get(entity) .map(|&l| l != *client_vel) .unwrap_or(true) { let _ = last_vel.insert(entity, comp::Last(*client_vel)); - let msg = ServerMsg::EntityVel { entity: uid.into(), vel: *client_vel, }; - match force_update { Some(_) => clients.notify_ingame_if(msg, in_vd), None => clients.notify_ingame_if_except(entity, msg, in_vd), } } + } + if let Some(client_ori) = ecs.read_storage::().get(entity) { if last_ori .get(entity) .map(|&l| l != *client_ori) .unwrap_or(true) { let _ = last_ori.insert(entity, comp::Last(*client_ori)); - let msg = ServerMsg::EntityOri { entity: uid.into(), ori: *client_ori, }; - match force_update { Some(_) => clients.notify_ingame_if(msg, in_vd), None => clients.notify_ingame_if_except(entity, msg, in_vd), } } + } + if let Some(client_action_state) = ecs.read_storage::().get(entity) { if last_action_state .get(entity) .map(|&l| l != *client_action_state) .unwrap_or(true) { let _ = last_action_state.insert(entity, comp::Last(*client_action_state)); - let msg = ServerMsg::EntityActionState { entity: uid.into(), action_state: *client_action_state, }; - match force_update { Some(_) => clients.notify_ingame_if(msg, in_vd), None => clients.notify_ingame_if_except(entity, msg, in_vd),