aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2026-02-27 19:41:22 +0100
committernokoe <nokoe@mailbox.org>2026-02-27 19:41:22 +0100
commitc1a20426838a5729c2c874eae73dbb974fcf7906 (patch)
tree7138b1a4ca5f7f6b561aa05b0aae05071c581084 /server/src/entity
parent70e6d510ba236730260371a3259ffb16f999f5d4 (diff)
parenta859bceeddc8e746bba630b3cc197532b68adbcb (diff)
downloadhurrycurry-c1a20426838a5729c2c874eae73dbb974fcf7906.tar
hurrycurry-c1a20426838a5729c2c874eae73dbb974fcf7906.tar.bz2
hurrycurry-c1a20426838a5729c2c874eae73dbb974fcf7906.tar.zst
Merge branch 'stable-rust'
Diffstat (limited to 'server/src/entity')
-rw-r--r--server/src/entity/customers.rs9
-rw-r--r--server/src/entity/pedestrians.rs7
-rw-r--r--server/src/entity/tag_minigame.rs5
3 files changed, 11 insertions, 10 deletions
diff --git a/server/src/entity/customers.rs b/server/src/entity/customers.rs
index 2e2f82af..d5e1751d 100644
--- a/server/src/entity/customers.rs
+++ b/server/src/entity/customers.rs
@@ -16,12 +16,11 @@
*/
use super::{Entity, EntityContext, bot::BotDriver};
-use crate::random_float;
use anyhow::Result;
use hurrycurry_bot::algos::Customer;
use hurrycurry_locale::TrError;
use hurrycurry_protocol::{Character, PlayerClass, TileIndex};
-use std::random::random;
+use rand::random;
pub struct Customers {
customers: Vec<BotDriver<Customer>>,
@@ -62,12 +61,12 @@ impl Entity for Customers {
self.current_spawn_cooldown = self.current_spawn_cooldown.max(0.);
if self.customers.len() < max_count && self.current_spawn_cooldown <= 0. {
self.current_spawn_cooldown =
- self.spawn_cooldown + random_float() * self.spawn_cooldown;
+ self.spawn_cooldown + random::<f32>() * self.spawn_cooldown;
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/pedestrians.rs b/server/src/entity/pedestrians.rs
index 0d33bfd0..4fe91464 100644
--- a/server/src/entity/pedestrians.rs
+++ b/server/src/entity/pedestrians.rs
@@ -21,7 +21,8 @@ use super::{Entity, EntityContext};
use anyhow::Result;
use hurrycurry_locale::TrError;
use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID, glam::Vec2};
-use std::{collections::HashMap, random::random};
+use rand::random;
+use std::collections::HashMap;
pub struct Pedestrians {
pub players: HashMap<PlayerID, usize>,
@@ -44,8 +45,8 @@ impl Entity for Pedestrians {
id: Some(id),
name: "Pedestrian".to_string(),
character: Character {
- color: random(..),
- hairstyle: random(..),
+ color: random(),
+ hairstyle: random(),
headwear: 0,
},
class: PlayerClass::Customer,
diff --git a/server/src/entity/tag_minigame.rs b/server/src/entity/tag_minigame.rs
index 48558b41..b0f3a711 100644
--- a/server/src/entity/tag_minigame.rs
+++ b/server/src/entity/tag_minigame.rs
@@ -22,7 +22,8 @@ use hurrycurry_locale::TrError;
use hurrycurry_protocol::{
Hand, ItemIndex, ItemLocation, Message, PacketC, PlayerID, TileIndex, glam::IVec2,
};
-use std::{collections::HashMap, fmt::Write, random::random};
+use rand::RngExt;
+use std::{collections::HashMap, fmt::Write};
#[derive(Debug, Clone)]
pub struct TagMinigame {
@@ -60,7 +61,7 @@ impl Entity for TagMinigame {
if player_ids.is_empty() {
break;
}
- let id = player_ids[random::<usize>(..) % player_ids.len()];
+ let id = player_ids[usize::from_ne_bytes(rand::rng().random())];
let player = c.game.players.get_mut(&id).expect("just got the ids");
if let Some(slot) = player.items.get_mut(0) {
*slot = Some(Item {