diff options
| author | Fuwn <[email protected]> | 2024-06-03 14:57:47 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-03 14:57:47 -0700 |
| commit | a6b766541ae58053ae705e0559d1a1ae8212634b (patch) | |
| tree | aeb55206e77679b2f5e1f47fae7f1bda5c6df5b9 /crates/whirl_server | |
| parent | Merge pull request #153 from Whirlsplash/renovate/actions-checkout-3.x (diff) | |
| download | whirl-old.tar.xz whirl-old.zip | |
fix: bump rust and update accordinglyold
Diffstat (limited to 'crates/whirl_server')
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/action.rs | 3 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/appear_actor.rs | 15 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/buddy_list.rs | 9 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/redirect_id.rs | 9 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/register_object_id.rs | 7 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/subscribe_room.rs | 11 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/teleport.rs | 3 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/text.rs | 7 | ||||
| -rw-r--r-- | crates/whirl_server/src/distributor.rs | 5 | ||||
| -rw-r--r-- | crates/whirl_server/src/hub.rs | 3 | ||||
| -rw-r--r-- | crates/whirl_server/src/lib.rs | 9 | ||||
| -rw-r--r-- | crates/whirl_server/src/net/property_list.rs | 15 |
12 files changed, 40 insertions, 56 deletions
diff --git a/crates/whirl_server/src/cmd/commands/action.rs b/crates/whirl_server/src/cmd/commands/action.rs index ac67eb2..6303528 100644 --- a/crates/whirl_server/src/cmd/commands/action.rs +++ b/crates/whirl_server/src/cmd/commands/action.rs @@ -8,7 +8,6 @@ // of actions, it will be of2m-ified. use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; pub fn create() -> Vec<u8> { let mut command = BytesMut::new(); @@ -20,7 +19,7 @@ pub fn create() -> Vec<u8> { // Convert to vector and insert the length let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); // Return bytes command_as_vec diff --git a/crates/whirl_server/src/cmd/commands/appear_actor.rs b/crates/whirl_server/src/cmd/commands/appear_actor.rs index 89f0022..efdfb6d 100644 --- a/crates/whirl_server/src/cmd/commands/appear_actor.rs +++ b/crates/whirl_server/src/cmd/commands/appear_actor.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-only use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::{constants::Command, extendable::Creatable}; @@ -25,16 +24,16 @@ impl Creatable for AppearActor { command.put_i8(Command::ApprActr as i32 as i8); // Type // Content - command.put_i8(self.short_object_id.as_(): i8); // ObjId, why is it here? Worlds... - command.put_u16(self.room_id.as_(): u16); // Room ID - command.put_u16(self.x.as_(): u16); // X - command.put_u16(self.y.as_(): u16); // Y - command.put_u16(self.z.as_(): u16); // Z - command.put_u16(self.direction.as_(): u16); // Direction + command.put_i8(self.short_object_id as i8); // ObjId, why is it here? Worlds... + command.put_u16(self.room_id as u16); // Room ID + command.put_u16(self.x as u16); // X + command.put_u16(self.y as u16); // Y + command.put_u16(self.z as u16); // Z + command.put_u16(self.direction as u16); // Direction // Length let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); // Return command_as_vec diff --git a/crates/whirl_server/src/cmd/commands/buddy_list.rs b/crates/whirl_server/src/cmd/commands/buddy_list.rs index 1deb442..05aae6d 100644 --- a/crates/whirl_server/src/cmd/commands/buddy_list.rs +++ b/crates/whirl_server/src/cmd/commands/buddy_list.rs @@ -4,7 +4,6 @@ use std::str::from_utf8; use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::extendable::{Creatable, Parsable}; @@ -20,7 +19,7 @@ impl Parsable for BuddyList { .to_string(), // Get the last byte - add: data[data[0] as usize - 1].as_(): i8, + add: data[data[0] as usize - 1] as i8, } } } @@ -34,12 +33,12 @@ impl Creatable for BuddyList { command.put_i8(crate::cmd::constants::Command::BuddyListNotify as i32 as i8); // Type // Content - command.put_u8(self.buddy.len().as_(): u8); // Buddy (name) length + command.put_u8(self.buddy.len() as u8); // Buddy (name) length command.put_slice(self.buddy.as_bytes()); // Buddy (name) - command.put_u8(self.add.as_(): u8); // "Is buddy logged on?" (?) + command.put_u8(self.add as u8); // "Is buddy logged on?" (?) let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); command_as_vec } diff --git a/crates/whirl_server/src/cmd/commands/redirect_id.rs b/crates/whirl_server/src/cmd/commands/redirect_id.rs index dec6eb1..0771fa7 100644 --- a/crates/whirl_server/src/cmd/commands/redirect_id.rs +++ b/crates/whirl_server/src/cmd/commands/redirect_id.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-only use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use whirl_config::Config; use crate::cmd::{constants::Command, extendable::Creatable}; @@ -22,21 +21,21 @@ impl Creatable for RedirectId { command.put_i8(Command::RedirId as i32 as i8); // Type // Content - command.put_u8(self.room_name.len().as_(): u8); // Room name length + command.put_u8(self.room_name.len() as u8); // Room name length command.put_slice(self.room_name.as_bytes()); // Room name // command.put_u8(0x00); // Unimplemented byte (?) // command.put_u8(room_id); // Room ID - command.put_u16(self.room_number.as_(): u16); // Room ID + command.put_u16(self.room_number as u16); // Room ID // IP for byte in Config::get().whirlsplash.ip.split('.') { command.put_u8(byte.parse::<u8>().unwrap()); } - command.put_u16(Config::get().hub.port.as_(): u16); // Port + command.put_u16(Config::get().hub.port as u16); // Port // Length let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); // Return command_as_vec diff --git a/crates/whirl_server/src/cmd/commands/register_object_id.rs b/crates/whirl_server/src/cmd/commands/register_object_id.rs index 61e15a5..8e4cec7 100644 --- a/crates/whirl_server/src/cmd/commands/register_object_id.rs +++ b/crates/whirl_server/src/cmd/commands/register_object_id.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-only use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::{constants::Command, extendable::Creatable}; @@ -21,13 +20,13 @@ impl Creatable for RegisterObjectId { command.put_i8(Command::RegObjId as i32 as i8); // Type // Content - command.put_u8(self.long_object_id.len().as_(): u8); // Long object ID length + command.put_u8(self.long_object_id.len() as u8); // Long object ID length command.put_slice(self.long_object_id.as_bytes()); // Long object ID - command.put_i8(self.short_object_id.as_(): i8); // Short object ID + command.put_i8(self.short_object_id as i8); // Short object ID // Length let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); // Return command_as_vec diff --git a/crates/whirl_server/src/cmd/commands/subscribe_room.rs b/crates/whirl_server/src/cmd/commands/subscribe_room.rs index b48790a..667ae7f 100644 --- a/crates/whirl_server/src/cmd/commands/subscribe_room.rs +++ b/crates/whirl_server/src/cmd/commands/subscribe_room.rs @@ -3,7 +3,6 @@ use byteorder::{BigEndian, ReadBytesExt}; use bytes::{Buf, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::extendable::Parsable; @@ -21,11 +20,11 @@ impl Parsable for SubscribeRoom { let mut data = BytesMut::from(data.as_slice()).reader(); Self { - room_number: data.read_i16::<BigEndian>().unwrap().as_(): i8, - x: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8), - y: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8), - z: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8), - distance: f32::from(data.read_i16::<BigEndian>().unwrap().as_(): i8), // + 100 + room_number: data.read_i16::<BigEndian>().unwrap() as i8, + x: f32::from(data.read_i16::<BigEndian>().unwrap() as i8), + y: f32::from(data.read_i16::<BigEndian>().unwrap() as i8), + z: f32::from(data.read_i16::<BigEndian>().unwrap() as i8), + distance: f32::from(data.read_i16::<BigEndian>().unwrap() as i8), // + 100 } } } diff --git a/crates/whirl_server/src/cmd/commands/teleport.rs b/crates/whirl_server/src/cmd/commands/teleport.rs index 0357108..0493033 100644 --- a/crates/whirl_server/src/cmd/commands/teleport.rs +++ b/crates/whirl_server/src/cmd/commands/teleport.rs @@ -3,7 +3,6 @@ use byteorder::{BigEndian, ReadBytesExt}; use bytes::{Buf, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::extendable::Parsable; @@ -23,7 +22,7 @@ impl Parsable for Teleport { let mut data = BytesMut::from(data.as_slice()).reader(); Self { - room_id: data.read_u16::<BigEndian>().unwrap().as_(): i8, + room_id: data.read_u16::<BigEndian>().unwrap() as i8, exit_type: data.read_u8().unwrap(), entry_type: data.read_u8().unwrap(), x: f32::from(data.read_i16::<BigEndian>().unwrap()), diff --git a/crates/whirl_server/src/cmd/commands/text.rs b/crates/whirl_server/src/cmd/commands/text.rs index 056d7d6..9a36521 100644 --- a/crates/whirl_server/src/cmd/commands/text.rs +++ b/crates/whirl_server/src/cmd/commands/text.rs @@ -4,7 +4,6 @@ use std::str::from_utf8; use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use crate::cmd::{ constants::Command, @@ -30,14 +29,14 @@ impl Creatable for Text { // The below byte is suspected to be the sender's short ObjId. command.put_i8(0x00); - command.put_u8(self.sender.len().as_(): u8); + command.put_u8(self.sender.len() as u8); command.put_slice(self.sender.as_bytes()); - command.put_u8(self.content.len().as_(): u8); + command.put_u8(self.content.len() as u8); command.put_slice(self.content.as_bytes()); // Convert to vector and insert the length let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command.len().as_(): u8 + 1); + command_as_vec.insert(0, command.len() as u8 + 1); // Return bytes command_as_vec diff --git a/crates/whirl_server/src/distributor.rs b/crates/whirl_server/src/distributor.rs index 3d684ff..1213090 100644 --- a/crates/whirl_server/src/distributor.rs +++ b/crates/whirl_server/src/distributor.rs @@ -13,7 +13,6 @@ use std::{error::Error, net::SocketAddr, sync::Arc}; -use num_traits::cast::AsPrimitive; use tokio::{io::AsyncWriteExt, net::TcpStream, sync::Mutex}; use tokio_stream::StreamExt; use tokio_util::codec::{BytesCodec, Decoder}; @@ -66,7 +65,7 @@ impl Server for Distributor { result = peer.bytes.next() => match result { Some(Ok(msg)) => { for msg in parse_commands_from_packet(msg) { - match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned().as_(): i32) { + match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned() as i32) { Some(Command::PropReq) => { debug!("received property request from client"); @@ -120,7 +119,7 @@ impl Server for Distributor { peer.bytes.get_mut().write_all(&RedirectId { room_name: (&*room.room_name).to_string(), - room_number: room_id.as_(): i8, + room_number: room_id as i8, }.create()).await?; trace!("sent redirect id to {}: {}", username, room.room_name); } diff --git a/crates/whirl_server/src/hub.rs b/crates/whirl_server/src/hub.rs index 848862d..f271c28 100644 --- a/crates/whirl_server/src/hub.rs +++ b/crates/whirl_server/src/hub.rs @@ -10,7 +10,6 @@ use std::{error::Error, net::SocketAddr, sync::Arc}; -use num_traits::cast::AsPrimitive; use tokio::{io::AsyncWriteExt, net::TcpStream, sync::Mutex}; use tokio_stream::StreamExt; use tokio_util::codec::{BytesCodec, Decoder}; @@ -71,7 +70,7 @@ impl Server for Hub { Some(Ok(msg)) => { // trace!("got some bytes: {:?}", &msg); for msg in parse_commands_from_packet(msg) { - match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned().as_(): i32) { + match num_traits::FromPrimitive::from_i32(msg.get(2).unwrap().to_owned() as i32) { Some(Command::PropReq) => { debug!("received property request from client"); diff --git a/crates/whirl_server/src/lib.rs b/crates/whirl_server/src/lib.rs index ad7d05e..2567cf7 100644 --- a/crates/whirl_server/src/lib.rs +++ b/crates/whirl_server/src/lib.rs @@ -3,13 +3,7 @@ //! Exposes the Distributor and Hub for further use. -#![feature( - type_ascription, - hash_set_entry, - type_name_of_val, - decl_macro, - proc_macro_hygiene -)] +#![feature(type_ascription, hash_set_entry, decl_macro, proc_macro_hygiene)] #![deny( warnings, nonstandard_style, @@ -24,6 +18,7 @@ html_logo_url = "https://raw.githubusercontent.com/Whirlsplash/assets/master/Whirl.png", html_favicon_url = "https://raw.githubusercontent.com/Whirlsplash/assets/master/Whirl.png" )] +#![allow(non_local_definitions, dead_code)] #[macro_use] extern crate log; diff --git a/crates/whirl_server/src/net/property_list.rs b/crates/whirl_server/src/net/property_list.rs index a1c4b34..554f344 100644 --- a/crates/whirl_server/src/net/property_list.rs +++ b/crates/whirl_server/src/net/property_list.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-3.0-only use bytes::{BufMut, BytesMut}; -use num_traits::AsPrimitive; use crate::{ cmd::constants::Command, @@ -31,15 +30,15 @@ impl PropertyList { let property = &property_list[0]; // Property we are currently iterating over trace!("current prop: {}:{}", property.prop_id, property.value); - command.put_u8(property.prop_id.as_(): u8); // Property ID + command.put_u8(property.prop_id as u8); // Property ID // NOTE: THIS IS SUPER BAD DO NOT DO THIS! But it works! if command_id == Command::PropUpd as i32 { - command.put_u8(PROPFLAG_DBSTORE.as_(): u8); // Flag (s) - command.put_u8(PROPACCESS_POSSESS.as_(): u8); // Access + command.put_u8(PROPFLAG_DBSTORE as u8); // Flag (s) + command.put_u8(PROPACCESS_POSSESS as u8); // Access } - command.put_u8(property.value.len().as_(): u8); // Property UTF-8 Length + command.put_u8(property.value.len() as u8); // Property UTF-8 Length command.put_slice(property.value.as_bytes()); // Property UTF-8 property_list.reverse(); @@ -50,9 +49,9 @@ impl PropertyList { // Convert to vector and insert the header let mut command_as_vec = command.to_vec(); - command_as_vec.insert(0, command_id.as_(): u8); // Command ID - command_as_vec.insert(0, obj_id.as_(): u8); // ObjId - command_as_vec.insert(0, command.len().as_(): u8 + 3); // Data length + command_as_vec.insert(0, command_id as u8); // Command ID + command_as_vec.insert(0, obj_id as u8); // ObjId + command_as_vec.insert(0, command.len() as u8 + 3); // Data length // Return bytes command_as_vec |