summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml2
-rw-r--r--core/src/lib.rs4
-rw-r--r--core/src/net/mod.rs9
-rw-r--r--core/src/net/request/mod.rs12
-rw-r--r--core/src/net/response/mod.rs12
-rw-r--r--core/src/net/session_token/mod.rs10
6 files changed, 47 insertions, 2 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index c55e42b..d835350 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -9,7 +9,7 @@ homepage.workspace = true
repository.workspace = true
[dependencies]
-bzipper = "0.5.2"
+bzipper = "0.6.0"
[lints]
workspace = true
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 343623c..24c65a0 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -4,6 +4,8 @@
macro_rules! use_mod {
($vis:vis $name:ident) => {
mod $name;
- use $name::*;
+ $vis use $name::*;
};
}
+
+pub mod net;
diff --git a/core/src/net/mod.rs b/core/src/net/mod.rs
new file mode 100644
index 0000000..f1d7f0d
--- /dev/null
+++ b/core/src/net/mod.rs
@@ -0,0 +1,9 @@
+// Copyright 2022-2024 Gabriel Bjørnager Jensen.
+
+use crate::use_mod;
+use_mod!(pub request);
+use_mod!(pub response);
+use_mod!(pub session_token);
+
+// HIP 37279, a.k.a. Procyon.
+pub const DEFAULT_SERVER_PORT: u16 = 37279;
diff --git a/core/src/net/request/mod.rs b/core/src/net/request/mod.rs
new file mode 100644
index 0000000..ed803ac
--- /dev/null
+++ b/core/src/net/request/mod.rs
@@ -0,0 +1,12 @@
+// Copyright 2022-2024 Gabriel Bjørnager Jensen.
+
+use crate::net::SessionToken;
+
+use bzipper::{Deserialise, FixedString, Serialise};
+
+#[derive(Debug, Deserialise, Serialise)]
+pub enum Request {
+ PlayerJoin { username: FixedString<0x10> },
+
+ PlayerQuit { token: SessionToken },
+}
diff --git a/core/src/net/response/mod.rs b/core/src/net/response/mod.rs
new file mode 100644
index 0000000..9c9a4cb
--- /dev/null
+++ b/core/src/net/response/mod.rs
@@ -0,0 +1,12 @@
+// Copyright 2022-2024 Gabriel Bjørnager Jensen.
+
+use crate::net::{Request, SessionToken};
+
+use bzipper::{Deserialise, FixedString, Serialise};
+
+#[derive(Debug, Deserialise, Serialise)]
+pub enum Response {
+ PlayerJoinAccepted { token: SessionToken },
+
+ RequestDenied { request: Request, reason: FixedString<0x20> },
+}
diff --git a/core/src/net/session_token/mod.rs b/core/src/net/session_token/mod.rs
new file mode 100644
index 0000000..cb3ab8c
--- /dev/null
+++ b/core/src/net/session_token/mod.rs
@@ -0,0 +1,10 @@
+// Copyright 2022-2024 Gabriel Bjørnager Jensen.
+
+use bzipper::{Deserialise, Serialise};
+
+#[derive(Debug, Deserialise, Serialise)]
+#[repr(align(0x10))]
+pub struct SessionToken {
+ pub time: u64,
+ pub key: u64,
+}