diff --git a/src/common/leveltable.rs b/src/common/leveltable.rs index d60d1fe..94ad8ae 100644 --- a/src/common/leveltable.rs +++ b/src/common/leveltable.rs @@ -71,7 +71,7 @@ impl Default for CharacterLevelTable { } CharacterLevelTable { - table: table, + table, } } } diff --git a/src/common/mainloop/client.rs b/src/common/mainloop/client.rs index 1bfc1ce..32562e9 100644 --- a/src/common/mainloop/client.rs +++ b/src/common/mainloop/client.rs @@ -49,8 +49,8 @@ struct PacketReceiver { impl PacketReceiver { fn new(socket: Arc, cipher: Arc>>) -> PacketReceiver { PacketReceiver { - socket: socket, - cipher: cipher, + socket, + cipher, recv_buffer: Vec::new(), incoming_data: Vec::new(), } diff --git a/src/common/mainloop/interserver.rs b/src/common/mainloop/interserver.rs index cc6cce2..3547f8b 100644 --- a/src/common/mainloop/interserver.rs +++ b/src/common/mainloop/interserver.rs @@ -29,7 +29,7 @@ struct MessageReceiver { impl MessageReceiver { fn new(socket: async_std::net::TcpStream) -> MessageReceiver { MessageReceiver { - socket: socket, + socket, } } diff --git a/src/entity/account.rs b/src/entity/account.rs index 0ab4452..9223797 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -75,7 +75,7 @@ pub struct NewUserSettingsEntity { impl NewUserSettingsEntity { pub fn new(user_id: UserAccountId) -> NewUserSettingsEntity { NewUserSettingsEntity { - user_id: user_id, + user_id, settings: settings::UserSettings::default(), } } @@ -98,7 +98,7 @@ pub struct NewGuildCardDataEntity { impl NewGuildCardDataEntity { pub fn new(user_id: UserAccountId) -> NewGuildCardDataEntity { NewGuildCardDataEntity { - user_id: user_id, + user_id, guildcard: guildcard::GuildCardData::default(), } } @@ -116,7 +116,7 @@ impl GuildCardDataEntity { pub fn new(user_id: UserAccountId) -> GuildCardDataEntity { GuildCardDataEntity { id: GuildCardDataId(0), - user_id: user_id, + user_id, guildcard: guildcard::GuildCardData::default(), } } diff --git a/src/entity/gateway/postgres/models.rs b/src/entity/gateway/postgres/models.rs index f33f399..02bd750 100644 --- a/src/entity/gateway/postgres/models.rs +++ b/src/entity/gateway/postgres/models.rs @@ -314,7 +314,7 @@ impl From for weapon::Weapon { weapon: other.weapon, special: other.special, grind: other.grind, - attrs: attrs, + attrs, tekked: other.tekked, } } diff --git a/src/entity/gateway/postgres/postgres.rs b/src/entity/gateway/postgres/postgres.rs index 1856fda..53609cf 100644 --- a/src/entity/gateway/postgres/postgres.rs +++ b/src/entity/gateway/postgres/postgres.rs @@ -1,5 +1,4 @@ use std::convert::{From, TryFrom, Into}; -use futures::future::join_all; use futures::TryStreamExt; use async_std::stream::StreamExt; use libpso::character::guildcard; @@ -40,7 +39,7 @@ impl PostgresGateway { }); PostgresGateway { - pool: pool, + pool, } } @@ -96,13 +95,13 @@ impl PostgresGateway { ItemDetail::Mag(mag) }, - item @ _ => item + item => item }; ItemEntity { - id: id, - item: item, - location: location + id, + item, + location } } } diff --git a/src/entity/item/esweapon.rs b/src/entity/item/esweapon.rs index 6c00e7f..908b026 100644 --- a/src/entity/item/esweapon.rs +++ b/src/entity/item/esweapon.rs @@ -247,10 +247,10 @@ impl ESWeapon { let name = ESWeapon::name_from_bytes(&bytes[6..12]); ESWeapon { - esweapon: esweapon, + esweapon, special: special.ok(), - grind: grind, - name: name, + grind, + name, } } } diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index 348d025..4f36983 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -651,12 +651,12 @@ impl Mag { Ok(Mag{ mag: m, - def: def, - pow: pow, - dex: dex, + def, + pow, + dex, mnd: mind, synchro: sync, - iq: iq, + iq, photon_blast: [None, None, None], // TODO: actually get PBs from bytes color: data[15] % 18, //modifiers: Vec::new(), diff --git a/src/entity/item/weapon.rs b/src/entity/item/weapon.rs index e18eac5..6473dd8 100644 --- a/src/entity/item/weapon.rs +++ b/src/entity/item/weapon.rs @@ -1536,25 +1536,25 @@ impl Weapon { // TODO: error handling pub fn from_bytes(data: [u8; 16]) -> Result { - 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 { - s = WeaponSpecial::from(data[4] - 0x80); - t = false; + special = WeaponSpecial::from(data[4] - 0x80); + tekked = false; } else if data[4] >= 0x01 && data[4] <= 0x28 { - s = WeaponSpecial::from(data[4]); - t = true; + special = WeaponSpecial::from(data[4]); + tekked = true; } // else { // return Err(ItemParseError::InvalidSpecial) // } - let mut a = [ + let mut attrs = [ None, None, None @@ -1562,26 +1562,22 @@ impl Weapon { for i in 0..3 { 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(), value: data[2 * (3 + i) + 1] as i8, }); } else { - a[i] = None; + attrs[i] = None; // return Err(ItemParseError::InvalidAttribute) } } Ok(Weapon { - weapon: w, - special: s, - grind: g, - attrs:[ - a[0], - a[1], - a[2], - ], - tekked: t, + weapon, + special, + grind, + attrs, + tekked, }) } else { diff --git a/src/login/character.rs b/src/login/character.rs index 6867189..12e874a 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -28,7 +28,7 @@ use crate::entity::item::tool::Tool; use crate::entity::item::mag::Mag; 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; pub const CHARACTER_PORT: u16 = 12001; @@ -148,7 +148,7 @@ fn generate_param_data(path: &str) -> (ParamDataHeader, Vec) { } (ParamDataHeader { - files: files + files }, buffer) } @@ -301,13 +301,13 @@ impl CharacterServerState { let (param_header, param_data) = generate_param_data("data/param/"); CharacterServerState { - entity_gateway: entity_gateway, - param_header: param_header, - param_data: param_data, + entity_gateway, + param_header, + param_data, clients: HashMap::new(), ships: BTreeMap::new(), level_table: CharacterLevelTable::default(), - auth_token: auth_token, + auth_token, authenticated_ships: BTreeSet::new(), ship_sender: BTreeMap::new(), connected_clients: BTreeMap::new(), @@ -481,7 +481,7 @@ impl CharacterServerState { Ok(vec![SendCharacterPacket::ParamDataChunk( Box::new(ParamDataChunk { chunk: chunk as u32, - data: data, + data, }) )]) } diff --git a/src/login/login.rs b/src/login/login.rs index f6ef7c4..617fad2 100644 --- a/src/login/login.rs +++ b/src/login/login.rs @@ -101,8 +101,8 @@ pub struct LoginServerState { impl LoginServerState { pub fn new(entity_gateway: EG, character_server_ip: net::Ipv4Addr) -> LoginServerState { LoginServerState { - entity_gateway: entity_gateway, - character_server_ip: character_server_ip, + entity_gateway, + character_server_ip, clients: HashMap::new(), } } diff --git a/src/patch/patch.rs b/src/patch/patch.rs index 13a9928..52dd7d2 100644 --- a/src/patch/patch.rs +++ b/src/patch/patch.rs @@ -146,10 +146,10 @@ pub struct PatchServerState { impl PatchServerState { pub fn new(patch_file_tree: PatchFileTree, patch_file_lookup: HashMap, patch_motd: String) -> 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_motd: patch_motd, + patch_motd, } } } @@ -222,9 +222,9 @@ fn load_patch_dir(basedir: &str, patchbase: &str, file_ids: &mut HashMap CharacterBytesBuilder<'a> { dfp: stats.dfp + character.materials.def as u16 * 2, ata: stats.ata, lck: stats.lck + character.materials.luck as u16 * 2, - level: level, + level, section_id: character.section_id.into(), ch_class: character.char_class.into(), costume: character.appearance.costume, @@ -221,7 +221,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { symbol_chats: *symbol_chat, tech_menu: *tech_menu, bank: bank.as_client_bank_items(), - option_flags: option_flags, + option_flags, ..character::FullCharacter::default() } } diff --git a/src/ship/drops/generic_weapon.rs b/src/ship/drops/generic_weapon.rs index 28a5007..d1fb2bb 100644 --- a/src/ship/drops/generic_weapon.rs +++ b/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"); 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; Some(WeaponAttribute { - attr: attr, + attr, value: percent }) } @@ -406,7 +406,7 @@ impl GenericWeaponTable { rank_table.insert(WeaponDropType::Wand, vec![WeaponType::Wand, WeaponType::Staff, WeaponType::Baton, WeaponType::Scepter]); GenericWeaponTable { - rank_table: rank_table, + rank_table, weapon_ratio: WeaponRatios::new(episode, difficulty, section_id), grind_rates: GrindRates::new(episode, difficulty, section_id), attribute_table: AttributeTable::new(episode, difficulty, section_id), diff --git a/src/ship/drops/rare_drop_table.rs b/src/ship/drops/rare_drop_table.rs index 0ca356c..6631654 100644 --- a/src/ship/drops/rare_drop_table.rs +++ b/src/ship/drops/rare_drop_table.rs @@ -87,7 +87,7 @@ impl RareDropTable { }).collect(); RareDropTable { - rates: rates, + rates, attribute_table: AttributeTable::new(episode, difficulty, section_id), armor_stats: GenericArmorTable::new(episode, difficulty, section_id), shield_stats: GenericShieldTable::new(episode, difficulty, section_id), @@ -98,7 +98,7 @@ impl RareDropTable { match item { RareDropItem::Weapon(weapon) => { ItemDropType::Weapon(Weapon { - weapon: weapon, + weapon, special: None, grind: 0, attrs: self.attribute_table.generate_rare_attributes(map_area, rng), @@ -108,7 +108,7 @@ impl RareDropTable { }, RareDropItem::Armor(armor) => { ItemDropType::Armor(Armor { - armor: armor, + armor, dfp: self.armor_stats.dfp_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, @@ -116,20 +116,20 @@ impl RareDropTable { }, RareDropItem::Shield(shield) => { ItemDropType::Shield(Shield { - shield: shield, + shield, dfp: self.shield_stats.dfp_modifier(&shield, rng) as u8, evp: self.shield_stats.evp_modifier(&shield, rng) as u8, }) }, RareDropItem::Unit(unit) => { ItemDropType::Unit(Unit { - unit: unit, + unit, modifier: None, }) }, RareDropItem::Tool(tool) => { ItemDropType::Tool(Tool { - tool: tool, + tool, }) }, RareDropItem::Mag(_mag) => { diff --git a/src/ship/items/bank.rs b/src/ship/items/bank.rs index 44b9cd1..f3d5d10 100644 --- a/src/ship/items/bank.rs +++ b/src/ship/items/bank.rs @@ -167,7 +167,7 @@ impl CharacterBank { items.sort(); CharacterBank { item_id_counter: 0, - items: items, + items, } } @@ -186,7 +186,7 @@ impl CharacterBank { })?; Some(BankItemHandle { bank: self, - index: index, + index, }) } @@ -221,8 +221,8 @@ impl CharacterBank { }, }; character::BankItem { - data1: data1, - data2: data2, + data1, + data2, item_id: item.item_id().0, amount: amount as u16, flags: 1, diff --git a/src/ship/items/floor.rs b/src/ship/items/floor.rs index 3083271..c976048 100644 --- a/src/ship/items/floor.rs +++ b/src/ship/items/floor.rs @@ -181,7 +181,7 @@ impl RoomFloorItems { let index = self.0.iter().position(|item| item.item_id() == item_id)?; Some(FloorItemHandle { floor: self, - index: index, + index, }) } @@ -234,7 +234,7 @@ impl RoomFloorItems { self.0.push(FloorItem::Stacked(StackedFloorItem { entity_ids: consumed_item.entity_ids(), item_id: new_item_id, - tool: tool, + tool, map_area: item_drop_location.0, x: item_drop_location.1, y: item_drop_location.2, diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index bbf833c..9589849 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -339,8 +339,8 @@ impl<'a> InventoryItemHandle<'a> { }) .ok_or(InventoryItemConsumeError::InvalidAmount)?; Ok(ConsumedItem::Stacked(StackedConsumedItem { - entity_ids: entity_ids, - tool: tool, + entity_ids, + tool, })) } } @@ -365,7 +365,7 @@ impl CharacterInventory { pub fn new(items: Vec, equipped: &EquippedEntity) -> CharacterInventory { CharacterInventory{ item_id_counter: 0, - items: items, + items, equipped: equipped.clone(), } } @@ -394,7 +394,7 @@ impl CharacterInventory { inventory[slot].data1[4] = self.equipped.unit.iter() .enumerate() .find(|(_, u_id)| **u_id == Some(individual_item.entity_id)) - .map(|(a, b)| a) + .map(|(a, _)| a) .unwrap_or(0) as u8 } inventory[slot].equipped = 1; @@ -421,7 +421,7 @@ impl CharacterInventory { })?; Some(InventoryItemHandle { inventory: self, - slot: slot, + slot, }) } @@ -438,7 +438,7 @@ impl CharacterInventory { })?; Some(InventoryItemHandle { inventory: self, - slot: slot, + slot, }) } @@ -455,7 +455,7 @@ impl CharacterInventory { })?; Some(InventoryItemHandle { inventory: self, - slot: slot, + slot, }) } @@ -472,7 +472,7 @@ impl CharacterInventory { })?; Some(InventoryItemHandle { inventory: self, - slot: slot, + slot, }) } @@ -489,7 +489,7 @@ impl CharacterInventory { })?; Some(InventoryItemHandle { inventory: self, - slot: slot, + slot, }) } diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index b975cc0..441c85b 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -1,12 +1,11 @@ use crate::ship::items::ClientItemId; -use std::collections::{HashMap, BTreeMap}; +use std::collections::HashMap; use thiserror::Error; use crate::entity::gateway::EntityGateway; use crate::entity::character::{CharacterEntity, CharacterEntityId, TechLevel}; 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::unit; use crate::entity::item::weapon; use crate::ship::map::MapArea; use crate::ship::ship::ItemDropLocation; @@ -237,7 +236,7 @@ impl ItemManager { Some(FloorItem::Individual(individual_floor_item)) => { let new_inventory_item = inventory.pick_up_individual_floor_item(individual_floor_item); match new_inventory_item { - Some((new_inventory_item, slot)) => { + Some((new_inventory_item, _slot)) => { entity_gateway.change_item_location( &new_inventory_item.entity_id, ItemLocation::Inventory { @@ -258,7 +257,7 @@ impl ItemManager { let new_inventory_item = inventory.pick_up_stacked_floor_item(stacked_floor_item); match new_inventory_item { - Some((new_inventory_item, slot)) => { + Some((new_inventory_item, _slot)) => { for entity_id in &new_inventory_item.entity_ids { entity_gateway.change_item_location( entity_id, @@ -337,7 +336,7 @@ impl ItemManager { }).await?; FloorItem::Individual(IndividualFloorItem { entity_id: entity.id, - item_id: item_id, + item_id, item: item_detail, map_area: item_drop.map_area, x: item_drop.x, @@ -358,8 +357,8 @@ impl ItemManager { }).await?; FloorItem::Stacked(StackedFloorItem { entity_ids: vec![entity.id], - item_id: item_id, - tool: tool, + item_id, + tool, map_area: item_drop.map_area, x: item_drop.x, y: item_drop.y, @@ -368,8 +367,8 @@ impl ItemManager { }, ItemOrMeseta::Meseta(meseta) => { FloorItem::Meseta(MesetaFloorItem { - item_id: item_id, - meseta: meseta, + item_id, + meseta, map_area: item_drop.map_area, x: item_drop.x, 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 floor_item = FloorItem::Meseta(MesetaFloorItem { - item_id: item_id, + item_id, meseta: Meseta(amount), map_area: drop_location.map_area, x: drop_location.x, @@ -571,13 +570,13 @@ impl ItemManager { let inventory_item = inventory.withdraw_item(item_to_withdraw, amount).ok_or(ItemManagerError::Idunnoman)?; 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, ItemLocation::Inventory { character_id: character.id, }).await?; }, - (InventoryItem::Stacked(stacked_inventory_item), slot) => { + (InventoryItem::Stacked(stacked_inventory_item), _slot) => { for entity_id in &stacked_inventory_item.entity_ids { entity_gateway.change_item_location(entity_id, ItemLocation::Inventory { @@ -768,8 +767,8 @@ impl ItemManager { } let floor_item = StackedFloorItem { 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 map_area: MapArea::Pioneer2Ep1, x: 0.0, @@ -777,7 +776,7 @@ impl ItemManager { z: 0.0, }; 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 { entity_gateway.change_item_location(entity_id, ItemLocation::Inventory { @@ -795,7 +794,7 @@ impl ItemManager { }).await?; let floor_item = IndividualFloorItem { entity_id: item_entity.id, - item_id: item_id, + item_id, item: ItemDetail::Tool(tool), // TODO: this is gonna choke if I ever require the item being near the player for pickup map_area: MapArea::Pioneer2Ep1, @@ -804,7 +803,7 @@ impl ItemManager { z: 0.0, }; 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, ItemLocation::Inventory { character_id: character.id, @@ -814,14 +813,14 @@ impl ItemManager { 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 { location: ItemLocation::Shop, item: item_detail.clone(), }).await?; let floor_item = IndividualFloorItem { entity_id: item_entity.id, - item_id: item_id, + item_id, item: item_detail, // TODO: this is gonna choke if I ever require the item being near the player for pickup map_area: MapArea::Pioneer2Ep1, @@ -830,7 +829,7 @@ impl ItemManager { z: 0.0, }; 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, ItemLocation::Inventory { character_id: character.id, @@ -911,8 +910,8 @@ impl ItemManager { entity_gateway.add_weapon_modifier(&entity_id, tek).await?; inventory.add_item(InventoryItem::Individual(IndividualInventoryItem { - entity_id: entity_id, - item_id: item_id, + entity_id, + item_id, item: ItemDetail::Weapon(weapon.clone()), }))?; diff --git a/src/ship/map/enemy.rs b/src/ship/map/enemy.rs index a9601d2..32e53df 100644 --- a/src/ship/map/enemy.rs +++ b/src/ship/map/enemy.rs @@ -252,7 +252,7 @@ impl MapEnemy { }; Ok(MapEnemy { - monster: monster, + monster, map_area: *map_area, hp: 0, dropped_item: false, @@ -263,8 +263,8 @@ impl MapEnemy { pub fn new(monster: MonsterType, map_area: MapArea) -> MapEnemy { MapEnemy { - monster: monster, - map_area: map_area, + monster, + map_area, hp: 0, dropped_item: false, gave_exp: false, diff --git a/src/ship/map/maps.rs b/src/ship/map/maps.rs index 15e790c..e1558d8 100644 --- a/src/ship/map/maps.rs +++ b/src/ship/map/maps.rs @@ -280,7 +280,7 @@ impl Maps { object_data: map_variants.iter().map(|map_variant| { objects_from_map_data(map_variant.obj_file().into(), &room_mode.episode(), &map_variant.map) }).flatten().collect(), - map_variants: map_variants, + map_variants, }; maps } diff --git a/src/ship/map/object.rs b/src/ship/map/object.rs index e431c88..8307bf0 100644 --- a/src/ship/map/object.rs +++ b/src/ship/map/object.rs @@ -159,7 +159,7 @@ impl MapObject { }; Ok(MapObject { - object: object, + object, map: *map_area, dropped_item: false, }) diff --git a/src/ship/map/variant.rs b/src/ship/map/variant.rs index 7e85bee..819bcdb 100644 --- a/src/ship/map/variant.rs +++ b/src/ship/map/variant.rs @@ -75,10 +75,10 @@ impl MapVariant { }; MapVariant { - map: map, - mode: mode, - major: major, - minor: minor, + map, + mode, + major, + minor, } } else { @@ -136,10 +136,10 @@ impl MapVariant { }; MapVariant { - map: map, - mode: mode, - major: major, - minor: minor, + map, + mode, + major, + minor, } } } diff --git a/src/ship/packet/builder/message.rs b/src/ship/packet/builder/message.rs index dfe1ac5..b7d7f97 100644 --- a/src/ship/packet/builder/message.rs +++ b/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 { let item_bytes = item_drop.as_client_bytes(); Ok(ItemDrop { - client: client, - target: target, + client, + target, map_area: item_drop.map_area().area_value(), variety: 0, unknown: 0, @@ -101,7 +101,7 @@ pub fn character_gained_exp(area_client: AreaClient, exp: u32) -> GiveCharacterE GiveCharacterExp { client: area_client.local_client.id(), 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(), target: 0, item_id: item_id.0, - amount: amount, + amount, } } @@ -157,10 +157,10 @@ pub fn shop_list(shop_type: u8, items: &[I]) -> ShopList { ShopList { client: 0, target: 0, - shop_type: shop_type, + shop_type, num_items: 0, unused: 0, - items: items, + items, } } diff --git a/src/ship/packet/builder/mod.rs b/src/ship/packet/builder/mod.rs index e0e5301..a5c30d7 100644 --- a/src/ship/packet/builder/mod.rs +++ b/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 { PlayerHeader { - tag: tag, + tag, guildcard: client.user.id.0, _unknown1: [0; 5], 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 items: inventory.as_client_inventory_items(), }, - character: character, + character, } } diff --git a/src/ship/packet/builder/quest.rs b/src/ship/packet/builder/quest.rs index 8078517..f162269 100644 --- a/src/ship/packet/builder/quest.rs +++ b/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 { QuestChunk { - chunk_num: chunk_num, - filename: filename, - blob: blob, + chunk_num, + filename, + blob, blob_length: blob_length as u32, unknown: 0, } diff --git a/src/ship/packet/builder/room.rs b/src/ship/packet/builder/room.rs index 2eb8fc7..1effe5d 100644 --- a/src/ship/packet/builder/room.rs +++ b/src/ship/packet/builder/room.rs @@ -30,7 +30,7 @@ pub fn join_room(id: ClientId, Ok(JoinRoom { flag: all_clients.len() as u32, maps: room.maps.map_headers(), - players: players, + players, client: area_client.local_client.id(), leader: leader.local_client.id(), one: 1, diff --git a/src/ship/packet/builder/ship.rs b/src/ship/packet/builder/ship.rs index 8b3e40f..1411f2a 100644 --- a/src/ship/packet/builder/ship.rs +++ b/src/ship/packet/builder/ship.rs @@ -1,16 +1,7 @@ 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 crate::common::interserver::Ship; -use libpso::packet::ship::BLOCK_MENU_ID; use crate::login::character::SHIP_MENU_ID; pub fn ship_list(ships: &[Ship]) -> ShipList { diff --git a/src/ship/packet/handler/auth.rs b/src/ship/packet/handler/auth.rs index 0bf5ebe..c9e6987 100644 --- a/src/ship/packet/handler/auth.rs +++ b/src/ship/packet/handler/auth.rs @@ -2,7 +2,7 @@ use libpso::packet::login::{Login, LoginResponse, AccountStatus, Session}; use libpso::packet::ship::*; use crate::common::serverstate::ClientId; 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::ship::items::ItemManager; use crate::common::interserver::ShipMessage; diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 6bf2106..39d3717 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -1,12 +1,11 @@ use libpso::packet::ship::*; use libpso::packet::messages::*; use crate::entity::gateway::EntityGateway; -use crate::entity::item::{ItemType}; use crate::common::serverstate::ClientId; use crate::common::leveltable::CharacterLevelTable; use crate::ship::ship::{SendShipPacket, ShipError, Rooms, Clients, ItemDropLocation}; use crate::ship::location::{ClientLocation, ClientLocationError}; -use crate::ship::items::{ItemManager, ClientItemId, InventoryItem}; +use crate::ship::items::{ItemManager, ClientItemId}; use crate::ship::packet::builder; pub async fn request_exp(id: ClientId, diff --git a/src/ship/quests.rs b/src/ship/quests.rs index 7b1316f..3b430ba 100644 --- a/src/ship/quests.rs +++ b/src/ship/quests.rs @@ -191,16 +191,16 @@ impl Quest { prs_dat.write_all(&dat)?; 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)?, dat_blob: prs_dat.into_inner().map_err(|_| QuestLoadError::CouldNotReadMetadata)?, - enemies: enemies, - objects: objects, - map_areas: map_areas, + enemies, + objects, + map_areas, }) } } diff --git a/src/ship/room.rs b/src/ship/room.rs index 5fbae80..3aae5da 100644 --- a/src/ship/room.rs +++ b/src/ship/room.rs @@ -238,7 +238,7 @@ impl RoomState { name: String::from_utf16_lossy(&create_room.name).trim_matches(char::from(0)).into(), password: create_room.password, 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)), bursting: false, map_areas: MapAreaLookup::new(&room_mode.episode()), diff --git a/src/ship/shops/tool.rs b/src/ship/shops/tool.rs index 66313b5..d3a8e4b 100644 --- a/src/ship/shops/tool.rs +++ b/src/ship/shops/tool.rs @@ -263,7 +263,7 @@ impl ToolShop { }; ToolShopItem::Tech(TechniqueDisk { - tech: tech, + tech, level: level as u32, }) }) diff --git a/src/ship/shops/weapon.rs b/src/ship/shops/weapon.rs index d978ad9..6818f23 100644 --- a/src/ship/shops/weapon.rs +++ b/src/ship/shops/weapon.rs @@ -329,8 +329,8 @@ pub struct WeaponShop { impl WeaponShop { pub fn new(difficulty: Difficulty, section_id: SectionID) -> WeaponShop { WeaponShop { - difficulty: difficulty, - section_id: section_id, + difficulty, + section_id, weapon: load_weapon_table(difficulty, section_id), special: load_special_table(), grind: load_grind_table(), @@ -405,7 +405,7 @@ impl WeaponShop { .choose(&mut self.rng)?; Some(WeaponAttribute { - attr: attr, + attr, value: percent as i8, }) } @@ -432,7 +432,7 @@ impl WeaponShop { .choose(&mut self.rng)?; Some(WeaponAttribute { - attr: attr, + attr, value: percent as i8, }) } @@ -512,9 +512,9 @@ impl WeaponShop { }; WeaponShopItem { - weapon: weapon, - grind: grind, - special: special, + weapon, + grind, + special, attributes: [attr1, attr2], } }