1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Fix some clippy issues for #38

This commit is contained in:
NG (Graham)
2026-03-18 17:37:53 -04:00
parent 6a953bc613
commit fa3ed24922
3 changed files with 9 additions and 9 deletions

View File

@@ -126,7 +126,7 @@ impl CustomGameMesh {
pub async fn get_user_game(&self, public_id: &str) -> Option<SessionInfo> {
if let Some(game_id) = self.user_to_game.read().await.get(public_id) {
if let Some(game) = self.games.read().await.get(game_id) {
return Some(Self::session_from_game(&game_id, game));
return Some(Self::session_from_game(game_id, game));
}
}
None
@@ -135,7 +135,7 @@ impl CustomGameMesh {
pub async fn invite_user(&self, inviter: &str, invitee: &str, is_team_a: bool) -> (InviteToCustomGameResponseCode, Option<SessionInfo>) {
if let Some(game_id) = { self.user_to_game.read().await.get(inviter).cloned() } {
if let Some(game) = self.games.write().await.get_mut(&game_id) {
if game.users.iter().find(|x| x.public_id == invitee).is_some() {
if game.users.iter().any(|x| x.public_id == invitee) {
let session = Self::session_from_game(&game_id, game);
(InviteToCustomGameResponseCode::InviteeHasAlreadyBeenInvited, Some(session))
} else {
@@ -200,7 +200,7 @@ impl CustomGameMesh {
.find(|mem| mem.public_id == public_id)
.unwrap();
target.status.store(status.to_u8(), std::sync::atomic::Ordering::Relaxed);
let session = Self::session_from_game(&game_id, game);
let session = Self::session_from_game(game_id, game);
return Some(session);
}
}
@@ -219,7 +219,7 @@ impl CustomGameMesh {
.unwrap();
let team = if is_team_b { 1 } else { 0 };
target.team.store(team, std::sync::atomic::Ordering::Relaxed);
let session = Self::session_from_game(&game_id, game);
let session = Self::session_from_game(game_id, game);
return (ChangeTeamResponseCode::Success, Some(session));
}
}
@@ -247,13 +247,13 @@ impl CustomGameMesh {
}
}
if let Ok(_) = game.config.set_field(field, value) {
if game.config.set_field(field, value).is_ok() {
log::debug!("Update custom game session {} config {} to {}", game_id, field, value);
let session = Self::session_from_game(&game_id, game);
let session = Self::session_from_game(game_id, game);
return (AdjustCustomGameConfigResponseCode::Success, Some(session));
}
}
return (AdjustCustomGameConfigResponseCode::AdjustmentRejected, None);
(AdjustCustomGameConfigResponseCode::AdjustmentRejected, None)
} else {
(AdjustCustomGameConfigResponseCode::NotInSession, None)
}

View File

@@ -24,7 +24,7 @@ impl <C: Send + 'static> SimpleOperation<C> for CustomGameInviter {
let my_pub_id = user_info.public_id();
let avatars = user_info.list_avatar_info(&[my_pub_id.to_owned(), invitee_id.string.clone()]).await?;
// TODO resolve public_id of invitee by provided display name
let resp_code = if avatars.iter().find(|x| x.public_id == invitee_id.string).is_none() {
let resp_code = if !avatars.iter().any(|x| x.public_id == invitee_id.string) {
crate::data::custom_games::InviteToCustomGameResponseCode::UserDoesNotExist
} else {
let (resp_code, session_opt) = self.games.invite_user(my_pub_id, &invitee_id.string, is_team_a).await;

View File

@@ -27,7 +27,7 @@ impl <C: Send + 'static> SimpleOperation<C> for CustomGamePendingInvites {
params.insert(RESULT_CODE_PARAM_KEY, Typed::Int(CustomGameInviteCode::PendingInvite as _));
// build invite data
let leader = session.users.first().unwrap();
let leader_avatar = user_info.list_avatar_info(&[leader.public_id.clone()]).await?;
let leader_avatar = user_info.list_avatar_info(std::slice::from_ref(&leader.public_id)).await?;
let resp = CustomGameInvite {
inviter_public_id: leader_avatar[0].public_id.clone(),
inviter_display_name: leader_avatar[0].display_name.clone(),