diff --git a/src/common/mainloop.rs b/src/common/mainloop.rs index 4668ece..cd4c714 100644 --- a/src/common/mainloop.rs +++ b/src/common/mainloop.rs @@ -1,8 +1,9 @@ +#![allow(dead_code)] use log::{trace, info, warn}; use async_std::sync::{Arc, Mutex}; -use async_std::io::{Read, Write}; +// use async_std::io::{Read, Write}; use async_std::io::prelude::{ReadExt, WriteExt}; -use async_std::prelude::{StreamExt}; +// use async_std::prelude::{StreamExt}; use std::collections::HashMap; use libpso::crypto::{PSOCipher, NullCipher, CipherError}; @@ -266,7 +267,7 @@ async fn client_send_loop(client_id: ClientId, } -pub async fn mainloop_async(mut state: STATE, port: u16) where +pub async fn mainloop_async(state: STATE, port: u16) where STATE: ServerState + Send + 'static, S: SendServerPacket + std::fmt::Debug + Send + Sync + 'static, R: RecvServerPacket + std::fmt::Debug + Send + Sync + 'static, diff --git a/src/entity/account.rs b/src/entity/account.rs index 74c3202..b72cb56 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use std::time::SystemTime; use libpso::character::settings; diff --git a/src/entity/character.rs b/src/entity/character.rs index 4c7f140..e2e44ed 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -1,4 +1,4 @@ -use std::convert::{From, Into, TryFrom, TryInto}; +use std::convert::{From, Into}; use std::collections::HashMap; use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; diff --git a/src/entity/gateway/entitygateway.rs b/src/entity/gateway/entitygateway.rs index 7381268..7cc674f 100644 --- a/src/entity/gateway/entitygateway.rs +++ b/src/entity/gateway/entitygateway.rs @@ -2,7 +2,7 @@ use crate::entity::account::*; use crate::entity::character::*; use crate::entity::item::*; -use libpso::item; +// use libpso::item; pub trait EntityGateway { fn create_user(&mut self, _user: NewUserAccountEntity) -> Option { diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index bbec553..1735e28 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -1,13 +1,13 @@ use std::collections::HashMap; -use std::default::Default; +// use std::default::Default; use crate::entity::account::*; use crate::entity::character::*; use crate::entity::gateway::EntityGateway; use crate::entity::item::*; -use libpso::character::settings; -use libpso::item; +// use libpso::character::settings; +// use libpso::item; use std::sync::{Arc, Mutex}; diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index e3c801d..9b31172 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] pub mod weapon; pub mod armor; pub mod shield; diff --git a/src/entity/item/tool.rs b/src/entity/item/tool.rs index dbde12b..207d2cb 100644 --- a/src/entity/item/tool.rs +++ b/src/entity/item/tool.rs @@ -388,7 +388,7 @@ impl ToolType { ToolType::TeamPoints1000 => [0x03, 0x19, 0x01], ToolType::TeamPoints5000 => [0x03, 0x19, 0x02], ToolType::TeamPoints10000 => [0x03, 0x19, 0x03], - _ => panic!() + // _ => panic!() } } } diff --git a/src/login/character.rs b/src/login/character.rs index ea291fe..8336fcb 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -1,3 +1,4 @@ +#![allow(dead_code, unused_assignments)] use std::io::Read; use std::collections::HashMap; @@ -16,8 +17,8 @@ use crate::common::leveltable::CharacterLevelTable; use libpso::{utf8_to_array, utf8_to_utf16_array}; use crate::entity::gateway::EntityGateway; -use crate::entity::account::{UserAccountEntity, UserSettingsEntity, NewUserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; -use crate::entity::item::{NewItemEntity, ItemEntity, ItemDetail, ItemLocation}; +use crate::entity::account::{UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; +use crate::entity::item::{NewItemEntity, ItemDetail, ItemLocation}; use crate::entity::item::weapon::Weapon; use crate::entity::item::armor::Armor; use crate::entity::item::tech::Technique; @@ -363,7 +364,7 @@ impl CharacterServerState { if select.reason == 0 { let chars = client.characters.as_ref().unwrap(); Ok(if let Some(char) = &chars[select.slot as usize] { - let (level, stats) = self.level_table.get_stats_from_exp(char.char_class, char.exp); + let (level, _stats) = self.level_table.get_stats_from_exp(char.char_class, char.exp); vec![SendCharacterPacket::CharacterPreview(CharacterPreview { slot: select.slot, character: SelectScreenCharacterBuilder::new() @@ -557,7 +558,7 @@ impl ServerState for CharacterServerState { }) } - fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, SendCharacterPacket)> { + fn on_disconnect(&mut self, _id: ClientId) -> Vec<(ClientId, SendCharacterPacket)> { Vec::new() } } @@ -711,7 +712,7 @@ mod test { #[test] fn test_character_create() { - let TestData = InMemoryGateway::new(); + let test_data = InMemoryGateway::new(); let mut fake_user = ClientState::new(); fake_user.user = Some(UserAccountEntity { id: UserAccountId(3), @@ -725,10 +726,10 @@ mod test { flags: 0, }); - let mut server = CharacterServerState::new(TestData.clone()); + let mut server = CharacterServerState::new(test_data.clone()); server.clients.insert(ClientId(1), fake_user.clone()); let mut send = server.handle(ClientId(1), &RecvCharacterPacket::SetFlag(SetFlag {flags: 1})).unwrap().collect::>(); - assert!(TestData.get_user_by_id(UserAccountId(3)).unwrap().flags == 1); + assert!(test_data.get_user_by_id(UserAccountId(3)).unwrap().flags == 1); send = server.handle(ClientId(1), &RecvCharacterPacket::CharacterPreview(CharacterPreview {slot: 1, character: character::SelectScreenCharacter { exp: 0, level: 0, @@ -758,7 +759,7 @@ mod test { } })).unwrap().collect::>(); assert!(send.len() == 2); - let chars = TestData.get_characters_by_user(&fake_user.user.unwrap()); + let chars = test_data.get_characters_by_user(&fake_user.user.unwrap()); assert!(chars[1].as_ref().unwrap().name == "\tEtest name"); assert!(chars[0].is_none()); } diff --git a/src/login/login.rs b/src/login/login.rs index 993a94d..b7ce2d7 100644 --- a/src/login/login.rs +++ b/src/login/login.rs @@ -14,7 +14,7 @@ use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; use crate::entity::gateway::EntityGateway; -use crate::entity::account::{UserAccountId, UserAccountEntity}; +use crate::entity::account::{UserAccountEntity}; pub const LOGIN_PORT: u16 = 12000; @@ -132,7 +132,7 @@ impl ServerState for LoginServerState { }) } - fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, SendLoginPacket)> { + fn on_disconnect(&mut self, _id: ClientId) -> Vec<(ClientId, SendLoginPacket)> { Vec::new() } } @@ -141,6 +141,7 @@ impl ServerState for LoginServerState { mod test { use std::time::SystemTime; use super::*; + use crate::entity::account::{UserAccountId}; const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login { tag: 65536, diff --git a/src/main.rs b/src/main.rs index 4e06152..eefe8be 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,7 @@ fn main() { let mut entity_gateway = InMemoryGateway::new(); for i in 0..5 { - let mut fake_user = NewUserAccountEntity { + let fake_user = NewUserAccountEntity { username: if i == 0 { "hi".to_string() } else { format!("hi{}", i+1) }, password: bcrypt::hash("qwer", 5).unwrap(), guildcard: i + 1, @@ -103,7 +103,7 @@ fn main() { } async_std::task::block_on(async move { - let thread_entity_gateway = entity_gateway.clone(); + // let thread_entity_gateway = entity_gateway.clone(); let patch = async_std::task::spawn(async { info!("[patch] starting server"); let patch_config = load_config(); diff --git a/src/patch/patch.rs b/src/patch/patch.rs index a48faa7..a5603c8 100644 --- a/src/patch/patch.rs +++ b/src/patch/patch.rs @@ -201,7 +201,7 @@ impl ServerState for PatchServerState { }) } - fn on_disconnect(&mut self, id: ClientId) -> Vec<(ClientId, SendPatchPacket)> { + fn on_disconnect(&mut self, _id: ClientId) -> Vec<(ClientId, SendPatchPacket)> { Vec::new() } } @@ -305,7 +305,7 @@ impl SendFileIterator { patch_file_lookup: state.patch_file_lookup.clone(), file_iter: Box::new(state.patch_file_tree.flatten().into_iter().filter(move |file| { match file { - PatchTreeIterItem::File(path, id) => { + PatchTreeIterItem::File(_path, id) => { file_ids_to_update.contains(&id) }, _ => true, diff --git a/src/ship/drops/box_drop_table.rs b/src/ship/drops/box_drop_table.rs index f78acdb..f2cf562 100644 --- a/src/ship/drops/box_drop_table.rs +++ b/src/ship/drops/box_drop_table.rs @@ -1,14 +1,15 @@ -use std::collections::HashMap; -use rand::{Rng, SeedableRng}; +#![allow(dead_code, unused_variables)] +// use std::collections::HashMap; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use serde::{Serialize, Deserialize}; -use crate::entity::item::weapon::{Weapon, WeaponType}; -use crate::entity::item::armor::{Armor, ArmorType}; -use crate::entity::item::shield::{Shield, ShieldType}; -use crate::entity::item::unit::{Unit, UnitType}; -use crate::entity::item::tool::{Tool, ToolType}; +// use crate::entity::item::weapon::{Weapon, WeaponType}; +// use crate::entity::item::armor::{Armor, ArmorType}; +// use crate::entity::item::shield::{Shield, ShieldType}; +// use crate::entity::item::unit::{Unit, UnitType}; +// use crate::entity::item::tool::{Tool, ToolType}; use crate::entity::character::SectionID; -use crate::ship::monster::MonsterType; +// use crate::ship::monster::MonsterType; use crate::ship::room::{Difficulty, Episode}; use crate::ship::map::MapArea; use crate::ship::drops::{ItemDropType, load_data_file}; @@ -236,6 +237,7 @@ impl BoxDropTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_box_drops() { diff --git a/src/ship/drops/generic_armor.rs b/src/ship/drops/generic_armor.rs index c9f6468..2bf5895 100644 --- a/src/ship/drops/generic_armor.rs +++ b/src/ship/drops/generic_armor.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use crate::entity::item::armor::{ArmorType, Armor}; @@ -79,7 +79,7 @@ impl GenericArmorTable { } } - pub fn slots(&self, area_map: &MapArea, rng: &mut R) -> usize { + pub fn slots(&self, _area_map: &MapArea, rng: &mut R) -> usize { let slot_weights = WeightedIndex::new(&[self.slot_rates.slot0, self.slot_rates.slot1, self.slot_rates.slot2, self.slot_rates.slot3, self.slot_rates.slot4]).unwrap(); slot_weights.sample(rng) @@ -115,6 +115,7 @@ impl GenericArmorTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_armor_generation() { let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]); diff --git a/src/ship/drops/generic_shield.rs b/src/ship/drops/generic_shield.rs index d0edfd9..9eec585 100644 --- a/src/ship/drops/generic_shield.rs +++ b/src/ship/drops/generic_shield.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use crate::entity::item::shield::{ShieldType, Shield}; @@ -94,6 +94,7 @@ impl GenericShieldTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_shield_generation() { let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]); diff --git a/src/ship/drops/generic_unit.rs b/src/ship/drops/generic_unit.rs index 1f432f8..0aaa13d 100644 --- a/src/ship/drops/generic_unit.rs +++ b/src/ship/drops/generic_unit.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; -use rand::distributions::{WeightedIndex, Distribution}; +use rand::{Rng}; +// use rand::distributions::{WeightedIndex, Distribution}; use rand::seq::IteratorRandom; use crate::entity::item::unit::{UnitType, Unit, UnitModifier}; @@ -99,6 +99,7 @@ impl GenericUnitTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_unit_drops() { let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]); diff --git a/src/ship/drops/generic_weapon.rs b/src/ship/drops/generic_weapon.rs index 761d329..6d04447 100644 --- a/src/ship/drops/generic_weapon.rs +++ b/src/ship/drops/generic_weapon.rs @@ -1,12 +1,11 @@ use std::collections::{HashMap, BTreeMap}; -use std::io::Read; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use rand::seq::SliceRandom; use crate::entity::item::weapon::{Weapon, WeaponType, Attribute, WeaponAttribute, WeaponSpecial}; -use crate::ship::monster::MonsterType; +// use crate::ship::monster::MonsterType; use crate::ship::room::{Difficulty, Episode}; use crate::ship::map::MapArea; use crate::entity::character::SectionID; @@ -458,7 +457,7 @@ impl GenericWeaponTable { valid_weapons } - fn weapon_type(&self, possible_weapon_types: &BTreeMap, map_area: &MapArea, rng: &mut R) -> WeaponDropType { + fn weapon_type(&self, possible_weapon_types: &BTreeMap, _map_area: &MapArea, rng: &mut R) -> WeaponDropType { let mut weapon_rates = possible_weapon_types.iter() .map(|(weapon, stat)| { (weapon, stat.rate) @@ -470,7 +469,7 @@ impl GenericWeaponTable { fn weapon_rank(&self, ratio: &WeaponRatio, map_area: &MapArea) -> u32 { let (area, rank) = self.area_rank(ratio, map_area); - let weapon_rank = (rank + area / ratio.inc); + let weapon_rank = rank + area / ratio.inc; std::cmp::max(weapon_rank, 0) } @@ -514,6 +513,7 @@ impl GenericWeaponTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_weapon_generation() { let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]); diff --git a/src/ship/drops/mod.rs b/src/ship/drops/mod.rs index 65aa1e2..05f966c 100644 --- a/src/ship/drops/mod.rs +++ b/src/ship/drops/mod.rs @@ -1,3 +1,4 @@ +#![allow(dead_code, unused_must_use)] // TODO: there is some structure duplication that occurs here: // the rare and box tables instantiate their own copies of the // generic drop tables as they need them to apply their modifiers diff --git a/src/ship/drops/tech_table.rs b/src/ship/drops/tech_table.rs index f576598..6e6396f 100644 --- a/src/ship/drops/tech_table.rs +++ b/src/ship/drops/tech_table.rs @@ -1,7 +1,6 @@ -use std::collections::{HashMap, BTreeMap}; -use std::io::Read; +use std::collections::{BTreeMap}; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use crate::entity::item::tech::{Technique, TechniqueDisk}; @@ -113,6 +112,7 @@ impl TechniqueTable { #[cfg(test)] mod test { use super::*; + use rand::{SeedableRng}; #[test] fn test_tech_drops() { let mut rng = rand_chacha::ChaCha20Rng::from_seed([23;32]); diff --git a/src/ship/drops/tool_table.rs b/src/ship/drops/tool_table.rs index d20d9da..69a14cd 100644 --- a/src/ship/drops/tool_table.rs +++ b/src/ship/drops/tool_table.rs @@ -1,7 +1,6 @@ -use std::collections::{HashMap, BTreeMap}; -use std::io::Read; +use std::collections::{BTreeMap}; use serde::{Serialize, Deserialize}; -use rand::{Rng, SeedableRng}; +use rand::{Rng}; use rand::distributions::{WeightedIndex, Distribution}; use crate::entity::item::tool::{Tool, ToolType}; diff --git a/src/ship/item_stats.rs b/src/ship/item_stats.rs index e6f2ec4..998ff70 100644 --- a/src/ship/item_stats.rs +++ b/src/ship/item_stats.rs @@ -1,3 +1,4 @@ +#![allow(dead_code, unused_must_use)] use std::collections::{HashMap, BTreeMap}; use serde::{Serialize, Deserialize}; use std::fs::File; diff --git a/src/ship/items.rs b/src/ship/items.rs index a00a1b1..53a0257 100644 --- a/src/ship/items.rs +++ b/src/ship/items.rs @@ -1,16 +1,9 @@ +#![allow(dead_code)] use std::collections::HashMap; - use libpso::character::character::InventoryItem; - use crate::entity::gateway::EntityGateway; use crate::entity::character::CharacterEntity; -use crate::entity::item::{ItemEntity, ItemId, ItemDetail, ItemLocation}; -use crate::entity::item::weapon::Weapon; -use crate::entity::item::armor::Armor; -use crate::entity::item::shield::Shield; -use crate::entity::item::unit::Unit; -use crate::entity::item::tool::Tool; -use crate::entity::item::mag::Mag; +use crate::entity::item::{ItemEntity, ItemDetail, ItemLocation}; use crate::entity::item::{Meseta, NewItemEntity}; use crate::ship::map::MapArea; use crate::ship::drops::{ItemDrop, ItemDropType}; @@ -97,13 +90,13 @@ fn inventory_item_index(item: &ItemInstance) -> usize { match item { ItemInstance::Individual(i) => { match i.location { - ItemLocation::Inventory{index: index, ..} => index, + ItemLocation::Inventory{index, ..} => index, _ => panic!() } }, ItemInstance::Stacked(i) => { match i[0].location { - ItemLocation::Inventory{index: index, ..} => index, + ItemLocation::Inventory{index, ..} => index, _ => panic!() } }, @@ -127,7 +120,7 @@ fn stack_items(items: Vec) -> Vec { } stacks.into_iter() - .map(|(itype, items)| { + .map(|(_, items)| { match items[0].item.is_stackable() { true => { vec![ItemInstance::Stacked(items)] @@ -233,6 +226,7 @@ mod test { use crate::entity::character::CharacterEntityId; use crate::entity::item; use crate::entity::item::{ItemEntity, ItemDetail, ItemEntityId, ItemLocation}; + use crate::entity::item::tool::Tool; #[test] fn test_stack_items() { let item1 = ItemEntity { diff --git a/src/ship/location.rs b/src/ship/location.rs index 08af31f..44cf113 100644 --- a/src/ship/location.rs +++ b/src/ship/location.rs @@ -1,6 +1,5 @@ +#![allow(dead_code, unused_must_use)] use std::collections::HashMap; -use std::sync::{Arc, RwLock}; -use std::convert::Into; use std::time::SystemTime; use thiserror::Error; use crate::common::serverstate::ClientId; @@ -181,7 +180,7 @@ impl ClientLocation { .nth(0) .ok_or(CreateRoomError::NoOpenSlots)?; *empty_slot = Some(Room([None; 4])); - self.add_client_to_room(id, RoomId(index)).map_err(|err| CreateRoomError::JoinError)?; + self.add_client_to_room(id, RoomId(index)).map_err(|_err| CreateRoomError::JoinError)?; Ok(RoomId(index)) } diff --git a/src/ship/map.rs b/src/ship/map.rs index 8d8375c..c4c8ac2 100644 --- a/src/ship/map.rs +++ b/src/ship/map.rs @@ -1,5 +1,4 @@ -use log::warn; -use std::io::Cursor; +#![allow(dead_code)] use std::convert::Into; use std::path::PathBuf; use std::io::{Read}; @@ -150,9 +149,9 @@ impl MapEnemy { (RawMapEnemy {id: 221, skin: 1, ..}, _) => MonsterType::Dolmolm, (RawMapEnemy {id: 222, ..}, _) => MonsterType::Morfos, (RawMapEnemy {id: 223, ..}, _) => MonsterType::Recobox, - (RawMapEnemy {id: 224, ..}, _) => MonsterType::Epsilon, (RawMapEnemy {id: 224, skin: 0, ..}, _) => MonsterType::SinowZoa, (RawMapEnemy {id: 224, skin: 1, ..}, _) => MonsterType::SinowZele, + (RawMapEnemy {id: 224, ..}, _) => MonsterType::Epsilon, (RawMapEnemy {id: 225, ..}, _) => MonsterType::IllGill, (RawMapEnemy {id: 272, ..}, _) => MonsterType::Astark, (RawMapEnemy {id: 273, field2: 0, ..}, _) => MonsterType::SatelliteLizard, @@ -665,7 +664,7 @@ impl Maps { _ => panic!() }; - let mut maps = Maps { + let maps = Maps { enemy_data: map_variants.iter().fold(Vec::new(), |mut enemy_data, map_variant| { enemy_data.append(&mut enemy_data_from_map_data(&map_variant, &episode)); enemy_data diff --git a/src/ship/monster.rs b/src/ship/monster.rs index 1d089d8..a474d01 100644 --- a/src/ship/monster.rs +++ b/src/ship/monster.rs @@ -1,4 +1,4 @@ -use std::convert::TryFrom; +#![allow(dead_code)] use serde::{Serialize, Deserialize}; diff --git a/src/ship/packet/builder/lobby.rs b/src/ship/packet/builder/lobby.rs index 84f1d14..dadaf09 100644 --- a/src/ship/packet/builder/lobby.rs +++ b/src/ship/packet/builder/lobby.rs @@ -1,15 +1,9 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, AreaClient, ClientLocationError}; -use crate::entity::character::CharacterEntity; -use crate::ship::items::ActiveInventory; -use crate::ship::packet::builder::{player_header, player_info}; -use libpso::character::character::{Inventory, InventoryItem}; -use libpso::utf8_to_utf16_array; +use crate::ship::ship::{ShipError, Clients}; +use crate::ship::location::{ClientLocation, LobbyId, ClientLocationError}; +use crate::ship::packet::builder::{player_info}; pub fn join_lobby(id: ClientId, diff --git a/src/ship/packet/builder/message.rs b/src/ship/packet/builder/message.rs index e724fc0..f588c28 100644 --- a/src/ship/packet/builder/message.rs +++ b/src/ship/packet/builder/message.rs @@ -1,17 +1,7 @@ -use std::collections::HashMap; -use libpso::packet::ship::*; use libpso::packet::messages::*; -use crate::common::serverstate::ClientId; -use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, AreaClient, ClientLocationError}; -use crate::entity::character::CharacterEntity; -use crate::ship::items::{ActiveInventory, ActiveItemOnFloor}; -use crate::ship::packet::builder::{player_header, player_info}; +use crate::ship::ship::{ShipError}; +use crate::ship::items::{ActiveItemOnFloor}; use std::convert::TryInto; -use libpso::character::character::{Inventory, InventoryItem}; -use libpso::utf8_to_utf16_array; pub fn item_drop(client: u8, target: u8, item_drop: &ActiveItemOnFloor) -> Result { diff --git a/src/ship/packet/builder/mod.rs b/src/ship/packet/builder/mod.rs index 2e8866e..83c6d2a 100644 --- a/src/ship/packet/builder/mod.rs +++ b/src/ship/packet/builder/mod.rs @@ -4,7 +4,6 @@ pub mod room; use libpso::character::character::Inventory; use libpso::packet::ship::{PlayerHeader, PlayerInfo}; -use libpso::utf8_to_utf16_array; use crate::common::leveltable::CharacterLevelTable; use crate::ship::character::CharacterBytesBuilder; use crate::ship::ship::ClientState; diff --git a/src/ship/packet/builder/room.rs b/src/ship/packet/builder/room.rs index ba45824..32716df 100644 --- a/src/ship/packet/builder/room.rs +++ b/src/ship/packet/builder/room.rs @@ -1,16 +1,10 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; +use crate::ship::ship::{ShipError, ClientState, Clients}; use crate::ship::location::{ClientLocation, RoomId, AreaClient, ClientLocationError}; -use crate::entity::character::CharacterEntity; -use crate::ship::items::ActiveInventory; use crate::ship::room::RoomState; use crate::ship::packet::builder::{player_header, player_info}; -use libpso::character::character::{Inventory, InventoryItem}; -use libpso::utf8_to_utf16_array; pub fn join_room(id: ClientId, clients: &Clients, @@ -53,12 +47,12 @@ pub fn join_room(id: ClientId, } -pub fn add_to_room(id: ClientId, +pub fn add_to_room(_id: ClientId, client: &ClientState, area_client: &AreaClient, leader: &AreaClient, level_table: &CharacterLevelTable, - room_id: RoomId, + _room_id: RoomId, ) -> Result { diff --git a/src/ship/packet/handler/auth.rs b/src/ship/packet/handler/auth.rs index 4b61d6b..0aae3c4 100644 --- a/src/ship/packet/handler/auth.rs +++ b/src/ship/packet/handler/auth.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session}; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; diff --git a/src/ship/packet/handler/communication.rs b/src/ship/packet/handler/communication.rs index e2c84aa..57e519d 100644 --- a/src/ship/packet/handler/communication.rs +++ b/src/ship/packet/handler/communication.rs @@ -1,11 +1,7 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; -use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS}; -use libpso::character::character; +use crate::ship::ship::{SendShipPacket, ShipError, Clients}; +use crate::ship::location::{ClientLocation}; use crate::entity::gateway::EntityGateway; pub fn player_chat(id: ClientId, @@ -22,7 +18,7 @@ pub fn player_chat(id: ClientId, } pub fn request_infoboard(id: ClientId, - request_infoboard: &ViewInfoboardRequest, + _request_infoboard: &ViewInfoboardRequest, client_location: &ClientLocation, clients: &Clients) -> Box + Send> { diff --git a/src/ship/packet/handler/direct_message.rs b/src/ship/packet/handler/direct_message.rs index 03855cb..a292618 100644 --- a/src/ship/packet/handler/direct_message.rs +++ b/src/ship/packet/handler/direct_message.rs @@ -1,18 +1,13 @@ -use std::collections::HashMap; use log::warn; use libpso::packet::ship::*; use libpso::packet::messages::*; use crate::common::serverstate::ClientId; -use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients, Rooms}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS, ClientLocationError}; -use crate::ship::room::RoomState; -use crate::ship::drops::{ItemDrop, ItemDropType}; +use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms}; +use crate::ship::location::{ClientLocation, ClientLocationError}; +use crate::ship::drops::{ItemDrop}; use crate::ship::items::ActiveItemDatabase; -use libpso::character::character; use crate::entity::gateway::EntityGateway; -use libpso::{utf8_to_array, utf8_to_utf16_array}; +use libpso::{utf8_to_utf16_array}; use crate::ship::packet::builder; fn send_to_client(id: ClientId, target: u8, msg: DirectMessage, client_location: &ClientLocation) @@ -59,7 +54,7 @@ pub fn request_item(id: ClientId, -> Result + Send>, ShipError> where EG: EntityGateway { let room_id = client_location.get_room(id).map_err(|err| -> ClientLocationError { err.into() })?; - let mut room = rooms.get_mut(room_id.0) + let room = rooms.get_mut(room_id.0) .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))? .as_mut() .ok_or_else(|| ShipError::InvalidRoom(room_id.0 as u32))?; @@ -69,7 +64,7 @@ where EG: EntityGateway { return Err(ShipError::MonsterAlreadyDroppedItem(id, request_item.enemy_id)) } - let area_client = client_location.get_local_client(id).map_err(|err| -> ClientLocationError { err.into() })?; + let _area_client = client_location.get_local_client(id).map_err(|err| -> ClientLocationError { err.into() })?; let clients_in_area = client_location.get_clients_in_room(room_id).map_err(|err| -> ClientLocationError { err.into() })?; let item_drop_packets = clients_in_area.into_iter() @@ -89,7 +84,7 @@ where EG: EntityGateway { }; let activated_item = active_items.activate_item_drop(entity_gateway, item_drop)?; - let mut client = clients.get_mut(&area_client.client).ok_or(ShipError::ClientNotFound(area_client.client))?; + let client = clients.get_mut(&area_client.client).ok_or(ShipError::ClientNotFound(area_client.client))?; let item_drop_msg = builder::message::item_drop(request_item.client, request_item.target, &activated_item)?; client.floor_items.push(activated_item); Ok((area_client.client, SendShipPacket::Message(Message::new(GameMessage::ItemDrop(item_drop_msg))))) diff --git a/src/ship/packet/handler/lobby.rs b/src/ship/packet/handler/lobby.rs index 25066ea..e488695 100644 --- a/src/ship/packet/handler/lobby.rs +++ b/src/ship/packet/handler/lobby.rs @@ -1,13 +1,10 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients, Rooms}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS, ClientLocationError}; +use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms}; +use crate::ship::character::{FullCharacterBytesBuilder}; +use crate::ship::location::{ClientLocation, LobbyId, RoomLobby, ClientLocationError}; use crate::ship::packet; -use libpso::character::character; -use crate::ship::location::ClientLocationError::GetAreaError; // this function needs a better home pub fn block_selected(id: ClientId, diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index d597768..003ac3e 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -1,14 +1,8 @@ -use std::collections::HashMap; use log::warn; -use libpso::packet::ship::*; use libpso::packet::messages::*; use crate::common::serverstate::ClientId; -use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Rooms}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS}; -use libpso::character::character; -use crate::entity::gateway::EntityGateway; +use crate::ship::ship::{SendShipPacket, Rooms}; +use crate::ship::location::{ClientLocation, RoomLobby}; pub fn request_exp(id: ClientId, request_exp: &RequestExp, diff --git a/src/ship/packet/handler/room.rs b/src/ship/packet/handler/room.rs index 11503a6..04d439e 100644 --- a/src/ship/packet/handler/room.rs +++ b/src/ship/packet/handler/room.rs @@ -1,12 +1,9 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Rooms, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS, ClientLocationError}; +use crate::ship::ship::{SendShipPacket, ShipError, Rooms, Clients}; +use crate::ship::location::{ClientLocation, RoomId, RoomLobby, ClientLocationError}; use crate::ship::packet::builder; -use libpso::character::character; use crate::ship::room; pub fn create_room(id: ClientId, diff --git a/src/ship/packet/handler/settings.rs b/src/ship/packet/handler/settings.rs index 93ed14a..4d69e70 100644 --- a/src/ship/packet/handler/settings.rs +++ b/src/ship/packet/handler/settings.rs @@ -1,11 +1,6 @@ -use std::collections::HashMap; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; -use crate::common::leveltable::CharacterLevelTable; -use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS}; -use libpso::character::character; +use crate::ship::ship::{SendShipPacket, ShipError, Clients}; use crate::entity::gateway::EntityGateway; pub fn update_config(id: ClientId, diff --git a/src/ship/room.rs b/src/ship/room.rs index 66c7830..516c9d7 100644 --- a/src/ship/room.rs +++ b/src/ship/room.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] use std::convert::{From, Into, TryFrom, TryInto}; use rand::Rng; diff --git a/src/ship/ship.rs b/src/ship/ship.rs index d646ac5..71ebbf5 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -1,28 +1,28 @@ +#![allow(dead_code, unused_must_use)] use std::collections::HashMap; -use log::warn; use rand::Rng; use thiserror::Error; use libpso::packet::ship::*; -use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session}; +use libpso::packet::login::{Login, LoginResponse, Session}; use libpso::packet::messages::*; use libpso::{PacketParseError, PSOPacket}; use libpso::crypto::bb::PSOBBCipher; -use libpso::character::character; + use libpso::packet::ship::{BLOCK_MENU_ID, ROOM_MENU_ID}; -use libpso::{utf8_to_array, utf8_to_utf16_array}; + use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; use crate::common::leveltable::CharacterLevelTable; use crate::entity::gateway::EntityGateway; -use crate::entity::account::{UserAccountEntity, UserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM}; +use crate::entity::account::{UserAccountEntity, UserSettingsEntity}; use crate::entity::character::CharacterEntity; -use crate::entity::item::{ItemLocation, ItemEntity}; -use crate::ship::location::{ClientLocation, LobbyId, RoomId, RoomLobby, MAX_ROOMS, ClientLocationError}; -use crate::ship::character::{CharacterBytesBuilder, FullCharacterBytesBuilder}; + +use crate::ship::location::{ClientLocation, RoomLobby, MAX_ROOMS, ClientLocationError}; + use crate::ship::items; use crate::ship::room; use crate::ship::map::MapsError; @@ -243,7 +243,7 @@ impl ServerState for ShipServerState { type RecvPacket = RecvShipPacket; type PacketError = ShipError; - fn on_connect(&mut self, id: ClientId) -> Vec> { + fn on_connect(&mut self, _id: ClientId) -> Vec> { let mut rng = rand::thread_rng(); let mut server_key = [0u8; 48];