Browse Source

dont forget to send client location packets to other clients

pbs
Andy Newjack 4 years ago
parent
commit
14089a197c
  1. 12
      src/ship/packet/handler/message.rs
  2. 2
      src/ship/ship.rs

12
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<EG>(id: ClientId,

2
src/ship/ship.rs

@ -290,7 +290,7 @@ impl<EG: EntityGateway> ShipServerState<EG> {
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

Loading…
Cancel
Save