commit fe2b9921b4e1f8ad4ef6b97b78c6290c0c1669cd Author: Quaternions Date: Mon Jan 15 19:09:34 2024 -0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..0adf322 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "snf" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1f86192 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "snf" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/bot.rs b/src/bot.rs new file mode 100644 index 0000000..c90b823 --- /dev/null +++ b/src/bot.rs @@ -0,0 +1,33 @@ +pub enum Error{ + +} + +/* block types + +BLOCK_BOT_HEADER: +u128 map_resource_uuid //which map is this bot running +u128 time_resource_uuid //resource database time +//don't include style info in bot header because it's in the simulation state +//blocks are laid out in chronological order, but indices may jump around. +u64 num_segments +for _ in 0..num_segments{ + i64 time //simulation_state timestamp + u64 block_id +} + +BLOCK_BOT_SEGMENT: +//format version indicates what version of these structures to use +SimulationState simulation_state //SimulationState is just under ClientState which includes Play/Pause events that the simulation doesn't know about. +//to read, greedily decode instructions until eof +loop{ + //delta encode as much as possible (time,mousepos) + //strafe ticks are implied + //physics can be implied in an input-only bot file + TimedInstruction instruction +} + +*/ + +pub struct Bot{ + // +} \ No newline at end of file diff --git a/src/demo.rs b/src/demo.rs new file mode 100644 index 0000000..c2d30d4 --- /dev/null +++ b/src/demo.rs @@ -0,0 +1,13 @@ +pub enum Error{ + +} + +/* +BLOCK_DEMO_HEADER: +//timeline of loading maps, bots +*/ + +pub struct Demo{ + map:Box, + bots:Vec, +} \ No newline at end of file diff --git a/src/file.rs b/src/file.rs new file mode 100644 index 0000000..d615526 --- /dev/null +++ b/src/file.rs @@ -0,0 +1,79 @@ +//file format "sniff" + +pub enum Error{ + Header(HeaderError), + Map(crate::map::Error), + Bot(crate::bot::Error), + Demo(crate::demo::Error), +} + +pub enum MissingData{ + NeedExactly(usize),//missing exactly this many bytes + NeedAtLeast(usize),//missing at least this many bytes +} + +pub enum HeaderError{ + InvalidMagic, + InvalidVersion, + UnexpectedEOF{ + eof:usize, + missing_data:MissingData, + },//file ends in the middle of the header +} + +/* spec + +//begin global header + +//global metadata (32 bytes) +b"SNFB" +u32 format_version +u64 priming_bytes + //how many bytes of the file must be read to guarantee all of the expected + //format-specific metadata is available to facilitate streaming the remaining contents + //used by the database to guarantee that it serves at least the bare minimum +u128 resource_uuid + //identifies the file from anywhere for any other file + +//global block layout (variable size) +u64 num_blocks +for block_id in 0..num_blocks{ + u64 first_byte +} + +//end global header + +//begin blocks + +//each block is compressed with zstd or gz or something + +*/ + +pub enum Magic{ + Map, //"SNFM" + Bot, //"SNFB" + Demo, //"SNFD" + PlaylistDemo, +} + +pub struct Header{ + /// Type of file + magic:Magic, + /// Type version + version:u32, + /// Minimum data required to know the location of all streamable resources for this specific file + priming:u64, + /// uuid for this file + resource:u128, +} + +pub struct BlockLayout{ + count:u64, + location:Vec, +} + +pub enum SNF{ + Map(crate::map::Map), + Bot(crate::bot::Bot), + Demo(crate::demo::Demo), +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..6312614 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,19 @@ +use std::io::Read; + +mod file; +mod map; +mod bot; +mod demo; + +pub fn read(input:R)->Result{ + Err(file::Error::Header(file::HeaderError::InvalidMagic)) +} + +#[cfg(test)] +mod tests { + //use super::*; + + #[test] + fn test() { + } +} diff --git a/src/map.rs b/src/map.rs new file mode 100644 index 0000000..81e73b6 --- /dev/null +++ b/src/map.rs @@ -0,0 +1,44 @@ +pub enum Error{ + +} + +/* block types + +BLOCK_MAP_HEADER: +DefaultStyleInfo style_info +//bvh goes here +u64 num_nodes +//node 0 parent node is implied to be None +for node_id in 1..num_nodes{ + u64 parent_node +} +u64 num_spacial_blocks +for spacial_block_id in 0..num_spacial_blocks{ + u64 node_id + u64 block_id //data block + Aabb block_extents +} +//ideally spacial blocks are sorted from distance to start zone +//texture blocks are inserted before the first spacial block they are used in + +BLOCK_MAP_RESOURCE: +//an individual one of the following: + - model (IndexedModel) + - shader (compiled SPIR-V) + - image (JpegXL) + - sound (Opus) + - video (AV1) + - animation (Trey thing) + +BLOCK_MAP_OBJECT: +//an individual one of the following: + - model instance + - located resource +//for a list of resources, parse the object. +//alternatively, BLOCK_MAP_REGION lists a group of objects to be decoded all at once + +*/ + +pub struct Map{ + // +} \ No newline at end of file