From cde9b8ebb6e0aa14a5ce41b8883e2e58e21cd5d6 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 27 May 2020 21:51:24 -0600 Subject: [PATCH] use btrees for these for easier testing --- src/entity/account.rs | 6 +++--- src/entity/character.rs | 2 +- src/entity/gateway/inmemory.rs | 18 +++++++++--------- src/entity/item/mod.rs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/entity/account.rs b/src/entity/account.rs index b72cb56..4699c09 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -7,11 +7,11 @@ use libpso::character::guildcard; pub const USERFLAG_NEWCHAR: u32 = 0x00000001; pub const USERFLAG_DRESSINGROOM: u32 = 0x00000002; -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct UserAccountId(pub u32); -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct UserSettingsId(pub u32); -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct GuildCardDataId(pub u32); diff --git a/src/entity/character.rs b/src/entity/character.rs index a9d868b..8f6f2b7 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -226,7 +226,7 @@ impl CharacterTechMenu { } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct CharacterEntityId(pub u32); #[derive(Clone)] diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 15c9bb2..1e10dad 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use crate::entity::account::*; use crate::entity::character::*; @@ -9,19 +9,19 @@ use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct InMemoryGateway { - users: Arc>>, - user_settings: Arc>>, - characters: Arc>>, - items: Arc>>, + users: Arc>>, + user_settings: Arc>>, + characters: Arc>>, + items: Arc>>, } impl InMemoryGateway { pub fn new() -> InMemoryGateway { InMemoryGateway { - users: Arc::new(Mutex::new(HashMap::new())), - user_settings: Arc::new(Mutex::new(HashMap::new())), - characters: Arc::new(Mutex::new(HashMap::new())), - items: Arc::new(Mutex::new(HashMap::new())), + users: Arc::new(Mutex::new(BTreeMap::new())), + user_settings: Arc::new(Mutex::new(BTreeMap::new())), + characters: Arc::new(Mutex::new(BTreeMap::new())), + items: Arc::new(Mutex::new(BTreeMap::new())), } } } diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index be29d74..b5f4db6 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -11,7 +11,7 @@ use crate::entity::character::CharacterEntityId; use crate::ship::map::MapArea; use crate::ship::drops::ItemDropType; -#[derive(PartialEq, Copy, Clone, Debug, Hash, Eq)] +#[derive(PartialEq, Copy, Clone, Debug, Hash, Eq, PartialOrd, Ord)] pub struct ItemEntityId(pub u32); #[derive(Hash, PartialEq, Eq, Debug, Clone)] pub struct ItemId(u32);