diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 87fb505..4df5e62 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -162,7 +162,7 @@ where } pub fn update_player_position(id: ClientId, - message: &GameMessage, + message: &Message, clients: &mut Clients, client_location: &ClientLocation, rooms: &Rooms) @@ -173,8 +173,8 @@ pub fn update_player_position(id: ClientId, .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))? .as_ref() .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?; - - match message { + + match &message.msg { GameMessage::PlayerChangedMap(p) => {client.x = p.x; client.y = p.y; client.z = p.z;}, GameMessage::PlayerChangedMap2(p) => {client.area = MapArea::from_value(&room.mode.episode(), p.map_area).ok();}, GameMessage::TellOtherPlayerMyLocation(p) => {client.x = p.x; client.y = p.y; client.z = p.z; client.area = MapArea::from_value(&room.mode.episode(), p.map_area).ok();}, @@ -190,7 +190,11 @@ pub fn update_player_position(id: ClientId, _ => {}, } } else {} - Ok(Box::new(None.into_iter())) + let m = message.clone(); + Ok(Box::new(client_location.get_client_neighbors(id).unwrap().into_iter() + .map(move |client| { + (client.client, SendShipPacket::Message(m.clone())) + }))) } pub async fn charge_attack(id: ClientId, diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 4fedf42..571a440 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -290,7 +290,7 @@ impl ShipServerState { GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) | GameMessage::PlayerLoadedIn(_) | GameMessage::PlayerWalking(_) | GameMessage::PlayerRunning(_) | GameMessage::PlayerWarped(_) | GameMessage::PlayerChangedFloor(_) | GameMessage::InitializeSpeechNpc(_) => { - handler::message::update_player_position(id, &msg.msg, &mut self.clients, &mut self.client_location, &self.rooms) + handler::message::update_player_position(id, &msg, &mut self.clients, &mut self.client_location, &self.rooms) }, GameMessage::ChargeAttack(charge_attack) => { handler::message::charge_attack(id, charge_attack, &mut self.clients, &mut self.entity_gateway).await