diff options
Diffstat (limited to 'server/src/entity')
| -rw-r--r-- | server/src/entity/customers.rs | 9 | ||||
| -rw-r--r-- | server/src/entity/pedestrians.rs | 7 | ||||
| -rw-r--r-- | server/src/entity/tag_minigame.rs | 5 |
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 { |