aboutsummaryrefslogtreecommitdiff
path: root/server/bot/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-20 14:19:32 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-20 14:21:32 +0200
commit1504c9975b03dba27b6047f74e604188cd91f710 (patch)
tree4b4f78577db2f79f6ce4cef477fed1b35d60036e /server/bot/src
parent1c4cd0e544fb819b1a57ec59536d16d31e77795a (diff)
downloadhurrycurry-1504c9975b03dba27b6047f74e604188cd91f710.tar
hurrycurry-1504c9975b03dba27b6047f74e604188cd91f710.tar.bz2
hurrycurry-1504c9975b03dba27b6047f74e604188cd91f710.tar.zst
fix customer crash when no demands exist
Diffstat (limited to 'server/bot/src')
-rw-r--r--server/bot/src/algos/customer.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index 592d0574..ec8f2283 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -65,22 +65,24 @@ impl BotAlgo for Customer {
let pos = playerdata.movement.position;
match self {
Customer::New => {
- if let Some(&chair) = game
- .tiles
- .iter()
- .filter(|(_, t)| game.data.tile_name(t.kind) == "chair")
- .map(|(p, _)| *p)
- .collect::<Vec<_>>()
- .choose(&mut thread_rng())
- {
- if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) {
- info!("{me:?} -> entering");
- *self = Customer::Entering {
- path,
- chair,
- origin: pos.as_ivec2(),
- ticks: 0,
- };
+ if !game.data.demands.is_empty() {
+ if let Some(&chair) = game
+ .tiles
+ .iter()
+ .filter(|(_, t)| game.data.tile_name(t.kind) == "chair")
+ .map(|(p, _)| *p)
+ .collect::<Vec<_>>()
+ .choose(&mut thread_rng())
+ {
+ if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), chair) {
+ info!("{me:?} -> entering");
+ *self = Customer::Entering {
+ path,
+ chair,
+ origin: pos.as_ivec2(),
+ ticks: 0,
+ };
+ }
}
}
BotInput::default()