Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
IntQuant committed Nov 28, 2024
1 parent b506dac commit d3023ad
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 34 deletions.
17 changes: 10 additions & 7 deletions noita-proxy/src/bookkeeping/mod_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,15 @@ impl Mods {
self.mod_entries.insert(0, entry);
&mut self.mod_entries[0]
} else {
self.mod_entries.insert(0, ModEntry {
enabled: 0,
name: name.to_owned(),
settings_fold_open: 0,
workshop_item_id: 0,
});
self.mod_entries.insert(
0,
ModEntry {
enabled: 0,
name: name.to_owned(),
settings_fold_open: 0,
workshop_item_id: 0,
},
);
&mut self.mod_entries[0]
}
}
Expand All @@ -474,4 +477,4 @@ fn enable_mod(saves_path: &Path) -> Result<(), Box<dyn Error>> {
let xml = quick_xml::se::to_string(&data)?;
fs::write(&mod_config_path, xml)?;
Ok(())
}
}
9 changes: 6 additions & 3 deletions noita-proxy/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl NetManager {
&NetMsg::PlayerColor(
self.init_settings.player_png_desc,
self.is_host(),
Some(self.peer.my_id())
Some(self.peer.my_id()),
),
Reliability::Reliable,
);
Expand Down Expand Up @@ -423,7 +423,7 @@ impl NetManager {
&NetMsg::PlayerColor(
self.init_settings.player_png_desc,
self.is_host(),
None
None,
),
Reliability::Reliable,
);
Expand Down Expand Up @@ -601,7 +601,10 @@ impl NetManager {
rgb[0] as u32 + ((rgb[1] as u32) << 8) + ((rgb[2] as u32) << 16),
);

state.try_ws_write_option("ping_lifetime", self.init_settings.ux_settings.ping_lifetime);
state.try_ws_write_option(
"ping_lifetime",
self.init_settings.ux_settings.ping_lifetime,
);
state.try_ws_write_option("ping_scale", self.init_settings.ux_settings.ping_scale);

let progress = settings.progress.join(",");
Expand Down
2 changes: 1 addition & 1 deletion noita-proxy/src/net/omni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl PeerVariant {
}
}
}

pub(crate) fn flush(&self) {
if let PeerVariant::Steam(p) = self {
p.flush()
Expand Down
5 changes: 2 additions & 3 deletions noita-proxy/src/net/steam_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,10 @@ impl SteamPeer {
for (i, p) in self.inner.lock().unwrap().remote_peers.iter().enumerate() {
if *p == Into::<SteamId>::into(peer) {
n = i as isize;
break
break;
}
}
if n >= 0
{
if n >= 0 {
self.inner.lock().unwrap().remote_peers.remove(n as usize);
}
}
Expand Down
45 changes: 27 additions & 18 deletions noita-proxy/src/player_cosmetics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ pub fn arrows_path(path: PathBuf, is_host: bool) -> (PathBuf, PathBuf, PathBuf)
let parent = path.parent().unwrap();
let p = parent.join("player_arrows");
let o = parent.join("player_ping");
(if is_host {
p.join("arrow_host.png")
} else {
p.join("arrow.png")
}, o.join("arrow.png"), parent.join("map/icon.png"))
(
if is_host {
p.join("arrow_host.png")
} else {
p.join("arrow.png")
},
o.join("arrow.png"),
parent.join("map/icon.png"),
)
}

pub fn cursor_path(path: PathBuf) -> PathBuf {
Expand Down Expand Up @@ -136,16 +140,22 @@ pub fn get_lch(color: [f64; 4]) -> (f64, f64, f64) {
}

pub fn rgb_to_oklch(color: &mut [f64; 4]) {
let mut l = 0.4122214694707629 * color[0] + 0.5363325372617349 * color[1] + 0.0514459932675022 * color[2];
let mut m = 0.2119034958178251 * color[0] + 0.6806995506452344 * color[1] + 0.1073969535369405 * color[2];
let mut s = 0.0883024591900564 * color[0] + 0.2817188391361215 * color[1] + 0.6299787016738222 * color[2];
let mut l = 0.4122214694707629 * color[0]
+ 0.5363325372617349 * color[1]
+ 0.0514459932675022 * color[2];
let mut m = 0.2119034958178251 * color[0]
+ 0.6806995506452344 * color[1]
+ 0.1073969535369405 * color[2];
let mut s = 0.0883024591900564 * color[0]
+ 0.2817188391361215 * color[1]
+ 0.6299787016738222 * color[2];

l = l.cbrt();
m = m.cbrt();
s = s.cbrt();

color[0] = 0.210454268309314 * l + 0.7936177747023054 * m - 0.0040720430116193 * s;
color[1] = 1.9779985324311684 * l - 2.42859224204858 * m + 0.450593709617411 * s;
color[0] = 0.210454268309314 * l + 0.7936177747023054 * m - 0.0040720430116193 * s;
color[1] = 1.9779985324311684 * l - 2.42859224204858 * m + 0.450593709617411 * s;
color[2] = 0.0259040424655478 * l + 0.7827717124575296 * m - 0.8086757549230774 * s;
}

Expand All @@ -158,7 +168,7 @@ fn oklch_to_rgb(color: &mut [f64; 4]) {
m = m.powi(3);
s = s.powi(3);

color[0] = 4.07674163607596 * l - 3.3077115392580635 * m + 0.2309699031821046 * s;
color[0] = 4.07674163607596 * l - 3.3077115392580635 * m + 0.2309699031821046 * s;
color[1] = -1.2684379732850317 * l + 2.6097573492876887 * m - 0.3413193760026572 * s;
color[2] = -0.0041960761386754 * l - 0.7034186179359363 * m + 1.7076146940746116 * s;
}
Expand Down Expand Up @@ -400,12 +410,11 @@ pub fn create_player_png(
edit_by_replacing(
tmp_path.join("unmodified_lukki.xml"),
tmp_path.join("tmp/".to_owned() + &id.clone() + "_lukki.xml"),
&[
(
"MARKER_LUKKI_PNG",
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.png", id),
),
]);
&[(
"MARKER_LUKKI_PNG",
format!("mods/quant.ew/files/system/player/tmp/{}_lukki.png", id),
)],
);
edit_by_replacing(
tmp_path.join("unmodified_base.xml"),
tmp_path.join("tmp/".to_owned() + &id.clone() + "_base.xml"),
Expand Down Expand Up @@ -504,4 +513,4 @@ fn edit_by_replacing(

fn rgb_to_hex(rgb: [u8; 4]) -> String {
format!("{:02X}{:02X}{:02X}", rgb[0], rgb[1], rgb[2])
}
}
3 changes: 2 additions & 1 deletion noita-proxy/src/util/steam_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ impl SteamState {
}
let app_id = env::var("NP_APPID").ok().and_then(|x| x.parse().ok());
info!("Initializing steam client...");
let (client, single) = steamworks::Client::init_app(app_id.unwrap_or(if spacewars {480} else {881100}))?;
let (client, single) =
steamworks::Client::init_app(app_id.unwrap_or(if spacewars { 480 } else { 881100 }))?;
info!("Initializing relay network accesss...");
client.networking_utils().init_relay_network_access();
if let Err(err) = client.networking_sockets().init_authentication() {
Expand Down
2 changes: 1 addition & 1 deletion noita-proxy/tangled/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Peer {
connection_manager.start()?;
Ok(Peer { shared })
}

pub fn remove(&self, peer: PeerId) {
self.shared.remote_peers.remove(&peer);
}
Expand Down

0 comments on commit d3023ad

Please sign in to comment.