Initial commit
This commit is contained in:
commit
fe2b9921b4
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -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"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
@ -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]
|
33
src/bot.rs
Normal file
33
src/bot.rs
Normal file
@ -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<SimulationInstruction> instruction
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
pub struct Bot{
|
||||
//
|
||||
}
|
13
src/demo.rs
Normal file
13
src/demo.rs
Normal file
@ -0,0 +1,13 @@
|
||||
pub enum Error{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
BLOCK_DEMO_HEADER:
|
||||
//timeline of loading maps, bots
|
||||
*/
|
||||
|
||||
pub struct Demo{
|
||||
map:Box<crate::map::Map>,
|
||||
bots:Vec<crate::bot::Bot>,
|
||||
}
|
79
src/file.rs
Normal file
79
src/file.rs
Normal file
@ -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<u64>,
|
||||
}
|
||||
|
||||
pub enum SNF{
|
||||
Map(crate::map::Map),
|
||||
Bot(crate::bot::Bot),
|
||||
Demo(crate::demo::Demo),
|
||||
}
|
19
src/lib.rs
Normal file
19
src/lib.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use std::io::Read;
|
||||
|
||||
mod file;
|
||||
mod map;
|
||||
mod bot;
|
||||
mod demo;
|
||||
|
||||
pub fn read<R:Read>(input:R)->Result<crate::file::SNF,crate::file::Error>{
|
||||
Err(file::Error::Header(file::HeaderError::InvalidMagic))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
//use super::*;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
}
|
||||
}
|
44
src/map.rs
Normal file
44
src/map.rs
Normal file
@ -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{
|
||||
//
|
||||
}
|
Loading…
Reference in New Issue
Block a user