From 041fed841f69ef3b76e4df05d53a2db568b1ea2b Mon Sep 17 00:00:00 2001
From: Quaternions <krakow20@gmail.com>
Date: Fri, 29 Sep 2023 17:47:33 -0700
Subject: [PATCH] sniffa

---
 src/main.rs    |  1 +
 src/sniffer.rs | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
 create mode 100644 src/sniffer.rs

diff --git a/src/main.rs b/src/main.rs
index a942459..742e1aa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,6 +7,7 @@ mod worker;
 mod zeroes;
 mod integer;
 mod physics;
+mod sniffer;
 mod graphics;
 mod settings;
 mod primitives;
diff --git a/src/sniffer.rs b/src/sniffer.rs
new file mode 100644
index 0000000..75c57ee
--- /dev/null
+++ b/src/sniffer.rs
@@ -0,0 +1,82 @@
+//file format "sniff"
+
+/* 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
+
+*/
+
+/* block types
+BLOCK_MAP_HEADER:
+StyleInfoOverrides style_info_overrides
+//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
+}
+//block 0 is the current block, not part of the map data
+u64 num_spacial_blocks
+for block_id in 1..num_spacial_blocks{
+	u64 node_id
+	u64 block_id
+	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)
+	- 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.
+
+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 physics state
+//blocks are not necessarily laid out in chronological order.
+//the timestamps should be sorted, keeping track of which block_id it refers to
+for block_id in 1..num_blocks{ //note that the header block id is skipped
+	i64 time //physics_state timestamp
+}
+
+BLOCK_BOT_SEGMENT:
+//format version indicates what version of these structures to use
+PhysicsState physics_state 
+//to read, greedily decode instructions until eof
+loop{
+	TimedInstruction<PhysicsInstruction> instruction
+}
+
+BLOCK_DEMO_HEADER:
+//timeline of loading maps, player equipment, bots
+*/
\ No newline at end of file