diff options
Diffstat (limited to 'crates/whirl_server/src/cmd')
8 files changed, 28 insertions, 36 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 |