diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 4f75667..0909d37 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -68,7 +68,7 @@ async fn main_loop(mut recv: Receiver) -> Result<(), std::io::Error> { let msg = FromServer::ActorSpawn(Actor { id: *id, hp: 100 }, common.clone()); - let _ = handle.send(msg).unwrap(); + handle.send(msg).unwrap(); } break; @@ -724,7 +724,7 @@ async fn client_loop( } } - let actor = actor.clone(); + let actor = *actor; connection.update_hp_mp(actor.id, actor.hp, 10000).await; } @@ -784,7 +784,7 @@ async fn client_loop( ClientZoneIpcData::InventoryModify(action) => { tracing::info!("Client is modifying inventory! {action:#?}"); - connection.player_data.inventory.process_action(&action); + connection.player_data.inventory.process_action(action); connection.send_inventory(true).await; } } diff --git a/src/common/mod.rs b/src/common/mod.rs index 0c106a0..ea8222b 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -63,7 +63,7 @@ pub(crate) fn write_string(str: &String) -> Vec { /// Converts a quantized rotation to degrees in f32 pub(crate) fn read_quantized_rotation(quantized: u16) -> f32 { - let max = std::u16::MAX as f32; + let max = u16::MAX as f32; let pi = std::f32::consts::PI; quantized as f32 / max * (2.0 * pi) - pi @@ -71,7 +71,7 @@ pub(crate) fn read_quantized_rotation(quantized: u16) -> f32 { /// Converts a rotation (in degrees) to pub(crate) fn write_quantized_rotation(quantized: &f32) -> u16 { - let max = std::u16::MAX as f32; + let max = u16::MAX as f32; let pi = std::f32::consts::PI; ((quantized + pi / (2.0 * pi)) * max) as u16 diff --git a/src/login/database.rs b/src/login/database.rs index 426b5ec..f68b46b 100644 --- a/src/login/database.rs +++ b/src/login/database.rs @@ -163,15 +163,13 @@ impl LoginDatabase { let accounts = stmt.query_map((user_id,), |row| row.get(0)).unwrap(); let mut service_accounts = Vec::new(); - let mut index = 0; - for id in accounts { + for (index, id) in accounts.enumerate() { service_accounts.push(ServiceAccount { id: id.unwrap(), unk1: 0, - index, + index: index as u32, name: format!("FINAL FANTASY XIV {}", index + 1), // TODO: don't add the "1" if you only have one service account }); - index += 1 } service_accounts diff --git a/src/world/connection.rs b/src/world/connection.rs index cbfdf5b..c7ab8d5 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -688,13 +688,7 @@ impl ZoneConnection { } pub fn get_actor(&mut self, id: ObjectId) -> Option<&mut Actor> { - for actor in &mut self.actors { - if actor.id == id { - return Some(actor); - } - } - - None + self.actors.iter_mut().find(|actor| actor.id == id) } pub async fn actor_control_self(&mut self, actor_control: ActorControlSelf) { @@ -746,7 +740,7 @@ impl ZoneConnection { game_data.get_primary_model_id(equipped.left_ring.id) as u32, game_data.get_primary_model_id(equipped.right_ring.id) as u32, ], - pos: exit_position.unwrap_or(Position::default()), + pos: exit_position.unwrap_or_default(), rotation: exit_rotation.unwrap_or(0.0), ..Default::default() } diff --git a/src/world/inventory.rs b/src/world/inventory.rs index ebb08ee..19f453b 100644 --- a/src/world/inventory.rs +++ b/src/world/inventory.rs @@ -11,7 +11,7 @@ use super::ipc::{ContainerType, InventoryModify}; // TODO: rename to storage? pub trait Container { fn num_items(&self) -> u32; - fn get_slot<'a>(&'a mut self, index: u16) -> &'a mut Item; + fn get_slot(&mut self, index: u16) -> &mut Item; } #[derive(Default, Copy, Clone, Serialize, Deserialize, Debug)] @@ -176,7 +176,7 @@ impl Inventory { { let src_container = self.get_container(&action.src_storage_id); let src_slot = src_container.get_slot(action.src_container_index); - src_item = src_slot.clone(); + src_item = *src_slot; } let dst_item; @@ -185,7 +185,7 @@ impl Inventory { let dst_container = self.get_container(&action.dst_storage_id); let dst_slot = dst_container.get_slot(action.dst_container_index); - dst_item = dst_slot.clone(); + dst_item = *dst_slot; dst_slot.clone_from(&src_item); } diff --git a/src/world/zone.rs b/src/world/zone.rs index 5994269..5bb5c95 100644 --- a/src/world/zone.rs +++ b/src/world/zone.rs @@ -50,9 +50,7 @@ impl Zone { let mut load_lgb = |name: &str| -> Option { let path = format!("bg/{}/level/{}.lgb", &bg_path[..level_index], name); tracing::info!("Loading {path}"); - let Some(lgb) = game_data.extract(&path) else { - return None; - }; + let lgb = game_data.extract(&path)?; LayerGroup::from_existing(&lgb) };