diff options
| author | Fuwn <[email protected]> | 2024-06-03 15:23:14 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-03 15:23:14 -0700 |
| commit | 19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52 (patch) | |
| tree | 22353b8c7a78b83c992b7bfb60c024fee6f78e3e /crates/whirl_server/src/cmd/commands | |
| parent | chore(rustfmt): add new rules (diff) | |
| download | whirl-19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52.tar.xz whirl-19010055c88fd7aac23f3ce39fa6a5ec1cbf9a52.zip | |
format: rustfmt with new rules
Diffstat (limited to 'crates/whirl_server/src/cmd/commands')
12 files changed, 77 insertions, 119 deletions
diff --git a/crates/whirl_server/src/cmd/commands/action.rs b/crates/whirl_server/src/cmd/commands/action.rs index 6303528..d7574ea 100644 --- a/crates/whirl_server/src/cmd/commands/action.rs +++ b/crates/whirl_server/src/cmd/commands/action.rs @@ -13,8 +13,8 @@ pub fn create() -> Vec<u8> { let mut command = BytesMut::new(); command.put_slice(&[ - 0x01, 0x11, 0x00, 0x05, 0x54, 0x52, 0x41, 0x44, 0x45, 0x07, 0x26, 0x7c, 0x2b, 0x69, 0x6e, 0x76, - 0x3e, + 0x01, 0x11, 0x00, 0x05, 0x54, 0x52, 0x41, 0x44, 0x45, 0x07, 0x26, 0x7c, + 0x2b, 0x69, 0x6e, 0x76, 0x3e, ]); // Convert to vector and insert the length diff --git a/crates/whirl_server/src/cmd/commands/appear_actor.rs b/crates/whirl_server/src/cmd/commands/appear_actor.rs index efdfb6d..836c681 100644 --- a/crates/whirl_server/src/cmd/commands/appear_actor.rs +++ b/crates/whirl_server/src/cmd/commands/appear_actor.rs @@ -1,9 +1,10 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use bytes::{BufMut, BytesMut}; - -use crate::cmd::{constants::Command, extendable::Creatable}; +use { + crate::cmd::{constants::Command, extendable::Creatable}, + bytes::{BufMut, BytesMut}, +}; #[derive(Debug)] pub struct AppearActor { diff --git a/crates/whirl_server/src/cmd/commands/buddy_list.rs b/crates/whirl_server/src/cmd/commands/buddy_list.rs index 05aae6d..f8c76f6 100644 --- a/crates/whirl_server/src/cmd/commands/buddy_list.rs +++ b/crates/whirl_server/src/cmd/commands/buddy_list.rs @@ -1,11 +1,11 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use std::str::from_utf8; - -use bytes::{BufMut, BytesMut}; - -use crate::cmd::extendable::{Creatable, Parsable}; +use { + crate::cmd::extendable::{Creatable, Parsable}, + bytes::{BufMut, BytesMut}, + std::str::from_utf8, +}; pub struct BuddyList { pub buddy: String, @@ -14,9 +14,7 @@ pub struct BuddyList { impl Parsable for BuddyList { fn parse(data: Vec<u8>) -> Self { Self { - buddy: from_utf8(&data[4..data[0] as usize - 1]) - .unwrap() - .to_string(), + buddy: from_utf8(&data[4..data[0] as usize - 1]).unwrap().to_string(), // Get the last byte add: data[data[0] as usize - 1] as i8, @@ -30,7 +28,8 @@ impl Creatable for BuddyList { // Header command.put_u8(0x01); // ObjId #[allow(clippy::cast_possible_truncation)] - command.put_i8(crate::cmd::constants::Command::BuddyListNotify as i32 as i8); // Type + 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 diff --git a/crates/whirl_server/src/cmd/commands/property/create.rs b/crates/whirl_server/src/cmd/commands/property/create.rs index 4d59521..c2afd59 100644 --- a/crates/whirl_server/src/cmd/commands/property/create.rs +++ b/crates/whirl_server/src/cmd/commands/property/create.rs @@ -3,28 +3,20 @@ // TODO: of2m-ify? -use whirl_config::Config; - -use crate::{ - cmd::constants::Command, - net::{ - constants::{ - VAR_APPNAME, - VAR_CHANNEL, - VAR_ERROR, - VAR_EXTERNAL_HTTP_SERVER, - VAR_MAIL_DOMAIN, - VAR_PRIV, - VAR_PROTOCOL, - VAR_SCRIPT_SERVER, - VAR_SERIAL, - VAR_SERVERTYPE, - VAR_SMTP_SERVER, - VAR_UPDATETIME, +use { + crate::{ + cmd::constants::Command, + net::{ + constants::{ + VAR_APPNAME, VAR_CHANNEL, VAR_ERROR, VAR_EXTERNAL_HTTP_SERVER, + VAR_MAIL_DOMAIN, VAR_PRIV, VAR_PROTOCOL, VAR_SCRIPT_SERVER, VAR_SERIAL, + VAR_SERVERTYPE, VAR_SMTP_SERVER, VAR_UPDATETIME, + }, + network_property::NetworkProperty, + property_list::PropertyList, }, - network_property::NetworkProperty, - property_list::PropertyList, }, + whirl_config::Config, }; pub fn property_update_as_distributor() -> Vec<u8> { @@ -45,14 +37,8 @@ pub fn property_update_as_distributor() -> Vec<u8> { prop_id: VAR_EXTERNAL_HTTP_SERVER, value: "http://www-static.us.worlds.net".to_string(), }, - NetworkProperty { - prop_id: VAR_SERVERTYPE, - value: "1".to_string(), - }, - NetworkProperty { - prop_id: VAR_PROTOCOL, - value: "24".to_string(), - }, + NetworkProperty { prop_id: VAR_SERVERTYPE, value: "1".to_string() }, + NetworkProperty { prop_id: VAR_PROTOCOL, value: "24".to_string() }, NetworkProperty { prop_id: VAR_APPNAME, value: Config::get().whirlsplash.worldsmaster_username, @@ -63,10 +49,7 @@ pub fn property_update_as_distributor() -> Vec<u8> { pub fn property_update_as_hub() -> Vec<u8> { PropertyList(vec![ - NetworkProperty { - prop_id: VAR_UPDATETIME, - value: "1000000".to_string(), - }, + NetworkProperty { prop_id: VAR_UPDATETIME, value: "1000000".to_string() }, NetworkProperty { prop_id: VAR_MAIL_DOMAIN, value: "worlds3d.com".to_string(), @@ -83,14 +66,8 @@ pub fn property_update_as_hub() -> Vec<u8> { prop_id: VAR_EXTERNAL_HTTP_SERVER, value: "http://www-static.us.worlds.net".to_string(), }, - NetworkProperty { - prop_id: VAR_SERVERTYPE, - value: "3".to_string(), - }, - NetworkProperty { - prop_id: VAR_PROTOCOL, - value: "24".to_string(), - }, + NetworkProperty { prop_id: VAR_SERVERTYPE, value: "3".to_string() }, + NetworkProperty { prop_id: VAR_PROTOCOL, value: "24".to_string() }, NetworkProperty { prop_id: VAR_APPNAME, value: Config::get().whirlsplash.worldsmaster_username, @@ -101,30 +78,18 @@ pub fn property_update_as_hub() -> Vec<u8> { pub fn property_request_as_distributor() -> Vec<u8> { PropertyList(vec![ - NetworkProperty { - prop_id: VAR_ERROR, - value: "0".to_string(), - }, + NetworkProperty { prop_id: VAR_ERROR, value: "0".to_string() }, NetworkProperty { prop_id: VAR_APPNAME, value: Config::get().whirlsplash.worldsmaster_username, }, - NetworkProperty { - prop_id: VAR_PROTOCOL, - value: "24".to_string(), - }, - NetworkProperty { - prop_id: VAR_SERVERTYPE, - value: "1".to_string(), - }, + NetworkProperty { prop_id: VAR_PROTOCOL, value: "24".to_string() }, + NetworkProperty { prop_id: VAR_SERVERTYPE, value: "1".to_string() }, NetworkProperty { prop_id: VAR_SERIAL, value: "DWLV000000000000".to_string(), }, - NetworkProperty { - prop_id: VAR_PRIV, - value: "0".to_string(), - }, + NetworkProperty { prop_id: VAR_PRIV, value: "0".to_string() }, NetworkProperty { prop_id: VAR_CHANNEL, value: "dimension-1".to_string(), @@ -135,22 +100,10 @@ pub fn property_request_as_distributor() -> Vec<u8> { pub fn property_request_as_hub() -> Vec<u8> { PropertyList(vec![ - NetworkProperty { - prop_id: VAR_ERROR, - value: "0".to_string(), - }, - NetworkProperty { - prop_id: VAR_SERVERTYPE, - value: "3".to_string(), - }, - NetworkProperty { - prop_id: VAR_UPDATETIME, - value: "1000000".to_string(), - }, - NetworkProperty { - prop_id: VAR_PROTOCOL, - value: "24".to_string(), - }, + NetworkProperty { prop_id: VAR_ERROR, value: "0".to_string() }, + NetworkProperty { prop_id: VAR_SERVERTYPE, value: "3".to_string() }, + NetworkProperty { prop_id: VAR_UPDATETIME, value: "1000000".to_string() }, + NetworkProperty { prop_id: VAR_PROTOCOL, value: "24".to_string() }, ]) .as_bytes(Command::SessInit as i32, 0x01) } diff --git a/crates/whirl_server/src/cmd/commands/redirect_id.rs b/crates/whirl_server/src/cmd/commands/redirect_id.rs index 0771fa7..fe380d0 100644 --- a/crates/whirl_server/src/cmd/commands/redirect_id.rs +++ b/crates/whirl_server/src/cmd/commands/redirect_id.rs @@ -1,10 +1,11 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use bytes::{BufMut, BytesMut}; -use whirl_config::Config; - -use crate::cmd::{constants::Command, extendable::Creatable}; +use { + crate::cmd::{constants::Command, extendable::Creatable}, + bytes::{BufMut, BytesMut}, + whirl_config::Config, +}; #[derive(Debug)] pub struct RedirectId { @@ -23,8 +24,8 @@ impl Creatable for RedirectId { // Content 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_u8(0x00); // Unimplemented byte (?) + // command.put_u8(room_id); // Room ID command.put_u16(self.room_number as u16); // Room ID // IP 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 8e4cec7..7791ae2 100644 --- a/crates/whirl_server/src/cmd/commands/register_object_id.rs +++ b/crates/whirl_server/src/cmd/commands/register_object_id.rs @@ -1,9 +1,10 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use bytes::{BufMut, BytesMut}; - -use crate::cmd::{constants::Command, extendable::Creatable}; +use { + crate::cmd::{constants::Command, extendable::Creatable}, + bytes::{BufMut, BytesMut}, +}; #[derive(Debug)] pub struct RegisterObjectId { diff --git a/crates/whirl_server/src/cmd/commands/room_id_request.rs b/crates/whirl_server/src/cmd/commands/room_id_request.rs index d6d269b..d90d26d 100644 --- a/crates/whirl_server/src/cmd/commands/room_id_request.rs +++ b/crates/whirl_server/src/cmd/commands/room_id_request.rs @@ -1,9 +1,7 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use std::str::from_utf8; - -use crate::cmd::extendable::Parsable; +use {crate::cmd::extendable::Parsable, std::str::from_utf8}; #[derive(Debug)] pub struct RoomIdRequest { diff --git a/crates/whirl_server/src/cmd/commands/session_exit.rs b/crates/whirl_server/src/cmd/commands/session_exit.rs index 47048ab..330f9bb 100644 --- a/crates/whirl_server/src/cmd/commands/session_exit.rs +++ b/crates/whirl_server/src/cmd/commands/session_exit.rs @@ -8,5 +8,7 @@ use crate::{ pub struct SessionExit(pub PropertyList); impl Creatable for SessionExit { - fn create(&self) -> Vec<u8> { self.0.clone().as_bytes(Command::SessExit as i32, 0x01) } + fn create(&self) -> Vec<u8> { + self.0.clone().as_bytes(Command::SessExit as i32, 0x01) + } } diff --git a/crates/whirl_server/src/cmd/commands/subscribe_distance.rs b/crates/whirl_server/src/cmd/commands/subscribe_distance.rs index cbf0269..9877a5d 100644 --- a/crates/whirl_server/src/cmd/commands/subscribe_distance.rs +++ b/crates/whirl_server/src/cmd/commands/subscribe_distance.rs @@ -1,10 +1,11 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use byteorder::{BigEndian, ReadBytesExt}; -use bytes::{Buf, BytesMut}; - -use crate::cmd::extendable::Parsable; +use { + crate::cmd::extendable::Parsable, + byteorder::{BigEndian, ReadBytesExt}, + bytes::{Buf, BytesMut}, +}; #[derive(Debug)] pub struct SubscribeDistance { diff --git a/crates/whirl_server/src/cmd/commands/subscribe_room.rs b/crates/whirl_server/src/cmd/commands/subscribe_room.rs index 667ae7f..2ed92a4 100644 --- a/crates/whirl_server/src/cmd/commands/subscribe_room.rs +++ b/crates/whirl_server/src/cmd/commands/subscribe_room.rs @@ -1,10 +1,11 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use byteorder::{BigEndian, ReadBytesExt}; -use bytes::{Buf, BytesMut}; - -use crate::cmd::extendable::Parsable; +use { + crate::cmd::extendable::Parsable, + byteorder::{BigEndian, ReadBytesExt}, + bytes::{Buf, BytesMut}, +}; #[derive(Debug)] pub struct SubscribeRoom { @@ -24,7 +25,7 @@ impl Parsable for SubscribeRoom { 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 + 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 0493033..aa4b7dd 100644 --- a/crates/whirl_server/src/cmd/commands/teleport.rs +++ b/crates/whirl_server/src/cmd/commands/teleport.rs @@ -1,10 +1,11 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use byteorder::{BigEndian, ReadBytesExt}; -use bytes::{Buf, BytesMut}; - -use crate::cmd::extendable::Parsable; +use { + crate::cmd::extendable::Parsable, + byteorder::{BigEndian, ReadBytesExt}, + bytes::{Buf, BytesMut}, +}; #[derive(Debug)] pub struct Teleport { diff --git a/crates/whirl_server/src/cmd/commands/text.rs b/crates/whirl_server/src/cmd/commands/text.rs index 9a36521..dac13b6 100644 --- a/crates/whirl_server/src/cmd/commands/text.rs +++ b/crates/whirl_server/src/cmd/commands/text.rs @@ -1,13 +1,13 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use std::str::from_utf8; - -use bytes::{BufMut, BytesMut}; - -use crate::cmd::{ - constants::Command, - extendable::{Creatable, ParsableWithArguments}, +use { + crate::cmd::{ + constants::Command, + extendable::{Creatable, ParsableWithArguments}, + }, + bytes::{BufMut, BytesMut}, + std::str::from_utf8, }; pub struct Text { |