From 924c5a1530b44bf05882c713b8fefd64eee0275f Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 31 Mar 2025 21:58:51 -0400 Subject: [PATCH] Fix various warnings --- src/bin/kawari-world.rs | 14 +++++++------- src/common/mod.rs | 16 +++++++++++++--- src/world/ipc/inventory_modify.rs | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 656215d..1205a6d 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -19,8 +19,8 @@ use kawari::world::ipc::{ ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType, }; use kawari::world::{ - Actor, ClientHandle, ClientId, EffectsBuilder, FromServer, Item, LuaPlayer, PlayerData, - ServerHandle, StatusEffects, ToServer, WorldDatabase, + Actor, ClientHandle, ClientId, EffectsBuilder, FromServer, LuaPlayer, PlayerData, ServerHandle, + StatusEffects, ToServer, WorldDatabase, }; use kawari::world::{ ChatHandler, Inventory, Zone, ZoneConnection, @@ -134,8 +134,8 @@ fn spawn_main_loop() -> (ServerHandle, JoinHandle<()>) { } struct ClientData { - id: ClientId, - handle: ServerHandle, + //id: ClientId, + // handle: ServerHandle, /// Socket for data recieved from the global server recv: Receiver, connection: ZoneConnection, @@ -149,15 +149,15 @@ pub fn spawn_client(connection: ZoneConnection) { let ip = &connection.ip.clone(); let data = ClientData { - id: connection.id, - handle: connection.handle.clone(), + //id: connection.id, + //handle: connection.handle.clone(), recv, connection, }; // Spawn a new client task let (my_send, my_recv) = oneshot::channel(); - let kill = tokio::spawn(start_client(my_recv, data)); + let _kill = tokio::spawn(start_client(my_recv, data)); // Send client information to said task let handle = ClientHandle { diff --git a/src/common/mod.rs b/src/common/mod.rs index 2ba0286..fc50d0d 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -78,15 +78,19 @@ pub(crate) fn write_quantized_rotation(quantized: &f32) -> u16 { } pub(crate) fn read_packed_float(packed: u16) -> f32 { - todo!() + ((packed as f32 / 0.327675) / 100.0) - 1000.0 } pub(crate) fn write_packed_float(float: f32) -> u16 { - (((float + 1000.0) * 100.0) * 0.327_675) as u16 + (((float + 1000.0) * 100.0) * 0.327675) as u16 } pub(crate) fn read_packed_position(packed: [u16; 3]) -> Position { - todo!() + Position { + x: read_packed_float(packed[0]), + y: read_packed_float(packed[1]), + z: read_packed_float(packed[2]), + } } pub(crate) fn write_packed_position(pos: &Position) -> [u16; 3] { @@ -171,4 +175,10 @@ mod tests { assert_eq!(write_quantized_rotation(&-std::f32::consts::PI), 0); assert_eq!(write_quantized_rotation(&std::f32::consts::PI), 65535); } + + #[test] + fn packed_floats() { + assert_eq!(read_packed_float(32931), 4.989685); + assert_eq!(write_packed_float(5.0), 32931); + } } diff --git a/src/world/ipc/inventory_modify.rs b/src/world/ipc/inventory_modify.rs index ef0ef4e..808c951 100644 --- a/src/world/ipc/inventory_modify.rs +++ b/src/world/ipc/inventory_modify.rs @@ -47,6 +47,6 @@ mod tests { assert_eq!(modify_inventory.dst_storage_id, 0); assert_eq!(modify_inventory.dst_container_index, 96); assert_eq!(modify_inventory.dst_stack, 0); - assert_eq!(modify_inventory.dst_catalog_id, 4194304); + assert_eq!(modify_inventory.dst_catalog_id, 0); } }