Browse Source

use btrees for these for easier testing

pbs
jake 5 years ago
parent
commit
cde9b8ebb6
  1. 6
      src/entity/account.rs
  2. 2
      src/entity/character.rs
  3. 18
      src/entity/gateway/inmemory.rs
  4. 2
      src/entity/item/mod.rs

6
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);

2
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)]

18
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<Mutex<HashMap<UserAccountId, UserAccountEntity>>>,
user_settings: Arc<Mutex<HashMap<UserSettingsId, UserSettingsEntity>>>,
characters: Arc<Mutex<HashMap<CharacterEntityId, CharacterEntity>>>,
items: Arc<Mutex<HashMap<ItemEntityId, ItemEntity>>>,
users: Arc<Mutex<BTreeMap<UserAccountId, UserAccountEntity>>>,
user_settings: Arc<Mutex<BTreeMap<UserSettingsId, UserSettingsEntity>>>,
characters: Arc<Mutex<BTreeMap<CharacterEntityId, CharacterEntity>>>,
items: Arc<Mutex<BTreeMap<ItemEntityId, ItemEntity>>>,
}
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())),
}
}
}

2
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);

Loading…
Cancel
Save