Start pushing quadrant

This commit is contained in:
xavo95 2024-11-03 03:12:05 +01:00
parent 432c68ff74
commit 46e57fe2dc
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783
5 changed files with 2681257 additions and 3 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@ async fn main() -> Result<()> {
::common::splash::print_splash();
::common::logging::init(::tracing::Level::DEBUG);
shorekeeper_data::load_json_data("assets/logic/BinData")?;
shorekeeper_data::load_all_json_data("assets/logic/BinData")?;
let database = Arc::new(shorekeeper_database::connect_to(&CONFIG.database).await?);
shorekeeper_database::run_migrations(database.as_ref()).await?;

View file

@ -0,0 +1,18 @@
use serde::Deserialize;
use crate::RawVectorData;
#[derive(Deserialize, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct LevelEntityConfigData {
pub id: i32,
pub map_id: i32,
pub entity_id: i64,
pub blueprint_type: String,
pub name: String,
pub in_sleep: bool,
pub is_hidden: bool,
pub area_id: i32,
pub transform: Vec<RawVectorData>,
// Schemaless property, any suggestions @xeondev??
pub components_data: serde_json::Value,
}

View file

@ -1,8 +1,8 @@
use paste::paste;
mod misc_data;
pub use misc_data::*;
mod misc_data;
#[derive(thiserror::Error, Debug)]
pub enum LoadDataError {
#[error("I/O error: {0}")]
@ -30,7 +30,7 @@ macro_rules! json_data {
}
})*
pub fn load_json_data(base_path: &str) -> Result<(), LoadDataError> {
fn load_json_data(base_path: &str) -> Result<(), LoadDataError> {
$(paste! {
let json_content = std::fs::read_to_string(&format!("{}/{}.json", base_path, stringify!($table_type)))?;
let _ = [<$table_type:snake _data>]::TABLE.set(serde_json::from_str(&json_content)?);
@ -41,6 +41,50 @@ macro_rules! json_data {
};
}
macro_rules! json_hash_table_data {
($($table_type:ident, $key_param:expr;)*) => {
$(paste! {
mod [<$table_type:snake>];
pub use [<$table_type:snake>]::[<$table_type Data>];
})*
$(paste! {
pub mod [<$table_type:snake _data>] {
use std::collections::HashMap;
use std::sync::OnceLock;
pub(crate) type Data = super::[<$table_type Data>];
pub(crate) static TABLE: OnceLock<HashMap<i64, Data>> = OnceLock::new();
pub fn iter() -> std::collections::hash_map::Iter<'static, i64, Data> {
TABLE.get().unwrap().iter()
}
}
})*
fn load_json_hash_table_data(base_path: &str) -> Result<(), LoadDataError> {
$(paste! {
let json_content = std::fs::read_to_string(&format!("{}/{}.json", base_path, stringify!($table_type)))?;
let _ = [<$table_type:snake _data>]::TABLE.set(
serde_json::from_str::<Vec<[<$table_type:snake _data>]::Data>>(&json_content)?
.iter()
.cloned()
.map(|element| (element.$key_param, element))
.collect::<std::collections::HashMap<_, _>>()
);
})*
Ok(())
}
};
}
pub fn load_all_json_data(base_path: &str) -> Result<(), LoadDataError> {
load_json_data(base_path)?;
load_json_hash_table_data(base_path)?;
Ok(())
}
json_data! {
RoleInfo;
WeaponConf;
@ -48,4 +92,9 @@ json_data! {
InstanceDungeon;
FunctionCondition;
ExploreTools;
LordGym;
}
json_hash_table_data! {
LevelEntityConfig, entity_id;
}

View file

@ -26,6 +26,28 @@ impl VectorData {
}
}
#[derive(Deserialize, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct RawVectorData {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl RawVectorData {
pub fn get_x(&self) -> f32 {
self.x
}
pub fn get_y(&self) -> f32 {
self.y
}
pub fn get_z(&self) -> f32 {
self.z
}
}
#[derive(Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct EntranceEntityData {