mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Fix clippy warnings in validation and chat logic
This commit is contained in:
@@ -202,7 +202,7 @@ impl BuiltIn {
|
||||
}
|
||||
}
|
||||
if stats.is_empty() {
|
||||
stats.push(format!("TODO: general stats (try db)"));
|
||||
stats.push("TODO: general stats (try db)".to_owned());
|
||||
}
|
||||
stats.join("\n")
|
||||
},
|
||||
@@ -282,9 +282,9 @@ impl Intercom {
|
||||
},
|
||||
vec![],
|
||||
).await;
|
||||
format!("Sent dev broadcast to everyone")
|
||||
"Sent dev broadcast to everyone".to_owned()
|
||||
} else {
|
||||
format!("Missing dev message, did not send")
|
||||
"Missing dev message, did not send".to_owned()
|
||||
}
|
||||
},
|
||||
Self::Maintenance => {
|
||||
@@ -293,9 +293,9 @@ impl Intercom {
|
||||
oj_rc_core::persist::user::intercom::IntercomMaintenanceMessage { message },
|
||||
vec![],
|
||||
).await;
|
||||
format!("Sent maintenance message")
|
||||
"Sent maintenance message".to_owned()
|
||||
} else {
|
||||
format!("Missing maintenance message, did not send")
|
||||
"Missing maintenance message, did not send".to_owned()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,6 +138,12 @@ impl super::config::SelfValidator for GameEventSequence {
|
||||
fn validate(&self, info: &mut super::config::ValidationInfo, ctx: &Self::Context) -> bool {
|
||||
// TODO
|
||||
let mut is_ok = true;
|
||||
if self.modes.is_empty() {
|
||||
info.error(super::config::ValidationMessage {
|
||||
path: vec!["modes".to_owned()],
|
||||
message: "Game sequence must have at least one mode (event) in the rotation".to_owned(),
|
||||
});
|
||||
}
|
||||
for (i, mode) in self.modes.iter().enumerate() {
|
||||
is_ok &= mode.validate_in(info, ctx, &format!("modes[{}]", i));
|
||||
}
|
||||
@@ -185,28 +191,36 @@ impl super::config::SelfValidator for GameEvents {
|
||||
});
|
||||
is_ok = false;
|
||||
}
|
||||
if matches!(self.multiplayer.mode, GameType::Pit) {
|
||||
if ctx.multiplayer.fakes.iter().any(|f| f.team.is_some_and(|t| (t as usize) < ctx.multiplayer.players_per_game))
|
||||
|| ctx.multiplayer.fakes.iter().enumerate()
|
||||
.any(|(i, f)| ctx.multiplayer.fakes.iter().enumerate()
|
||||
.any(|(i2, f2)| i != i2 && f.team == f2.team)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with more than one (fake) player per team", self.multiplayer.mode),
|
||||
});
|
||||
}
|
||||
if ctx.multiplayer.fakes.iter().any(|f| matches!(f.implementation, super::multiplayer::ClientEmulation::ClientAI)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with client-side AI", self.multiplayer.mode),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if ctx.multiplayer.fakes.iter().any(|f| f.team.is_some_and(|t| t > 1)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with (fake) players split between more than 2 teams", self.multiplayer.mode),
|
||||
});
|
||||
if ctx.multiplayer.enabled {
|
||||
if matches!(self.multiplayer.mode, GameType::Pit) {
|
||||
if ctx.multiplayer.fakes.iter().any(|f| f.team.is_some_and(|t| (t as usize) < ctx.multiplayer.players_per_game))
|
||||
|| ctx.multiplayer.fakes.iter().enumerate()
|
||||
.any(|(i, f)| ctx.multiplayer.fakes.iter().enumerate()
|
||||
.any(|(i2, f2)| i != i2 && f.team == f2.team)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with more than one (fake) player per team", self.multiplayer.mode),
|
||||
});
|
||||
}
|
||||
if ctx.multiplayer.fakes.iter().any(|f| matches!(f.implementation, super::multiplayer::ClientEmulation::ClientAI)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with client-side AI", self.multiplayer.mode),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if ctx.multiplayer.fakes.iter().any(|f| f.team.is_some_and(|t| t > 1)) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "mode".to_owned()],
|
||||
message: format!("Multiplayer game mode {:?} does not work well with (fake) players split between more than 2 teams", self.multiplayer.mode),
|
||||
});
|
||||
}
|
||||
if !ctx.maps.map.contains_key(&self.multiplayer.map) {
|
||||
info.warn(crate::persist::config::ValidationMessage {
|
||||
path: vec!["multiplayer".to_owned(), "map".to_owned()],
|
||||
message: format!("Multiplayer game map {:?} is not configured", self.multiplayer.map),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
is_ok
|
||||
|
||||
@@ -12,7 +12,7 @@ impl UserData {
|
||||
pub(super) async fn generate_fake_players_data(
|
||||
&self,
|
||||
_guid: i64,
|
||||
real_players: &Vec<super::PlayerLobbyDescriptor>,
|
||||
real_players: &[super::PlayerLobbyDescriptor],
|
||||
factory: &dyn oj_rc_factory::VehicleFactoryAdapter,
|
||||
cpu_counter: &crate::cubes::CpuListParser,
|
||||
weapon_lister: &crate::cubes::WeaponListParser,
|
||||
|
||||
@@ -19,7 +19,7 @@ impl ArcAdapter {
|
||||
orm: db,
|
||||
ignore_expiry: show_expired,
|
||||
cdn: cdn.to_owned(),
|
||||
override_cdn: override_cdn,
|
||||
override_cdn,
|
||||
spoof_users: username_spoofing,
|
||||
};
|
||||
// do query to ensure database is ok
|
||||
|
||||
Reference in New Issue
Block a user