mirror of
https://github.com/redstrate/Kawari.git
synced 2025-06-30 11:47:45 +00:00
Fix more easy Clippy warnings
This commit is contained in:
parent
a76de282c9
commit
ddb67383af
5 changed files with 27 additions and 45 deletions
|
@ -58,7 +58,7 @@ impl GameData {
|
|||
let sheet = WorldSheet::read_from(&mut self.game_data, Language::None)?;
|
||||
let row = sheet.get_row(world_id as u32)?;
|
||||
|
||||
row.Name().into_string().map(|x| x.clone())
|
||||
row.Name().into_string().cloned()
|
||||
}
|
||||
|
||||
/// Gets the starting city-state from a given class/job id.
|
||||
|
@ -66,7 +66,7 @@ impl GameData {
|
|||
let sheet = ClassJobSheet::read_from(&mut self.game_data, Language::English)?;
|
||||
let row = sheet.get_row(classjob_id as u32)?;
|
||||
|
||||
row.StartingTown().into_u8().map(|x| *x)
|
||||
row.StartingTown().into_u8().copied()
|
||||
}
|
||||
|
||||
pub fn get_racial_base_attributes(&mut self, tribe_id: u8) -> Option<Attributes> {
|
||||
|
@ -127,11 +127,7 @@ impl GameData {
|
|||
}
|
||||
|
||||
// Retrieves a zone's internal name, place name or parent region name.
|
||||
pub fn get_territory_name(
|
||||
&mut self,
|
||||
zone_id: u32,
|
||||
which: TerritoryNameKind,
|
||||
) -> Option<String> {
|
||||
pub fn get_territory_name(&mut self, zone_id: u32, which: TerritoryNameKind) -> Option<String> {
|
||||
let sheet = TerritoryTypeSheet::read_from(&mut self.game_data, Language::None)?;
|
||||
let row = sheet.get_row(zone_id)?;
|
||||
|
||||
|
@ -269,7 +265,7 @@ impl GameData {
|
|||
.Weather()
|
||||
.iter()
|
||||
.cloned()
|
||||
.zip(row.Rate().clone())
|
||||
.zip(row.Rate())
|
||||
.map(|(x, y)| (*x.into_i32().unwrap(), *y.into_u8().unwrap() as i32))
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -2,19 +2,11 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::{Item, Storage};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
||||
pub struct GenericStorage<const N: usize> {
|
||||
pub slots: Vec<Item>,
|
||||
}
|
||||
|
||||
impl<const N: usize> GenericStorage<N> {
|
||||
pub fn default() -> Self {
|
||||
Self {
|
||||
slots: vec![Item::default(); N],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> Storage for GenericStorage<N> {
|
||||
fn max_slots(&self) -> u32 {
|
||||
N as u32
|
||||
|
|
|
@ -46,12 +46,12 @@ pub enum SegmentType {
|
|||
}
|
||||
|
||||
#[binrw]
|
||||
#[brw(import(kind: &SegmentType, size: u32, encryption_key: Option<&[u8]>))]
|
||||
#[brw(import(kind: SegmentType, size: u32, encryption_key: Option<&[u8]>))]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum SegmentData<T: ReadWriteIpcSegment> {
|
||||
#[br(pre_assert(*kind == SegmentType::None))]
|
||||
#[br(pre_assert(kind == SegmentType::None))]
|
||||
None(),
|
||||
#[br(pre_assert(*kind == SegmentType::Setup))]
|
||||
#[br(pre_assert(kind == SegmentType::Setup))]
|
||||
Setup {
|
||||
#[brw(pad_before = 4)] // empty
|
||||
#[brw(pad_size_to = 36)]
|
||||
|
@ -60,13 +60,13 @@ pub enum SegmentData<T: ReadWriteIpcSegment> {
|
|||
#[bw(map = write_string)]
|
||||
ticket: String, // square enix in their infinite wisdom has this as a STRING REPRESENTATION of an integer. what
|
||||
},
|
||||
#[br(pre_assert(*kind == SegmentType::Initialize))]
|
||||
#[br(pre_assert(kind == SegmentType::Initialize))]
|
||||
Initialize {
|
||||
player_id: u32,
|
||||
#[brw(pad_after = 32)]
|
||||
timestamp: u32,
|
||||
},
|
||||
#[br(pre_assert(*kind == SegmentType::SecuritySetup))]
|
||||
#[br(pre_assert(kind == SegmentType::SecuritySetup))]
|
||||
SecuritySetup {
|
||||
#[brw(pad_before = 36)] // empty
|
||||
#[brw(pad_size_to = 32)]
|
||||
|
@ -79,24 +79,24 @@ pub enum SegmentData<T: ReadWriteIpcSegment> {
|
|||
#[brw(pad_after = 512)] // empty
|
||||
key: [u8; 4],
|
||||
},
|
||||
#[br(pre_assert(*kind == SegmentType::Ipc))]
|
||||
#[br(pre_assert(kind == SegmentType::Ipc))]
|
||||
Ipc {
|
||||
#[br(parse_with = decrypt, args(size, encryption_key))]
|
||||
#[bw(write_with = encrypt, args(size, encryption_key))]
|
||||
data: T,
|
||||
},
|
||||
#[br(pre_assert(*kind == SegmentType::KeepAliveRequest))]
|
||||
#[br(pre_assert(kind == SegmentType::KeepAliveRequest))]
|
||||
KeepAliveRequest { id: u32, timestamp: u32 },
|
||||
#[br(pre_assert(*kind == SegmentType::SecurityInitialize))]
|
||||
#[br(pre_assert(kind == SegmentType::SecurityInitialize))]
|
||||
SecurityInitialize {
|
||||
#[br(count = 0x280)]
|
||||
#[brw(pad_size_to = 640)]
|
||||
data: Vec<u8>,
|
||||
},
|
||||
#[br(pre_assert(*kind == SegmentType::KeepAliveResponse))]
|
||||
#[br(pre_assert(kind == SegmentType::KeepAliveResponse))]
|
||||
KeepAliveResponse { id: u32, timestamp: u32 },
|
||||
|
||||
#[br(pre_assert(*kind == SegmentType::KawariIpc))]
|
||||
#[br(pre_assert(kind == SegmentType::KawariIpc))]
|
||||
KawariIpc { data: CustomIpcSegment },
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,8 @@ pub struct PacketSegment<T: ReadWriteIpcSegment> {
|
|||
pub target_actor: u32,
|
||||
#[brw(pad_after = 2)] // padding
|
||||
pub segment_type: SegmentType,
|
||||
#[brw(args(&segment_type, size, encryption_key))]
|
||||
#[bw(args(*segment_type, size, encryption_key))]
|
||||
#[br(args(segment_type, size, encryption_key))]
|
||||
#[br(err_context("segment size = {}", size))]
|
||||
pub data: SegmentData<T>,
|
||||
}
|
||||
|
|
|
@ -51,11 +51,9 @@ impl WorldDatabase {
|
|||
connection.execute(query, ()).unwrap();
|
||||
}
|
||||
|
||||
let this = Self {
|
||||
Self {
|
||||
connection: Mutex::new(connection),
|
||||
};
|
||||
|
||||
this
|
||||
}
|
||||
}
|
||||
|
||||
pub fn import_character(&self, service_account_id: u32, path: &str) {
|
||||
|
|
|
@ -93,17 +93,14 @@ impl WorldServer {
|
|||
|
||||
/// Finds the instance associated with a zone, or creates it if it doesn't exist yet
|
||||
fn find_instance_mut(&mut self, zone_id: u16) -> &mut Instance {
|
||||
self.instances.entry(zone_id).or_insert(Instance::default())
|
||||
self.instances.entry(zone_id).or_default()
|
||||
}
|
||||
|
||||
/// Finds the instance associated with an actor, or returns None if they are not found.
|
||||
fn find_actor_instance_mut(&mut self, actor_id: u32) -> Option<&mut Instance> {
|
||||
for instance in self.instances.values_mut() {
|
||||
if instance.actors.contains_key(&ObjectId(actor_id)) {
|
||||
return Some(instance);
|
||||
}
|
||||
}
|
||||
None
|
||||
self.instances
|
||||
.values_mut()
|
||||
.find(|instance| instance.actors.contains_key(&ObjectId(actor_id)))
|
||||
}
|
||||
|
||||
/// Tell all the clients that a new NPC spawned.
|
||||
|
@ -139,9 +136,9 @@ pub async fn server_main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::i
|
|||
let mut data = data.lock().unwrap();
|
||||
|
||||
// create a new instance if necessary
|
||||
if !data.instances.contains_key(&zone_id) {
|
||||
data.instances.insert(zone_id, Instance::default());
|
||||
}
|
||||
data.instances
|
||||
.entry(zone_id)
|
||||
.or_insert_with(Instance::default);
|
||||
|
||||
// Send existing player data, if any
|
||||
if let Some(instance) = data.find_instance(zone_id).cloned() {
|
||||
|
@ -571,7 +568,7 @@ pub async fn server_main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::i
|
|||
|
||||
if cast_time == 0 {
|
||||
// If instantaneous, send right back
|
||||
send_execution(from_id.clone(), data.clone());
|
||||
send_execution(from_id, data.clone());
|
||||
} else {
|
||||
// Otherwise, delay
|
||||
// NOTE: I know this won't scale, but it's a fine hack for now
|
||||
|
@ -582,8 +579,6 @@ pub async fn server_main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::i
|
|||
);
|
||||
|
||||
// we have to shadow these variables to tell rust not to move them into the async closure
|
||||
let cast_time = cast_time.clone();
|
||||
let from_id = from_id.clone();
|
||||
let data = data.clone();
|
||||
tokio::task::spawn(async move {
|
||||
let mut interval =
|
||||
|
|
Loading…
Add table
Reference in a new issue