Crates.io | ryot_tibia |
lib.rs | ryot_tibia |
version | 0.2.3 |
source | src |
created_at | 2024-04-29 18:10:21.081494 |
updated_at | 2024-05-06 07:03:01.374964 |
description | Specializes in managing and integrating Tibia-specific legacy assets, tailored for games inspired by the classic Tibia. |
homepage | https://github.com/ry-ot/Ryot |
repository | https://github.com/ry-ot/Ryot |
max_upload_size | |
id | 1224384 |
size | 22,294 |
A specialized crate for managing Tibia-specific legacy assets, ensuring compatibility and enhancing functionalities tailored to games inspired by Tibia.
This crate encapsulates the protocol definitions for Tibia's appearance data, providing a structured interface to Tibia appearance assets. It primarily consists of automatically generated Rust code from protocol buffer definitions, ensuring type safety and easy integration with Rust codebases.
Protocol Definitions: The core definitions are generated from Tibia's .proto
files,
providing Rust structs that match the protobuf specifications for appearances. This is done
at build time, and the generated code is included directly in the crate.
Conversions Module: Contains implementations for converting raw Tibia appearance data into more usable internal formats. This submodule bridges the gap between raw protocol data and the application-specific data structures used within the Ryot system.
This crate is used internally to decode appearance data received in the Tibia-specific format. It allows the Ryot system to work directly with well-defined Rust structs instead of handling raw binary data, simplifying data manipulation and integration tasks.
Here is an example of how you might use this crate to decode appearance data:
use ryot_core::prelude::VisualElements;
use ryot_tibia as tibia;
fn main() {
// Vec::new() simulates raw bytes received from Tibia's appearance data
let visual_elements: VisualElements = tibia::from_bytes(&Vec::new()).unwrap();
println!("{:?}", visual_elements);
}
The actual .proto
definitions and the generation of Rust code from these definitions are
handled in the crate build script, if the ci_assets feature is enabled. This ensures that the
generated code is always up-to-date and in sync with the latest Tibia appearance definitions.
Tibia assets are stored in a content-catalog.json file that lists the resources the client needs. There are 5 known types of tibia content: appearances, staticdata, staticmapdata, map and sprite. We only use the sprites and appearances in this library.
[
{
"type": "appearances",
"file": "appearances.dat"
},
{
"type": "staticdata",
"file": "staticdata.dat"
},
{
"type": "staticmapdata",
"file": "staticmapdata.dat"
},
{
"type": "map",
"file": "map.otbm"
},
{
"type": "sprite",
"file": "spritesheet.png",
"spritetype": 0,
"firstspriteid": 100,
"lastspriteid": 200,
"area": 64
}
]