diff options
Diffstat (limited to 'server/src/protocol.rs')
-rw-r--r-- | server/src/protocol.rs | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/server/src/protocol.rs b/server/src/protocol.rs index a318a9b2..ae87ffb4 100644 --- a/server/src/protocol.rs +++ b/server/src/protocol.rs @@ -1,15 +1,12 @@ use glam::{IVec2, Vec2}; use serde::{Deserialize, Serialize}; -pub type ID = u32; +use crate::recipes::Gamedata; -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct Item(pub String); - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(transparent)] -pub struct Tile(pub String); +pub type PlayerID = usize; +pub type ItemID = usize; +pub type ItemIndex = usize; +pub type TileIndex = usize; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] @@ -24,36 +21,37 @@ pub enum PacketS { #[serde(rename_all = "snake_case")] pub enum PacketC { Joined { - id: ID, + data: Gamedata, + id: PlayerID, }, AddPlayer { - id: ID, + id: PlayerID, name: String, - hand: Option<(ID, Item)>, + hand: Option<(ItemID, ItemIndex)>, }, RemovePlayer { - id: ID, + id: PlayerID, }, Position { - player: ID, + player: PlayerID, pos: Vec2, rot: f32, }, TakeItem { - item: ID, - player: ID, + item: ItemID, + player: PlayerID, }, PutItem { - item: ID, + item: ItemID, pos: IVec2, }, ProduceItem { - id: ID, + id: ItemID, pos: IVec2, - kind: Item, + kind: ItemIndex, }, ConsumeItem { - id: ID, + id: ItemID, pos: IVec2, }, SetActive { @@ -62,6 +60,6 @@ pub enum PacketC { }, UpdateMap { pos: IVec2, - tile: Tile, + tile: TileIndex, }, } |