summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--client/menu/character.gd7
-rw-r--r--client/menu/character.tscn2
-rw-r--r--client/menu/settings/input/input_value_node.gd2
-rw-r--r--client/menu/setup.tscn2
-rw-r--r--client/multiplayer.gd4
-rw-r--r--locale/en.ini2
-rw-r--r--protocol.md9
-rw-r--r--server/protocol/Cargo.toml2
-rw-r--r--server/src/main.rs2
-rw-r--r--server/src/server.rs8
-rw-r--r--test-client/main.ts13
12 files changed, 39 insertions, 16 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 967b9358..b3d1ec3e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1194,7 +1194,7 @@ dependencies = [
[[package]]
name = "hurrycurry-protocol"
-version = "7.5.0"
+version = "8.0.0"
dependencies = [
"bincode",
"glam",
diff --git a/client/menu/character.gd b/client/menu/character.gd
index dd3bc5cd..fb224dd7 100644
--- a/client/menu/character.gd
+++ b/client/menu/character.gd
@@ -60,7 +60,12 @@ func _input(_event):
func _on_back_pressed():
if username_edit.text == "":
- await submenu("res://menu/warning_popup.tscn", tr("c.error.username_empty"))
+ var popup_data := MenuPopup.Data.new()
+ popup_data.text = tr("c.error.empty_username")
+ var accept_button := Button.new()
+ accept_button.text = tr("c.menu.accept")
+ popup_data.buttons = [accept_button]
+ await submenu("res://menu/popup.tscn", popup_data)
return
Global.set_profile("username", username_edit.text)
diff --git a/client/menu/character.tscn b/client/menu/character.tscn
index bc4e1663..673f4489 100644
--- a/client/menu/character.tscn
+++ b/client/menu/character.tscn
@@ -87,7 +87,7 @@ horizontal_alignment = 1
[node name="username" type="LineEdit" parent="VBoxContainer/top_panel/a"]
layout_mode = 2
-max_length = 16
+max_length = 32
[node name="Spacer" type="MarginContainer" parent="VBoxContainer"]
layout_mode = 2
diff --git a/client/menu/settings/input/input_value_node.gd b/client/menu/settings/input/input_value_node.gd
index 0eb356f3..9cf8327a 100644
--- a/client/menu/settings/input/input_value_node.gd
+++ b/client/menu/settings/input/input_value_node.gd
@@ -72,4 +72,4 @@ func events_equal(e1: InputEvent, e2: InputEvent) -> bool:
func _on_add_pressed() -> void:
listening = not listening
- add_button.text = tr("Press any key...") if listening else add_text
+ add_button.text = tr("c.settings.input.press_any_key") if listening else add_text
diff --git a/client/menu/setup.tscn b/client/menu/setup.tscn
index 0ad994a5..df9642ad 100644
--- a/client/menu/setup.tscn
+++ b/client/menu/setup.tscn
@@ -192,7 +192,7 @@ tooltip_text = "c.setup.name.desc"
[node name="LineEdit" type="LineEdit" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/NameEntry"]
custom_minimum_size = Vector2(300, 30)
layout_mode = 2
-max_length = 64
+max_length = 32
[node name="Control" type="Control" parent="ScrollContainer/Control/TextureRect/PaperMargin/Contents/NameEntry"]
layout_mode = 2
diff --git a/client/multiplayer.gd b/client/multiplayer.gd
index 11a5bd84..5a9406ab 100644
--- a/client/multiplayer.gd
+++ b/client/multiplayer.gd
@@ -21,8 +21,8 @@ extends Node
signal packet(packet: Dictionary)
signal connection_closed()
-static var VERSION_MAJOR: int = 7
-static var VERSION_MINOR: int = 5
+static var VERSION_MAJOR: int = 8
+static var VERSION_MINOR: int = 0
var connected := false
var socket := WebSocketPeer.new()
diff --git a/locale/en.ini b/locale/en.ini
index 63ffa715..041e79bc 100644
--- a/locale/en.ini
+++ b/locale/en.ini
@@ -230,7 +230,7 @@ s.error.quoting_invalid=Command quoting invalid
s.error.self_interact=Interacting with yourself. This is impossible.
s.error.tutorial_already_running=Tutorial already running
s.error.tutorial_no_running=No tutorial running
-s.error.username_length_limit=Username length limit of 64 bytes exceeded
+s.error.username_length_limit=Username length limit of {0} characters or {1} bytes exceeded.
s.error.too_many_players=Too many players joined
s.replay.cannot_join=Replays cannot be joined.
s.state.abort_no_players=Game was aborted due to a lack of players.
diff --git a/protocol.md b/protocol.md
index 9562ab6f..35a13076 100644
--- a/protocol.md
+++ b/protocol.md
@@ -75,3 +75,12 @@ latency. For this reason it implemented three times:
- In Rust (for server, pixelcurry and customers):
[movement.rs](./server/protocol/src/movement.rs)
- In TypeScript (for test-client): [movement.ts](./test-client/movement.ts)
+
+## Limits
+
+The server currently enforces the following network limits:
+
+- Server inbound json packets are at most 8196 bytes in size
+- Server inbound binary packets are at most 4096 bytes in size
+- Player names are no longer than 32 characters
+- Player names are no longer than 64 bytes
diff --git a/server/protocol/Cargo.toml b/server/protocol/Cargo.toml
index 44533f9d..b6da120a 100644
--- a/server/protocol/Cargo.toml
+++ b/server/protocol/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "hurrycurry-protocol"
-version = "7.5.0"
+version = "8.0.0"
edition = "2021"
[dependencies]
diff --git a/server/src/main.rs b/server/src/main.rs
index 2d5ba390..7f3de073 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -248,7 +248,7 @@ async fn run(args: Args) -> anyhow::Result<()> {
info!("{id:?} connected");
while let Some(Ok(message)) = read.next().await {
let packet = match message {
- Message::Text(line) => match serde_json::from_str(&line) {
+ Message::Text(line) if line.len() < 8196 => match serde_json::from_str(&line) {
Ok(p) => p,
Err(e) => {
warn!("Invalid json packet: {e}");
diff --git a/server/src/server.rs b/server/src/server.rs
index f59cd2b9..0889cd71 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -371,8 +371,12 @@ impl Server {
id,
class,
} => {
- if name.len() > 64 {
- return Err(tre!("s.error.username_length_limit"));
+ if name.chars().count() > 32 || name.len() > 64 {
+ return Err(tre!(
+ "s.error.username_length_limit",
+ s = "32".to_string(),
+ s = "64".to_string()
+ ));
}
if self.game.players.len() > 64 {
return Err(tre!("s.error.too_many_players"));
diff --git a/test-client/main.ts b/test-client/main.ts
index b2a5ef46..4c1f28f0 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -39,9 +39,9 @@ export let canvas: HTMLCanvasElement;
let ws: WebSocket;
document.addEventListener("DOMContentLoaded", async () => {
await init_locale()
- const ws_uri = window.location.protocol.endsWith("s:")
- ? `wss://${window.location.host}/`
- : `ws://${window.location.hostname}:27032/`
+ const ws_uri = globalThis.location.protocol.endsWith("s:")
+ ? `wss://${globalThis.location.host}/`
+ : `ws://${globalThis.location.hostname}:27032/`
ws = new WebSocket(ws_uri)
ws.onerror = console.error
ws.onmessage = m => {
@@ -297,7 +297,12 @@ function packet(p: PacketC) {
break;
case "menu":
switch (p.menu) {
- case "book": open("https://s.metamuffin.org/static/hurrycurry/book.pdf"); break
+ case "document":
+ // TODO implement document format
+ if (JSON.stringify(p.data).search("b.toc") != -1)
+ open("https://s.metamuffin.org/static/hurrycurry/book.pdf");
+ else alert("document display not supported yet")
+ break
case "score":
global_message = {
timeout: { initial: 5, remaining: 5, pinned: false },