summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml2
-rw-r--r--core/src/net/mod.rs1
-rw-r--r--core/src/net/request/mod.rs6
-rw-r--r--core/src/net/response/mod.rs8
-rw-r--r--core/src/net/server_status/mod.rs9
-rw-r--r--core/src/net/session_token/mod.rs13
6 files changed, 32 insertions, 7 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index d835350..e14b1e3 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -9,7 +9,7 @@ homepage.workspace = true
repository.workspace = true
[dependencies]
-bzipper = "0.6.0"
+bzipper = "0.6.2"
[lints]
workspace = true
diff --git a/core/src/net/mod.rs b/core/src/net/mod.rs
index f1d7f0d..39916c9 100644
--- a/core/src/net/mod.rs
+++ b/core/src/net/mod.rs
@@ -3,6 +3,7 @@
use crate::use_mod;
use_mod!(pub request);
use_mod!(pub response);
+use_mod!(pub server_status);
use_mod!(pub session_token);
// HIP 37279, a.k.a. Procyon.
diff --git a/core/src/net/request/mod.rs b/core/src/net/request/mod.rs
index ed803ac..40114d9 100644
--- a/core/src/net/request/mod.rs
+++ b/core/src/net/request/mod.rs
@@ -6,7 +6,9 @@ use bzipper::{Deserialise, FixedString, Serialise};
#[derive(Debug, Deserialise, Serialise)]
pub enum Request {
- PlayerJoin { username: FixedString<0x10> },
+ Ping,
- PlayerQuit { token: SessionToken },
+ Join { username: FixedString<0x10> },
+
+ Quit { token: SessionToken },
}
diff --git a/core/src/net/response/mod.rs b/core/src/net/response/mod.rs
index 9c9a4cb..86e7db9 100644
--- a/core/src/net/response/mod.rs
+++ b/core/src/net/response/mod.rs
@@ -1,12 +1,14 @@
// Copyright 2022-2024 Gabriel Bjørnager Jensen.
-use crate::net::{Request, SessionToken};
+use crate::net::{ServerStatus, SessionToken};
use bzipper::{Deserialise, FixedString, Serialise};
#[derive(Debug, Deserialise, Serialise)]
pub enum Response {
- PlayerJoinAccepted { token: SessionToken },
+ JoinAccepted { token: SessionToken },
- RequestDenied { request: Request, reason: FixedString<0x20> },
+ JoinDenied { reason: FixedString<0x20> },
+
+ ServerStatus(ServerStatus),
}
diff --git a/core/src/net/server_status/mod.rs b/core/src/net/server_status/mod.rs
new file mode 100644
index 0000000..e74e4dc
--- /dev/null
+++ b/core/src/net/server_status/mod.rs
@@ -0,0 +1,9 @@
+// Copyright 2022-2024 Gabriel Bjørnager Jensen.
+
+use bzipper::{Deserialise, Serialise};
+
+#[derive(Debug, Deserialise, Serialise)]
+pub struct ServerStatus {
+ pub player_count: u32,
+ pub max_player_count: u32,
+}
diff --git a/core/src/net/session_token/mod.rs b/core/src/net/session_token/mod.rs
index cb3ab8c..0c839af 100644
--- a/core/src/net/session_token/mod.rs
+++ b/core/src/net/session_token/mod.rs
@@ -1,10 +1,21 @@
// Copyright 2022-2024 Gabriel Bjørnager Jensen.
use bzipper::{Deserialise, Serialise};
+use std::fmt::{Debug, Display, Formatter};
-#[derive(Debug, Deserialise, Serialise)]
+#[derive(Clone, Copy, Eq, Deserialise, PartialEq, Serialise)]
#[repr(align(0x10))]
pub struct SessionToken {
pub time: u64,
pub key: u64,
}
+
+impl Debug for SessionToken {
+ #[inline(always)]
+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f, "{self}") }
+}
+
+impl Display for SessionToken {
+ #[inline(always)]
+ fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!(f, "{:016X}:{:016X}", self.time, self.key) }
+}