|
|
@ -44,6 +44,7 @@ pub enum RecvShipPacket { |
|
|
|
CreateRoom(CreateRoom),
|
|
|
|
RoomNameRequest(RoomNameRequest),
|
|
|
|
UpdateConfig(UpdateConfig),
|
|
|
|
WriteInfoboard(WriteInfoboard),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RecvServerPacket for RecvShipPacket {
|
|
|
@ -58,6 +59,7 @@ impl RecvServerPacket for RecvShipPacket { |
|
|
|
0xC1 => Ok(RecvShipPacket::CreateRoom(CreateRoom::from_bytes(data)?)),
|
|
|
|
0x8A => Ok(RecvShipPacket::RoomNameRequest(RoomNameRequest::from_bytes(data)?)),
|
|
|
|
0x7ED => Ok(RecvShipPacket::UpdateConfig(UpdateConfig::from_bytes(data)?)),
|
|
|
|
0xD9 => Ok(RecvShipPacket::WriteInfoboard(WriteInfoboard::from_bytes(data)?)),
|
|
|
|
_ => Err(PacketParseError::WrongPacketForServerType(u16::from_le_bytes([data[2], data[3]]), data.to_vec()))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -197,12 +199,13 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
let (level, stats) = self.level_table.get_stats_from_exp(client.character.char_class, client.character.exp);
|
|
|
|
|
|
|
|
let fc = FullCharacterBytesBuilder::new()
|
|
|
|
.character(&client.character)
|
|
|
|
.character(&client.character.clone())
|
|
|
|
.stats(&stats)
|
|
|
|
.level(level)
|
|
|
|
.inventory(&client.inventory)
|
|
|
|
.key_config(&client.settings.settings.key_config)
|
|
|
|
.joystick_config(&client.settings.settings.joystick_config)
|
|
|
|
.info_board(&client.character.info_board.as_bytes())
|
|
|
|
.build();
|
|
|
|
|
|
|
|
Ok(vec![
|
|
|
@ -407,6 +410,13 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
self.entity_gateway.set_character(&client.character);
|
|
|
|
Box::new(None.into_iter())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn write_infoboard(&mut self, id: ClientId, new_infoboard: &WriteInfoboard) -> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|
|
|
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id)).unwrap();
|
|
|
|
client.character.info_board.update_infoboard(new_infoboard);
|
|
|
|
self.entity_gateway.set_character(&client.character);
|
|
|
|
Box::new(None.into_iter())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -463,6 +473,10 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
RecvShipPacket::UpdateConfig(pkt) => {
|
|
|
|
self.update_config(id, pkt)
|
|
|
|
},
|
|
|
|
|
|
|
|
RecvShipPacket::WriteInfoboard(pkt) => {
|
|
|
|
self.write_infoboard(id, pkt)
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|