Skip to main content

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 .cdb definition 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 .nav zone 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:

  1. Obtain ClientDefs.xml and ServerDefs.xml.
  2. Convert each XML file into a .cdb file.
  3. Merge the client and server .cdb files into one combined table.
  4. Load MergedDefs.cdb when 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, UnknownClass for valid but unmapped data, and None for invalid binary XML.
  • The loader expects .cdb files generated in the current format.
  • The repository includes scripts such as convert_worlddata.py and the easy_deserialize tooling 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiclass-0.6.0.tar.gz (671.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kiclass-0.6.0-cp310-abi3-win_amd64.whl (582.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

kiclass-0.6.0-cp310-abi3-manylinux_2_34_x86_64.whl (654.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

File details

Details for the file kiclass-0.6.0.tar.gz.

File metadata

  • Download URL: kiclass-0.6.0.tar.gz
  • Upload date:
  • Size: 671.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiclass-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7611e6bf934191bff421f1a1e4a2088c1ea5dae9839f8e3d109c3e3135ff15c6
MD5 367685cb3f610b71482716e525332b38
BLAKE2b-256 6d20fe2ba5e6770f10cd15dabeb5e1742f5d4578a07e980e3786d6bb1529c7c8

See more details on using hashes here.

File details

Details for the file kiclass-0.6.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: kiclass-0.6.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 582.0 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

Hashes for kiclass-0.6.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5b304b67e6eff78858eb413ea1f250e0772d65c50c6be50a9def511bbbdb9888
MD5 48d293569e8f5b54aa5a51a7687f9f2b
BLAKE2b-256 3fd14dbe8568e2b93ac667f245425da74fde150d9af500d99a3f5117bd3f6c4e

See more details on using hashes here.

File details

Details for the file kiclass-0.6.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kiclass-0.6.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4066adec68d8e20e3f2d9f386329761fafa9db369a94a95bf205d3c4079227dc
MD5 25bc61e36325e3f044984e2a41d5e4b8
BLAKE2b-256 d8b9e1d6d78df7b2d53335ea156aa90b5b8273d4259f32440919aa47c77ee564

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page