mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-22 07:27:44 +00:00
Fix various warnings
This commit is contained in:
parent
0c76d847d5
commit
924c5a1530
3 changed files with 21 additions and 11 deletions
|
@ -19,8 +19,8 @@ use kawari::world::ipc::{
|
||||||
ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType,
|
ServerZoneIpcData, ServerZoneIpcSegment, SocialListRequestType,
|
||||||
};
|
};
|
||||||
use kawari::world::{
|
use kawari::world::{
|
||||||
Actor, ClientHandle, ClientId, EffectsBuilder, FromServer, Item, LuaPlayer, PlayerData,
|
Actor, ClientHandle, ClientId, EffectsBuilder, FromServer, LuaPlayer, PlayerData, ServerHandle,
|
||||||
ServerHandle, StatusEffects, ToServer, WorldDatabase,
|
StatusEffects, ToServer, WorldDatabase,
|
||||||
};
|
};
|
||||||
use kawari::world::{
|
use kawari::world::{
|
||||||
ChatHandler, Inventory, Zone, ZoneConnection,
|
ChatHandler, Inventory, Zone, ZoneConnection,
|
||||||
|
@ -134,8 +134,8 @@ fn spawn_main_loop() -> (ServerHandle, JoinHandle<()>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ClientData {
|
struct ClientData {
|
||||||
id: ClientId,
|
//id: ClientId,
|
||||||
handle: ServerHandle,
|
// handle: ServerHandle,
|
||||||
/// Socket for data recieved from the global server
|
/// Socket for data recieved from the global server
|
||||||
recv: Receiver<FromServer>,
|
recv: Receiver<FromServer>,
|
||||||
connection: ZoneConnection,
|
connection: ZoneConnection,
|
||||||
|
@ -149,15 +149,15 @@ pub fn spawn_client(connection: ZoneConnection) {
|
||||||
let ip = &connection.ip.clone();
|
let ip = &connection.ip.clone();
|
||||||
|
|
||||||
let data = ClientData {
|
let data = ClientData {
|
||||||
id: connection.id,
|
//id: connection.id,
|
||||||
handle: connection.handle.clone(),
|
//handle: connection.handle.clone(),
|
||||||
recv,
|
recv,
|
||||||
connection,
|
connection,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Spawn a new client task
|
// Spawn a new client task
|
||||||
let (my_send, my_recv) = oneshot::channel();
|
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
|
// Send client information to said task
|
||||||
let handle = ClientHandle {
|
let handle = ClientHandle {
|
||||||
|
|
|
@ -78,15 +78,19 @@ pub(crate) fn write_quantized_rotation(quantized: &f32) -> u16 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read_packed_float(packed: u16) -> f32 {
|
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 {
|
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 {
|
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] {
|
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), 0);
|
||||||
assert_eq!(write_quantized_rotation(&std::f32::consts::PI), 65535);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,6 @@ mod tests {
|
||||||
assert_eq!(modify_inventory.dst_storage_id, 0);
|
assert_eq!(modify_inventory.dst_storage_id, 0);
|
||||||
assert_eq!(modify_inventory.dst_container_index, 96);
|
assert_eq!(modify_inventory.dst_container_index, 96);
|
||||||
assert_eq!(modify_inventory.dst_stack, 0);
|
assert_eq!(modify_inventory.dst_stack, 0);
|
||||||
assert_eq!(modify_inventory.dst_catalog_id, 4194304);
|
assert_eq!(modify_inventory.dst_catalog_id, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue