Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Aug 16, 2023
1 parent 8774112 commit 1f58b87
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 17 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ de_lobby_model = { path = "crates/lobby_model", version = "0.1.0-dev" }
de_log = { path = "crates/log", version = "0.1.0-dev" }
de_map = { path = "crates/map", version = "0.1.0-dev" }
de_menu = { path = "crates/menu", version = "0.1.0-dev" }
de_messages = { path = "crates/messages", version = "0.1.0-dev" }
de_movement = { path = "crates/movement", version = "0.1.0-dev" }
de_multiplayer = { path = "crates/multiplayer", version = "0.1.0-dev" }
de_net = { path = "crates/net", version = "0.1.0-dev" }
Expand Down
1 change: 1 addition & 0 deletions crates/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ name = "de_connector"

[dependencies]
# DE
de_messages.workspace = true
de_net.workspace = true

# Other
Expand Down
3 changes: 2 additions & 1 deletion crates/connector/src/game/ereceiver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::time::Duration;

use async_std::{channel::Sender, future::timeout};
use de_net::{ConnErrorReceiver, ToGame};
use de_messages::ToGame;
use de_net::ConnErrorReceiver;
use tracing::{error, info, warn};

use super::greceiver::ToGameMessage;
Expand Down
3 changes: 2 additions & 1 deletion crates/connector/src/game/greceiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use async_std::{
channel::{Receiver, Sender},
task,
};
use de_net::{FromGame, JoinError, OutPackage, Peers, Readiness, Targets, ToGame};
use de_messages::{FromGame, JoinError, Readiness, ToGame};
use de_net::{OutPackage, Peers, Targets};
use tracing::{error, info, warn};

use super::state::{GameState, JoinError as JoinErrorInner};
Expand Down
3 changes: 2 additions & 1 deletion crates/connector/src/game/preceiver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::net::SocketAddr;

use async_std::channel::Receiver;
use de_net::{FromGame, OutPackage, PackageSender, Peers};
use de_messages::FromGame;
use de_net::{OutPackage, PackageSender, Peers};
use tracing::{error, info, warn};

use super::state::GameState;
Expand Down
3 changes: 2 additions & 1 deletion crates/connector/src/game/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::{collections::hash_map::Entry, net::SocketAddr};

use ahash::AHashMap;
use async_std::sync::{Arc, RwLock};
use de_net::{Readiness, Targets};
use de_messages::Readiness;
use de_net::Targets;
use thiserror::Error;

#[derive(Clone)]
Expand Down
6 changes: 2 additions & 4 deletions crates/connector/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ use std::net::SocketAddr;

use anyhow::Context;
use async_std::task;
use de_net::{
self, FromServer, GameOpenError, MessageDecoder, OutPackage, PackageReceiver, PackageSender,
Peers, Socket, ToServer,
};
use de_messages::{FromServer, GameOpenError, ToServer};
use de_net::{self, MessageDecoder, OutPackage, PackageReceiver, PackageSender, Peers, Socket};
use tracing::{error, info, warn};

use crate::{clients::Clients, game};
Expand Down
6 changes: 2 additions & 4 deletions crates/connector/tests/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use std::{
};

use async_std::{future::timeout, task};
use de_net::{
self, ConnErrorReceiver, FromGame, FromServer, JoinError, OutPackage, PackageReceiver,
PackageSender, Peers, Readiness, Socket, ToGame, ToServer,
};
use de_messages::{FromGame, FromServer, JoinError, Readiness, ToGame, ToServer};
use de_net::{self, ConnErrorReceiver, OutPackage, PackageReceiver, PackageSender, Peers, Socket};
use ntest::timeout;

use crate::common::{spawn_and_wait, term_and_wait};
Expand Down
15 changes: 15 additions & 0 deletions crates/messages/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "de_messages"
description = "Digital Extinction multiplayer message protocol."

version.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
keywords.workspace = true
homepage.workspace = true
license.workspace = true
categories.workspace = true

[dependencies]
bincode.workspace = true
4 changes: 4 additions & 0 deletions crates/messages/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub use messages::{FromGame, FromServer, GameOpenError, JoinError, Readiness, ToGame, ToServer};

// TODO split
mod messages;
File renamed without changes.
1 change: 1 addition & 0 deletions crates/multiplayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ categories.workspace = true
# DE
de_core.workspace = true
de_gui.workspace = true
de_messages.workspace = true
de_net.workspace = true

# Other
Expand Down
2 changes: 1 addition & 1 deletion crates/multiplayer/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::net::SocketAddr;

use bevy::prelude::*;
use de_core::{player::Player, schedule::PreMovement};
use de_net::{FromGame, FromServer, GameOpenError, JoinError, ToGame, ToServer};
use de_messages::{FromGame, FromServer, GameOpenError, JoinError, ToGame, ToServer};

use crate::{
config::ConnectionType,
Expand Down
3 changes: 2 additions & 1 deletion crates/multiplayer/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::{net::SocketAddr, time::Instant};

use bevy::prelude::*;
use de_core::schedule::PreMovement;
use de_net::{FromGame, FromServer, InPackage, PackageBuilder, Peers, ToGame, ToServer};
use de_messages::{FromGame, FromServer, ToGame, ToServer};
use de_net::{InPackage, PackageBuilder, Peers};

use crate::{
config::ConnectionType,
Expand Down
2 changes: 1 addition & 1 deletion crates/multiplayer/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use bevy::prelude::*;
use de_core::schedule::PreMovement;
use de_net::{FromGame, ToGame};
use de_messages::{FromGame, ToGame};
use tracing::{debug, info, trace};

use crate::{
Expand Down
2 changes: 0 additions & 2 deletions crates/net/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub use header::Peers;
pub use messages::{FromGame, FromServer, GameOpenError, JoinError, Readiness, ToGame, ToServer};
pub use protocol::{Targets, MAX_PACKAGE_SIZE};
pub use socket::{RecvError, SendError, Socket, MAX_DATAGRAM_SIZE};
pub use tasks::{
Expand All @@ -9,7 +8,6 @@ pub use tasks::{

mod connection;
mod header;
mod messages;
mod protocol;
mod socket;
mod tasks;

0 comments on commit 1f58b87

Please sign in to comment.