Digimon profiles are now created from a toml file.
This commit is contained in:
parent
88bbdca460
commit
4907f6b28a
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -326,6 +326,6 @@
|
||||
"Zanden",
|
||||
"Zweihander"
|
||||
],
|
||||
"rust-analyzer.linkedProjects": ["tools/Cargo.toml"],
|
||||
"rust-analyzer.linkedProjects": ["tools/Cargo.toml", "rust/Cargo.toml"],
|
||||
"rust-analyzer.check.allTargets": false
|
||||
}
|
||||
|
||||
2749
data/digimon_profiles.toml
Normal file
2749
data/digimon_profiles.toml
Normal file
File diff suppressed because it is too large
Load Diff
141
rust/Cargo.lock
generated
141
rust/Cargo.lock
generated
@ -26,6 +26,9 @@ name = "dw2003_exe_digimon_profiles"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"panic_handler",
|
||||
"serde",
|
||||
"toml",
|
||||
"types",
|
||||
"util",
|
||||
]
|
||||
|
||||
@ -81,14 +84,152 @@ dependencies = [
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "panic_handler"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "types"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "util"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
@ -37,3 +37,6 @@ dw2003_pro_stitshop = { path = "dw2003_pro_stitshop" }
|
||||
types = { path = "types" }
|
||||
util = { path = "util" }
|
||||
panic_handler = { path = "panic_handler" }
|
||||
|
||||
serde = { version = "1.0.210", default-features = false }
|
||||
toml = "0.8.19"
|
||||
|
||||
@ -5,5 +5,15 @@ version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
|
||||
util = { workspace = true }
|
||||
# Workspace
|
||||
panic_handler = { workspace = true }
|
||||
types = { workspace = true }
|
||||
util = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
# Workspace
|
||||
types = { workspace = true }
|
||||
|
||||
serde = { workspace = true }
|
||||
toml = { workspace = true }
|
||||
|
||||
155
rust/dw2003_exe_digimon_profiles/build.rs
Normal file
155
rust/dw2003_exe_digimon_profiles/build.rs
Normal file
@ -0,0 +1,155 @@
|
||||
// Build
|
||||
|
||||
// Imports
|
||||
use {
|
||||
std::{env, fs, io::Write, path::Path},
|
||||
types::DigimonProfile,
|
||||
};
|
||||
|
||||
/// Config
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Config {
|
||||
profiles: Vec<DigimonProfile>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo::rerun-if-changed=build.rs");
|
||||
|
||||
// Read the config
|
||||
let config_path = "../../data/digimon_profiles.toml";
|
||||
println!("cargo::rerun-if-changed={config_path}");
|
||||
let config = fs::read_to_string(config_path).expect("Unalbe to read config");
|
||||
let config = toml::from_str::<Config>(&config).expect("Unable to parse config");
|
||||
|
||||
// Then create the output
|
||||
let out_dir = env::var_os("OUT_DIR").expect("Missing `OUT_DIR`");
|
||||
let out_path = Path::new(&out_dir).join("digimon_profiles.rs");
|
||||
let mut output = fs::File::create(out_path).expect("Unable to create output path");
|
||||
|
||||
// And finally write the profiles
|
||||
let len = config.profiles.len();
|
||||
writeln!(
|
||||
output,
|
||||
r#"
|
||||
// Imports
|
||||
use types::DigimonProfile;
|
||||
|
||||
/// Digimon profiles
|
||||
#[no_mangle]
|
||||
#[link_section = "dw2003_exe_digimon_profiles"]
|
||||
pub static mut DIGIMON_PROFILES: [DigimonProfile; {len}] = [
|
||||
"#,
|
||||
)
|
||||
.expect("Unable to write to output");
|
||||
|
||||
for profile in config.profiles {
|
||||
let DigimonProfile {
|
||||
value0,
|
||||
stat_str,
|
||||
stat_def,
|
||||
stat_spt,
|
||||
stat_wis,
|
||||
stat_spd,
|
||||
stat_chr,
|
||||
stat_fire,
|
||||
stat_water,
|
||||
stat_ice,
|
||||
stat_wind,
|
||||
stat_thunder,
|
||||
stat_machine,
|
||||
stat_dark,
|
||||
tech_basic,
|
||||
techs,
|
||||
tech_signature,
|
||||
tech_dna_dv,
|
||||
res_poison,
|
||||
res_paralyze,
|
||||
res_confuse,
|
||||
res_sleep,
|
||||
res_ko,
|
||||
tech_level_learn,
|
||||
tech_level_load,
|
||||
unknown0,
|
||||
unknown1,
|
||||
growth_xp,
|
||||
stat_hp,
|
||||
stat_mp,
|
||||
growth_hp,
|
||||
growth_mp,
|
||||
growth_str,
|
||||
growth_def,
|
||||
growth_spt,
|
||||
growth_wis,
|
||||
growth_spd,
|
||||
growth_chr,
|
||||
growth_fire,
|
||||
growth_water,
|
||||
growth_ice,
|
||||
growth_wind,
|
||||
growth_thunder,
|
||||
growth_machine,
|
||||
growth_dark,
|
||||
blasts,
|
||||
this,
|
||||
unknown2,
|
||||
} = profile;
|
||||
writeln!(
|
||||
output,
|
||||
r#"
|
||||
DigimonProfile {{
|
||||
value0: {value0},
|
||||
stat_str: {stat_str},
|
||||
stat_def: {stat_def},
|
||||
stat_spt: {stat_spt},
|
||||
stat_wis: {stat_wis},
|
||||
stat_spd: {stat_spd},
|
||||
stat_chr: {stat_chr},
|
||||
stat_fire: {stat_fire},
|
||||
stat_water: {stat_water},
|
||||
stat_ice: {stat_ice},
|
||||
stat_wind: {stat_wind},
|
||||
stat_thunder: {stat_thunder},
|
||||
stat_machine: {stat_machine},
|
||||
stat_dark: {stat_dark},
|
||||
tech_basic: {tech_basic},
|
||||
techs: {techs:?},
|
||||
tech_signature: {tech_signature},
|
||||
tech_dna_dv: {tech_dna_dv},
|
||||
res_poison: {res_poison},
|
||||
res_paralyze: {res_paralyze},
|
||||
res_confuse: {res_confuse},
|
||||
res_sleep: {res_sleep},
|
||||
res_ko: {res_ko},
|
||||
tech_level_learn: {tech_level_learn:?},
|
||||
tech_level_load: {tech_level_load:?},
|
||||
unknown0: {unknown0:?},
|
||||
unknown1: {unknown1:?},
|
||||
growth_xp: {growth_xp},
|
||||
stat_hp: {stat_hp},
|
||||
stat_mp: {stat_mp},
|
||||
growth_hp: {growth_hp},
|
||||
growth_mp: {growth_mp},
|
||||
growth_str: {growth_str},
|
||||
growth_def: {growth_def},
|
||||
growth_spt: {growth_spt},
|
||||
growth_wis: {growth_wis},
|
||||
growth_spd: {growth_spd},
|
||||
growth_chr: {growth_chr},
|
||||
growth_fire: {growth_fire},
|
||||
growth_water: {growth_water},
|
||||
growth_ice: {growth_ice},
|
||||
growth_wind: {growth_wind},
|
||||
growth_thunder: {growth_thunder},
|
||||
growth_machine: {growth_machine},
|
||||
growth_dark: {growth_dark},
|
||||
blasts: {blasts:?},
|
||||
this: {this},
|
||||
unknown2: {unknown2:?},
|
||||
}},
|
||||
"#,
|
||||
)
|
||||
.expect("Unable to write to output");
|
||||
}
|
||||
|
||||
writeln!(output, "];").expect("Unable to write to output");
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,3 +4,5 @@ name = "types"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
/// A digimon profile
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct DigimonProfile {
|
||||
pub value0: u16,
|
||||
|
||||
@ -8,8 +8,9 @@
|
||||
|
||||
// Modules
|
||||
pub mod digimon_id;
|
||||
pub mod digimon_profile;
|
||||
pub mod enemy_id;
|
||||
pub mod item_id;
|
||||
|
||||
// Exports
|
||||
pub use self::{digimon_id::DigimonId, enemy_id::EnemyId, item_id::ItemId};
|
||||
pub use self::{digimon_id::DigimonId, digimon_profile::DigimonProfile, enemy_id::EnemyId, item_id::ItemId};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user