aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/Cargo.toml5
-rw-r--r--server/bot/Cargo.toml3
-rw-r--r--server/bot/src/algos/customer.rs33
-rw-r--r--server/bot/src/algos/frank.rs11
-rw-r--r--server/bot/src/lib.rs8
-rw-r--r--server/client-lib/Cargo.toml2
-rw-r--r--server/client-lib/src/lib.rs1
-rw-r--r--server/discover/Cargo.toml2
-rw-r--r--server/locale-export/Cargo.toml2
-rw-r--r--server/protocol/Cargo.toml2
-rw-r--r--server/registry/Cargo.toml2
-rw-r--r--server/replaytool/Cargo.toml3
-rw-r--r--server/replaytool/src/main.rs6
-rw-r--r--server/replaytool/src/render.rs9
-rw-r--r--server/src/entity/bot.rs5
-rw-r--r--server/src/entity/customers.rs13
-rw-r--r--server/src/entity/environment_effect.rs7
-rw-r--r--server/src/entity/mod.rs11
-rw-r--r--server/src/entity/pedestrians.rs19
-rw-r--r--server/src/entity/tram.rs7
-rw-r--r--server/src/lib.rs10
-rw-r--r--server/src/main.rs1
-rw-r--r--server/src/network/mdns.rs5
-rw-r--r--server/src/network/register.rs10
-rw-r--r--server/src/server.rs18
25 files changed, 103 insertions, 92 deletions
diff --git a/server/Cargo.toml b/server/Cargo.toml
index f72cb7fa..57dcad6c 100644
--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-server"
version = "2.3.5"
-edition = "2021"
+edition = "2024"
default-run = "hurrycurry-server"
[dependencies]
@@ -13,13 +13,10 @@ tokio = { version = "1.47.1", features = ["full"] }
serde_json = "1.0.145"
tokio-tungstenite = "0.27.0"
futures-util = "0.3.31"
-rand = "0.9.2"
-rand_distr = "0.5.1"
shlex = "1.3.0"
clap = { version = "4.5.47", features = ["derive"] }
reqwest = { version = "0.12.23", optional = true, default-features = false, features = [
"json",
- "http2",
"charset",
"rustls-tls-native-roots",
] }
diff --git a/server/bot/Cargo.toml b/server/bot/Cargo.toml
index 17534947..94170510 100644
--- a/server/bot/Cargo.toml
+++ b/server/bot/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-bot"
version = "2.3.5"
-edition = "2021"
+edition = "2024"
[dependencies]
hurrycurry-client-lib = { path = "../client-lib", features = ["tokio-network"] }
@@ -11,4 +11,3 @@ anyhow = "1.0.99"
env_logger = "0.11.8"
rustls = { version = "0.23.31", features = ["ring"] }
clap = { version = "4.5.47", features = ["derive"] }
-rand = "0.9.2"
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index 8a53ac20..17ade544 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -1,3 +1,5 @@
+use std::random::random;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -16,16 +18,16 @@
*/
use crate::{
- pathfinding::{find_path, Path},
BotAlgo, BotInput,
+ pathfinding::{Path, find_path},
+ random_float,
};
use hurrycurry_client_lib::Game;
use hurrycurry_protocol::{
- glam::{IVec2, Vec2},
DemandIndex, Hand, Message, PacketS, PlayerClass, PlayerID, Score,
+ glam::{IVec2, Vec2},
};
-use log::info;
-use rand::{random, rng, seq::IndexedRandom};
+use log::debug;
#[derive(Debug, Clone, Default)]
pub struct Customer {
@@ -103,16 +105,15 @@ impl CustomerState {
match self {
CustomerState::New => {
if !game.data.demands.is_empty() {
- if let Some(&chair) = game
+ let chairs = game
.tiles
.iter()
.filter(|(_, t)| game.data.tile_name(t.kind) == "chair")
.map(|(p, _)| *p)
- .collect::<Vec<_>>()
- .choose(&mut rng())
- {
+ .collect::<Vec<_>>();
+ if let Some(&chair) = chairs.get(random::<usize>(..) % chairs.len().max(1)) {
if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) {
- info!("{me:?} -> entering");
+ debug!("{me:?} -> entering");
*self = CustomerState::Entering {
path,
chair,
@@ -133,10 +134,10 @@ impl CustomerState {
*ticks += 1;
let check = *ticks % 10 == 0;
if path.is_done() {
- let demand = DemandIndex(random::<u32>() as usize % game.data.demands.len());
+ let demand = DemandIndex(random::<usize>(..) % game.data.demands.len());
let requested_item = game.data.demands[demand.0].input;
- info!("{me:?} -> waiting");
- let timeout = 90. + random::<f32>() * 60.;
+ debug!("{me:?} -> waiting");
+ let timeout = 90. + random_float() * 60.;
let mut facing = Vec2::ZERO;
for off in [IVec2::NEG_X, IVec2::NEG_Y, IVec2::X, IVec2::Y] {
if game.tiles.get(&(off + *chair)).is_some_and(|t| {
@@ -209,7 +210,7 @@ impl CustomerState {
if *timeout <= 0. {
let path = find_path(&game.walkable, pos.as_ivec2(), *origin)
.expect("no path to exit");
- info!("{me:?} -> exiting");
+ debug!("{me:?} -> exiting");
*self = CustomerState::Exiting { path };
return BotInput {
extra: vec![
@@ -285,7 +286,7 @@ impl CustomerState {
}
});
if let Some(pos) = demand_pos {
- info!("{me:?} -> eating");
+ debug!("{me:?} -> eating");
let points = game.data.demands[demand.0].points;
*self = CustomerState::Eating {
demand: *demand,
@@ -348,7 +349,7 @@ impl CustomerState {
let demand = &game.data.demands[demand.0];
*progress += dt / demand.duration;
if *progress >= 1. {
- info!("{me:?} -> finishing");
+ debug!("{me:?} -> finishing");
*self = CustomerState::Finishing {
table: *table,
origin: *origin,
@@ -414,7 +415,7 @@ impl CustomerState {
}
CustomerState::Exiting { path } => {
if path.is_done() || path.is_stuck() {
- info!("{me:?} -> leave");
+ debug!("{me:?} -> leave");
BotInput {
leave: true,
..Default::default()
diff --git a/server/bot/src/algos/frank.rs b/server/bot/src/algos/frank.rs
index c8127198..c815c75f 100644
--- a/server/bot/src/algos/frank.rs
+++ b/server/bot/src/algos/frank.rs
@@ -1,3 +1,5 @@
+use std::random::random;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -16,12 +18,11 @@
*/
use crate::{
- pathfinding::{find_path_to_neighbour, Path},
BotAlgo, BotInput,
+ pathfinding::{Path, find_path_to_neighbour},
};
use hurrycurry_client_lib::Game;
-use hurrycurry_protocol::{glam::Vec2, Message, PacketS, PlayerClass, PlayerID};
-use rand::{random, rng, seq::IndexedRandom};
+use hurrycurry_protocol::{Message, PacketS, PlayerClass, PlayerID, glam::Vec2};
#[derive(Default)]
pub struct Frank {
@@ -71,7 +72,7 @@ impl BotAlgo for Frank {
extra: vec![PacketS::Communicate {
player: me,
message: Some(Message::Translation {
- id: format!("s.bot.frank.line.{}", random::<u32>() % 8),
+ id: format!("s.bot.frank.line.{}", random::<u32>(..) % 8),
params: vec![Message::Text(player.name.clone())],
}),
timeout: Some(3.),
@@ -110,5 +111,5 @@ fn find_chef(game: &Game, me: PlayerID) -> Option<PlayerID> {
.filter(|(i, p)| p.class == PlayerClass::Chef && **i != me)
.map(|(i, _)| *i)
.collect::<Vec<_>>();
- chefs.choose(&mut rng()).copied()
+ chefs.get(random::<usize>(..) % chefs.len().max(1)).copied()
}
diff --git a/server/bot/src/lib.rs b/server/bot/src/lib.rs
index cc1cb2a8..927ac7b0 100644
--- a/server/bot/src/lib.rs
+++ b/server/bot/src/lib.rs
@@ -15,14 +15,16 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+#![feature(random)]
pub mod algos;
pub mod pathfinding;
use hurrycurry_client_lib::Game;
use hurrycurry_protocol::{
- glam::{IVec2, Vec2},
PacketS, PlayerID,
+ glam::{IVec2, Vec2},
};
+use std::random::random;
#[derive(Default, Clone)]
pub struct BotInput {
@@ -43,3 +45,7 @@ impl<T: BotAlgo + ?Sized> BotAlgo for Box<T> {
(**self).tick(me, game, dt)
}
}
+
+fn random_float() -> f32 {
+ random::<u32>(..) as f32 / u32::MAX as f32
+}
diff --git a/server/client-lib/Cargo.toml b/server/client-lib/Cargo.toml
index 9d1cb94c..17a3b259 100644
--- a/server/client-lib/Cargo.toml
+++ b/server/client-lib/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-client-lib"
version = "2.3.5"
-edition = "2021"
+edition = "2024"
[dependencies]
hurrycurry-protocol = { path = "../protocol" }
diff --git a/server/client-lib/src/lib.rs b/server/client-lib/src/lib.rs
index c77f95e7..b3939388 100644
--- a/server/client-lib/src/lib.rs
+++ b/server/client-lib/src/lib.rs
@@ -15,7 +15,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#![feature(let_chains)]
pub mod gamedata_index;
pub mod network;
pub mod spatial_index;
diff --git a/server/discover/Cargo.toml b/server/discover/Cargo.toml
index 566b3fa9..c41f574c 100644
--- a/server/discover/Cargo.toml
+++ b/server/discover/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-discover"
version = "2.3.5"
-edition = "2021"
+edition = "2024"
[dependencies]
mdns-sd = "0.15.1"
diff --git a/server/locale-export/Cargo.toml b/server/locale-export/Cargo.toml
index 56067c7a..6bcb4a34 100644
--- a/server/locale-export/Cargo.toml
+++ b/server/locale-export/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-locale-export"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
clap = { version = "4.5.47", features = ["derive"] }
diff --git a/server/protocol/Cargo.toml b/server/protocol/Cargo.toml
index 8d0f6b51..84067758 100644
--- a/server/protocol/Cargo.toml
+++ b/server/protocol/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-protocol"
version = "11.0.0"
-edition = "2021"
+edition = "2024"
[dependencies]
serde = { version = "1.0.225", features = ["derive"] }
diff --git a/server/registry/Cargo.toml b/server/registry/Cargo.toml
index a7c26883..ba65f7ca 100644
--- a/server/registry/Cargo.toml
+++ b/server/registry/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-registry"
version = "2.3.5"
-edition = "2021"
+edition = "2024"
[dependencies]
log = "0.4.28"
diff --git a/server/replaytool/Cargo.toml b/server/replaytool/Cargo.toml
index cfc50b3a..cc13b4a9 100644
--- a/server/replaytool/Cargo.toml
+++ b/server/replaytool/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "hurrycurry-replaytool"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
log = "0.4.28"
@@ -14,7 +14,6 @@ tokio-tungstenite = { version = "0.27.0", features = [
"rustls-tls-native-roots",
] }
futures-util = "0.3.31"
-rand = "0.9.2"
clap = { version = "4.5.47", features = ["derive"] }
async-compression = { version = "0.4.30", features = ["zstd", "tokio"] }
rustls = { version = "0.23.31", features = ["ring"] }
diff --git a/server/replaytool/src/main.rs b/server/replaytool/src/main.rs
index 1e5be601..5238a675 100644
--- a/server/replaytool/src/main.rs
+++ b/server/replaytool/src/main.rs
@@ -15,7 +15,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#![feature(exit_status_error)]
+#![feature(exit_status_error, random)]
pub mod record;
pub mod render;
@@ -23,12 +23,12 @@ pub mod replay;
use crate::{
record::record,
- render::{render, RenderArgs},
+ render::{RenderArgs, render},
replay::replay,
};
use clap::Parser;
use hurrycurry_protocol::PacketC;
-use log::{info, warn, LevelFilter};
+use log::{LevelFilter, info, warn};
use serde::{Deserialize, Serialize};
use std::{
path::PathBuf,
diff --git a/server/replaytool/src/render.rs b/server/replaytool/src/render.rs
index 2314de79..12e7d43c 100644
--- a/server/replaytool/src/render.rs
+++ b/server/replaytool/src/render.rs
@@ -17,12 +17,11 @@
*/
use crate::replay::replay;
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use log::info;
-use rand::random;
-use std::{path::PathBuf, str::FromStr};
+use std::{path::PathBuf, random::random, str::FromStr};
use tokio::{
- fs::{create_dir_all, remove_dir, remove_file, File},
+ fs::{File, create_dir_all, remove_dir, remove_file},
io::AsyncWriteExt,
net::TcpListener,
process::Command,
@@ -57,7 +56,7 @@ pub async fn render(a: RenderArgs) -> Result<()> {
let cwd = PathBuf::from_str("/tmp")
.unwrap()
- .join(format!("hurrycurry-render-cfg-{:016x}", random::<u64>()));
+ .join(format!("hurrycurry-render-cfg-{:016x}", random::<u64>(..)));
let config = {
let (width, height) = a
diff --git a/server/src/entity/bot.rs b/server/src/entity/bot.rs
index 8757cc97..26ae77a6 100644
--- a/server/src/entity/bot.rs
+++ b/server/src/entity/bot.rs
@@ -20,8 +20,7 @@ use anyhow::Result;
use hurrycurry_bot::{BotAlgo, DynBotAlgo};
use hurrycurry_protocol::{Character, Hand, PacketS, PlayerClass, PlayerID};
use log::info;
-use rand::random;
-use std::any::Any;
+use std::{any::Any, random::random};
pub type DynBotDriver = BotDriver<DynBotAlgo>;
@@ -50,7 +49,7 @@ impl<T: BotAlgo + Any> Entity for BotDriver<T> {
}
fn tick(&mut self, c: EntityContext<'_>) -> Result<()> {
if let Some((name, character, class)) = self.join_data.take() {
- self.id = PlayerID(random()); // TODO bad code, can collide
+ self.id = PlayerID(random(..)); // TODO bad code, can collide
info!("spawn {:?} ({name:?})", self.id);
c.packet_in.push_back(PacketS::Join {
name,
diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs
index 22522e4e..1e795ac5 100644
--- a/server/src/entity/customers.rs
+++ b/server/src/entity/customers.rs
@@ -1,3 +1,7 @@
+use std::random::random;
+
+use crate::random_float;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -15,11 +19,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use super::{bot::BotDriver, Entity, EntityContext};
+use super::{Entity, EntityContext, bot::BotDriver};
use anyhow::Result;
use hurrycurry_bot::algos::{Customer, CustomerConfig};
use hurrycurry_protocol::{Character, PlayerClass};
-use rand::random;
pub struct Customers {
customers: Vec<BotDriver<Customer>>,
@@ -53,12 +56,12 @@ impl Entity for Customers {
self.spawn_cooldown -= c.dt;
self.spawn_cooldown = self.spawn_cooldown.max(0.);
if self.customers.len() < max_count && self.spawn_cooldown <= 0. {
- self.spawn_cooldown = 5. + random::<f32>() * 5.;
+ self.spawn_cooldown = 5. + random_float() * 5.;
let bot = BotDriver::new(
"".to_string(),
Character {
- color: random(),
- hairstyle: random(),
+ color: random(..),
+ hairstyle: random(..),
headwear: 0,
},
PlayerClass::Customer,
diff --git a/server/src/entity/environment_effect.rs b/server/src/entity/environment_effect.rs
index ba2c395e..b5344a27 100644
--- a/server/src/entity/environment_effect.rs
+++ b/server/src/entity/environment_effect.rs
@@ -1,3 +1,5 @@
+use crate::random_float;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -18,7 +20,6 @@
use super::{Entity, EntityContext};
use hurrycurry_data::entities::EnvironmentEffect;
use hurrycurry_protocol::PacketC;
-use rand::random;
use std::time::{Duration, Instant};
#[derive(Clone, Debug)]
@@ -42,12 +43,12 @@ impl Entity for EnvironmentEffectController {
if self.next_transition < Instant::now() {
if self.active {
self.next_transition +=
- Duration::from_secs_f32(self.config.on * (0.5 + random::<f32>()));
+ Duration::from_secs_f32(self.config.on * (0.5 + random_float()));
self.active = false;
c.game.environment_effects.remove(&self.config.name);
} else {
self.next_transition +=
- Duration::from_secs_f32(self.config.off * (0.5 + random::<f32>()));
+ Duration::from_secs_f32(self.config.off * (0.5 + random_float()));
self.active = true;
c.game.environment_effects.insert(self.config.name.clone());
}
diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs
index 47d37f3d..ce7cb849 100644
--- a/server/src/entity/mod.rs
+++ b/server/src/entity/mod.rs
@@ -35,9 +35,9 @@ use conveyor::Conveyor;
use customers::Customers;
use environment_effect::{EnvironmentController, EnvironmentEffectController};
use hurrycurry_client_lib::Game;
-use hurrycurry_data::{entities::EntityDecl, Serverdata};
+use hurrycurry_data::{Serverdata, entities::EntityDecl};
use hurrycurry_locale::TrError;
-use hurrycurry_protocol::{glam::IVec2, Character, Gamedata, PacketC, PacketS, PlayerID};
+use hurrycurry_protocol::{Character, Gamedata, PacketC, PacketS, PlayerID, glam::IVec2};
use item_portal::ItemPortal;
use player_portal::PlayerPortal;
use std::{
@@ -133,11 +133,8 @@ pub fn construct_entity(decl: &EntityDecl, data: &Gamedata) -> DynEntity {
} => Box::new(Pedestrians {
players: HashMap::new(),
points,
- spawn_delay_distr: rand_distr::Normal::new(
- spawn_delay,
- spawn_delay_stdev.unwrap_or(0.),
- )
- .unwrap(),
+ spawn_delay,
+ spawn_delay_stdev: spawn_delay_stdev.unwrap_or(0.),
cooldown: 0.,
speed: speed.unwrap_or(0.6),
}),
diff --git a/server/src/entity/pedestrians.rs b/server/src/entity/pedestrians.rs
index fa3276d2..cc5d6d90 100644
--- a/server/src/entity/pedestrians.rs
+++ b/server/src/entity/pedestrians.rs
@@ -1,3 +1,5 @@
+use crate::random_gauss;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -17,15 +19,14 @@
*/
use super::{Entity, EntityContext};
use anyhow::Result;
-use hurrycurry_protocol::{glam::Vec2, Character, PacketS, PlayerClass, PlayerID};
-use rand::{random, rng};
-use rand_distr::Distribution;
-use std::collections::HashMap;
+use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID, glam::Vec2};
+use std::{collections::HashMap, random::random};
pub struct Pedestrians {
pub players: HashMap<PlayerID, usize>,
pub points: Vec<Vec2>,
- pub spawn_delay_distr: rand_distr::Normal<f32>,
+ pub spawn_delay: f32,
+ pub spawn_delay_stdev: f32,
pub cooldown: f32,
pub speed: f32,
}
@@ -37,12 +38,12 @@ impl Entity for Pedestrians {
fn tick(&mut self, c: EntityContext<'_>) -> Result<()> {
self.cooldown -= c.dt;
if self.cooldown <= 0. && self.players.len() < 32 {
- let id = PlayerID(random());
+ let id = PlayerID(random(..));
c.packet_in.push_back(PacketS::Join {
name: "Pedestrian".to_string(),
character: Character {
- color: random(),
- hairstyle: random(),
+ color: random(..),
+ hairstyle: random(..),
headwear: 0,
},
class: PlayerClass::Customer,
@@ -50,7 +51,7 @@ impl Entity for Pedestrians {
position: self.points.first().copied(),
});
self.players.insert(id, 0);
- self.cooldown += self.spawn_delay_distr.sample(&mut rng()).max(0.1);
+ self.cooldown += (self.spawn_delay + self.spawn_delay_stdev * random_gauss()).max(0.1);
}
let mut remove = Vec::new();
diff --git a/server/src/entity/tram.rs b/server/src/entity/tram.rs
index 3186b650..391d16a9 100644
--- a/server/src/entity/tram.rs
+++ b/server/src/entity/tram.rs
@@ -1,3 +1,5 @@
+use std::random::random;
+
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
@@ -17,8 +19,7 @@
*/
use super::{Entity, EntityContext};
use anyhow::Result;
-use hurrycurry_protocol::{glam::Vec2, Character, PacketS, PlayerClass, PlayerID};
-use rand::random;
+use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID, glam::Vec2};
pub struct Tram {
pub length: usize,
@@ -37,7 +38,7 @@ impl Entity for Tram {
fn tick(&mut self, c: EntityContext<'_>) -> Result<()> {
if self.ids.is_empty() {
for i in 0..self.length {
- let id = PlayerID(random());
+ let id = PlayerID(random(..));
c.packet_in.push_back(PacketS::Join {
name: format!("Tram {i}"),
character: self.character,
diff --git a/server/src/lib.rs b/server/src/lib.rs
index da49f85d..2d3a62cc 100644
--- a/server/src/lib.rs
+++ b/server/src/lib.rs
@@ -15,7 +15,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#![feature(if_let_guard, let_chains, iterator_try_collect, stmt_expr_attributes)]
+#![feature(if_let_guard, iterator_try_collect, stmt_expr_attributes, random)]
pub mod commands;
pub mod entity;
pub mod interaction;
@@ -25,6 +25,7 @@ pub mod server;
pub mod state;
use hurrycurry_protocol::glam::Vec2;
+use std::random::random;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ConnectionID(pub i64);
@@ -43,3 +44,10 @@ impl InterpolateExt for f32 {
*self = target + (*self - target) * (-dt).exp();
}
}
+
+fn random_float() -> f32 {
+ random::<u32>(..) as f32 / u32::MAX as f32
+}
+fn random_gauss() -> f32 {
+ [(); 12].map(|()| random_float()).iter().sum::<f32>() - 6.
+}
diff --git a/server/src/main.rs b/server/src/main.rs
index 7ab19f30..be0bb005 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -47,6 +47,7 @@ pub(crate) struct Args {
listen: SocketAddr,
/// Enables submissions to the public server registry
#[arg(long)]
+ #[cfg(feature = "register")]
register: bool,
/// Enables the mDNS responder for local network discovery
#[cfg(feature = "mdns")]
diff --git a/server/src/network/mdns.rs b/server/src/network/mdns.rs
index b15a197a..590ad656 100644
--- a/server/src/network/mdns.rs
+++ b/server/src/network/mdns.rs
@@ -21,8 +21,7 @@ use get_if_addrs::get_if_addrs;
use hurrycurry_protocol::VERSION;
use log::{info, warn};
use mdns_sd::{ServiceDaemon, ServiceInfo};
-use rand::random;
-use std::{collections::HashMap, net::SocketAddr, sync::Arc, time::Duration};
+use std::{collections::HashMap, net::SocketAddr, random::random, sync::Arc, time::Duration};
use tokio::{sync::RwLock, time::interval};
pub async fn mdns_loop(name: String, listen_addr: SocketAddr, state: Arc<RwLock<Server>>) {
@@ -34,7 +33,7 @@ pub async fn mdns_loop(name: String, listen_addr: SocketAddr, state: Arc<RwLock<
}
};
let mut interval = interval(Duration::from_secs(60));
- let hostname = format!("hurrycurry-{}.local.", random::<u64>()); // TODO use system hostname
+ let hostname = format!("hurrycurry-{}.local.", random::<u64>(..)); // TODO use system hostname
loop {
interval.tick().await;
if let Err(e) = update_service(&d, &state, &name, &hostname, listen_addr).await {
diff --git a/server/src/network/register.rs b/server/src/network/register.rs
index 8617af4d..47dac4a8 100644
--- a/server/src/network/register.rs
+++ b/server/src/network/register.rs
@@ -16,13 +16,13 @@
*/
use crate::server::Server;
-use anyhow::{bail, Result};
-use hurrycurry_protocol::{registry::Submission, VERSION};
+use anyhow::{Result, bail};
+use hurrycurry_protocol::{VERSION, registry::Submission};
use log::{debug, error, info, warn};
-use rand::random;
-use reqwest::{header::USER_AGENT, Client, Url};
+use reqwest::{Client, Url, header::USER_AGENT};
use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr},
+ random::random,
str::FromStr,
sync::Arc,
time::Duration,
@@ -56,7 +56,7 @@ impl Register {
register_uri,
players: 0,
port,
- secret: random(),
+ secret: random(..),
state,
ip4_client: if no4 {
None
diff --git a/server/src/server.rs b/server/src/server.rs
index 3f54fe38..48439b5f 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -16,23 +16,23 @@
*/
use crate::{
- entity::{construct_entity, Entities, EntityContext},
+ ConnectionID,
+ entity::{Entities, EntityContext, construct_entity},
interaction::{interact, tick_slot},
+ random_float,
scoreboard::ScoreboardStore,
- ConnectionID,
};
use anyhow::{Context, Result};
-use hurrycurry_client_lib::{gamedata_index::GamedataIndex, Game, Involvement, Item, Player, Tile};
-use hurrycurry_data::{index::DataIndex, Serverdata};
-use hurrycurry_locale::{tre, TrError};
+use hurrycurry_client_lib::{Game, Involvement, Item, Player, Tile, gamedata_index::GamedataIndex};
+use hurrycurry_data::{Serverdata, index::DataIndex};
+use hurrycurry_locale::{TrError, tre};
use hurrycurry_protocol::{
- glam::{IVec2, Vec2},
- movement::MovementBase,
Character, Gamedata, Hand, ItemLocation, Menu, MessageTimeout, PacketC, PacketS, PlayerClass,
PlayerID, Score, TileIndex,
+ glam::{IVec2, Vec2},
+ movement::MovementBase,
};
use log::{info, warn};
-use rand::random;
use std::{
collections::{HashMap, HashSet, VecDeque},
path::PathBuf,
@@ -277,7 +277,7 @@ impl GameServerExt for Game {
PlayerClass::Customer => serverdata.customer_spawn.unwrap_or(serverdata.chef_spawn),
PlayerClass::Bot | PlayerClass::Chef => serverdata.chef_spawn,
PlayerClass::Tram => Vec2::ZERO, // should always have custom location
- }) + (Vec2::new(random(), random()) - 0.5);
+ }) + (Vec2::new(random_float(), random_float()) - 0.5);
self.players.insert(
id,
Player {