Browse Source

clean up last of normal warnings

pull/42/head
jake 3 years ago
parent
commit
1b506e014f
  1. 2
      src/common/leveltable.rs
  2. 4
      src/common/mainloop/client.rs
  3. 2
      src/common/mainloop/interserver.rs
  4. 6
      src/entity/account.rs
  5. 2
      src/entity/gateway/postgres/models.rs
  6. 11
      src/entity/gateway/postgres/postgres.rs
  7. 6
      src/entity/item/esweapon.rs
  8. 8
      src/entity/item/mag.rs
  9. 38
      src/entity/item/weapon.rs
  10. 14
      src/login/character.rs
  11. 4
      src/login/login.rs
  12. 12
      src/patch/patch.rs
  13. 4
      src/ship/character.rs
  14. 10
      src/ship/drops/generic_weapon.rs
  15. 12
      src/ship/drops/rare_drop_table.rs
  16. 8
      src/ship/items/bank.rs
  17. 4
      src/ship/items/floor.rs
  18. 18
      src/ship/items/inventory.rs
  19. 45
      src/ship/items/manager.rs
  20. 6
      src/ship/map/enemy.rs
  21. 2
      src/ship/map/maps.rs
  22. 2
      src/ship/map/object.rs
  23. 16
      src/ship/map/variant.rs
  24. 12
      src/ship/packet/builder/message.rs
  25. 4
      src/ship/packet/builder/mod.rs
  26. 6
      src/ship/packet/builder/quest.rs
  27. 2
      src/ship/packet/builder/room.rs
  28. 9
      src/ship/packet/builder/ship.rs
  29. 2
      src/ship/packet/handler/auth.rs
  30. 3
      src/ship/packet/handler/message.rs
  31. 16
      src/ship/quests.rs
  32. 2
      src/ship/room.rs
  33. 2
      src/ship/shops/tool.rs
  34. 14
      src/ship/shops/weapon.rs

2
src/common/leveltable.rs

@ -71,7 +71,7 @@ impl Default for CharacterLevelTable {
} }
CharacterLevelTable { CharacterLevelTable {
table: table,
table,
} }
} }
} }

4
src/common/mainloop/client.rs

@ -49,8 +49,8 @@ struct PacketReceiver {
impl PacketReceiver { impl PacketReceiver {
fn new(socket: Arc<async_std::net::TcpStream>, cipher: Arc<Mutex<Box<dyn PSOCipher + Send>>>) -> PacketReceiver { fn new(socket: Arc<async_std::net::TcpStream>, cipher: Arc<Mutex<Box<dyn PSOCipher + Send>>>) -> PacketReceiver {
PacketReceiver { PacketReceiver {
socket: socket,
cipher: cipher,
socket,
cipher,
recv_buffer: Vec::new(), recv_buffer: Vec::new(),
incoming_data: Vec::new(), incoming_data: Vec::new(),
} }

2
src/common/mainloop/interserver.rs

@ -29,7 +29,7 @@ struct MessageReceiver {
impl MessageReceiver { impl MessageReceiver {
fn new(socket: async_std::net::TcpStream) -> MessageReceiver { fn new(socket: async_std::net::TcpStream) -> MessageReceiver {
MessageReceiver { MessageReceiver {
socket: socket,
socket,
} }
} }

6
src/entity/account.rs

@ -75,7 +75,7 @@ pub struct NewUserSettingsEntity {
impl NewUserSettingsEntity { impl NewUserSettingsEntity {
pub fn new(user_id: UserAccountId) -> NewUserSettingsEntity { pub fn new(user_id: UserAccountId) -> NewUserSettingsEntity {
NewUserSettingsEntity { NewUserSettingsEntity {
user_id: user_id,
user_id,
settings: settings::UserSettings::default(), settings: settings::UserSettings::default(),
} }
} }
@ -98,7 +98,7 @@ pub struct NewGuildCardDataEntity {
impl NewGuildCardDataEntity { impl NewGuildCardDataEntity {
pub fn new(user_id: UserAccountId) -> NewGuildCardDataEntity { pub fn new(user_id: UserAccountId) -> NewGuildCardDataEntity {
NewGuildCardDataEntity { NewGuildCardDataEntity {
user_id: user_id,
user_id,
guildcard: guildcard::GuildCardData::default(), guildcard: guildcard::GuildCardData::default(),
} }
} }
@ -116,7 +116,7 @@ impl GuildCardDataEntity {
pub fn new(user_id: UserAccountId) -> GuildCardDataEntity { pub fn new(user_id: UserAccountId) -> GuildCardDataEntity {
GuildCardDataEntity { GuildCardDataEntity {
id: GuildCardDataId(0), id: GuildCardDataId(0),
user_id: user_id,
user_id,
guildcard: guildcard::GuildCardData::default(), guildcard: guildcard::GuildCardData::default(),
} }
} }

2
src/entity/gateway/postgres/models.rs

@ -314,7 +314,7 @@ impl From<PgWeapon> for weapon::Weapon {
weapon: other.weapon, weapon: other.weapon,
special: other.special, special: other.special,
grind: other.grind, grind: other.grind,
attrs: attrs,
attrs,
tekked: other.tekked, tekked: other.tekked,
} }
} }

11
src/entity/gateway/postgres/postgres.rs

@ -1,5 +1,4 @@
use std::convert::{From, TryFrom, Into}; use std::convert::{From, TryFrom, Into};
use futures::future::join_all;
use futures::TryStreamExt; use futures::TryStreamExt;
use async_std::stream::StreamExt; use async_std::stream::StreamExt;
use libpso::character::guildcard; use libpso::character::guildcard;
@ -40,7 +39,7 @@ impl PostgresGateway {
}); });
PostgresGateway { PostgresGateway {
pool: pool,
pool,
} }
} }
@ -96,13 +95,13 @@ impl PostgresGateway {
ItemDetail::Mag(mag) ItemDetail::Mag(mag)
}, },
item @ _ => item
item => item
}; };
ItemEntity { ItemEntity {
id: id,
item: item,
location: location
id,
item,
location
} }
} }
} }

6
src/entity/item/esweapon.rs

@ -247,10 +247,10 @@ impl ESWeapon {
let name = ESWeapon::name_from_bytes(&bytes[6..12]); let name = ESWeapon::name_from_bytes(&bytes[6..12]);
ESWeapon { ESWeapon {
esweapon: esweapon,
esweapon,
special: special.ok(), special: special.ok(),
grind: grind,
name: name,
grind,
name,
} }
} }
} }

8
src/entity/item/mag.rs

@ -651,12 +651,12 @@ impl Mag {
Ok(Mag{ Ok(Mag{
mag: m, mag: m,
def: def,
pow: pow,
dex: dex,
def,
pow,
dex,
mnd: mind, mnd: mind,
synchro: sync, synchro: sync,
iq: iq,
iq,
photon_blast: [None, None, None], // TODO: actually get PBs from bytes photon_blast: [None, None, None], // TODO: actually get PBs from bytes
color: data[15] % 18, color: data[15] % 18,
//modifiers: Vec::new(), //modifiers: Vec::new(),

38
src/entity/item/weapon.rs

@ -1536,25 +1536,25 @@ impl Weapon {
// TODO: error handling // TODO: error handling
pub fn from_bytes(data: [u8; 16]) -> Result<Weapon, ItemParseError> { pub fn from_bytes(data: [u8; 16]) -> Result<Weapon, ItemParseError> {
let w = WeaponType::parse_type([data[0], data[1], data[2]]);
if let Ok(w) = w {
let mut s = None;
let mut t = true;
let g = data[3];
let wep = WeaponType::parse_type([data[0], data[1], data[2]]);
if let Ok(weapon) = wep {
let mut special = None;
let mut tekked = true;
let grind = data[3];
if data[4] >= 0x81 && data[4] <= 0xA8 { if data[4] >= 0x81 && data[4] <= 0xA8 {
s = WeaponSpecial::from(data[4] - 0x80);
t = false;
special = WeaponSpecial::from(data[4] - 0x80);
tekked = false;
} }
else if data[4] >= 0x01 && data[4] <= 0x28 { else if data[4] >= 0x01 && data[4] <= 0x28 {
s = WeaponSpecial::from(data[4]);
t = true;
special = WeaponSpecial::from(data[4]);
tekked = true;
} }
// else { // else {
// return Err(ItemParseError::InvalidSpecial) // return Err(ItemParseError::InvalidSpecial)
// } // }
let mut a = [
let mut attrs = [
None, None,
None, None,
None None
@ -1562,26 +1562,22 @@ impl Weapon {
for i in 0..3 { for i in 0..3 {
if data[2 * (3 + i)] >= 1 && data[2 * (3 + i)] <= 5 { if data[2 * (3 + i)] >= 1 && data[2 * (3 + i)] <= 5 {
a[i] = Some(WeaponAttribute{
attrs[i] = Some(WeaponAttribute{
attr: Attribute::from(data[2 * (3 + i)]).unwrap(), attr: Attribute::from(data[2 * (3 + i)]).unwrap(),
value: data[2 * (3 + i) + 1] as i8, value: data[2 * (3 + i) + 1] as i8,
}); });
} else { } else {
a[i] = None;
attrs[i] = None;
// return Err(ItemParseError::InvalidAttribute) // return Err(ItemParseError::InvalidAttribute)
} }
} }
Ok(Weapon { Ok(Weapon {
weapon: w,
special: s,
grind: g,
attrs:[
a[0],
a[1],
a[2],
],
tekked: t,
weapon,
special,
grind,
attrs,
tekked,
}) })
} }
else { else {

14
src/login/character.rs

@ -28,7 +28,7 @@ use crate::entity::item::tool::Tool;
use crate::entity::item::mag::Mag; use crate::entity::item::mag::Mag;
use crate::entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel}; use crate::entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel};
use crate::login::login::{get_login_status, check_if_already_online};
use crate::login::login::{get_login_status};
use crate::common::interserver::AuthToken; use crate::common::interserver::AuthToken;
pub const CHARACTER_PORT: u16 = 12001; pub const CHARACTER_PORT: u16 = 12001;
@ -148,7 +148,7 @@ fn generate_param_data(path: &str) -> (ParamDataHeader, Vec<u8>) {
} }
(ParamDataHeader { (ParamDataHeader {
files: files
files
}, buffer) }, buffer)
} }
@ -301,13 +301,13 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
let (param_header, param_data) = generate_param_data("data/param/"); let (param_header, param_data) = generate_param_data("data/param/");
CharacterServerState { CharacterServerState {
entity_gateway: entity_gateway,
param_header: param_header,
param_data: param_data,
entity_gateway,
param_header,
param_data,
clients: HashMap::new(), clients: HashMap::new(),
ships: BTreeMap::new(), ships: BTreeMap::new(),
level_table: CharacterLevelTable::default(), level_table: CharacterLevelTable::default(),
auth_token: auth_token,
auth_token,
authenticated_ships: BTreeSet::new(), authenticated_ships: BTreeSet::new(),
ship_sender: BTreeMap::new(), ship_sender: BTreeMap::new(),
connected_clients: BTreeMap::new(), connected_clients: BTreeMap::new(),
@ -481,7 +481,7 @@ impl<EG: EntityGateway> CharacterServerState<EG> {
Ok(vec![SendCharacterPacket::ParamDataChunk( Ok(vec![SendCharacterPacket::ParamDataChunk(
Box::new(ParamDataChunk { Box::new(ParamDataChunk {
chunk: chunk as u32, chunk: chunk as u32,
data: data,
data,
}) })
)]) )])
} }

4
src/login/login.rs

@ -101,8 +101,8 @@ pub struct LoginServerState<EG: EntityGateway> {
impl<EG: EntityGateway> LoginServerState<EG> { impl<EG: EntityGateway> LoginServerState<EG> {
pub fn new(entity_gateway: EG, character_server_ip: net::Ipv4Addr) -> LoginServerState<EG> { pub fn new(entity_gateway: EG, character_server_ip: net::Ipv4Addr) -> LoginServerState<EG> {
LoginServerState { LoginServerState {
entity_gateway: entity_gateway,
character_server_ip: character_server_ip,
entity_gateway,
character_server_ip,
clients: HashMap::new(), clients: HashMap::new(),
} }
} }

12
src/patch/patch.rs

@ -146,10 +146,10 @@ pub struct PatchServerState {
impl PatchServerState { impl PatchServerState {
pub fn new(patch_file_tree: PatchFileTree, patch_file_lookup: HashMap<u32, PatchFile>, patch_motd: String) -> PatchServerState { pub fn new(patch_file_tree: PatchFileTree, patch_file_lookup: HashMap<u32, PatchFile>, patch_motd: String) -> PatchServerState {
PatchServerState { PatchServerState {
patch_file_tree: patch_file_tree,
patch_file_lookup: patch_file_lookup,
patch_file_tree,
patch_file_lookup,
patch_file_info: Vec::new(), patch_file_info: Vec::new(),
patch_motd: patch_motd,
patch_motd,
} }
} }
} }
@ -222,9 +222,9 @@ fn load_patch_dir(basedir: &str, patchbase: &str, file_ids: &mut HashMap<u32, Pa
files.push(PatchFileTree::File(patch_path.to_path_buf(), file_ids.len() as u32)); files.push(PatchFileTree::File(patch_path.to_path_buf(), file_ids.len() as u32));
let (checksum, size) = get_checksum_and_size(&path).unwrap(); let (checksum, size) = get_checksum_and_size(&path).unwrap();
file_ids.insert(file_ids.len() as u32, PatchFile { file_ids.insert(file_ids.len() as u32, PatchFile {
path: path,
checksum: checksum,
size: size,
path,
checksum,
size,
}); });
} }
} }

4
src/ship/character.rs

@ -55,7 +55,7 @@ impl<'a> CharacterBytesBuilder<'a> {
dfp: stats.dfp + character.materials.def as u16 * 2, dfp: stats.dfp + character.materials.def as u16 * 2,
ata: stats.ata, ata: stats.ata,
lck: stats.lck + character.materials.luck as u16 * 2, lck: stats.lck + character.materials.luck as u16 * 2,
level: level,
level,
section_id: character.section_id.into(), section_id: character.section_id.into(),
ch_class: character.char_class.into(), ch_class: character.char_class.into(),
costume: character.appearance.costume, costume: character.appearance.costume,
@ -221,7 +221,7 @@ impl<'a> FullCharacterBytesBuilder<'a> {
symbol_chats: *symbol_chat, symbol_chats: *symbol_chat,
tech_menu: *tech_menu, tech_menu: *tech_menu,
bank: bank.as_client_bank_items(), bank: bank.as_client_bank_items(),
option_flags: option_flags,
option_flags,
..character::FullCharacter::default() ..character::FullCharacter::default()
} }
} }

10
src/ship/drops/generic_weapon.rs

@ -232,9 +232,9 @@ impl AttributeTable {
let area_percent_patterns: AreaPercentPatterns = load_data_file(episode, difficulty, section_id, "area_percent_pattern.toml"); let area_percent_patterns: AreaPercentPatterns = load_data_file(episode, difficulty, section_id, "area_percent_pattern.toml");
AttributeTable { AttributeTable {
attribute_rates: attribute_rates,
percent_rates: percent_rates,
area_percent_patterns: area_percent_patterns,
attribute_rates,
percent_rates,
area_percent_patterns,
} }
} }
@ -258,7 +258,7 @@ impl AttributeTable {
let percent = ((value + 1) * 5) as i8; let percent = ((value + 1) * 5) as i8;
Some(WeaponAttribute { Some(WeaponAttribute {
attr: attr,
attr,
value: percent value: percent
}) })
} }
@ -406,7 +406,7 @@ impl GenericWeaponTable {
rank_table.insert(WeaponDropType::Wand, vec![WeaponType::Wand, WeaponType::Staff, WeaponType::Baton, WeaponType::Scepter]); rank_table.insert(WeaponDropType::Wand, vec![WeaponType::Wand, WeaponType::Staff, WeaponType::Baton, WeaponType::Scepter]);
GenericWeaponTable { GenericWeaponTable {
rank_table: rank_table,
rank_table,
weapon_ratio: WeaponRatios::new(episode, difficulty, section_id), weapon_ratio: WeaponRatios::new(episode, difficulty, section_id),
grind_rates: GrindRates::new(episode, difficulty, section_id), grind_rates: GrindRates::new(episode, difficulty, section_id),
attribute_table: AttributeTable::new(episode, difficulty, section_id), attribute_table: AttributeTable::new(episode, difficulty, section_id),

12
src/ship/drops/rare_drop_table.rs

@ -87,7 +87,7 @@ impl RareDropTable {
}).collect(); }).collect();
RareDropTable { RareDropTable {
rates: rates,
rates,
attribute_table: AttributeTable::new(episode, difficulty, section_id), attribute_table: AttributeTable::new(episode, difficulty, section_id),
armor_stats: GenericArmorTable::new(episode, difficulty, section_id), armor_stats: GenericArmorTable::new(episode, difficulty, section_id),
shield_stats: GenericShieldTable::new(episode, difficulty, section_id), shield_stats: GenericShieldTable::new(episode, difficulty, section_id),
@ -98,7 +98,7 @@ impl RareDropTable {
match item { match item {
RareDropItem::Weapon(weapon) => { RareDropItem::Weapon(weapon) => {
ItemDropType::Weapon(Weapon { ItemDropType::Weapon(Weapon {
weapon: weapon,
weapon,
special: None, special: None,
grind: 0, grind: 0,
attrs: self.attribute_table.generate_rare_attributes(map_area, rng), attrs: self.attribute_table.generate_rare_attributes(map_area, rng),
@ -108,7 +108,7 @@ impl RareDropTable {
}, },
RareDropItem::Armor(armor) => { RareDropItem::Armor(armor) => {
ItemDropType::Armor(Armor { ItemDropType::Armor(Armor {
armor: armor,
armor,
dfp: self.armor_stats.dfp_modifier(&armor, rng) as u8, dfp: self.armor_stats.dfp_modifier(&armor, rng) as u8,
evp: self.armor_stats.evp_modifier(&armor, rng) as u8, evp: self.armor_stats.evp_modifier(&armor, rng) as u8,
slots: self.armor_stats.slots(map_area, rng) as u8, slots: self.armor_stats.slots(map_area, rng) as u8,
@ -116,20 +116,20 @@ impl RareDropTable {
}, },
RareDropItem::Shield(shield) => { RareDropItem::Shield(shield) => {
ItemDropType::Shield(Shield { ItemDropType::Shield(Shield {
shield: shield,
shield,
dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8, dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8,
evp: self.shield_stats.evp_modifier(&shield, rng) as u8, evp: self.shield_stats.evp_modifier(&shield, rng) as u8,
}) })
}, },
RareDropItem::Unit(unit) => { RareDropItem::Unit(unit) => {
ItemDropType::Unit(Unit { ItemDropType::Unit(Unit {
unit: unit,
unit,
modifier: None, modifier: None,
}) })
}, },
RareDropItem::Tool(tool) => { RareDropItem::Tool(tool) => {
ItemDropType::Tool(Tool { ItemDropType::Tool(Tool {
tool: tool,
tool,
}) })
}, },
RareDropItem::Mag(_mag) => { RareDropItem::Mag(_mag) => {

8
src/ship/items/bank.rs

@ -167,7 +167,7 @@ impl CharacterBank {
items.sort(); items.sort();
CharacterBank { CharacterBank {
item_id_counter: 0, item_id_counter: 0,
items: items,
items,
} }
} }
@ -186,7 +186,7 @@ impl CharacterBank {
})?; })?;
Some(BankItemHandle { Some(BankItemHandle {
bank: self, bank: self,
index: index,
index,
}) })
} }
@ -221,8 +221,8 @@ impl CharacterBank {
}, },
}; };
character::BankItem { character::BankItem {
data1: data1,
data2: data2,
data1,
data2,
item_id: item.item_id().0, item_id: item.item_id().0,
amount: amount as u16, amount: amount as u16,
flags: 1, flags: 1,

4
src/ship/items/floor.rs

@ -181,7 +181,7 @@ impl RoomFloorItems {
let index = self.0.iter().position(|item| item.item_id() == item_id)?; let index = self.0.iter().position(|item| item.item_id() == item_id)?;
Some(FloorItemHandle { Some(FloorItemHandle {
floor: self, floor: self,
index: index,
index,
}) })
} }
@ -234,7 +234,7 @@ impl RoomFloorItems {
self.0.push(FloorItem::Stacked(StackedFloorItem { self.0.push(FloorItem::Stacked(StackedFloorItem {
entity_ids: consumed_item.entity_ids(), entity_ids: consumed_item.entity_ids(),
item_id: new_item_id, item_id: new_item_id,
tool: tool,
tool,
map_area: item_drop_location.0, map_area: item_drop_location.0,
x: item_drop_location.1, x: item_drop_location.1,
y: item_drop_location.2, y: item_drop_location.2,

18
src/ship/items/inventory.rs

@ -339,8 +339,8 @@ impl<'a> InventoryItemHandle<'a> {
}) })
.ok_or(InventoryItemConsumeError::InvalidAmount)?; .ok_or(InventoryItemConsumeError::InvalidAmount)?;
Ok(ConsumedItem::Stacked(StackedConsumedItem { Ok(ConsumedItem::Stacked(StackedConsumedItem {
entity_ids: entity_ids,
tool: tool,
entity_ids,
tool,
})) }))
} }
} }
@ -365,7 +365,7 @@ impl CharacterInventory {
pub fn new(items: Vec<InventoryItem>, equipped: &EquippedEntity) -> CharacterInventory { pub fn new(items: Vec<InventoryItem>, equipped: &EquippedEntity) -> CharacterInventory {
CharacterInventory{ CharacterInventory{
item_id_counter: 0, item_id_counter: 0,
items: items,
items,
equipped: equipped.clone(), equipped: equipped.clone(),
} }
} }
@ -394,7 +394,7 @@ impl CharacterInventory {
inventory[slot].data1[4] = self.equipped.unit.iter() inventory[slot].data1[4] = self.equipped.unit.iter()
.enumerate() .enumerate()
.find(|(_, u_id)| **u_id == Some(individual_item.entity_id)) .find(|(_, u_id)| **u_id == Some(individual_item.entity_id))
.map(|(a, b)| a)
.map(|(a, _)| a)
.unwrap_or(0) as u8 .unwrap_or(0) as u8
} }
inventory[slot].equipped = 1; inventory[slot].equipped = 1;
@ -421,7 +421,7 @@ impl CharacterInventory {
})?; })?;
Some(InventoryItemHandle { Some(InventoryItemHandle {
inventory: self, inventory: self,
slot: slot,
slot,
}) })
} }
@ -438,7 +438,7 @@ impl CharacterInventory {
})?; })?;
Some(InventoryItemHandle { Some(InventoryItemHandle {
inventory: self, inventory: self,
slot: slot,
slot,
}) })
} }
@ -455,7 +455,7 @@ impl CharacterInventory {
})?; })?;
Some(InventoryItemHandle { Some(InventoryItemHandle {
inventory: self, inventory: self,
slot: slot,
slot,
}) })
} }
@ -472,7 +472,7 @@ impl CharacterInventory {
})?; })?;
Some(InventoryItemHandle { Some(InventoryItemHandle {
inventory: self, inventory: self,
slot: slot,
slot,
}) })
} }
@ -489,7 +489,7 @@ impl CharacterInventory {
})?; })?;
Some(InventoryItemHandle { Some(InventoryItemHandle {
inventory: self, inventory: self,
slot: slot,
slot,
}) })
} }

45
src/ship/items/manager.rs

@ -1,12 +1,11 @@
use crate::ship::items::ClientItemId; use crate::ship::items::ClientItemId;
use std::collections::{HashMap, BTreeMap};
use std::collections::HashMap;
use thiserror::Error; use thiserror::Error;
use crate::entity::gateway::EntityGateway; use crate::entity::gateway::EntityGateway;
use crate::entity::character::{CharacterEntity, CharacterEntityId, TechLevel}; use crate::entity::character::{CharacterEntity, CharacterEntityId, TechLevel};
use crate::entity::item::{ItemDetail, ItemLocation, BankName}; use crate::entity::item::{ItemDetail, ItemLocation, BankName};
use crate::entity::item::{Meseta, NewItemEntity, ItemEntity, InventoryItemEntity, EquippedEntity, InventoryEntity, BankItemEntity, BankEntity};
use crate::entity::item::{Meseta, NewItemEntity, ItemEntity, InventoryItemEntity, BankItemEntity};
use crate::entity::item::tool::{Tool, ToolType}; use crate::entity::item::tool::{Tool, ToolType};
use crate::entity::item::unit;
use crate::entity::item::weapon; use crate::entity::item::weapon;
use crate::ship::map::MapArea; use crate::ship::map::MapArea;
use crate::ship::ship::ItemDropLocation; use crate::ship::ship::ItemDropLocation;
@ -237,7 +236,7 @@ impl ItemManager {
Some(FloorItem::Individual(individual_floor_item)) => { Some(FloorItem::Individual(individual_floor_item)) => {
let new_inventory_item = inventory.pick_up_individual_floor_item(individual_floor_item); let new_inventory_item = inventory.pick_up_individual_floor_item(individual_floor_item);
match new_inventory_item { match new_inventory_item {
Some((new_inventory_item, slot)) => {
Some((new_inventory_item, _slot)) => {
entity_gateway.change_item_location( entity_gateway.change_item_location(
&new_inventory_item.entity_id, &new_inventory_item.entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
@ -258,7 +257,7 @@ impl ItemManager {
let new_inventory_item = inventory.pick_up_stacked_floor_item(stacked_floor_item); let new_inventory_item = inventory.pick_up_stacked_floor_item(stacked_floor_item);
match new_inventory_item { match new_inventory_item {
Some((new_inventory_item, slot)) => {
Some((new_inventory_item, _slot)) => {
for entity_id in &new_inventory_item.entity_ids { for entity_id in &new_inventory_item.entity_ids {
entity_gateway.change_item_location( entity_gateway.change_item_location(
entity_id, entity_id,
@ -337,7 +336,7 @@ impl ItemManager {
}).await?; }).await?;
FloorItem::Individual(IndividualFloorItem { FloorItem::Individual(IndividualFloorItem {
entity_id: entity.id, entity_id: entity.id,
item_id: item_id,
item_id,
item: item_detail, item: item_detail,
map_area: item_drop.map_area, map_area: item_drop.map_area,
x: item_drop.x, x: item_drop.x,
@ -358,8 +357,8 @@ impl ItemManager {
}).await?; }).await?;
FloorItem::Stacked(StackedFloorItem { FloorItem::Stacked(StackedFloorItem {
entity_ids: vec![entity.id], entity_ids: vec![entity.id],
item_id: item_id,
tool: tool,
item_id,
tool,
map_area: item_drop.map_area, map_area: item_drop.map_area,
x: item_drop.x, x: item_drop.x,
y: item_drop.y, y: item_drop.y,
@ -368,8 +367,8 @@ impl ItemManager {
}, },
ItemOrMeseta::Meseta(meseta) => { ItemOrMeseta::Meseta(meseta) => {
FloorItem::Meseta(MesetaFloorItem { FloorItem::Meseta(MesetaFloorItem {
item_id: item_id,
meseta: meseta,
item_id,
meseta,
map_area: item_drop.map_area, map_area: item_drop.map_area,
x: item_drop.x, x: item_drop.x,
y: item_drop.y, y: item_drop.y,
@ -445,7 +444,7 @@ impl ItemManager {
let item_id = self.room_item_id_counter.get_mut(room_id).ok_or(ItemManagerError::NoCharacter(character.id))?(); let item_id = self.room_item_id_counter.get_mut(room_id).ok_or(ItemManagerError::NoCharacter(character.id))?();
let floor_item = FloorItem::Meseta(MesetaFloorItem { let floor_item = FloorItem::Meseta(MesetaFloorItem {
item_id: item_id,
item_id,
meseta: Meseta(amount), meseta: Meseta(amount),
map_area: drop_location.map_area, map_area: drop_location.map_area,
x: drop_location.x, x: drop_location.x,
@ -571,13 +570,13 @@ impl ItemManager {
let inventory_item = inventory.withdraw_item(item_to_withdraw, amount).ok_or(ItemManagerError::Idunnoman)?; let inventory_item = inventory.withdraw_item(item_to_withdraw, amount).ok_or(ItemManagerError::Idunnoman)?;
match inventory_item { match inventory_item {
(InventoryItem::Individual(individual_inventory_item), slot) => {
(InventoryItem::Individual(individual_inventory_item), _slot) => {
entity_gateway.change_item_location(&individual_inventory_item.entity_id, entity_gateway.change_item_location(&individual_inventory_item.entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: character.id, character_id: character.id,
}).await?; }).await?;
}, },
(InventoryItem::Stacked(stacked_inventory_item), slot) => {
(InventoryItem::Stacked(stacked_inventory_item), _slot) => {
for entity_id in &stacked_inventory_item.entity_ids { for entity_id in &stacked_inventory_item.entity_ids {
entity_gateway.change_item_location(entity_id, entity_gateway.change_item_location(entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
@ -768,8 +767,8 @@ impl ItemManager {
} }
let floor_item = StackedFloorItem { let floor_item = StackedFloorItem {
entity_ids: item_entities.into_iter().map(|i| i.id).collect(), entity_ids: item_entities.into_iter().map(|i| i.id).collect(),
item_id: item_id,
tool: tool,
item_id,
tool,
// TODO: this is gonna choke if I ever require the item being near the player for pickup // TODO: this is gonna choke if I ever require the item being near the player for pickup
map_area: MapArea::Pioneer2Ep1, map_area: MapArea::Pioneer2Ep1,
x: 0.0, x: 0.0,
@ -777,7 +776,7 @@ impl ItemManager {
z: 0.0, z: 0.0,
}; };
let item_id = { let item_id = {
let (picked_up_item, slot) = inventory.pick_up_stacked_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
let (picked_up_item, _slot) = inventory.pick_up_stacked_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
for entity_id in &picked_up_item.entity_ids { for entity_id in &picked_up_item.entity_ids {
entity_gateway.change_item_location(entity_id, entity_gateway.change_item_location(entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
@ -795,7 +794,7 @@ impl ItemManager {
}).await?; }).await?;
let floor_item = IndividualFloorItem { let floor_item = IndividualFloorItem {
entity_id: item_entity.id, entity_id: item_entity.id,
item_id: item_id,
item_id,
item: ItemDetail::Tool(tool), item: ItemDetail::Tool(tool),
// TODO: this is gonna choke if I ever require the item being near the player for pickup // TODO: this is gonna choke if I ever require the item being near the player for pickup
map_area: MapArea::Pioneer2Ep1, map_area: MapArea::Pioneer2Ep1,
@ -804,7 +803,7 @@ impl ItemManager {
z: 0.0, z: 0.0,
}; };
let item_id = { let item_id = {
let (picked_up_item, slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
let (picked_up_item, _slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
entity_gateway.change_item_location(&picked_up_item.entity_id, entity_gateway.change_item_location(&picked_up_item.entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: character.id, character_id: character.id,
@ -814,14 +813,14 @@ impl ItemManager {
inventory.get_item_by_id(item_id).ok_or(ItemManagerError::ItemIdNotInInventory(item_id))? inventory.get_item_by_id(item_id).ok_or(ItemManagerError::ItemIdNotInInventory(item_id))?
} }
}, },
item_detail @ _ => {
item_detail => {
let item_entity = entity_gateway.create_item(NewItemEntity { let item_entity = entity_gateway.create_item(NewItemEntity {
location: ItemLocation::Shop, location: ItemLocation::Shop,
item: item_detail.clone(), item: item_detail.clone(),
}).await?; }).await?;
let floor_item = IndividualFloorItem { let floor_item = IndividualFloorItem {
entity_id: item_entity.id, entity_id: item_entity.id,
item_id: item_id,
item_id,
item: item_detail, item: item_detail,
// TODO: this is gonna choke if I ever require the item being near the player for pickup // TODO: this is gonna choke if I ever require the item being near the player for pickup
map_area: MapArea::Pioneer2Ep1, map_area: MapArea::Pioneer2Ep1,
@ -830,7 +829,7 @@ impl ItemManager {
z: 0.0, z: 0.0,
}; };
let item_id = { let item_id = {
let (picked_up_item, slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
let (picked_up_item, _slot) = inventory.pick_up_individual_floor_item(&floor_item).ok_or(ItemManagerError::CouldNotAddBoughtItemToInventory)?;
entity_gateway.change_item_location(&picked_up_item.entity_id, entity_gateway.change_item_location(&picked_up_item.entity_id,
ItemLocation::Inventory { ItemLocation::Inventory {
character_id: character.id, character_id: character.id,
@ -911,8 +910,8 @@ impl ItemManager {
entity_gateway.add_weapon_modifier(&entity_id, tek).await?; entity_gateway.add_weapon_modifier(&entity_id, tek).await?;
inventory.add_item(InventoryItem::Individual(IndividualInventoryItem { inventory.add_item(InventoryItem::Individual(IndividualInventoryItem {
entity_id: entity_id,
item_id: item_id,
entity_id,
item_id,
item: ItemDetail::Weapon(weapon.clone()), item: ItemDetail::Weapon(weapon.clone()),
}))?; }))?;

6
src/ship/map/enemy.rs

@ -252,7 +252,7 @@ impl MapEnemy {
}; };
Ok(MapEnemy { Ok(MapEnemy {
monster: monster,
monster,
map_area: *map_area, map_area: *map_area,
hp: 0, hp: 0,
dropped_item: false, dropped_item: false,
@ -263,8 +263,8 @@ impl MapEnemy {
pub fn new(monster: MonsterType, map_area: MapArea) -> MapEnemy { pub fn new(monster: MonsterType, map_area: MapArea) -> MapEnemy {
MapEnemy { MapEnemy {
monster: monster,
map_area: map_area,
monster,
map_area,
hp: 0, hp: 0,
dropped_item: false, dropped_item: false,
gave_exp: false, gave_exp: false,

2
src/ship/map/maps.rs

@ -280,7 +280,7 @@ impl Maps {
object_data: map_variants.iter().map(|map_variant| { object_data: map_variants.iter().map(|map_variant| {
objects_from_map_data(map_variant.obj_file().into(), &room_mode.episode(), &map_variant.map) objects_from_map_data(map_variant.obj_file().into(), &room_mode.episode(), &map_variant.map)
}).flatten().collect(), }).flatten().collect(),
map_variants: map_variants,
map_variants,
}; };
maps maps
} }

2
src/ship/map/object.rs

@ -159,7 +159,7 @@ impl MapObject {
}; };
Ok(MapObject { Ok(MapObject {
object: object,
object,
map: *map_area, map: *map_area,
dropped_item: false, dropped_item: false,
}) })

16
src/ship/map/variant.rs

@ -75,10 +75,10 @@ impl MapVariant {
}; };
MapVariant { MapVariant {
map: map,
mode: mode,
major: major,
minor: minor,
map,
mode,
major,
minor,
} }
} }
else { else {
@ -136,10 +136,10 @@ impl MapVariant {
}; };
MapVariant { MapVariant {
map: map,
mode: mode,
major: major,
minor: minor,
map,
mode,
major,
minor,
} }
} }
} }

12
src/ship/packet/builder/message.rs

@ -12,8 +12,8 @@ use crate::ship::shops::ShopItem;
pub fn item_drop(client: u8, target: u8, item_drop: &FloorItem) -> Result<ItemDrop, ShipError> { pub fn item_drop(client: u8, target: u8, item_drop: &FloorItem) -> Result<ItemDrop, ShipError> {
let item_bytes = item_drop.as_client_bytes(); let item_bytes = item_drop.as_client_bytes();
Ok(ItemDrop { Ok(ItemDrop {
client: client,
target: target,
client,
target,
map_area: item_drop.map_area().area_value(), map_area: item_drop.map_area().area_value(),
variety: 0, variety: 0,
unknown: 0, unknown: 0,
@ -101,7 +101,7 @@ pub fn character_gained_exp(area_client: AreaClient, exp: u32) -> GiveCharacterE
GiveCharacterExp { GiveCharacterExp {
client: area_client.local_client.id(), client: area_client.local_client.id(),
target: 0, target: 0,
exp: exp,
exp,
} }
} }
@ -138,7 +138,7 @@ pub fn player_no_longer_has_item(area_client: AreaClient, item_id: ClientItemId,
client: area_client.local_client.id(), client: area_client.local_client.id(),
target: 0, target: 0,
item_id: item_id.0, item_id: item_id.0,
amount: amount,
amount,
} }
} }
@ -157,10 +157,10 @@ pub fn shop_list<I: ShopItem>(shop_type: u8, items: &[I]) -> ShopList {
ShopList { ShopList {
client: 0, client: 0,
target: 0, target: 0,
shop_type: shop_type,
shop_type,
num_items: 0, num_items: 0,
unused: 0, unused: 0,
items: items,
items,
} }
} }

4
src/ship/packet/builder/mod.rs

@ -14,7 +14,7 @@ use crate::ship::items::ItemManager;
pub fn player_header(tag: u32, client: &ClientState, area_client: &AreaClient) -> PlayerHeader { pub fn player_header(tag: u32, client: &ClientState, area_client: &AreaClient) -> PlayerHeader {
PlayerHeader { PlayerHeader {
tag: tag,
tag,
guildcard: client.user.id.0, guildcard: client.user.id.0,
_unknown1: [0; 5], _unknown1: [0; 5],
client_id: area_client.local_client.id() as u32, client_id: area_client.local_client.id() as u32,
@ -40,6 +40,6 @@ pub fn player_info(tag: u32, client: &ClientState, area_client: &AreaClient, ite
language: 0, // TODO: account language language: 0, // TODO: account language
items: inventory.as_client_inventory_items(), items: inventory.as_client_inventory_items(),
}, },
character: character,
character,
} }
} }

6
src/ship/packet/builder/quest.rs

@ -59,9 +59,9 @@ pub fn quest_header(quest_menu_select: &QuestMenuSelect, data_blob: &[u8], suffi
pub fn quest_chunk(chunk_num: u32, filename: [u8; 16], blob: [u8; 0x400], blob_length: usize) -> QuestChunk { pub fn quest_chunk(chunk_num: u32, filename: [u8; 16], blob: [u8; 0x400], blob_length: usize) -> QuestChunk {
QuestChunk { QuestChunk {
chunk_num: chunk_num,
filename: filename,
blob: blob,
chunk_num,
filename,
blob,
blob_length: blob_length as u32, blob_length: blob_length as u32,
unknown: 0, unknown: 0,
} }

2
src/ship/packet/builder/room.rs

@ -30,7 +30,7 @@ pub fn join_room(id: ClientId,
Ok(JoinRoom { Ok(JoinRoom {
flag: all_clients.len() as u32, flag: all_clients.len() as u32,
maps: room.maps.map_headers(), maps: room.maps.map_headers(),
players: players,
players,
client: area_client.local_client.id(), client: area_client.local_client.id(),
leader: leader.local_client.id(), leader: leader.local_client.id(),
one: 1, one: 1,

9
src/ship/packet/builder/ship.rs

@ -1,16 +1,7 @@
use libpso::packet::login::{ShipList, ShipListEntry}; use libpso::packet::login::{ShipList, ShipListEntry};
use libpso::packet::ship::*;
use crate::common::serverstate::ClientId;
use crate::common::leveltable::CharacterLevelTable;
use crate::ship::ship::{ShipError, ClientState, Clients};
use crate::ship::location::{ClientLocation, RoomId, AreaClient, ClientLocationError};
use crate::ship::room::RoomState;
use crate::ship::items::ItemManager;
use crate::ship::packet::builder::{player_header, player_info};
use libpso::utf8_to_utf16_array; use libpso::utf8_to_utf16_array;
use crate::common::interserver::Ship; use crate::common::interserver::Ship;
use libpso::packet::ship::BLOCK_MENU_ID;
use crate::login::character::SHIP_MENU_ID; use crate::login::character::SHIP_MENU_ID;
pub fn ship_list(ships: &[Ship]) -> ShipList { pub fn ship_list(ships: &[Ship]) -> ShipList {

2
src/ship/packet/handler/auth.rs

@ -2,7 +2,7 @@ use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session};
use libpso::packet::ship::*; use libpso::packet::ship::*;
use crate::common::serverstate::ClientId; use crate::common::serverstate::ClientId;
use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients}; use crate::ship::ship::{SendShipPacket, ShipError, ClientState, Clients};
use crate::login::login::{get_login_status, check_if_already_online};
use crate::login::login::get_login_status;
use crate::entity::gateway::EntityGateway; use crate::entity::gateway::EntityGateway;
use crate::ship::items::ItemManager; use crate::ship::items::ItemManager;
use crate::common::interserver::ShipMessage; use crate::common::interserver::ShipMessage;

3
src/ship/packet/handler/message.rs

@ -1,12 +1,11 @@
use libpso::packet::ship::*; use libpso::packet::ship::*;
use libpso::packet::messages::*; use libpso::packet::messages::*;
use crate::entity::gateway::EntityGateway; use crate::entity::gateway::EntityGateway;
use crate::entity::item::{ItemType};
use crate::common::serverstate::ClientId; use crate::common::serverstate::ClientId;
use crate::common::leveltable::CharacterLevelTable; use crate::common::leveltable::CharacterLevelTable;
use crate::ship::ship::{SendShipPacket, ShipError, Rooms, Clients, ItemDropLocation}; use crate::ship::ship::{SendShipPacket, ShipError, Rooms, Clients, ItemDropLocation};
use crate::ship::location::{ClientLocation, ClientLocationError}; use crate::ship::location::{ClientLocation, ClientLocationError};
use crate::ship::items::{ItemManager, ClientItemId, InventoryItem};
use crate::ship::items::{ItemManager, ClientItemId};
use crate::ship::packet::builder; use crate::ship::packet::builder;
pub async fn request_exp<EG: EntityGateway>(id: ClientId, pub async fn request_exp<EG: EntityGateway>(id: ClientId,

16
src/ship/quests.rs

@ -191,16 +191,16 @@ impl Quest {
prs_dat.write_all(&dat)?; prs_dat.write_all(&dat)?;
Ok(Quest { Ok(Quest {
name: name,
description: description,
full_description: full_description,
id: id,
language: language,
name,
description,
full_description,
id,
language,
bin_blob: prs_bin.into_inner().map_err(|_| QuestLoadError::CouldNotReadMetadata)?, bin_blob: prs_bin.into_inner().map_err(|_| QuestLoadError::CouldNotReadMetadata)?,
dat_blob: prs_dat.into_inner().map_err(|_| QuestLoadError::CouldNotReadMetadata)?, dat_blob: prs_dat.into_inner().map_err(|_| QuestLoadError::CouldNotReadMetadata)?,
enemies: enemies,
objects: objects,
map_areas: map_areas,
enemies,
objects,
map_areas,
}) })
} }
} }

2
src/ship/room.rs

@ -238,7 +238,7 @@ impl RoomState {
name: String::from_utf16_lossy(&create_room.name).trim_matches(char::from(0)).into(), name: String::from_utf16_lossy(&create_room.name).trim_matches(char::from(0)).into(),
password: create_room.password, password: create_room.password,
maps: Maps::new(room_mode), maps: Maps::new(room_mode),
section_id: section_id,
section_id,
drop_table: Box::new(DropTable::new(room_mode.episode(), room_mode.difficulty(), section_id)), drop_table: Box::new(DropTable::new(room_mode.episode(), room_mode.difficulty(), section_id)),
bursting: false, bursting: false,
map_areas: MapAreaLookup::new(&room_mode.episode()), map_areas: MapAreaLookup::new(&room_mode.episode()),

2
src/ship/shops/tool.rs

@ -263,7 +263,7 @@ impl<R: Rng + SeedableRng> ToolShop<R> {
}; };
ToolShopItem::Tech(TechniqueDisk { ToolShopItem::Tech(TechniqueDisk {
tech: tech,
tech,
level: level as u32, level: level as u32,
}) })
}) })

14
src/ship/shops/weapon.rs

@ -329,8 +329,8 @@ pub struct WeaponShop<R: Rng + SeedableRng> {
impl<R: Rng + SeedableRng> WeaponShop<R> { impl<R: Rng + SeedableRng> WeaponShop<R> {
pub fn new(difficulty: Difficulty, section_id: SectionID) -> WeaponShop<R> { pub fn new(difficulty: Difficulty, section_id: SectionID) -> WeaponShop<R> {
WeaponShop { WeaponShop {
difficulty: difficulty,
section_id: section_id,
difficulty,
section_id,
weapon: load_weapon_table(difficulty, section_id), weapon: load_weapon_table(difficulty, section_id),
special: load_special_table(), special: load_special_table(),
grind: load_grind_table(), grind: load_grind_table(),
@ -405,7 +405,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
.choose(&mut self.rng)?; .choose(&mut self.rng)?;
Some(WeaponAttribute { Some(WeaponAttribute {
attr: attr,
attr,
value: percent as i8, value: percent as i8,
}) })
} }
@ -432,7 +432,7 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
.choose(&mut self.rng)?; .choose(&mut self.rng)?;
Some(WeaponAttribute { Some(WeaponAttribute {
attr: attr,
attr,
value: percent as i8, value: percent as i8,
}) })
} }
@ -512,9 +512,9 @@ impl<R: Rng + SeedableRng> WeaponShop<R> {
}; };
WeaponShopItem { WeaponShopItem {
weapon: weapon,
grind: grind,
special: special,
weapon,
grind,
special,
attributes: [attr1, attr2], attributes: [attr1, attr2],
} }
} }

Loading…
Cancel
Save