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

Readability fixes for cargo clippy

This commit is contained in:
NG (Graham)
2025-09-03 22:33:26 -04:00
parent 9dcb12131b
commit 0e35aced01
77 changed files with 725 additions and 735 deletions

View File

@@ -17,7 +17,7 @@ impl CustomisationData {
(Typed::Str("skinsceneName".into()), Typed::Str(self.skin_scene_name.clone().into())),
(Typed::Str("simulationPrefab".into()), Typed::Str(self.simulation_prefab.clone().into())),
(Typed::Str("previewImageName".into()), Typed::Str(self.preview_image_name.clone().into())),
(Typed::Str("isDefault".into()), Typed::Bool(self.is_default.into())),
(Typed::Str("isDefault".into()), Typed::Bool(self.is_default)),
].into())
}
}

View File

@@ -67,7 +67,7 @@ impl ItemShopBundle {
pub fn as_transmissible_vec(items: Vec<Self>) -> Typed {
let mut buf = Vec::new();
let mut writer = std::io::Cursor::new(&mut buf);
writer.write(&(items.len() as i32).to_le_bytes()).unwrap();
writer.write_all(&(items.len() as i32).to_le_bytes()).unwrap();
for item in items.iter() {
item.dump(&mut writer).unwrap();
}

View File

@@ -9,11 +9,11 @@ pub struct ColourValue {
impl ColourValue {
fn read_no_alpha<R: std::io::Read>(reader: &mut R) -> std::io::Result<Self> {
let mut buf = [0u8; 1];
reader.read(&mut buf)?;
reader.read_exact(&mut buf)?;
let r = buf[0];
reader.read(&mut buf)?;
reader.read_exact(&mut buf)?;
let g = buf[0];
reader.read(&mut buf)?;
reader.read_exact(&mut buf)?;
let b = buf[0];
Ok(Self {
r, g, b, a: u8::MAX,
@@ -39,7 +39,7 @@ impl Colour {
let specular = ColourValue::read_no_alpha(reader)?;
let overlay = ColourValue::read_no_alpha(reader)?;
let mut buf = [0u8; 1];
reader.read(&mut buf)?;
reader.read_exact(&mut buf)?;
let premium = buf[0] != 0;
Ok(Self {
index, diffuse, specular, overlay, premium,
@@ -48,7 +48,7 @@ impl Colour {
pub fn read_many<R: std::io::Read>(reader: &mut R) -> std::io::Result<Vec<Self>> {
let mut buf = [0u8; 4];
reader.read(&mut buf)?;
reader.read_exact(&mut buf)?;
let count = i32::from_le_bytes(buf);
let mut results = Vec::with_capacity(count as _);
for i in 0..count {

View File

@@ -17,7 +17,7 @@ impl PlayerRoboPassSeasonInfo {
items: vec![
(Typed::Str("deltaXpToShow".into()), Typed::Int(self.delta_xp_to_show)),
(Typed::Str("grade".into()), Typed::Int(self.grade)),
(Typed::Str("hasDeluxe".into()), Typed::Bool(self.has_deluxe.into())),
(Typed::Str("hasDeluxe".into()), Typed::Bool(self.has_deluxe)),
(Typed::Str("progressInGrade".into()), Typed::Float(self.progress_in_grade)),
(Typed::Str("xpFromSeasonStart".into()), Typed::Int(self.xp_from_start)),
],

View File

@@ -7,7 +7,7 @@ const PAID_BALANCE_PARAM_KEY: u8 = 87;
pub(super) fn balance_wallet_provider() -> SimpleFunc<66, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(FREE_BALANCE_PARAM_KEY, Typed::Long(31337_000));
params.insert(FREE_BALANCE_PARAM_KEY, Typed::Long(31_337_000));
params.insert(PAID_BALANCE_PARAM_KEY, Typed::Long(1));
Ok(params.into())
})

View File

@@ -7,7 +7,7 @@ pub(super) fn chat_settings_provider() -> SimpleFunc<18, crate::UserTy, impl (Fn
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(PARAM_KEY, Typed::HashMap(vec![
(Typed::Str("chatEnabled".into()), Typed::Bool(true.into())),
(Typed::Str("chatEnabled".into()), Typed::Bool(true)),
].into()));
Ok(params.into())
})

View File

@@ -19,7 +19,7 @@ async fn do_handling(params: ParameterTable<()>, _user: &crate::UserTy, factory:
log::error!("Failed to retrieve vehicles from factory: {}", e);
oj_rc_core::data::error_codes::WebServicesError::DatabaseError as i16
})?;
let vehicles: Vec<_> = vehicles.into_iter().map(|x| crate::data::crf::ItemResult::from(x)).collect();
let vehicles: Vec<_> = vehicles.into_iter().map(crate::data::crf::ItemResult::from).collect();
params.insert(ITEMS_PARAM_KEY, crate::data::crf::ItemResult::as_transmissible(&vehicles));
}
Ok(params.into())

View File

@@ -32,7 +32,7 @@ impl OperationCode for CubeInventoryProvider {
}
}
pub(super) fn cube_inv_provider<'a>(cubes: &'a oj_rc_core::ConfigImpl) -> CubeInventoryProvider {
pub(super) fn cube_inv_provider(cubes: &oj_rc_core::ConfigImpl) -> CubeInventoryProvider {
let cube_ids = <oj_rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
CubeInventoryProvider { cube_ids }
}

View File

@@ -50,7 +50,7 @@ impl Operation<()> for GameEventsParamsProvider {
code: Self::op_code(),
return_code: e,
message: polariton::operation::Typed::Null,
params: params.into(),
params,
}
}
}

View File

@@ -8,7 +8,7 @@ const AVAILABLE_PARAM_KEY: u8 = 89; // bool
pub(super) fn completed_campaign_provider() -> SimpleFunc<77, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(AVAILABLE_PARAM_KEY, Typed::Bool(false.into()));
params.insert(AVAILABLE_PARAM_KEY, Typed::Bool(false));
Ok(params.into())
})
}

View File

@@ -19,13 +19,13 @@ impl <C: Send + 'static> Operation<C> for UserFlagsTeller {
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
let mut resp_params = std::collections::HashMap::new();
resp_params.insert(Self::REMOVE_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(Self::REMOVE_UNOWNED_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(Self::REMOVE_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false));
resp_params.insert(Self::REMOVE_UNOWNED_CUBES_KEY, polariton::operation::Typed::Bool(false));
resp_params.insert(Self::REWARD_TITLE_KEY, polariton::operation::Typed::Str("".into()));
resp_params.insert(Self::REWARD_BODY_KEY, polariton::operation::Typed::Str("".into())); // set this to non-empty to display pop-up at login
resp_params.insert(Self::REFUND_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(Self::CUBES_ARE_REPLACED_KEY, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(Self::NEW_USER_KEY, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(Self::REFUND_OBSOLETE_CUBES_KEY, polariton::operation::Typed::Bool(false));
resp_params.insert(Self::CUBES_ARE_REPLACED_KEY, polariton::operation::Typed::Bool(false));
resp_params.insert(Self::NEW_USER_KEY, polariton::operation::Typed::Bool(false));
resp_params.insert(Self::AB_TEST_KEY, polariton::operation::Typed::Str("".into()));
resp_params.insert(Self::AB_GROUP_KEY, polariton::operation::Typed::Str("".into()));
polariton::operation::OperationResponse {

View File

@@ -9,7 +9,7 @@ impl <C: Send + 'static> Operation<C> for MaintenanceModeTeller {
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
let mut resp_params = HashMap::new();
resp_params.insert(20 /* is in maintenance mode? */, polariton::operation::Typed::Bool(false.into()));
resp_params.insert(20 /* is in maintenance mode? */, polariton::operation::Typed::Bool(false));
resp_params.insert(19 /* maintenace mode message */, polariton::operation::Typed::Str("OpenJam's servers are currently undergoing maintenance".into()));
polariton::operation::OperationResponse {
code: 20,

View File

@@ -47,7 +47,7 @@ impl <C: Send + 'static> SimpleOperation<C> for PlatformConfigProvider {
(Typed::Str("FeedbackURL".into()), Typed::Str(self.links.feedback_url.clone().into())),
(Typed::Str("SupportURL".into()), Typed::Str(self.links.support_url.clone().into())),
(Typed::Str("WikiURL".into()), Typed::Str(self.links.wiki_url.clone().into())),
].into(),
],
}));
Ok(params.into())
}

View File

@@ -6,7 +6,7 @@ const PARAM_KEY: u8 = 135;
pub(super) fn started_purchase_provider() -> SimpleFunc<54, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(PARAM_KEY, Typed::Bool(false.into()));
params.insert(PARAM_KEY, Typed::Bool(false));
Ok(params.into())
})
}

View File

@@ -6,7 +6,7 @@ const PARAM_KEY: u8 = 207;
pub(super) fn available_reconnect_provider() -> SimpleFunc<171, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(PARAM_KEY, Typed::Bool(false.into()));
params.insert(PARAM_KEY, Typed::Bool(false));
Ok(params.into())
})
}

View File

@@ -18,7 +18,7 @@ pub(super) fn special_item_list_provider() -> SimpleFunc<6, crate::UserTy, impl
sprite: "chair".to_string(),
size: 1,
}.as_transmissible())
].into(),
],
}));
Ok(params.into())
})

View File

@@ -14,7 +14,7 @@ pub(super) fn tiers_banding_provider() -> SimpleFunc<7, crate::UserTy, impl (Fn(
1
].into())),
(Typed::Str("maximumRobotRankingARobotCanObtain".into()), Typed::Int(1)),
].into(),
],
}));
Ok(params.into())
})

View File

@@ -8,9 +8,9 @@ const SKIPPED_PARAM_KEY: u8 = 142;
pub(super) fn tutorial_info_provider() -> SimpleFunc<122, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(IN_PROGRESS_PARAM_KEY, Typed::Bool(false.into()));
params.insert(COMPLETED_PARAM_KEY, Typed::Bool(true.into()));
params.insert(SKIPPED_PARAM_KEY, Typed::Bool(true.into()));
params.insert(IN_PROGRESS_PARAM_KEY, Typed::Bool(false));
params.insert(COMPLETED_PARAM_KEY, Typed::Bool(true));
params.insert(SKIPPED_PARAM_KEY, Typed::Bool(true));
Ok(params.into())
})
}