From f92e9f6f07b1e3834c2ca58ce3510734819d08e4 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Wed, 27 Jan 2021 14:01:50 +0100 Subject: Rework graf karto to fit the client/server structure --- src/net/cargo.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/net/cargo.rs (limited to 'src/net/cargo.rs') diff --git a/src/net/cargo.rs b/src/net/cargo.rs new file mode 100644 index 0000000..b05944c --- /dev/null +++ b/src/net/cargo.rs @@ -0,0 +1,33 @@ +//! The cargo is information actually concerning the inner workings of graf karto, +//! as opposed to the inner workings of the network library. + +use crate::world::{Icon, Room, Wall, World}; +use nalgebra::Matrix3; +use serde::{Deserialize, Serialize}; + +/// Packets sent oven the network will carry this cargo to inform on what the client needs or the +/// server wants. +#[derive(Debug, Deserialize, Serialize)] +pub enum Cargo { + /// Client -> Server: Request to add an icon to the map + AddIcon(Icon), + /// Client -> Server: Request to add a room to the map + AddRoom(Room), + /// Client -> Server: Request to add a wall to the map + AddWall(Wall), + /// Client <-> Server: Update the info of the icon with the given id. + UpdateIcon((usize, Icon)), + /// Client <-> Server: Update the info of the room with the given id. + UpdateRoom((usize, Room)), + /// Client <-> Server: Update the info of the wall with the given id. + UpdateWall((usize, Wall)), + /// Client -> Server: Request to apply the given matrix to the item with the provided id. + /// If the matrix cannot be applied to an item with the given id, it will do nothing. + ApplyMatrix((usize, Matrix3)), + /// Client <-> Remove the item with the given id. + Remove(usize), + /// Server -> Client: Add all of the data additively to the map + AddMapData(World), + /// Server -> Client: Clear the current map data of the client and replace it with this. + UpdateMapData(World), +} -- cgit v1.2.3-70-g09d2