|
|
@ -43,6 +43,7 @@ pub enum RecvShipPacket { |
|
|
|
PlayerChat(PlayerChat),
|
|
|
|
CreateRoom(CreateRoom),
|
|
|
|
RoomNameRequest(RoomNameRequest),
|
|
|
|
UpdateConfig(UpdateConfig),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RecvServerPacket for RecvShipPacket {
|
|
|
@ -56,6 +57,7 @@ impl RecvServerPacket for RecvShipPacket { |
|
|
|
0x06 => Ok(RecvShipPacket::PlayerChat(PlayerChat::from_bytes(data)?)),
|
|
|
|
0xC1 => Ok(RecvShipPacket::CreateRoom(CreateRoom::from_bytes(data)?)),
|
|
|
|
0x8A => Ok(RecvShipPacket::RoomNameRequest(RoomNameRequest::from_bytes(data)?)),
|
|
|
|
0x7ED => Ok(RecvShipPacket::UpdateConfig(UpdateConfig::from_bytes(data)?)),
|
|
|
|
_ => Err(PacketParseError::WrongPacketForServerType(u16::from_le_bytes([data[2], data[3]]), data.to_vec()))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -398,6 +400,13 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
let room_state = self.rooms[area.id()].as_ref().unwrap();
|
|
|
|
Box::new(vec![(id, SendShipPacket::RoomNameResponse(RoomNameResponse {name: room_state.name.clone()}))].into_iter())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update_config(&mut self, id: ClientId, update_config: &UpdateConfig) -> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|
|
|
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
|
|
|
|
client.character.config.update(update_config);
|
|
|
|
self.entity_gateway.set_character(&client.character);
|
|
|
|
Box::new(None.into_iter())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -450,7 +459,10 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::RoomNameRequest(_req) => {
|
|
|
|
self.room_name_request(id)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
RecvShipPacket::UpdateConfig(pkt) => {
|
|
|
|
self.update_config(id, pkt)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|