summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-12-23 12:41:15 +0100
committermetamuffin <metamuffin@disroot.org>2024-12-23 12:41:15 +0100
commit464ebd6fa686d32a16aaa6bd27d8f445caa42f6a (patch)
tree22587801553e44c6d707ca1fac8f3da864ed6ea8 /server
parent6ddb571e02dc04b1125669135eab5731523e8f73 (diff)
downloadhurrycurry-464ebd6fa686d32a16aaa6bd27d8f445caa42f6a.tar
hurrycurry-464ebd6fa686d32a16aaa6bd27d8f445caa42f6a.tar.bz2
hurrycurry-464ebd6fa686d32a16aaa6bd27d8f445caa42f6a.tar.zst
clippy: mostly map_or replaced with is_some_and
Diffstat (limited to 'server')
-rw-r--r--server/bot/src/algos/customer.rs6
-rw-r--r--server/bot/src/algos/simple.rs8
-rw-r--r--server/registry/src/register.rs2
-rw-r--r--server/src/commands.rs2
-rw-r--r--server/src/entity/campaign.rs6
-rw-r--r--server/src/entity/tutorial.rs12
-rw-r--r--server/src/server.rs4
7 files changed, 20 insertions, 20 deletions
diff --git a/server/bot/src/algos/customer.rs b/server/bot/src/algos/customer.rs
index e26acf09..b243bd55 100644
--- a/server/bot/src/algos/customer.rs
+++ b/server/bot/src/algos/customer.rs
@@ -141,7 +141,7 @@ impl CustomerState {
if game
.tiles
.get(&(off + *chair))
- .map_or(false, |t| game.data.is_tile_interactable(t.kind))
+ .is_some_and(|t| game.data.is_tile_interactable(t.kind))
{
facing = off.as_vec2();
}
@@ -240,7 +240,7 @@ impl CustomerState {
if game
.players
.get(&pid)
- .map_or(false, |p| p.class.is_cheflike())
+ .is_some_and(|p| p.class.is_cheflike())
{
pin = true
}
@@ -369,7 +369,7 @@ impl CustomerState {
cooldown,
} => {
*cooldown -= dt;
- if game.players.get(&me).map_or(false, |pl| pl.item.is_none()) {
+ if game.players.get(&me).is_some_and(|pl| pl.item.is_none()) {
if let Some(path) = find_path(&game.walkable, pos.as_ivec2(), *origin) {
*self = CustomerState::Exiting { path };
}
diff --git a/server/bot/src/algos/simple.rs b/server/bot/src/algos/simple.rs
index b275b522..14eb38c4 100644
--- a/server/bot/src/algos/simple.rs
+++ b/server/bot/src/algos/simple.rs
@@ -109,7 +109,7 @@ impl<S> Context<'_, S> {
self.game
.players
.get(&self.me)
- .map_or(false, |p| p.item.as_ref().map_or(false, |i| i.kind == item))
+ .is_some_and(|p| p.item.as_ref().is_some_and(|i| i.kind == item))
}
pub fn is_hand_occupied(&self) -> bool {
self.game
@@ -131,7 +131,7 @@ impl<S> Context<'_, S> {
self.game
.tiles
.get(&(pos + *off))
- .map_or(false, |t| self.game.data.tile_interact[t.kind.0])
+ .is_some_and(|t| self.game.data.tile_interact[t.kind.0])
})
.map(|off| pos + off)
.map(|pos| (*item, pos))
@@ -155,7 +155,7 @@ impl<S> Context<'_, S> {
self.game
.tiles
.get(&(pos + *off))
- .map_or(false, |t| self.game.data.tile_interact[t.kind.0])
+ .is_some_and(|t| self.game.data.tile_interact[t.kind.0])
})
.map(|off| pos + off)
.map(|pos| (*item, pos))
@@ -177,7 +177,7 @@ impl<S> Context<'_, S> {
self.game
.tiles
.iter()
- .find(|(_, t)| t.item.as_ref().map_or(false, |t| t.kind == item))
+ .find(|(_, t)| t.item.as_ref().is_some_and(|t| t.kind == item))
.map(|(p, _)| *p)
}
pub fn find_tile(&self, tile: TileIndex) -> Option<IVec2> {
diff --git a/server/registry/src/register.rs b/server/registry/src/register.rs
index 1e90fc68..d15fb01c 100644
--- a/server/registry/src/register.rs
+++ b/server/registry/src/register.rs
@@ -29,7 +29,7 @@ use std::{
use tokio::{net::lookup_host, sync::RwLock};
#[post("/v1/register", data = "<submission>")]
-pub(super) async fn r_register<'a>(
+pub(super) async fn r_register(
client_addr: IpAddr,
registry: &State<Arc<RwLock<Registry>>>,
submission: Json<Submission>,
diff --git a/server/src/commands.rs b/server/src/commands.rs
index 24752cc5..5daedda9 100644
--- a/server/src/commands.rs
+++ b/server/src/commands.rs
@@ -334,7 +334,7 @@ impl Server {
#[cfg(not(test))] // TODO rust-analyser does not undestand trait upcasting
if self.entities.iter().any(|e| {
<dyn std::any::Any>::downcast_ref::<Tutorial>(e.as_ref())
- .map_or(false, |t| t.player == player)
+ .is_some_and(|t| t.player == player)
}) {
return Err(tre!("s.error.tutorial_already_running"));
}
diff --git a/server/src/entity/campaign.rs b/server/src/entity/campaign.rs
index 39926a12..7f07be48 100644
--- a/server/src/entity/campaign.rs
+++ b/server/src/entity/campaign.rs
@@ -99,9 +99,9 @@ impl GateCondition {
match self {
GateCondition::All(cs) => cs.iter().all(|c| c.check(scoreboard)),
GateCondition::Any(cs) => cs.iter().any(|c| c.check(scoreboard)),
- GateCondition::Stars(map, thres) => scoreboard.get(map).map_or(false, |s| {
- s.best.first().map_or(false, |b| b.score.stars >= *thres)
- }),
+ GateCondition::Stars(map, thres) => scoreboard
+ .get(map)
+ .is_some_and(|s| s.best.first().is_some_and(|b| b.score.stars >= *thres)),
}
}
pub fn show(&self, scoreboard: &ScoreboardStore) -> Message {
diff --git a/server/src/entity/tutorial.rs b/server/src/entity/tutorial.rs
index 60b32c79..44244862 100644
--- a/server/src/entity/tutorial.rs
+++ b/server/src/entity/tutorial.rs
@@ -144,7 +144,7 @@ impl StepContext<'_> {
.game
.players
.get(&self.player)
- .map_or(false, |p| p.item.as_ref().map_or(false, |i| i.kind == item))
+ .is_some_and(|p| p.item.as_ref().is_some_and(|i| i.kind == item))
}
pub fn find_demand(&self, item: ItemIndex) -> Option<IVec2> {
self.ent
@@ -171,7 +171,7 @@ impl StepContext<'_> {
.game
.tiles
.iter()
- .find(|(_, t)| t.item.as_ref().map_or(false, |t| t.kind == item))
+ .find(|(_, t)| t.item.as_ref().is_some_and(|t| t.kind == item))
.map(|(p, _)| *p)
}
fn find_tile(&self, tile: TileIndex) -> Option<IVec2> {
@@ -195,9 +195,9 @@ impl StepContext<'_> {
}
fn prevent_burning(&self) -> Result<(), (Option<IVec2>, Message)> {
if let Some((pos, tile)) = self.ent.game.tiles.iter().find(|(_, t)| {
- t.item.as_ref().map_or(false, |t| {
- t.active.as_ref().map_or(false, |i| i.warn && i.speed > 0.)
- })
+ t.item
+ .as_ref()
+ .is_some_and(|t| t.active.as_ref().is_some_and(|i| i.warn && i.speed > 0.))
}) {
Err((
Some(*pos),
@@ -228,7 +228,7 @@ impl StepContext<'_> {
.game
.players
.get(&self.player)
- .map_or(false, |p| p.item.as_ref().map_or(false, |i| i.kind == item))
+ .is_some_and(|p| p.item.as_ref().is_some_and(|i| i.kind == item))
{
if let Some(pos) = self.find_demand(item) {
Err((Some(pos), trm!("s.tutorial.serve")))
diff --git a/server/src/server.rs b/server/src/server.rs
index f69ea5e4..9928ac90 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -23,7 +23,7 @@ use crate::{
scoreboard::ScoreboardStore,
tre, ConnectionID,
};
-use anyhow::{bail, Context, Result};
+use anyhow::{Context, Result};
use hurrycurry_client_lib::{Game, Involvement, Item, Player, Tile};
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
@@ -373,7 +373,7 @@ impl Server {
return Err(tre!("s.error.username_length_limit"));
}
if self.game.players.len() > 64 {
- return Err(tre!("s.error.too_many_players"))
+ return Err(tre!("s.error.too_many_players"));
}
let id = id.unwrap_or_else(|| {
let id = self.player_id_counter;