Merge pull request 'cleanup_warnings' (#141) from cleanup_warnings into master
This commit is contained in:
commit
cb758b3b85
@ -1,8 +1,7 @@
|
||||
#![allow(dead_code)]
|
||||
use log::{trace, info, warn};
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
use async_std::io::{Read, Write};
|
||||
use async_std::io::prelude::{ReadExt, WriteExt};
|
||||
use async_std::prelude::{StreamExt};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use libpso::crypto::{PSOCipher, NullCipher, CipherError};
|
||||
@ -266,7 +265,7 @@ async fn client_send_loop<S>(client_id: ClientId,
|
||||
}
|
||||
|
||||
|
||||
pub async fn mainloop_async<STATE, S, R, E>(mut state: STATE, port: u16) where
|
||||
pub async fn mainloop_async<STATE, S, R, E>(state: STATE, port: u16) where
|
||||
STATE: ServerState<SendPacket=S, RecvPacket=R, PacketError=E> + Send + 'static,
|
||||
S: SendServerPacket + std::fmt::Debug + Send + Sync + 'static,
|
||||
R: RecvServerPacket + std::fmt::Debug + Send + Sync + 'static,
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
use std::time::SystemTime;
|
||||
|
||||
use libpso::character::settings;
|
||||
|
@ -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};
|
||||
|
@ -2,8 +2,6 @@ use crate::entity::account::*;
|
||||
use crate::entity::character::*;
|
||||
use crate::entity::item::*;
|
||||
|
||||
use libpso::item;
|
||||
|
||||
pub trait EntityGateway {
|
||||
fn create_user(&mut self, _user: NewUserAccountEntity) -> Option<UserAccountEntity> {
|
||||
unimplemented!()
|
||||
|
@ -1,14 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
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 std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
pub mod weapon;
|
||||
pub mod armor;
|
||||
pub mod shield;
|
||||
|
@ -388,7 +388,6 @@ impl ToolType {
|
||||
ToolType::TeamPoints1000 => [0x03, 0x19, 0x01],
|
||||
ToolType::TeamPoints5000 => [0x03, 0x19, 0x02],
|
||||
ToolType::TeamPoints10000 => [0x03, 0x19, 0x03],
|
||||
_ => panic!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<EG: EntityGateway> CharacterServerState<EG> {
|
||||
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<EG: EntityGateway> ServerState for CharacterServerState<EG> {
|
||||
})
|
||||
}
|
||||
|
||||
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::<Vec<_>>();
|
||||
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::<Vec<_>>();
|
||||
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());
|
||||
}
|
||||
|
@ -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<EG: EntityGateway> ServerState for LoginServerState<EG> {
|
||||
})
|
||||
}
|
||||
|
||||
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<EG: EntityGateway> ServerState for LoginServerState<EG> {
|
||||
mod test {
|
||||
use std::time::SystemTime;
|
||||
use super::*;
|
||||
use crate::entity::account::{UserAccountId};
|
||||
|
||||
const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login {
|
||||
tag: 65536,
|
||||
|
@ -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,6 @@ fn main() {
|
||||
}
|
||||
|
||||
async_std::task::block_on(async move {
|
||||
let thread_entity_gateway = entity_gateway.clone();
|
||||
let patch = async_std::task::spawn(async {
|
||||
info!("[patch] starting server");
|
||||
let patch_config = load_config();
|
||||
|
@ -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,
|
||||
|
@ -1,14 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use rand::{Rng, SeedableRng};
|
||||
#![allow(dead_code, unused_variables)]
|
||||
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::character::SectionID;
|
||||
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 +230,7 @@ impl BoxDropTable {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use rand::{SeedableRng};
|
||||
|
||||
#[test]
|
||||
fn test_box_drops() {
|
||||
|
@ -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<R: Rng>(&self, area_map: &MapArea, rng: &mut R) -> usize {
|
||||
pub fn slots<R: Rng>(&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]);
|
||||
|
@ -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]);
|
||||
|
@ -1,7 +1,6 @@
|
||||
use std::collections::BTreeMap;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand::distributions::{WeightedIndex, Distribution};
|
||||
use rand::{Rng};
|
||||
use rand::seq::IteratorRandom;
|
||||
|
||||
use crate::entity::item::unit::{UnitType, Unit, UnitModifier};
|
||||
@ -99,6 +98,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]);
|
||||
|
@ -1,12 +1,10 @@
|
||||
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::room::{Difficulty, Episode};
|
||||
use crate::ship::map::MapArea;
|
||||
use crate::entity::character::SectionID;
|
||||
@ -458,7 +456,7 @@ impl GenericWeaponTable {
|
||||
valid_weapons
|
||||
}
|
||||
|
||||
fn weapon_type<R: Rng>(&self, possible_weapon_types: &BTreeMap<WeaponDropType, WeaponRatio>, map_area: &MapArea, rng: &mut R) -> WeaponDropType {
|
||||
fn weapon_type<R: Rng>(&self, possible_weapon_types: &BTreeMap<WeaponDropType, WeaponRatio>, _map_area: &MapArea, rng: &mut R) -> WeaponDropType {
|
||||
let mut weapon_rates = possible_weapon_types.iter()
|
||||
.map(|(weapon, stat)| {
|
||||
(weapon, stat.rate)
|
||||
@ -470,7 +468,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 +512,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]);
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -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};
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(dead_code, unused_must_use)]
|
||||
use std::collections::{HashMap, BTreeMap};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::fs::File;
|
||||
|
@ -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<ItemEntity>) -> Vec<ItemInstance> {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::convert::TryFrom;
|
||||
#![allow(dead_code)]
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<ItemDrop, ShipError> {
|
||||
|
@ -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;
|
||||
|
@ -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<AddToRoom, ShipError> {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,6 @@ pub fn player_chat(id: ClientId,
|
||||
}
|
||||
|
||||
pub fn request_infoboard(id: ClientId,
|
||||
request_infoboard: &ViewInfoboardRequest,
|
||||
client_location: &ClientLocation,
|
||||
clients: &Clients)
|
||||
-> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
||||
|
@ -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<EG>(id: ClientId,
|
||||
-> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + 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)))))
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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<EG: EntityGateway>(id: ClientId,
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
use std::convert::{From, Into, TryFrom, TryInto};
|
||||
|
||||
use rand::Rng;
|
||||
|
@ -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<EG: EntityGateway> ServerState for ShipServerState<EG> {
|
||||
type RecvPacket = RecvShipPacket;
|
||||
type PacketError = ShipError;
|
||||
|
||||
fn on_connect(&mut self, id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
|
||||
fn on_connect(&mut self, _id: ClientId) -> Vec<OnConnect<Self::SendPacket>> {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let mut server_key = [0u8; 48];
|
||||
@ -305,8 +305,8 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> {
|
||||
RecvShipPacket::UpdateConfig(pkt) => {
|
||||
handler::settings::update_config(id, pkt, &mut self.clients, &mut self.entity_gateway)
|
||||
},
|
||||
RecvShipPacket::ViewInfoboardRequest(pkt) => {
|
||||
handler::communication::request_infoboard(id, pkt, &self.client_location, &self.clients)
|
||||
RecvShipPacket::ViewInfoboardRequest(_pkt) => {
|
||||
handler::communication::request_infoboard(id, &self.client_location, &self.clients)
|
||||
},
|
||||
RecvShipPacket::WriteInfoboard(pkt) => {
|
||||
handler::communication::write_infoboard(id, pkt, &mut self.clients, &mut self.entity_gateway)
|
||||
|
Loading…
x
Reference in New Issue
Block a user