From 8d1556fce91bbd4301cd13d4ad087640d343fad1 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Thu, 19 Mar 2020 07:58:35 +0100 Subject: Adding update methods to the map --- src/wire/update.rs | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/wire/update.rs') diff --git a/src/wire/update.rs b/src/wire/update.rs index 27f2d0ddded3..a1b47ff07e50 100644 --- a/src/wire/update.rs +++ b/src/wire/update.rs @@ -1,6 +1,7 @@ //! Update to the game state use super::UserId; +use crate::data::{NodeId, PacketId, Player, Upgrade}; use serde::{Deserialize, Serialize}; /// An update provided by the game server @@ -20,15 +21,34 @@ pub enum Update { /// Update made to a node #[derive(Serialize, Deserialize)] -pub enum NodeUpdate {} +pub enum NodeUpdate { + /// The node owner changed + Owner(Player), + /// Represent a new upgrade state + Level { node: NodeId, new: Upgrade }, + /// A new packet was consumed from a link + NewPacket(PacketId), + /// Remove a packet from the node buffer + SentPacket(PacketId), + /// Dropped a packet + DropPacket(PacketId), +} /// Update made to a link #[derive(Serialize, Deserialize)] -pub enum LinkUpdate {} +pub enum LinkUpdate { + /// Take a packet from a node's buffer + TakePacket(PacketId), + /// Give a packet to a node's buffer + GivePacket(PacketId), +} /// Update made to a packet #[derive(Serialize, Deserialize)] -pub enum PacketUpdate {} +pub enum PacketUpdate { + /// Advance a packet along one step along the link + Increment(PacketId), +} /// Update made to the user set #[derive(Serialize, Deserialize)] @@ -41,4 +61,12 @@ pub enum UserUpdate { pub enum UpdateError { /// You are the last user in the match LastUser, + /// The game crashed, so kick all + GameCrashed, + /// The server's time was behind the client time + /// + /// This means that newer events will be dropped from the map + /// state. This should prompt the client to warn the user this + /// has happened, then resync the time of the game states. + TimeAheadServer, } -- cgit v1.2.3