feat(wow-cdbc): add JSON import support for DBC files#53
Conversation
Add `dbc import` CLI subcommand and `import_from_json` library function to convert JSON data back into valid DBC binary files. - `warcraft-rs dbc import --schema <yaml> --output <dbc> <json>` reads a JSON array exported by `dbc export`, applies the schema for type coercion and string interning, and writes a WDBC-format DBC file. - `import_from_json` in `wow-cdbc` builds a `RecordSet` from JSON, deduplicating strings into a fresh string block before handing off to the existing `DbcWriter`. - `StringBlock::from_bytes` adds an in-memory constructor needed by the importer. - Fix `dbd_to_yaml` binary to use `convert_to_yaml_schemas` (correct `type_name` field, per-build layout, array sizes) instead of the broken column-dump approach. - Fix `generate_yaml_schema` to omit `key_field` when no `$id$` marker exists in the build definition, preventing schema load panics. - Fix `schema_loader::to_schema` to use `try_set_key_field` and return a proper error instead of panicking on unknown key field names. Three unit tests cover: JSON round-trip, missing field error, and type mismatch error.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
Hey, I tried to test this PR since I am the original requester. I am quite struggling to be honest. Could you provide more detail on how to test this, please? |
|
So it turns out the command is |
Notes:
|
|
I pushed one fix for localize string fields and build selection from the source files. Anyway, the above instructions are what I use myself frequently and they work. |
Summary
dbc importCLI subcommand: reads a JSON file + schema YAML and writes a valid WDBC-format DBC binaryimport_from_jsontowow-cdbclibrary: builds aRecordSetfrom JSON with type coercion and string block deduplicationdbd_to_yamlbinary to produce schemas compatible with the schema loader (type_namefield, per-build layout, array sizes)generate_yaml_schemaindbd.rsto omitkey_fieldwhen no$id$marker exists in the build definitionschema_loader::to_schemato return an error instead of panicking on unknown key field namesUsage
Test plan
cargo test --workspacepasses (all tests green, zero failures)cargo clippy --workspace --all-featurespasses (no warnings)export.rs: JSON round-trip, missing field error, type mismatch errorAttackAnimTypes.dbc: validate → export → modify → import → validate