Skip to content

Commit

Permalink
Map all act databases
Browse files Browse the repository at this point in the history
  • Loading branch information
HybridEidolon committed Oct 13, 2023
1 parent 2fa4b6e commit 2bd63a8
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 4 deletions.
5 changes: 5 additions & 0 deletions databases-d7/examples/d7db-unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ fn main() -> Result<(), anyhow::Error> {

let dest = args.out_dir.unwrap_or(PathBuf::from(""));

unpack_db::<_, ActData>(&mut archive, "act", &dest)?;
unpack_db::<_, ActEffectData>(&mut archive, "acteffect", &dest)?;
unpack_db::<_, ActFeatureData>(&mut archive, "actfeature", &dest)?;
unpack_db::<_, ActLearnData>(&mut archive, "actlearn", &dest)?;
unpack_db::<_, ActMapData>(&mut archive, "actmap", &dest)?;
unpack_db::<_, BattleFlagData>(&mut archive, "battleflag", &dest)?;
unpack_db::<_, BgmData>(&mut archive, "bgm", &dest)?;
unpack_db::<_, CharaClassData>(&mut archive, "characlass", &dest)?;
Expand Down
89 changes: 89 additions & 0 deletions databases-d7/src/act.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
use crate::CmlString;
use makaikit_databases_serde::DatabaseRecord;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Effect {
r#type: i32,
value: Vec<i32>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActData {
#[serde(rename = "ID")]
pub id: i32,

pub enum_name: String,

#[serde(rename = "refID")]
pub ref_id: i32,

pub name: CmlString,
pub help_text: CmlString,

#[serde(rename = "iconID")]
pub icon_id: i32,

pub is_use: i32,
pub r#type: i32,
pub record_type: i32,
pub weapon_type: i32,
pub attack_type: i32,
pub target_type: i32,
pub attribute: i32,
pub depend: i32,
pub range: i32,
pub range_type: i32,
pub act_map: i32,
pub valid_target: i32,
pub valid_feature: Vec<i32>,
pub invalid_feature: Vec<i32>,
pub upper_range: i32,
pub lower_range: i32,
pub is_self_target: i32,
pub act_feature: Vec<i32>,

#[serde(rename = "consumeSP")]
pub consume_sp: i32,

pub is_enhance: i32,
pub mana: [i32; 9],
pub power: i32,
pub power_coefficient: [i32; 9],
pub effect: [Effect; 5],
pub is_enemy_disabled: i32,
pub is_exclusive: i32,
pub script_file_name: String,
pub script_func_name: String,

#[serde(rename = "scriptFileName_omit")]
pub script_file_name_omit: String,

#[serde(rename = "scriptFuncName_omit")]
pub script_func_name_omit: String,

#[serde(rename = "scriptFileName_veryomit")]
pub script_file_name_veryomit: String,

#[serde(rename = "scriptFuncName_veryomit")]
pub script_func_name_veryomit: String,

pub required_flag: Vec<i32>,

pub version: i32,
pub region: u32,
pub product: u32,
pub platform: u32,
}

impl DatabaseRecord for ActData {
fn database_id(&self) -> i32 {
self.id
}

fn database_enum_name(&self) -> &str {
&self.enum_name
}
}
26 changes: 26 additions & 0 deletions databases-d7/src/acteffect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use makaikit_databases_serde::DatabaseRecord;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActEffectData {
#[serde(rename = "ID")]
pub id: i32,

pub enum_name: String,
pub name: String,
pub version: i32,
pub region: u32,
pub product: u32,
pub platform: u32,
}

impl DatabaseRecord for ActEffectData {
fn database_id(&self) -> i32 {
self.id
}

fn database_enum_name(&self) -> &str {
&self.enum_name
}
}
26 changes: 26 additions & 0 deletions databases-d7/src/actfeature.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use makaikit_databases_serde::DatabaseRecord;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActFeatureData {
#[serde(rename = "ID")]
pub id: i32,

pub enum_name: String,
pub name: String,
pub version: i32,
pub region: u32,
pub product: u32,
pub platform: u32,
}

impl DatabaseRecord for ActFeatureData {
fn database_id(&self) -> i32 {
self.id
}

fn database_enum_name(&self) -> &str {
&self.enum_name
}
}
35 changes: 35 additions & 0 deletions databases-d7/src/actlearn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use makaikit_databases_serde::DatabaseRecord;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActLearnData {
#[serde(rename = "ID")]
pub id: i32,

pub enum_name: String,
pub comment: String,

#[serde(rename = "actID")]
pub act_id: i32,

pub weapon_type: i32,

#[serde(rename = "needWMLv")]
pub need_wm_lv: i32,

pub version: i32,
pub region: u32,
pub product: u32,
pub platform: u32,
}

impl DatabaseRecord for ActLearnData {
fn database_id(&self) -> i32 {
self.id
}

fn database_enum_name(&self) -> &str {
&self.enum_name
}
}
32 changes: 32 additions & 0 deletions databases-d7/src/actmap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use makaikit_databases_serde::DatabaseRecord;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct MapLine {
pub check: i32,
pub column: [i32; 21],
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActMapData {
#[serde(rename = "ID")]
pub id: i32,

pub enum_name: String,
pub name: String,
pub range_type: i32,
pub rot_type: i32,
pub line: Vec<MapLine>,
}

impl DatabaseRecord for ActMapData {
fn database_id(&self) -> i32 {
self.id
}

fn database_enum_name(&self) -> &str {
&self.enum_name
}
}
11 changes: 11 additions & 0 deletions databases-d7/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
use serde::{Deserialize, Serialize};

pub mod act;
pub mod acteffect;
pub mod actfeature;
pub mod actlearn;
pub mod actmap;
pub mod battleflag;
pub mod bgm;
pub mod characlass;
Expand All @@ -10,11 +15,17 @@ pub mod cheatsetting;
pub mod job;
pub mod string;

pub use self::act::ActData;
pub use self::acteffect::ActEffectData;
pub use self::actfeature::ActFeatureData;
pub use self::actlearn::ActLearnData;
pub use self::actmap::ActMapData;
pub use self::battleflag::BattleFlagData;
pub use self::bgm::BgmData;
pub use self::characlass::CharaClassData;
pub use self::character::CharaData;
pub use self::charafeature::CharaFeatureData;
pub use self::charazukan::CharaZukanData;
pub use self::cheatsetting::CheatSettingData;
pub use self::job::JobData;
pub use self::string::StringData;
Expand Down
10 changes: 6 additions & 4 deletions modloader-d7/src/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ use log4rs::{
encode::pattern::PatternEncoder,
Config,
};
use makaikit_databases_d7::{
charazukan::CharaZukanData, BattleFlagData, BgmData, CharaClassData, CharaData,
CharaFeatureData, CheatSettingData, JobData, StringData,
};
use makaikit_databases_d7::*;
use makaikit_databases_serde::DatabaseRecord;
use winapi::{
shared::{
Expand Down Expand Up @@ -449,6 +446,11 @@ fn repack_database<R: Read + Seek, T: DatabaseRecord>(

fn repack_databases() {
let mut archive = makaikit_fafullfs::Archive::open(File::open("data.dat").unwrap()).unwrap();
repack_database::<_, ActData>(&mut archive, "act");
repack_database::<_, ActEffectData>(&mut archive, "acteffect");
repack_database::<_, ActFeatureData>(&mut archive, "actfeature");
repack_database::<_, ActLearnData>(&mut archive, "actlearn");
repack_database::<_, ActMapData>(&mut archive, "actmap");
repack_database::<_, BattleFlagData>(&mut archive, "battleflag");
repack_database::<_, BgmData>(&mut archive, "bgm");
repack_database::<_, CharaClassData>(&mut archive, "characlass");
Expand Down

0 comments on commit 2bd63a8

Please sign in to comment.