diff options
author | Katharina Fey <kookie@spacekookie.de> | 2021-01-29 11:16:03 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2021-01-29 11:27:30 +0100 |
commit | 398027b443cfb331fee64cf351036ca45502ae1b (patch) | |
tree | 0be40f365f6fbdf9ad7a01a10febff2f7c21f9e0 /games/rstnode/src | |
parent | 31ec889558d6a32d4861d7d14eff1f559e7ca72c (diff) |
rstnode: update dependencies and fixing game build
Diffstat (limited to 'games/rstnode/src')
-rw-r--r-- | games/rstnode/src/_if.rs | 13 | ||||
-rw-r--r-- | games/rstnode/src/_loop.rs | 1 | ||||
-rw-r--r-- | games/rstnode/src/_match.rs | 8 | ||||
-rw-r--r-- | games/rstnode/src/lib.rs | 25 | ||||
-rw-r--r-- | games/rstnode/src/server.rs | 5 |
5 files changed, 35 insertions, 17 deletions
diff --git a/games/rstnode/src/_if.rs b/games/rstnode/src/_if.rs index 59d80fb165af..1a842840708c 100644 --- a/games/rstnode/src/_if.rs +++ b/games/rstnode/src/_if.rs @@ -8,7 +8,12 @@ use async_std::sync::Arc; use async_trait::async_trait; use chrono::{DateTime, Utc}; -/// The main game interface implemented by the server and client +/// Main game interface implemented by the server and client +/// +/// The client implementation simply translates requests to network +/// requests that are sent to the server. The server implementation +/// consists of two parts: the network layer listening loop, and the +/// game server state which then implements the actual game logic. #[async_trait] pub trait GameIf { /// Register a new user on a game server @@ -38,7 +43,11 @@ pub trait GameIf { ) -> Result<LobbyUpdate, LobbyErr>; /// Send a start request (as lobby admin) - async fn start_req(self: Arc<Self>, user: UserId, lobby: LobbyId) -> Result<DateTime<Utc>, LobbyErr>; + async fn start_req( + self: Arc<Self>, + user: UserId, + lobby: LobbyId, + ) -> Result<DateTime<Utc>, LobbyErr>; /// Perform a game action as a user async fn perform_action(self: Arc<Self>, user: User, mtch: MatchId, act: Action) diff --git a/games/rstnode/src/_loop.rs b/games/rstnode/src/_loop.rs index 7ba7ad7cdd27..862325490322 100644 --- a/games/rstnode/src/_loop.rs +++ b/games/rstnode/src/_loop.rs @@ -11,6 +11,7 @@ use std::{ }; /// Number of ticks per second +#[from_env("RSTNODE_TICKS")] const TICKS: u64 = 100; const TICK_TIME: Duration = Duration::from_millis(1000 / TICKS); diff --git a/games/rstnode/src/_match.rs b/games/rstnode/src/_match.rs index 53f4d2604fe4..6ae69c54e935 100644 --- a/games/rstnode/src/_match.rs +++ b/games/rstnode/src/_match.rs @@ -17,7 +17,7 @@ pub struct Match { pub players: Vec<Player>, /// The active game map pub map: Map, - /// Input inbox, + /// Input inbox (handled in-order each game tick) inbox: RwLock<VecDeque<Action>>, /// The time the match was initialised init_t: DateTime<Utc>, @@ -59,9 +59,9 @@ impl Match { self.inbox.write().await.push_back(cmd); } - pub async fn handle_inbex(&mut self) { - for act in self.inbox.write().await.drain() { + pub async fn handle_inbox(&mut self) { + // for act in self.inbox.write().await.drain() { - } + // } } } diff --git a/games/rstnode/src/lib.rs b/games/rstnode/src/lib.rs index 94117ddbcffc..e063da34d8bf 100644 --- a/games/rstnode/src/lib.rs +++ b/games/rstnode/src/lib.rs @@ -1,21 +1,24 @@ #![allow(warnings)] +#[macro_use] +extern crate const_env; + mod _if; pub use _if::GameIf; pub mod data; pub mod gens; -mod _loop; -mod _match; -mod config; -mod io; -mod lobby; -mod map; -mod mapstore; -mod server; -mod stats; -mod users; -mod wire; +pub mod _loop; +pub mod _match; +pub mod config; +pub mod io; +pub mod lobby; +pub mod map; +pub mod mapstore; +pub mod server; +pub mod stats; +pub mod users; +pub mod wire; pub use identity::Identity as Id; diff --git a/games/rstnode/src/server.rs b/games/rstnode/src/server.rs index 7a2fad27bb1f..3d95c3638c98 100644 --- a/games/rstnode/src/server.rs +++ b/games/rstnode/src/server.rs @@ -1,3 +1,8 @@ +//! Game server state handler +//! +//! A server can host many lobbies at the same time. It listens for +//! connections according to a address given to the initialiser. + use crate::{ _if::GameIf, _match::Match, |