summaryrefslogtreecommitdiff
path: root/server/src/protocol.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-17 17:39:39 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-23 19:20:50 +0200
commit6f0424b9b4cddc0495eb673d314c570e27e61e83 (patch)
tree3ca2f5c8f1d16020dfa432d8a93fb1f53be93c4b /server/src/protocol.rs
parent428fa6fb8dac18c541c0c231f1b640ba172e52b9 (diff)
downloadhurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar
hurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar.bz2
hurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar.zst
everything indexed
Diffstat (limited to 'server/src/protocol.rs')
-rw-r--r--server/src/protocol.rs38
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,
},
}