From b6687dc82b0808baf8dde963f6eaa47eb1e89fa0 Mon Sep 17 00:00:00 2001 From: Serkyo Date: Thu, 9 Jul 2026 19:47:00 +0200 Subject: [PATCH] refactor(shared): migrate mod.rs modules to path-style files --- crates/shared/src/save.rs | 12 ++++++++++++ crates/shared/src/world.rs | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 crates/shared/src/save.rs create mode 100644 crates/shared/src/world.rs diff --git a/crates/shared/src/save.rs b/crates/shared/src/save.rs new file mode 100644 index 0000000..f7304eb --- /dev/null +++ b/crates/shared/src/save.rs @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +//! On-disk save format: the framing that persists modified chunks to region files. +//! +//! The format is built bottom-up. The smallest unit is the `SYNC` per-chunk [`record`], which wraps one [`crate::world::ChunkData`] in a self-describing, compressed frame. Region-level framing (the `SYNR` file and its header table) is layered on top of it. All parsing treats on-disk bytes as untrusted and reports failures through [`SaveError`]. + +mod cursor; +mod error; +pub mod record; +pub mod region; + +pub use error::SaveError; diff --git a/crates/shared/src/world.rs b/crates/shared/src/world.rs new file mode 100644 index 0000000..2d85aa0 --- /dev/null +++ b/crates/shared/src/world.rs @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +//! Core data structures representing the voxel world. +//! +//! The module is split by concept: [`BlockId`] material handles, the [`Chunk`] storage forms, chunk-space coordinates in [`ChunkPos`], and precision-safe entity positions in [`EntityPos`]. Each lives in its own submodule and is re-exported here so callers continue to refer to `shared::world::` regardless of the internal layout. + +mod block; +mod chunk; +mod chunk_data; +mod coords; +mod entity; + +pub use block::BlockId; +pub use chunk::{Chunk, PalettedChunk}; +pub use chunk_data::ChunkData; +pub use coords::ChunkPos; +pub use entity::EntityPos; + +/// The size of a chunk along one axis in blocks. +pub const CHUNK_SIZE: usize = 32; +/// The total number of blocks within a single chunk. +pub const CHUNK_VOLUME: usize = CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE;