aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-04 15:19:39 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-04 15:19:39 +0200
commitce0b808a01081322abc7ed51e09d0f452b606ad7 (patch)
treef3574b5b1a6d935629f78ec80b5ce191c41c4cfa /src/main.rs
parent3d107ea4710f3dec0eedd91ed5bc1e52d8f15912 (diff)
downloadgpn-tron-rust-ce0b808a01081322abc7ed51e09d0f452b606ad7.tar
gpn-tron-rust-ce0b808a01081322abc7ed51e09d0f452b606ad7.tar.bz2
gpn-tron-rust-ce0b808a01081322abc7ed51e09d0f452b606ad7.tar.zst
more code
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index 368f439..2e379fc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,21 +1,11 @@
-#![feature(iterator_try_collect)]
-use config::Config;
-use game::{server::game_server, Game};
-use spectate::server::spectate_server;
-use std::sync::Arc;
-use tokio::{
- spawn,
- sync::{broadcast, RwLock},
+use gpn_tron2::{
+ config::Config,
+ game::{server::game_server, Game},
+ spectate::server::spectate_server,
+ State,
};
-
-pub mod config;
-pub mod game;
-pub mod spectate;
-
-pub struct State {
- tick: broadcast::Sender<bool>, // true for new game
- game: RwLock<Game>,
-}
+use std::sync::Arc;
+use tokio::{spawn, sync::broadcast};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@@ -24,6 +14,8 @@ async fn main() -> anyhow::Result<()> {
let state = Arc::new(State {
tick: broadcast::channel(16).0,
game: Game::new(vec![]).into(),
+ players: Default::default(),
+ chat: broadcast::channel(16).0,
});
spawn(spectate_server(config.spectate, state.clone()));
game_server(config.game, state.clone()).await?;