|
|
@ -160,3 +160,35 @@ where |
|
|
|
})))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn update_player_position(id: ClientId,
|
|
|
|
message: &GameMessage,
|
|
|
|
clients: &mut Clients,
|
|
|
|
client_location: &ClientLocation,
|
|
|
|
rooms: &Rooms)
|
|
|
|
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, ShipError> {
|
|
|
|
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
if let Ok(room_id) = client_location.get_room(id).map_err(|err| -> ClientLocationError { err.into() }) {
|
|
|
|
let room = rooms.get(room_id.0)
|
|
|
|
.ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?
|
|
|
|
.as_ref()
|
|
|
|
.ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?;
|
|
|
|
|
|
|
|
match message {
|
|
|
|
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();},
|
|
|
|
GameMessage::PlayerWarpingToFloor(p) => {client.area = MapArea::from_value(&room.mode.episode(), p.area as u32).ok();},
|
|
|
|
GameMessage::PlayerTeleported(p) => {client.x = p.x; client.y = p.y; client.z = p.z;},
|
|
|
|
GameMessage::PlayerStopped(p) => {client.x = p.x; client.y = p.y; client.z = p.z;},
|
|
|
|
GameMessage::PlayerLoadedIn(p) => {client.x = p.x; client.y = p.y; client.z = p.z;},
|
|
|
|
GameMessage::PlayerWalking(p) => {client.x = p.x; client.z = p.z;},
|
|
|
|
GameMessage::PlayerRunning(p) => {client.x = p.x; client.z = p.z;},
|
|
|
|
GameMessage::PlayerWarped(p) => {client.x = p.x; client.y = p.y;},
|
|
|
|
GameMessage::PlayerChangedFloor(p) => {client.area = MapArea::from_value(&room.mode.episode(), p.map).ok();},
|
|
|
|
GameMessage::InitializeSpeechNpc(p) => {client.x = p.x; client.z = p.z;}
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
} else {}
|
|
|
|
Ok(Box::new(None.into_iter()))
|
|
|
|
}
|