Browse Source

clippy

pull/130/head
jake 2 years ago
parent
commit
4e4f5e4ee2
  1. 8
      src/entity/gateway/postgres/models.rs
  2. 2
      src/entity/gateway/postgres/postgres.rs
  3. 2
      src/login/character.rs
  4. 19
      src/ship/chatcommand.rs
  5. 1
      src/ship/items/actions.rs
  6. 2
      src/ship/items/bank.rs
  7. 2
      src/ship/ship.rs

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

@ -650,13 +650,13 @@ impl From<ItemNote> for PgItemNoteDetail {
ItemNote::Withdraw{character_id, bank} => {
PgItemNoteDetail::Withdraw {
character_id: character_id.0,
bank: bank,
bank,
}
},
ItemNote::Deposit{character_id, bank} => {
PgItemNoteDetail::Deposit {
character_id: character_id.0,
bank: bank,
bank,
}
}
}
@ -697,11 +697,11 @@ impl From<PgItemNoteDetail> for ItemNote {
},
PgItemNoteDetail::Withdraw{character_id, bank} => ItemNote::Withdraw {
character_id: CharacterEntityId(character_id),
bank: bank,
bank,
},
PgItemNoteDetail::Deposit{character_id, bank} => ItemNote::Deposit {
character_id: CharacterEntityId(character_id),
bank: bank,
bank,
},
}
}

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

@ -635,7 +635,7 @@ async fn get_bank_meseta(conn: &mut sqlx::PgConnection, char_id: &CharacterEntit
.bind(&bank_name.0)
.fetch_optional(conn)
.await?
.unwrap_or_else(|| PgMeseta(0))
.unwrap_or(PgMeseta(0))
}
};
Ok(Meseta(meseta.0 as u32))

2
src/login/character.rs

@ -23,7 +23,7 @@ use libpso::{utf8_to_array, utf8_to_utf16_array};
use crate::entity::gateway::{EntityGateway, GatewayError};
use crate::entity::account::{UserAccountId, UserAccountEntity, NewUserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::item::{NewItemEntity, ItemDetail, ItemNote, InventoryItemEntity, InventoryEntity, BankEntity, BankName, BankIdentifier, EquippedEntity, Meseta};
use crate::entity::item::{NewItemEntity, ItemDetail, ItemNote, InventoryItemEntity, InventoryEntity, BankEntity, BankIdentifier, EquippedEntity, Meseta};
use crate::entity::item::weapon::Weapon;
use crate::entity::item::armor::Armor;
use crate::entity::item::tech::Technique;

19
src/ship/chatcommand.rs

@ -7,15 +7,13 @@ use crate::ship::items::state::ItemState;
use crate::entity::item::{BankName, BankIdentifier};
use crate::ship::packet::builder::message::bank_item_list;
async fn default_bank<'a, EG, T>(id: ClientId,
tokens: T,
async fn default_bank<'a, EG>(id: ClientId,
entity_gateway: &mut EG,
clients: &Clients,
item_state: &mut ItemState)
-> Result<Vec<(ClientId, SendShipPacket)>, String>
where
EG: EntityGateway + Clone + 'static,
T: Iterator<Item = &'a str> + 'a,
{
let bank = clients
.with_mut(id, |client| {
@ -28,8 +26,8 @@ where
})
})
.await
.map_err(|err| format!("an error occured\n{:?}", err))?
.map_err(|err| format!("an error occured\n{:?}", err))?;
.map_err(|err| format!("an error occured\n{err:?}"))?
.map_err(|err| format!("an error occured\n{err:?}"))?;
let bank_items_pkt = bank_item_list(&bank);
Ok(vec![(id, SendShipPacket::BankItemList(bank_items_pkt))])
@ -45,8 +43,7 @@ where
EG: EntityGateway + Clone + 'static,
T: Iterator<Item = &'a str> + 'a,
{
let bank_name = BankName(tokens.next().unwrap_or(&"").into());
let bank_name = BankName(tokens.next().unwrap_or("").into());
let bank = clients
.with_mut(id, |client| {
let mut item_state = item_state.clone();
@ -58,8 +55,8 @@ where
})
})
.await
.map_err(|err| format!("an error occured\n{:?}", err))?
.map_err(|err| format!("an error occured\n{:?}", err))?;
.map_err(|err| format!("an error occured\n{err:?}"))?
.map_err(|err| format!("an error occured\n{err:?}"))?;
let bank_items_pkt = bank_item_list(&bank);
Ok(vec![(id, SendShipPacket::BankItemList(bank_items_pkt))])
@ -76,11 +73,11 @@ where
let mut tokens = message.message
.trim_start_matches("\tJ")
.trim_start_matches("\tE")
.trim_end_matches("\0")
.trim_end_matches('\0')
.split_whitespace();
let cmd = tokens.next()?;
match cmd {
"/bank" => Some(default_bank(id, tokens, &mut state.entity_gateway, &state.clients, &mut state.item_state).await),
"/bank" => Some(default_bank(id, &mut state.entity_gateway, &state.clients, &mut state.item_state).await),
"/sbank" => Some(switch_bank(id, tokens, &mut state.entity_gateway, &state.clients, &mut state.item_state).await),
_ => None,

1
src/ship/items/actions.rs

@ -424,7 +424,6 @@ where
transaction.gateway().set_character_bank(&character_id, &bank.as_bank_entity(), &bank.identifier).await?;
item_state.set_bank(bank).await;
Ok(((item_state, transaction), ()))
})
}

2
src/ship/items/bank.rs

@ -1,7 +1,7 @@
use std::cmp::Ordering;
use libpso::character::character;
use crate::ship::items::ClientItemId;
use crate::entity::item::{Meseta, ItemEntityId, ItemDetail, ItemEntity, BankEntity, BankItemEntity, BankName};
use crate::entity::item::{Meseta, ItemEntityId, ItemDetail, ItemEntity, BankEntity, BankItemEntity};
use std::future::Future;
use async_std::sync::{Arc, Mutex};

2
src/ship/ship.rs

@ -736,7 +736,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
self.direct_message(id, msg).await?
},
RecvShipPacket::PlayerChat(msg) => {
match chatcommand::handle_chat_command(id, msg.clone(), &mut self).await {
match chatcommand::handle_chat_command(id, msg.clone(), self).await {
Some(ccmd) => {
match ccmd {
Ok(pkts) => pkts,

Loading…
Cancel
Save