make clippy happy(stable)

This commit is contained in:
bgkillas 2025-06-26 14:28:50 -04:00
parent feff08d3e3
commit 79c4a9a15e
10 changed files with 54 additions and 68 deletions

View file

@ -454,7 +454,7 @@ pub unsafe extern "C" fn luaopen_ewext(lua: *mut lua_State) -> c_int {
if let Err(_e) = KEEP_SELF_LOADED.as_ref() {
#[cfg(debug_assertions)]
println!("Got an error while loading self: {}", _e);
println!("Got an error while loading self: {_e}");
}
#[cfg(debug_assertions)]
println!(

View file

@ -64,15 +64,12 @@ fn download_thread(
.header("X-GitHub-Api-Version", "2022-11-28")
.header("User-agent", "noita proxy")
.send()
.wrap_err_with(|| format!("Failed to download from {}", url))?;
.wrap_err_with(|| format!("Failed to download from {url}"))?;
let mut buf = [0; 4096];
loop {
let len = response.read(&mut buf).wrap_err_with(|| {
format!(
"Failed to download from {}: couldn't read from response",
url
)
format!("Failed to download from {url}: couldn't read from response")
})?;
shared
.progress
@ -81,7 +78,7 @@ fn download_thread(
break;
}
file.write_all(&buf[..len])
.wrap_err_with(|| format!("Failed to download from {}: couldn't write to file", url))?;
.wrap_err_with(|| format!("Failed to download from {url}: couldn't write to file"))?;
}
Ok(())
@ -109,7 +106,7 @@ impl Downloader {
pub fn show_progress(&self, ui: &mut Ui) {
let (current, max) = self.progress();
ui.label(format!("{} out of {} bytes", current, max));
ui.label(format!("{current} out of {max} bytes"));
ui.add(egui::ProgressBar::new(current as f32 / max as f32));
ui.ctx().request_repaint_after(Duration::from_millis(200));
}
@ -230,12 +227,9 @@ pub fn get_release_by_tag(client: &Client, tag: Tag) -> Result<Release, Releases
.header("X-GitHub-Api-Version", "2022-11-28")
.header("User-agent", "noita proxy")
.send()
.wrap_err_with(|| format!("Failed to get release by tag from {}", url))?;
.wrap_err_with(|| format!("Failed to get release by tag from {url}"))?;
let response = response.error_for_status().wrap_err_with(|| {
format!(
"Failed to get release by tag from {}: response returned an error",
url
)
format!("Failed to get release by tag from {url}: response returned an error")
})?;
Ok(response.json()?)
}

View file

@ -20,7 +20,7 @@ impl SelfRestarter {
pub fn override_lobby_kind(&mut self, lobby_mode: LobbyKind) -> &mut Self {
self.command.arg("--override-lobby-kind");
self.command.arg(format!("{:?}", lobby_mode));
self.command.arg(format!("{lobby_mode:?}"));
self
}

View file

@ -128,7 +128,7 @@ impl SelfUpdateManager {
None => {}
}
}
Some(Err(err)) => self.state = State::ReleasesError2(format!("{:?}", err)),
Some(Err(err)) => self.state = State::ReleasesError2(format!("{err:?}")),
None => {
ui.label(tr("selfupdate_receiving_rel_info"));
ui.spinner();
@ -140,7 +140,7 @@ impl SelfUpdateManager {
let _ = SelfRestarter::new().and_then(|mut r| r.restart());
}
Some(Err(err)) => {
ui.label(format!("Could not update proxy: {}", err));
ui.label(format!("Could not update proxy: {err}"));
}
None => {
ctx.request_repaint();
@ -149,10 +149,10 @@ impl SelfUpdateManager {
}
},
State::ReleasesError(err) => {
ui.label(format!("Encountered an error: {:?}", err));
ui.label(format!("Encountered an error: {err:?}"));
}
State::ReleasesError2(err) => {
ui.label(format!("Encountered an error:\n{}", err));
ui.label(format!("Encountered an error:\n{err}"));
}
}
}

View file

@ -95,7 +95,7 @@ impl Display for GameMode {
GameMode::LocalHealth(LocalHealthMode::PermaDeath) => "LocalPermadeath",
GameMode::LocalHealth(LocalHealthMode::PvP) => "PvP",
};
write!(f, "{}", desc)
write!(f, "{desc}")
}
}
@ -1086,7 +1086,7 @@ impl ImageMap {
) {
for (p, (coord, is_dead, does_exist, img)) in map {
if !self.players.contains_key(p) {
let name = format!("{}", p);
let name = format!("{p}");
let size = [img.width() as usize, img.height() as usize];
let color_image = egui::ColorImage::from_rgba_unmultiplied(
size,
@ -1814,7 +1814,7 @@ impl App {
let color = game_mode.color();
ui.colored_label(
color,
tr(&format!("game_mode_{}", game_mode)),
tr(&format!("game_mode_{game_mode}")),
);
}
},
@ -1829,7 +1829,7 @@ impl App {
} else {
Color32::RED
};
ui.colored_label(color, format!("EW {}", version));
ui.colored_label(color, format!("EW {version}"));
} else if info.is_noita_online {
ui.colored_label(
Color32::LIGHT_BLUE,
@ -1940,7 +1940,7 @@ impl App {
}
}
Err(err) => {
ui.label(format!("Could not init steam networking: {}", err));
ui.label(format!("Could not init steam networking: {err}"));
}
}
}
@ -2628,7 +2628,7 @@ impl eframe::App for App {
.connect_to(*target_lobby)
.restart()
});
self.notify_error(format!("Failed to self-restart: {}", err));
self.notify_error(format!("Failed to self-restart: {err}"));
}
if button_back {
self.state = AppState::Connect;

View file

@ -50,7 +50,7 @@ pub mod world;
pub(crate) fn ws_encode_proxy(key: &'static str, value: impl Display) -> NoitaInbound {
let mut buf = Vec::new();
buf.push(2);
write!(buf, "{} {}", key, value).unwrap();
write!(buf, "{key} {value}").unwrap();
NoitaInbound::RawMessage(buf)
}
@ -891,10 +891,10 @@ impl NetManager {
}
}
NetMsg::RespondFlagNormal(flag, new) => {
state.try_ms_write(&ws_encode_proxy("normal_flag", format!("{} {}", flag, new)));
state.try_ms_write(&ws_encode_proxy("normal_flag", format!("{flag} {new}")));
}
NetMsg::RespondFlagSlow(ent, new) => {
state.try_ms_write(&ws_encode_proxy("slow_flag", format!("{} {}", ent, new)));
state.try_ms_write(&ws_encode_proxy("slow_flag", format!("{ent} {new}")));
}
NetMsg::RespondFlagMoon(x, y, b) => {
state.try_ms_write(&ws_encode_proxy(

View file

@ -20,19 +20,19 @@ impl ProxyOpt for bool {
impl ProxyOpt for u32 {
fn write_opt(self, buf: &mut Vec<u8>, key: &str) {
write!(buf, "proxy_opt_num {} {}", key, self).unwrap();
write!(buf, "proxy_opt_num {key} {self}").unwrap();
}
}
impl ProxyOpt for f32 {
fn write_opt(self, buf: &mut Vec<u8>, key: &str) {
write!(buf, "proxy_opt_num {} {}", key, self).unwrap();
write!(buf, "proxy_opt_num {key} {self}").unwrap();
}
}
impl ProxyOpt for &str {
fn write_opt(self, buf: &mut Vec<u8>, key: &str) {
write!(buf, "proxy_opt {} {}", key, self).unwrap();
write!(buf, "proxy_opt {key} {self}").unwrap();
}
}
@ -40,10 +40,10 @@ impl ProxyOpt for GameMode {
fn write_opt(self, buf: &mut Vec<u8>, key: &str) {
match self {
GameMode::SharedHealth => {
write!(buf, "proxy_opt {} shared_health", key).unwrap();
write!(buf, "proxy_opt {key} shared_health").unwrap();
}
GameMode::LocalHealth(_) => {
write!(buf, "proxy_opt {} local_health", key).unwrap();
write!(buf, "proxy_opt {key} local_health").unwrap();
}
}
}

View file

@ -46,7 +46,7 @@ impl Display for ConnectError {
),
],
);
write!(f, "{}", translated)
write!(f, "{translated}")
}
ConnectError::VersionMissing => write!(f, "{}", tr("error_missing_version_field")),
ConnectError::LobbyDoesNotExist => write!(f, "{}", tr("error_lobby_does_not_exist")),

View file

@ -396,11 +396,11 @@ pub fn create_player_png(
let (arrows_path, ping_path, map_icon) = arrows_path(tmp_path.into(), is_host);
let cursor_path = cursor_path(tmp_path.into());
let player_lukki = tmp_path.join("unmodified_lukki.png");
icon.save(tmp_path.join(format!("tmp/{}_icon.png", id)))
icon.save(tmp_path.join(format!("tmp/{id}_icon.png")))
.unwrap();
replace_colors(
player_path.into(),
tmp_path.join(format!("tmp/{}.png", id)),
tmp_path.join(format!("tmp/{id}.png")),
&rgb,
);
{
@ -414,49 +414,48 @@ pub fn create_player_png(
for px in img.pixels_mut() {
px.0[3] = px.0[3].min(64)
}
img.save(tmp_path.join(format!("tmp/{}_dc.png", id)))
.unwrap();
img.save(tmp_path.join(format!("tmp/{id}_dc.png"))).unwrap();
}
replace_colors(
player_lukki,
tmp_path.join(format!("tmp/{}_lukki.png", id)),
tmp_path.join(format!("tmp/{id}_lukki.png")),
&rgb,
);
replace_colors_opt(
arrows_path,
tmp_path.join(format!("tmp/{}_arrow.png", id)),
tmp_path.join(format!("tmp/{id}_arrow.png")),
&rgb,
inv,
);
replace_colors_opt(
ping_path,
tmp_path.join(format!("tmp/{}_ping.png", id)),
tmp_path.join(format!("tmp/{id}_ping.png")),
&rgb,
inv,
);
replace_colors_opt(
cursor_path,
tmp_path.join(format!("tmp/{}_cursor.png", id)),
tmp_path.join(format!("tmp/{id}_cursor.png")),
&rgb,
inv,
);
replace_colors(
tmp_path.join("knee.png"),
tmp_path.join(format!("tmp/{}_knee.png", id)),
tmp_path.join(format!("tmp/{id}_knee.png")),
&rgb,
);
replace_colors(
tmp_path.join("limb_a.png"),
tmp_path.join(format!("tmp/{}_limb_a.png", id)),
tmp_path.join(format!("tmp/{id}_limb_a.png")),
&rgb,
);
replace_colors(
tmp_path.join("limb_b.png"),
tmp_path.join(format!("tmp/{}_limb_b.png", id)),
tmp_path.join(format!("tmp/{id}_limb_b.png")),
&rgb,
);
replace_colors(map_icon, tmp_path.join(format!("tmp/{}_map.png", id)), &rgb);
let ragdoll_path = tmp_path.join(format!("tmp/{}_ragdoll.txt", id));
replace_colors(map_icon, tmp_path.join(format!("tmp/{id}_map.png")), &rgb);
let ragdoll_path = tmp_path.join(format!("tmp/{id}_ragdoll.txt"));
if ragdoll_path.exists() {
remove_file(ragdoll_path.clone()).unwrap()
}
@ -476,21 +475,16 @@ pub fn create_player_png(
.rev()
{
let f = tmp_path.join(s);
replace_colors(f, tmp_path.join(format!("tmp/{}_ragdoll_{}", id, s)), &rgb);
files = format!(
"{}mods/quant.ew/files/system/player/tmp/{}_ragdoll_{}\n",
files, id, s
);
replace_colors(f, tmp_path.join(format!("tmp/{id}_ragdoll_{s}")), &rgb);
files = format!("{files}mods/quant.ew/files/system/player/tmp/{id}_ragdoll_{s}\n");
}
ragdoll.write_all(files.as_bytes()).unwrap();
let img = create_arm(Rgba::from(to_u8(rgb.player_forearm)));
let path = tmp_path.join(format!("tmp/{}_arm.png", id));
let path = tmp_path.join(format!("tmp/{id}_arm.png"));
img.save(path).unwrap();
edit_nth_line(
tmp_path.join("unmodified_cape.xml").into(),
tmp_path
.join(format!("tmp/{}_cape.xml", id))
.into_os_string(),
tmp_path.join(format!("tmp/{id}_cape.xml")).into_os_string(),
vec![16, 16],
vec![
format!("cloth_color=\"0xFF{}\"", rgb_to_hex(to_u8(rgb.player_cape))),
@ -502,7 +496,7 @@ pub fn create_player_png(
);
edit_nth_line(
tmp_path.join("unmodified.xml").into(),
tmp_path.join(format!("tmp/{}_dc.xml", id)).into_os_string(),
tmp_path.join(format!("tmp/{id}_dc.xml")).into_os_string(),
vec![1],
vec![format!(
"filename=\"mods/quant.ew/files/system/player/tmp/{}_dc.png\"",
@ -511,7 +505,7 @@ pub fn create_player_png(
);
edit_nth_line(
tmp_path.join("unmodified.xml").into(),
tmp_path.join(format!("tmp/{}.xml", id)).into_os_string(),
tmp_path.join(format!("tmp/{id}.xml")).into_os_string(),
vec![1],
vec![format!(
"filename=\"mods/quant.ew/files/system/player/tmp/{}.png\"",
@ -523,7 +517,7 @@ pub fn create_player_png(
tmp_path.join("tmp/".to_owned() + &id.clone() + "_lukki.xml"),
&[(
"MARKER_LUKKI_PNG",
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.png", id),
format!("mods/quant.ew/files/system/player/tmp/{id}_lukki.png"),
)],
);
edit_by_replacing(
@ -559,31 +553,29 @@ pub fn create_player_png(
),
(
"MARKER_MAIN_SPRITE",
format!("mods/quant.ew/files/system/player/tmp/{}.xml", id),
format!("mods/quant.ew/files/system/player/tmp/{id}.xml"),
),
(
"MARKER_LUKKI_SPRITE",
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.xml", id),
format!("mods/quant.ew/files/system/player/tmp/{id}_lukki.xml"),
),
(
"MARKER_ARM_SPRITE",
format!("mods/quant.ew/files/system/player/tmp/{}_arm.xml", id),
format!("mods/quant.ew/files/system/player/tmp/{id}_arm.xml"),
),
(
"MARKER_CAPE",
format!("mods/quant.ew/files/system/player/tmp/{}_cape.xml", id),
format!("mods/quant.ew/files/system/player/tmp/{id}_cape.xml"),
),
(
"RAGDOLL_MARKER",
format!("mods/quant.ew/files/system/player/tmp/{}_ragdoll.txt", id),
format!("mods/quant.ew/files/system/player/tmp/{id}_ragdoll.txt"),
),
],
);
edit_nth_line(
tmp_path.join("unmodified_arm.xml").into(),
tmp_path
.join(format!("tmp/{}_arm.xml", id))
.into_os_string(),
tmp_path.join(format!("tmp/{id}_arm.xml")).into_os_string(),
vec![1],
vec![format!(
"filename=\"mods/quant.ew/files/system/player/tmp/{}_arm.png\"",
@ -609,7 +601,7 @@ fn edit_nth_line(path: OsString, exit: OsString, v: Vec<usize>, newline: Vec<Str
}
let mut file = File::create(exit).unwrap();
for line in lines {
writeln!(file, "{}", line).unwrap();
writeln!(file, "{line}").unwrap();
}
}

View file

@ -24,7 +24,7 @@ impl Display for NetError {
NetError::UnknownPeer => write!(f, "No peer with this id"),
NetError::Disconnected => write!(f, "Not connected"),
NetError::MessageTooLong => {
write!(f, "Message len exceeds the limit of {}", MAX_MESSAGE_LEN)
write!(f, "Message len exceeds the limit of {MAX_MESSAGE_LEN}")
}
NetError::Dropped => write!(f, "Message dropped"),
NetError::Other => write!(f, "Other"),