Python bindings and Rust tooling for working with KingsIsle class and binary XML data
Project description
kiclass
kiclass is a Rust-powered Python extension for working with KingsIsle class definition files and binary XML data.
It can:
- load class tables from
.cdbdefinition files, - convert definition XML files into
.cdb, - merge client and server definition tables,
- deserialize KI binary XML files into dynamic Python objects,
- serialize parsed objects back to JSON or XML,
- expose the hashing helpers used by Wizard101 and Pirate101.
- parse
.navzone navigation map files.
Install
From PyPI:
pip install kiclass
From source:
maturin develop --release
To build a wheel manually:
maturin build --release
CDB Setup
kiclass loads class definitions from .cdb files. These are compiled class tables generated from KingsIsle definition XML files.
Typical layout:
ClientDefs.xml
ServerDefs.xml
ClientDefs.cdb
ServerDefs.cdb
MergedDefs.cdb
Recommended workflow:
- Obtain
ClientDefs.xmlandServerDefs.xml. - Convert each XML file into a
.cdbfile. - Merge the client and server
.cdbfiles into one combined table. - Load
MergedDefs.cdbwhen reading binary XML files.
Example:
from kiclass import Mode, convert_xml_to_cdb, merge_cdb_defs
convert_xml_to_cdb("ClientDefs.xml", "ClientDefs.cdb", Mode.Wizard)
convert_xml_to_cdb("ServerDefs.xml", "ServerDefs.cdb", Mode.Wizard)
merge_cdb_defs("ClientDefs.cdb", "ServerDefs.cdb", "MergedDefs.cdb")
If you are working with Pirate101 data, use Mode.Pirate when generating the .cdb files.
kiclass expects the current .cdb file format. If your generated files are stale or invalid, regenerate them from the XML sources instead of relying on backwards compatibility.
Usage
Load a class table and read a binary XML file
from kiclass import KIBinaryFileReader, load_classes
classes = load_classes("MergedDefs.cdb")
reader = KIBinaryFileReader(classes)
result = reader.read_file("some_file.xml")
if result is None:
print("Not a valid KI binary XML file")
elif not result.is_known():
print(f"Unknown class id: {result.id()}")
else:
print(result.class_name())
print(result.to_json())
Create a class from the loaded table
from kiclass import load_classes
classes = load_classes("MergedDefs.cdb")
obj = classes.create_class("ClientObject")
if obj is not None:
print(obj.class_name())
print(obj.to_json())
Use the hashing helpers
from kiclass import Mode, hash_field_type, light_hash_string, wiz_hash_string
print(wiz_hash_string("ClientObject"))
print(light_hash_string("string"))
print(hash_field_type("m_templateID", "unsigned int", Mode.Wizard))
Notes
read_file()returns a dynamic class for known data,UnknownClassfor valid but unmapped data, andNonefor invalid binary XML.- The loader expects
.cdbfiles generated in the current format. - The repository includes scripts such as
convert_worlddata.pyand theeasy_deserializetooling for larger batch workflows.
Nav files
.nav files are zlib-compressed zone navigation maps. Each node represents a
game zone and each edge a navigable connection (e.g. ship route, storm gate)
between zones on the world map.
from kiclass import parse_nav
nav = parse_nav("zonemap.nav")
print(nav) # NavMap(nodes=3352, edges=10193)
print(nav.node_count) # 3352
print(nav.edge_count) # 10193
# Look up a zone by name
node = nav.node_by_zone("Aquila/AQ_Z00_Hub")
print(node.index, node.zone_name)
# Find all zones reachable from node 0
for nid in nav.neighbors(0):
print(nav.get_zone_name(nid))
# Iterate all nodes / edges
for node in nav.nodes:
print(node.index, node.zone_name)
for edge in nav.edges:
print(edge.from_node, "->", edge.to_node)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiclass-0.5.0.tar.gz.
File metadata
- Download URL: kiclass-0.5.0.tar.gz
- Upload date:
- Size: 671.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0a4ca9d2c3c0ce6bc7e799a42f1c0c5ec46202e2c516debd6a037c572d79af2
|
|
| MD5 |
64e309e12008f64995d10132588fb9fc
|
|
| BLAKE2b-256 |
fb6ba7226b63c7e65af58e9faa87069f54b572ede2804a63064dd62a93f27ec2
|
File details
Details for the file kiclass-0.5.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: kiclass-0.5.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 575.4 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3e60b6f70acc093b74575138a155498e2150aa20e12468005b3529486ca2c29
|
|
| MD5 |
a21f64869f3391933c4d241148425186
|
|
| BLAKE2b-256 |
977c2fb0aa0e7549c9bec4aaa300887b39b13dcc2f39a7493cd3699e7411b662
|
File details
Details for the file kiclass-0.5.0-cp310-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: kiclass-0.5.0-cp310-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 648.9 kB
- Tags: CPython 3.10+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e787e782bba6e736e9e4b618b3f52985ec8c4c78d680479a54cae31f70436c8
|
|
| MD5 |
62278ffe5854e600a9b264248384338c
|
|
| BLAKE2b-256 |
34d4d87b3d6aab395235114e6b63bc5f37e2a76cc75cf206e3701f07c65f0ed1
|