wow_wdl/
lib.rs

1//! Parser for World of Warcraft WDL (World Detail Level) files.
2//!
3//! This crate provides support for reading and writing WDL files used in
4//! World of Warcraft. WDL files store low-resolution versions of terrain
5//! used for distant terrain rendering and the world map interface.
6//!
7//! # Overview
8//!
9//! WDL files contain low-resolution heightmap data for entire continents,
10//! providing:
11//! - 17x17 heightmap points per map tile (ADT)
12//! - Hole information for terrain gaps
13//! - Optional low-resolution world object placements
14//! - Support for efficient distant terrain rendering
15//! - Data for world map and minimap generation
16//!
17//! ## File Structure
18//!
19//! WDL files use a chunk-based format similar to other WoW files:
20//! - **MVER**: Version information (always first)
21//! - **MAOF**: Map Area Offset table (64x64 grid of file offsets)
22//! - **MARE**: Map Area heightmap data (17x17 outer + 16x16 inner heights)
23//! - **MAHO**: Map Area hole data (16 uint16 bitmasks)
24//! - **MWMO/MWID/MODF**: WMO placement data (pre-Legion)
25//! - **ML\*\***: Model placement chunks (Legion+)
26//!
27//! # Examples
28//!
29//! ```rust,no_run
30//! use std::fs::File;
31//! use std::io::BufReader;
32//! use wow_wdl::parser::WdlParser;
33//!
34//! // Open a WDL file
35//! let file = File::open("path/to/file.wdl").unwrap();
36//! let mut reader = BufReader::new(file);
37//!
38//! // Parse the file
39//! let parser = WdlParser::new();
40//! let wdl_file = parser.parse(&mut reader).unwrap();
41//!
42//! // Use the data
43//! println!("WDL version: {}", wdl_file.version);
44//! println!("Map tiles: {}", wdl_file.heightmap_tiles.len());
45//!
46//! // Get heightmap for a specific tile
47//! if let Some(tile) = wdl_file.heightmap_tiles.get(&(32, 32)) {
48//!     println!("Tile 32,32 has {} height values", tile.outer_values.len());
49//! }
50//! ```
51//!
52//! ## Version Conversion
53//!
54//! ```rust,no_run
55//! use wow_wdl::parser::WdlParser;
56//! use wow_wdl::version::WdlVersion;
57//! use wow_wdl::conversion::convert_wdl_file;
58//! use std::fs::File;
59//! use std::io::{BufReader, BufWriter};
60//!
61//! // Parse an existing file
62//! let file = File::open("input.wdl").unwrap();
63//! let mut reader = BufReader::new(file);
64//! let parser = WdlParser::new();
65//! let wdl_file = parser.parse(&mut reader).unwrap();
66//!
67//! // Convert to Legion version
68//! let legion_file = convert_wdl_file(&wdl_file, WdlVersion::Legion).unwrap();
69//!
70//! // Save the converted file
71//! let output = File::create("output.wdl").unwrap();
72//! let mut writer = BufWriter::new(output);
73//! let legion_parser = WdlParser::with_version(WdlVersion::Legion);
74//! legion_parser.write(&mut writer, &legion_file).unwrap();
75//! ```
76//!
77//! See the `examples` directory for more detailed usage examples.
78
79#![doc = include_str!("../README.md")]
80#![forbid(unsafe_code)]
81#![deny(missing_docs)]
82#![cfg_attr(docsrs, feature(doc_cfg))]
83
84pub mod conversion;
85pub mod error;
86pub mod parser;
87pub mod types;
88pub mod validation;
89pub mod version;
90
91// Re-export primary types
92pub use error::{Result, WdlError};
93pub use types::WdlFile;
94pub use version::WdlVersion;