From c2ee65a83838a0ce13402e2c4634bae409d55071 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 6 Jan 2025 01:33:20 +0100 Subject: a --- a.md | 2 +- shared/src/packets.rs | 10 ++++++++-- world/src/main.rs | 9 +-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/a.md b/a.md index 48136ce..5539e14 100644 --- a/a.md +++ b/a.md @@ -26,7 +26,7 @@ Prefab = *(part) ### Part ``` -Part = *(len_key:u8 len_value:u8 *(key:u8) *(value:u8)) +Part = *(len_key:u16 len_value:u16 *(key:u8) *(value:u8)) ``` | Key | Value Type | diff --git a/shared/src/packets.rs b/shared/src/packets.rs index e339dd1..626da07 100644 --- a/shared/src/packets.rs +++ b/shared/src/packets.rs @@ -1,11 +1,11 @@ use anyhow::{Result, bail}; use glam::Vec3; use std::{ - fmt::Display, + fmt::{Debug, Display}, io::{Read, Write}, }; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Resource(pub [u8; 32]); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Object(pub u128); @@ -156,3 +156,9 @@ impl Display for Resource { ) } } + +impl Debug for Resource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self) + } +} diff --git a/world/src/main.rs b/world/src/main.rs index fd354b3..4f641c3 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -26,7 +26,6 @@ fn main() -> Result<()> { let (gltf, buffers, _) = gltf::import(args.scene)?; - let mut parts = Vec::new(); for node in gltf.nodes() { if let Some(mesh) = node.mesh() { for p in mesh.primitives() { @@ -63,17 +62,11 @@ fn main() -> Result<()> { }; let mut out = Vec::new(); part.serialize(&mut out)?; - parts.push(store.set(&out)?); + Packet::Add(Object::new(), store.set(&out)?).serialize(&mut sock)?; } } } - let mut out = Vec::new(); - Prefab(parts).serialize(&mut out)?; - let prefab = store.set(&out)?; - - Packet::Add(Object::new(), prefab).serialize(&mut sock)?; - store.iter(|d| { Packet::RespondResource(d.to_vec()) .serialize(&mut sock) -- cgit v1.2.3-70-g09d2