1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-22 23:27:46 +00:00

Fix various warnings

This commit is contained in:
Joshua Goins 2025-03-31 21:58:51 -04:00
parent 0c76d847d5
commit 924c5a1530
3 changed files with 21 additions and 11 deletions

View file

@ -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<FromServer>,
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 {

View file

@ -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);
}
}

View file

@ -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);
}
}