diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/Cargo.toml | 14 | ||||
-rw-r--r-- | server/bot/Cargo.toml | 6 | ||||
-rw-r--r-- | server/bot/src/algos/simple.rs | 3 | ||||
-rw-r--r-- | server/client-lib/Cargo.toml | 10 | ||||
-rw-r--r-- | server/discover/src/main.rs | 8 | ||||
-rw-r--r-- | server/protocol/Cargo.toml | 4 | ||||
-rw-r--r-- | server/registry/Cargo.toml | 8 | ||||
-rw-r--r-- | server/registry/src/list.rs | 24 | ||||
-rw-r--r-- | server/registry/src/main.rs | 6 | ||||
-rw-r--r-- | server/replaytool/Cargo.toml | 14 | ||||
-rw-r--r-- | server/src/commands.rs | 2 | ||||
-rw-r--r-- | server/src/entity/customers.rs | 2 | ||||
-rw-r--r-- | server/src/entity/tutorial.rs | 24 | ||||
-rw-r--r-- | server/src/network/register.rs | 2 |
14 files changed, 85 insertions, 42 deletions
diff --git a/server/Cargo.toml b/server/Cargo.toml index 978de4c6..38db0bdd 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -7,16 +7,16 @@ default-run = "hurrycurry-server" [dependencies] log = "0.4.22" env_logger = "0.11.5" -anyhow = "1.0.86" -serde = { version = "1.0.205", features = ["derive"] } -tokio = { version = "1.39.2", features = ["full"] } -serde_json = "1.0.122" -tokio-tungstenite = "0.23.1" +anyhow = "1.0.89" +serde = { version = "1.0.210", features = ["derive"] } +tokio = { version = "1.40.0", features = ["full"] } +serde_json = "1.0.128" +tokio-tungstenite = "0.24.0" futures-util = "0.3.30" -serde_yml = "0.0.11" +serde_yml = "0.0.12" rand = "0.9.0-alpha.2" shlex = "1.3.0" -clap = { version = "4.5.15", features = ["derive"] } +clap = { version = "4.5.18", features = ["derive"] } reqwest = { version = "0.12.7", optional = true, default-features = false, features = [ "json", "http2", diff --git a/server/bot/Cargo.toml b/server/bot/Cargo.toml index 3143ab55..c8d60270 100644 --- a/server/bot/Cargo.toml +++ b/server/bot/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" hurrycurry-client-lib = { path = "../client-lib", features = ["tokio-network"] } hurrycurry-protocol = { path = "../protocol" } log = "0.4.22" -anyhow = "1.0.86" +anyhow = "1.0.89" env_logger = "0.11.5" -rustls = { version = "0.23.12", features = ["ring"] } -clap = { version = "4.5.15", features = ["derive"] } +rustls = { version = "0.23.13", features = ["ring"] } +clap = { version = "4.5.18", features = ["derive"] } rand = "0.9.0-alpha.2" diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs index dbe8bbfe..b275b522 100644 --- a/server/bot/src/algos/simple.rs +++ b/server/bot/src/algos/simple.rs @@ -145,6 +145,9 @@ impl<S> Context<'_, S> { .iter() .filter_map(|(_, pl)| match &pl.communicate_persist { Some((Message::Item(item), _)) => { + if self.game.data.item_name(*item) == "unknown-order" { + return None; + } let pos = pl.movement.position.as_ivec2(); [IVec2::X, IVec2::Y, -IVec2::X, -IVec2::Y] .into_iter() diff --git a/server/client-lib/Cargo.toml b/server/client-lib/Cargo.toml index 291c07f4..517dbba0 100644 --- a/server/client-lib/Cargo.toml +++ b/server/client-lib/Cargo.toml @@ -5,17 +5,17 @@ edition = "2021" [dependencies] hurrycurry-protocol = { path = "../protocol" } -tungstenite = { version = "0.23.0", optional = true, features = [ +tungstenite = { version = "0.24.0", optional = true, features = [ "rustls-tls-native-roots", ] } -tokio-tungstenite = { version = "0.23.1", optional = true, features = [ +tokio-tungstenite = { version = "0.24.0", optional = true, features = [ "rustls-tls-native-roots", ] } -tokio = { version = "1.39.2", features = ["net", "sync"], optional = true } -serde_json = "1.0.122" +tokio = { version = "1.40.0", features = ["net", "sync"], optional = true } +serde_json = "1.0.128" bincode = "2.0.0-rc.3" log = "0.4.22" -anyhow = "1.0.86" +anyhow = "1.0.89" futures-util = { version = "0.3.30", optional = true } [features] diff --git a/server/discover/src/main.rs b/server/discover/src/main.rs index 1c23de85..f1f2bb35 100644 --- a/server/discover/src/main.rs +++ b/server/discover/src/main.rs @@ -26,7 +26,7 @@ use hyper::{ use hyper_util::rt::TokioIo; use log::warn; use mdns_sd::{ServiceDaemon, ServiceEvent}; -use std::{cmp::Reverse, collections::HashMap, sync::Arc}; +use std::{cmp::Reverse, collections::HashMap, net::SocketAddr, sync::Arc}; use tokio::{net::TcpListener, spawn, sync::RwLock}; fn main() -> Result<()> { @@ -58,7 +58,9 @@ async fn async_main() -> Result<!> { address: service_info .get_addresses() .into_iter() - .map(|a| format!("ws://{a}:{}", service_info.get_port())) + .map(|a| { + format!("ws://{}", SocketAddr::new(*a, service_info.get_port())) + }) .collect(), players_online: service_info .get_property_val_str("players") @@ -83,7 +85,7 @@ async fn async_main() -> Result<!> { } }); - let listener = TcpListener::bind("127.0.0.1:27035").await?; + let listener = TcpListener::bind("127.0.0.1:27033").await?; loop { let (stream, _) = listener.accept().await?; let entries = entries.clone(); diff --git a/server/protocol/Cargo.toml b/server/protocol/Cargo.toml index 9c3f26e8..2a7a989c 100644 --- a/server/protocol/Cargo.toml +++ b/server/protocol/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -serde = { version = "1.0.205", features = ["derive"] } -glam = { version = "0.28.0", features = ["serde"] } +serde = { version = "1.0.210", features = ["derive"] } +glam = { version = "0.29.0", features = ["serde"] } bincode = { version = "2.0.0-rc.3", features = ["serde", "derive"] } diff --git a/server/registry/Cargo.toml b/server/registry/Cargo.toml index c616174f..49f58a46 100644 --- a/server/registry/Cargo.toml +++ b/server/registry/Cargo.toml @@ -6,16 +6,16 @@ edition = "2021" [dependencies] log = "0.4.22" env_logger = "0.11.5" -anyhow = "1.0.86" +anyhow = "1.0.89" rocket = { version = "0.5.1", features = ["json"] } -tokio = { version = "1.39.2", features = ["full"] } +tokio = { version = "1.40.0", features = ["full"] } serde_json = "1.0.128" markup = "0.15.0" serde = { version = "1.0.210", features = ["derive"] } -tokio-tungstenite = { version = "0.23.1", features = [ +tokio-tungstenite = { version = "0.24.0", features = [ "rustls-tls-native-roots", ] } -rustls = { version = "0.23.12", features = ["ring"] } +rustls = { version = "0.23.13", features = ["ring"] } hurrycurry-protocol = { path = "../protocol" } hurrycurry-client-lib = { path = "../client-lib" } diff --git a/server/registry/src/list.rs b/server/registry/src/list.rs index 1c2cd4a3..5684b473 100644 --- a/server/registry/src/list.rs +++ b/server/registry/src/list.rs @@ -20,9 +20,13 @@ use anyhow::Result; use hurrycurry_protocol::registry::Entry; use rocket::{ get, - http::MediaType, + http::{Header, MediaType}, request::{self, FromRequest, Outcome}, - response::content::{RawHtml, RawJson}, + response::{ + self, + content::{RawHtml, RawJson}, + Responder, + }, Either, Request, State, }; use std::sync::Arc; @@ -32,12 +36,12 @@ use tokio::sync::RwLock; pub(super) async fn r_list( registry: &State<Arc<RwLock<Registry>>>, json: AcceptJson, -) -> Either<RawJson<Arc<str>>, RawHtml<Arc<str>>> { - if json.0 { +) -> Cors<Either<RawJson<Arc<str>>, RawHtml<Arc<str>>>> { + Cors(if json.0 { Either::Left(RawJson(registry.read().await.json_response.clone())) } else { Either::Right(RawHtml(registry.read().await.html_response.clone())) - } + }) } pub(super) fn generate_json_list(entries: &[Entry]) -> Result<Arc<str>> { @@ -100,3 +104,13 @@ impl<'r> FromRequest<'r> for AcceptJson { }) } } + +pub struct Cors<T>(pub T); +#[rocket::async_trait] +impl<'r, T: Responder<'r, 'static>> Responder<'r, 'static> for Cors<T> { + fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> { + let mut b = self.0.respond_to(req)?; + b.set_header(Header::new("access-control-allow-origin", "*")); + Ok(b) + } +} diff --git a/server/registry/src/main.rs b/server/registry/src/main.rs index 5bb7a0a3..30fb8d66 100644 --- a/server/registry/src/main.rs +++ b/server/registry/src/main.rs @@ -26,7 +26,7 @@ use list::{generate_html_list, generate_json_list, r_list}; use lobby::lobby_wrapper; use log::{error, info}; use register::r_register; -use rocket::{get, routes, shield::Shield, Config}; +use rocket::{fairing::AdHoc, get, http::Header, routes, shield::Shield, Config}; use std::{ cmp::Reverse, collections::HashMap, @@ -73,6 +73,10 @@ fn main() { }) .attach(Shield::new()) .manage(registry) + .attach(AdHoc::on_response("set server header", |_req, res| { + res.set_header(Header::new("server", "hurrycurry-registry")); + Box::pin(async {}) + })) .mount("/", routes![r_index, r_list, r_register]) .ignite() .await diff --git a/server/replaytool/Cargo.toml b/server/replaytool/Cargo.toml index fb27ed4b..9d5ac20a 100644 --- a/server/replaytool/Cargo.toml +++ b/server/replaytool/Cargo.toml @@ -6,17 +6,17 @@ edition = "2021" [dependencies] log = "0.4.22" env_logger = "0.11.5" -anyhow = "1.0.86" -serde = { version = "1.0.205", features = ["derive"] } -tokio = { version = "1.39.2", features = ["full"] } -serde_json = "1.0.122" -tokio-tungstenite = { version = "0.23.1", features = [ +anyhow = "1.0.89" +serde = { version = "1.0.210", features = ["derive"] } +tokio = { version = "1.40.0", features = ["full"] } +serde_json = "1.0.128" +tokio-tungstenite = { version = "0.24.0", features = [ "rustls-tls-native-roots", ] } futures-util = "0.3.30" rand = "0.9.0-alpha.2" -clap = { version = "4.5.15", features = ["derive"] } +clap = { version = "4.5.18", features = ["derive"] } async-compression = { version = "0.4.12", features = ["zstd", "tokio"] } -rustls = { version = "0.23.12", features = ["ring"] } +rustls = { version = "0.23.13", features = ["ring"] } hurrycurry-protocol = { path = "../protocol" } diff --git a/server/src/commands.rs b/server/src/commands.rs index 06659161..478d88e3 100644 --- a/server/src/commands.rs +++ b/server/src/commands.rs @@ -70,7 +70,7 @@ enum Command { }, /// Reload the resource index ReloadIndex, - #[clap(alias = "summon-bot", alias = "spawn-bot")] + #[clap(alias = "summon", alias = "bot")] CreateBot { algo: String, name: Option<String>, diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs index bb423e58..a9ddb6f1 100644 --- a/server/src/entity/customers.rs +++ b/server/src/entity/customers.rs @@ -54,7 +54,7 @@ impl Entity for Customers { self.spawn_cooldown = 10. + random::<f32>() * 10.; let bot = BotDriver::new( "".to_string(), - random::<u16>() as i32, + -1 - random::<u16>() as i32, PlayerClass::Customer, Customer::default(), ); diff --git a/server/src/entity/tutorial.rs b/server/src/entity/tutorial.rs index 3189687b..1d28f13e 100644 --- a/server/src/entity/tutorial.rs +++ b/server/src/entity/tutorial.rs @@ -211,6 +211,13 @@ impl<'a> StepContext<'a> { } } fn fulfil_demand(&mut self, item: ItemIndex) -> Result<(), (Option<IVec2>, Message)> { + if self.ent.game.data.item_name(item) == "unknown-order" { + return if let Some(pos) = self.find_demand(item) { + Err((Some(pos), trm!("s.tutorial.accept_order"))) + } else { + Ok(()) + }; + } if !*self.had_aquired_target { self.prevent_burning()?; self.aquire_item(item)?; @@ -264,7 +271,16 @@ impl<'a> StepContext<'a> { } => { let apos = self.aquire_placed_item(*a)?; self.aquire_item(*b)?; - return Err((Some(apos), trm!("s.tutorial.interact"))); + let aname = self.ent.game.data.item_name(*a); + let bname = self.ent.game.data.item_name(*b); + return Err(( + Some(apos), + if aname.starts_with("plate:") || bname.starts_with("plate:") { + trm!("s.tutorial.interact_plate") + } else { + trm!("s.tutorial.interact") + }, + )); } Recipe::Instant { tile: None, @@ -291,7 +307,11 @@ impl<'a> StepContext<'a> { self.aquire_item(*input)?; return Err(( Some(pos), - trm!("s.tutorial.active", s = format!("{:.01}", 1. / speed)), + if self.ent.game.data.tile_name(*tile) == "cuttingboard" { + trm!("s.tutorial.active_cuttingboard") + } else { + trm!("s.tutorial.active", s = format!("{:.01}", 1. / speed)) + }, )); } } diff --git a/server/src/network/register.rs b/server/src/network/register.rs index 8e0464fa..f75b8639 100644 --- a/server/src/network/register.rs +++ b/server/src/network/register.rs @@ -48,8 +48,8 @@ impl Register { port: u16, register_uri: Option<String>, state: Arc<RwLock<Server>>, - no6: bool, no4: bool, + no6: bool, ) -> Self { Self { name, |