Browse Source

move characterclass/sectionid to libpso

jake 1 year ago
parent
commit
ea27d7338c
  1. 2
      Cargo.toml
  2. 2
      src/drops/Cargo.toml
  3. 2
      src/drops/src/box_drop_table.rs
  4. 2
      src/drops/src/generic_armor.rs
  5. 2
      src/drops/src/generic_shield.rs
  6. 2
      src/drops/src/generic_unit.rs
  7. 2
      src/drops/src/generic_weapon.rs
  8. 2
      src/drops/src/lib.rs
  9. 2
      src/drops/src/rare_drop_table.rs
  10. 2
      src/drops/src/tech_table.rs
  11. 2
      src/drops/src/tool_table.rs
  12. 135
      src/entity/src/character.rs
  13. 1
      src/entity/src/gateway/postgres/models.rs
  14. 2
      src/entity/src/item/mag.rs
  15. 3
      src/entity/src/room.rs
  16. 3
      src/login_server/src/character.rs
  17. 2
      src/room/Cargo.toml
  18. 2
      src/room/src/lib.rs
  19. 2
      src/ship_server/src/lib.rs
  20. 2
      src/ship_server/src/room.rs
  21. 2
      src/shops/Cargo.toml
  22. 2
      src/shops/src/lib.rs
  23. 2
      src/shops/src/weapon.rs
  24. 1
      src/stats/Cargo.toml
  25. 2
      src/stats/src/leveltable.rs
  26. 3
      tests/common.rs
  27. 2
      tests/test_mags.rs

2
Cargo.toml

@ -42,7 +42,7 @@ patch_server = { path = "./src/patch_server" }
login_server = { path = "./src/login_server" } login_server = { path = "./src/login_server" }
ship_server = { path = "./src/ship_server" } ship_server = { path = "./src/ship_server" }
libpso = { git = "http://git.sharnoth.com/jake/libpso", rev="90246b6" }
libpso = { git = "http://git.sharnoth.com/jake/libpso", rev="240ddc7" }
async-std = { version = "1.9.0", features = ["unstable", "attributes"] } async-std = { version = "1.9.0", features = ["unstable", "attributes"] }
futures = "0.3.5" futures = "0.3.5"

2
src/drops/Cargo.toml

@ -9,6 +9,8 @@ entity = { workspace = true }
maps = { workspace = true } maps = { workspace = true }
stats = { workspace = true } stats = { workspace = true }
libpso = { workspace = true }
rand = { workspace = true } rand = { workspace = true }
rand_chacha = { workspace = true } rand_chacha = { workspace = true }
serde = { workspace = true } serde = { workspace = true }

2
src/drops/src/box_drop_table.rs

@ -2,7 +2,7 @@
use rand::{Rng}; use rand::{Rng};
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use entity::character::SectionID;
use libpso::character::SectionID;
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;
use crate::{ItemDropType, load_data_file}; use crate::{ItemDropType, load_data_file};

2
src/drops/src/generic_armor.rs

@ -3,7 +3,7 @@ use serde::{Serialize, Deserialize};
use rand::Rng; use rand::Rng;
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::item::armor::{ArmorType, Armor}; use entity::item::armor::{ArmorType, Armor};
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;

2
src/drops/src/generic_shield.rs

@ -4,7 +4,7 @@ use rand::Rng;
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use entity::item::shield::{ShieldType, Shield}; use entity::item::shield::{ShieldType, Shield};
use entity::character::SectionID;
use libpso::character::SectionID;
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;
use crate::{ItemDropType, load_data_file}; use crate::{ItemDropType, load_data_file};

2
src/drops/src/generic_unit.rs

@ -3,7 +3,7 @@ use serde::{Serialize, Deserialize};
use rand::Rng; use rand::Rng;
use rand::seq::IteratorRandom; use rand::seq::IteratorRandom;
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::item::unit::{UnitType, Unit, UnitModifier}; use entity::item::unit::{UnitType, Unit, UnitModifier};
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;

2
src/drops/src/generic_weapon.rs

@ -4,7 +4,7 @@ use rand::Rng;
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use rand::seq::SliceRandom; use rand::seq::SliceRandom;
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::item::weapon::{Weapon, WeaponType, Attribute, WeaponAttribute, WeaponSpecial}; use entity::item::weapon::{Weapon, WeaponType, Attribute, WeaponAttribute, WeaponSpecial};
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;

2
src/drops/src/lib.rs

@ -24,7 +24,7 @@ use rand::{Rng, SeedableRng};
use maps::monster::MonsterType; use maps::monster::MonsterType;
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;
use entity::character::SectionID;
use libpso::character::SectionID;
use crate::generic_weapon::GenericWeaponTable; use crate::generic_weapon::GenericWeaponTable;
use crate::generic_armor::GenericArmorTable; use crate::generic_armor::GenericArmorTable;
use crate::generic_shield::GenericShieldTable; use crate::generic_shield::GenericShieldTable;

2
src/drops/src/rare_drop_table.rs

@ -7,7 +7,7 @@ use entity::item::shield::{Shield, ShieldType};
use entity::item::unit::{Unit, UnitType}; use entity::item::unit::{Unit, UnitType};
use entity::item::tool::{Tool, ToolType}; use entity::item::tool::{Tool, ToolType};
use entity::item::mag::{Mag, MagType}; use entity::item::mag::{Mag, MagType};
use entity::character::SectionID;
use libpso::character::SectionID;
use maps::monster::MonsterType; use maps::monster::MonsterType;
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;

2
src/drops/src/tech_table.rs

@ -6,7 +6,7 @@ use rand::distributions::{WeightedIndex, Distribution};
use entity::item::tech::{Technique, TechniqueDisk}; use entity::item::tech::{Technique, TechniqueDisk};
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;
use entity::character::SectionID;
use libpso::character::SectionID;
use crate::{ItemDropType, load_data_file}; use crate::{ItemDropType, load_data_file};

2
src/drops/src/tool_table.rs

@ -6,7 +6,7 @@ use rand::distributions::{WeightedIndex, Distribution};
use entity::item::tool::{Tool, ToolType}; use entity::item::tool::{Tool, ToolType};
use maps::room::{Difficulty, Episode}; use maps::room::{Difficulty, Episode};
use maps::area::MapArea; use maps::area::MapArea;
use entity::character::SectionID;
use libpso::character::SectionID;
use crate::{ItemDropType, load_data_file}; use crate::{ItemDropType, load_data_file};
use crate::tech_table::TechniqueTable; use crate::tech_table::TechniqueTable;

135
src/entity/src/character.rs

@ -3,144 +3,11 @@ use std::collections::HashMap;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; use libpso::packet::ship::{UpdateConfig, WriteInfoboard};
use libpso::character::{CharacterClass, SectionID};
use libpso::character::settings::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU}; use libpso::character::settings::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU};
use crate::item::tech::Technique; use crate::item::tech::Technique;
use crate::account::UserAccountId; use crate::account::UserAccountId;
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, enum_utils::FromStr, derive_more::Display, Serialize, Deserialize, Default)]
pub enum CharacterClass {
#[default]
HUmar,
HUnewearl,
HUcast,
HUcaseal,
RAmar,
RAmarl,
RAcast,
RAcaseal,
FOmar,
FOmarl,
FOnewm,
FOnewearl,
}
// TODO: TryFrom
impl From<u8> for CharacterClass {
fn from(f: u8) -> CharacterClass {
match f {
0 => CharacterClass::HUmar,
1 => CharacterClass::HUnewearl,
2 => CharacterClass::HUcast,
3 => CharacterClass::RAmar,
4 => CharacterClass::RAcast,
5 => CharacterClass::RAcaseal,
6 => CharacterClass::FOmarl,
7 => CharacterClass::FOnewm,
8 => CharacterClass::FOnewearl,
9 => CharacterClass::HUcaseal,
10 => CharacterClass::FOmar,
11 => CharacterClass::RAmarl,
_ => panic!("unknown class")
}
}
}
impl From<CharacterClass> for u8 {
fn from(other: CharacterClass) -> u8 {
match other {
CharacterClass::HUmar => 0,
CharacterClass::HUnewearl => 1,
CharacterClass::HUcast => 2,
CharacterClass::RAmar => 3,
CharacterClass::RAcast => 4,
CharacterClass::RAcaseal => 5,
CharacterClass::FOmarl => 6,
CharacterClass::FOnewm => 7,
CharacterClass::FOnewearl => 8,
CharacterClass::HUcaseal => 9,
CharacterClass::FOmar => 10,
CharacterClass::RAmarl => 11,
}
}
}
impl CharacterClass {
pub fn is_human(&self) -> bool {
matches!(self,
CharacterClass::HUmar |
CharacterClass::RAmar |
CharacterClass::RAmarl |
CharacterClass::FOmar |
CharacterClass::FOmarl)
}
pub fn is_newman(&self) -> bool {
matches!(self,
CharacterClass::HUnewearl |
CharacterClass::FOnewm |
CharacterClass::FOnewearl)
}
pub fn is_android(&self) -> bool {
matches!(self,
CharacterClass::HUcast |
CharacterClass::HUcaseal |
CharacterClass::RAcast |
CharacterClass::RAcaseal)
}
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, enum_utils::FromStr, derive_more::Display, Serialize, Deserialize, Default)]
pub enum SectionID {
#[default]
Viridia,
Greenill,
Skyly,
Bluefull,
Purplenum,
Pinkal,
Redria,
Oran,
Yellowboze,
Whitill,
}
impl From<u8> for SectionID {
fn from(id: u8) -> SectionID {
match id {
0 => SectionID::Viridia,
1 => SectionID::Greenill,
2 => SectionID::Skyly,
3 => SectionID::Bluefull,
4 => SectionID::Purplenum,
5 => SectionID::Pinkal,
6 => SectionID::Redria,
7 => SectionID::Oran,
8 => SectionID::Yellowboze,
9 => SectionID::Whitill,
_ => panic!(),
}
}
}
impl From<SectionID> for u8 {
fn from(other: SectionID) -> u8 {
match other {
SectionID::Viridia => 0,
SectionID::Greenill => 1,
SectionID::Skyly => 2,
SectionID::Bluefull => 3,
SectionID::Purplenum => 4,
SectionID::Pinkal => 5,
SectionID::Redria => 6,
SectionID::Oran => 7,
SectionID::Yellowboze => 8,
SectionID::Whitill => 9,
}
}
}
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct CharacterAppearance { pub struct CharacterAppearance {

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

@ -6,6 +6,7 @@ use libpso::character::settings;
use libpso::util::vec_to_array; use libpso::util::vec_to_array;
use crate::account::*; use crate::account::*;
use crate::character::*; use crate::character::*;
use libpso::character::{CharacterClass, SectionID};
use crate::item::*; use crate::item::*;
use crate::room::*; use crate::room::*;
use maps::area::MapArea; use maps::area::MapArea;

2
src/entity/src/item/mag.rs

@ -1,8 +1,8 @@
use std::collections::HashMap; use std::collections::HashMap;
use thiserror::Error; use thiserror::Error;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use libpso::character::{CharacterClass, SectionID};
use crate::item::tool::ToolType; use crate::item::tool::ToolType;
use crate::character::{CharacterClass, SectionID};
use crate::item::ItemEntityId; use crate::item::ItemEntityId;
use std::io::Read; use std::io::Read;

3
src/entity/src/room.rs

@ -1,7 +1,8 @@
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use crate::character::{CharacterEntityId, SectionID};
use crate::character::CharacterEntityId;
use libpso::character::SectionID;
use maps::room::{Episode, Difficulty}; use maps::room::{Episode, Difficulty};

3
src/login_server/src/character.rs

@ -13,6 +13,7 @@ use libpso::packet::ship::{MenuDetail, SmallLeftDialog};
use libpso::{PacketParseError, PSOPacket}; use libpso::{PacketParseError, PSOPacket};
use libpso::crypto::bb::PSOBBCipher; use libpso::crypto::bb::PSOBBCipher;
use libpso::character::character; use libpso::character::character;
use libpso::character::CharacterClass;
use entity::item; use entity::item;
use networking::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY}; use networking::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
@ -29,7 +30,7 @@ use entity::item::armor::Armor;
use entity::item::tech::Technique; use entity::item::tech::Technique;
use entity::item::tool::Tool; use entity::item::tool::Tool;
use entity::item::mag::Mag; use entity::item::mag::Mag;
use entity::character::{CharacterEntity, NewCharacterEntity, CharacterClass, TechLevel};
use entity::character::{CharacterEntity, NewCharacterEntity, TechLevel};
use crate::login::get_login_status; use crate::login::get_login_status;
use networking::interserver::AuthToken; use networking::interserver::AuthToken;

2
src/room/Cargo.toml

@ -10,6 +10,8 @@ quests = { workspace = true }
location = { workspace = true } location = { workspace = true }
drops = { workspace = true } drops = { workspace = true }
libpso = { workspace = true }
rand = { workspace = true } rand = { workspace = true }
async-std = { workspace = true } async-std = { workspace = true }
futures = { workspace = true } futures = { workspace = true }

2
src/room/src/lib.rs

@ -10,7 +10,7 @@ use rand::Rng;
use quests::{QuestList, QuestLoadError}; use quests::{QuestList, QuestLoadError};
use maps::maps::Maps; use maps::maps::Maps;
use drops::DropTable; use drops::DropTable;
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::room::{RoomEntityId, RoomEntityMode}; use entity::room::{RoomEntityId, RoomEntityMode};
use maps::monster::{load_monster_stats_table, MonsterType, MonsterStats}; use maps::monster::{load_monster_stats_table, MonsterType, MonsterStats};
use maps::area::MapAreaLookup; use maps::area::MapAreaLookup;

2
src/ship_server/src/lib.rs

@ -30,7 +30,7 @@ use networking::serverstate::{SendServerPacket, RecvServerPacket, ServerState, O
use networking::interserver::{AuthToken, Ship, ServerId, InterserverActor, LoginMessage, ShipMessage}; use networking::interserver::{AuthToken, Ship, ServerId, InterserverActor, LoginMessage, ShipMessage};
use pktbuilder::ship::SHIP_MENU_ID; use pktbuilder::ship::SHIP_MENU_ID;
use entity::gateway::{EntityGateway, GatewayError}; use entity::gateway::{EntityGateway, GatewayError};
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::room::RoomNote; use entity::room::RoomNote;
use location::{ClientLocation, RoomLobby, ClientLocationError, RoomId}; use location::{ClientLocation, RoomLobby, ClientLocationError, RoomId};
use drops::{DropTable, StandardDropTable}; use drops::{DropTable, StandardDropTable};

2
src/ship_server/src/room.rs

@ -8,7 +8,7 @@ use libpso::packet::messages::*;
use networking::serverstate::ClientId; use networking::serverstate::ClientId;
use stats::leveltable::LEVEL_TABLE; use stats::leveltable::LEVEL_TABLE;
use entity::gateway::EntityGateway; use entity::gateway::EntityGateway;
use entity::character::SectionID;
use libpso::character::SectionID;
use entity::room::{NewRoomEntity, RoomEntityMode, RoomNote}; use entity::room::{NewRoomEntity, RoomEntityMode, RoomNote};
use drops::DropTable; use drops::DropTable;
use crate::SendShipPacket; use crate::SendShipPacket;

2
src/shops/Cargo.toml

@ -8,6 +8,8 @@ maps = { workspace = true }
stats = { workspace = true } stats = { workspace = true }
entity = { workspace = true } entity = { workspace = true }
libpso = { workspace = true }
async-std = { workspace = true } async-std = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
futures = { workspace = true } futures = { workspace = true }

2
src/shops/src/lib.rs

@ -7,7 +7,7 @@ use futures::future::OptionFuture;
use std::collections::HashMap; use std::collections::HashMap;
use entity::item::ItemDetail; use entity::item::ItemDetail;
use maps::room::Difficulty; use maps::room::Difficulty;
use entity::character::SectionID;
use libpso::character::SectionID;
pub use weapon::{WeaponShop, WeaponShopItem}; pub use weapon::{WeaponShop, WeaponShopItem};
pub use tool::{ToolShop, ToolShopItem}; pub use tool::{ToolShop, ToolShopItem};

2
src/shops/src/weapon.rs

@ -8,7 +8,7 @@ use serde::Deserialize;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
use rand::distributions::{WeightedIndex, Distribution}; use rand::distributions::{WeightedIndex, Distribution};
use rand::seq::{SliceRandom, IteratorRandom}; use rand::seq::{SliceRandom, IteratorRandom};
use entity::character::SectionID;
use libpso::character::SectionID;
use maps::room::Difficulty; use maps::room::Difficulty;
use entity::item::ItemDetail; use entity::item::ItemDetail;
use entity::item::weapon::{Weapon, WeaponType, WeaponSpecial, Attribute, WeaponAttribute}; use entity::item::weapon::{Weapon, WeaponType, WeaponSpecial, Attribute, WeaponAttribute};

1
src/stats/Cargo.toml

@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
libpso = { workspace = true }
entity = { workspace = true } entity = { workspace = true }
toml = { workspace = true } toml = { workspace = true }
serde = { workspace = true } serde = { workspace = true }

2
src/stats/src/leveltable.rs

@ -1,6 +1,6 @@
use std::fs::File; use std::fs::File;
use serde_json::Value; use serde_json::Value;
use entity::character::CharacterClass;
use libpso::character::CharacterClass;
use std::sync::LazyLock; use std::sync::LazyLock;
pub static LEVEL_TABLE: LazyLock<CharacterLevelTable> = LazyLock::new(CharacterLevelTable::default); pub static LEVEL_TABLE: LazyLock<CharacterLevelTable> = LazyLock::new(CharacterLevelTable::default);

3
tests/common.rs

@ -3,7 +3,8 @@
use networking::serverstate::{ClientId, ServerState}; use networking::serverstate::{ClientId, ServerState};
use entity::gateway::EntityGateway; use entity::gateway::EntityGateway;
use entity::account::{UserAccountEntity, NewUserAccountEntity, NewUserSettingsEntity}; use entity::account::{UserAccountEntity, NewUserAccountEntity, NewUserSettingsEntity};
use entity::character::{CharacterEntity, NewCharacterEntity, SectionID};
use entity::character::{CharacterEntity, NewCharacterEntity};
use libpso::character::SectionID;
use entity::item::{Meseta, BankIdentifier}; use entity::item::{Meseta, BankIdentifier};
use ship_server::{ShipServerState, ShipServerStateBuilder, RecvShipPacket}; use ship_server::{ShipServerState, ShipServerStateBuilder, RecvShipPacket};
use maps::room::{RoomMode, Difficulty, Episode}; use maps::room::{RoomMode, Difficulty, Episode};

2
tests/test_mags.rs

@ -2,7 +2,7 @@ use networking::serverstate::{ClientId, ServerState};
use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item; use entity::item;
use ship_server::RecvShipPacket; use ship_server::RecvShipPacket;
use entity::character::{CharacterClass, SectionID};
use libpso::character::{CharacterClass, SectionID};
use libpso::packet::ship::*; use libpso::packet::ship::*;
use libpso::packet::messages::*; use libpso::packet::messages::*;

Loading…
Cancel
Save