make clippy happy(nightly)

This commit is contained in:
bgkillas 2025-06-26 14:37:19 -04:00
parent 79c4a9a15e
commit 5c1dafb239
10 changed files with 267 additions and 296 deletions

View file

@ -162,20 +162,18 @@ impl EntityID {
&& self.check_all_phys_init().unwrap_or(false)
{
let body_id = self.get_physics_body_ids().unwrap_or_default();
if !body_id.is_empty() {
if let Ok(iter) = EntityID::get_with_tag("ew_peer") {
for com in iter
.filter_map(|e| {
e.try_get_first_component_including_disabled::<TelekinesisComponent>(
None,
)
if !body_id.is_empty()
&& let Ok(iter) = EntityID::get_with_tag("ew_peer")
{
for com in iter
.filter_map(|e| {
e.try_get_first_component_including_disabled::<TelekinesisComponent>(None)
.ok()
})
.flatten()
{
if body_id.contains(&com.get_body_id()) {
let _ = com.set_m_state(0);
}
})
.flatten()
{
if body_id.contains(&com.get_body_id()) {
let _ = com.set_m_state(0);
}
}
}
@ -367,10 +365,10 @@ impl EntityID {
let name = effect.effect()?;
match name {
GameEffectEnum::Custom => {
if let Ok(file) = ent.filename() {
if !file.is_empty() {
effects.push((GameEffectData::Custom(file.to_string()), ent))
}
if let Ok(file) = ent.filename()
&& !file.is_empty()
{
effects.push((GameEffectData::Custom(file.to_string()), ent))
} /* else if let Ok(data) = serialize::serialize_entity(ent) {
let n = ent.filename().unwrap_or(String::new());
effects.push((GameEffectData::Projectile((n, data)), ent))
@ -399,31 +397,28 @@ impl EntityID {
fn set_frames(ent: EntityID) -> eyre::Result<()> {
if let Some(effect) =
ent.try_get_first_component_including_disabled::<GameEffectComponent>(None)?
&& effect.frames()? >= 0
{
if effect.frames()? >= 0 {
effect.set_frames(i32::MAX)?;
}
effect.set_frames(i32::MAX)?;
}
if let Some(life) =
ent.try_get_first_component_including_disabled::<LifetimeComponent>(None)?
&& life.lifetime()? >= 0
{
if life.lifetime()? >= 0 {
life.set_lifetime(i32::MAX)?;
}
life.set_lifetime(i32::MAX)?;
}
Ok(())
}
let local_effects = self.get_game_effects()?;
for (i, (e1, ent)) in local_effects.iter().enumerate() {
if let GameEffectData::Normal(e1) = e1 {
if *e1 == GameEffectEnum::Polymorph
if let GameEffectData::Normal(e1) = e1
&& (*e1 == GameEffectEnum::Polymorph
|| *e1 == GameEffectEnum::PolymorphRandom
|| *e1 == GameEffectEnum::PolymorphUnstable
|| *e1 == GameEffectEnum::PolymorphCessation
{
ent.kill();
continue;
}
|| *e1 == GameEffectEnum::PolymorphCessation)
{
ent.kill();
continue;
}
for (j, (e2, _)) in local_effects.iter().enumerate() {
if i < j && e1 == e2 {
@ -1610,11 +1605,10 @@ impl EntityManager {
[const { CachedComponent::from_component::<C>() as usize }]
.iter_mut()
.find(|c| c.id == id)
&& n.enabled != enabled
{
if n.enabled != enabled {
n.enabled = enabled;
self.current_entity.set_component_enabled(id, enabled)?;
}
n.enabled = enabled;
self.current_entity.set_component_enabled(id, enabled)?;
}
Ok(())
}

View file

@ -229,10 +229,10 @@ fn netmanager_recv(_lua: LuaState) -> eyre::Result<Option<RawString>> {
NoitaInbound::Ready { .. } => bail!("Unexpected Ready message"),
NoitaInbound::ProxyToDes(proxy_to_des) => ExtState::with_global(|state| {
let _lock = IN_MODULE_LOCK.lock().unwrap();
if let Some(entity_sync) = &mut state.modules.entity_sync {
if let Err(e) = entity_sync.handle_proxytodes(proxy_to_des) {
let _ = print_error(e);
}
if let Some(entity_sync) = &mut state.modules.entity_sync
&& let Err(e) = entity_sync.handle_proxytodes(proxy_to_des)
{
let _ = print_error(e);
}
})?,
NoitaInbound::RemoteMessage {

View file

@ -566,13 +566,11 @@ impl Module for EntitySync {
if let Some(cost) = self
.entity_manager
.try_get_first_component::<ItemCostComponent>(ComponentTag::None)
&& cost.stealable()?
{
if cost.stealable()? {
cost.set_stealable(false)?;
self.entity_manager.get_var_or_default(
const { VarName::from_str("ew_was_stealable") },
)?;
}
cost.set_stealable(false)?;
self.entity_manager
.get_var_or_default(const { VarName::from_str("ew_was_stealable") })?;
}
if let Some(vel) = self
.entity_manager
@ -706,15 +704,14 @@ impl Module for EntitySync {
let data = proj
.drain(..)
.map(|(ent, mut proj)| {
if ent.is_alive() {
if let Ok(Some(vel)) = ent
if ent.is_alive()
&& let Ok(Some(vel)) = ent
.try_get_first_component_including_disabled::<VelocityComponent>(
None,
)
{
proj.vel = vel.m_velocity().ok()
}
}
proj
})
.collect();

View file

@ -142,25 +142,24 @@ impl LocalDiffModel {
gid,
last,
}) = self.entity_entries.get(&lid)
&& !self.dont_upload.contains(&lid)
{
if !self.dont_upload.contains(&lid) {
if last.is_some() {
res.push(UpdateOrUpload::Upload(FullEntityData {
gid: *gid,
pos: WorldPos::from_f32(current.x, current.y),
data: current.spawn_info.clone(),
wand: current.wand.clone().map(|(_, w, _)| w),
//rotation: entry_pair.current.r,
drops_gold: current.drops_gold,
is_charmed: current.is_charmed(),
hp: current.hp,
counter: current.counter,
phys: current.phys.clone(),
synced_var: current.synced_var.clone(),
}));
} else {
self.upload.insert(lid);
}
if last.is_some() {
res.push(UpdateOrUpload::Upload(FullEntityData {
gid: *gid,
pos: WorldPos::from_f32(current.x, current.y),
data: current.spawn_info.clone(),
wand: current.wand.clone().map(|(_, w, _)| w),
//rotation: entry_pair.current.r,
drops_gold: current.drops_gold,
is_charmed: current.is_charmed(),
hp: current.hp,
counter: current.counter,
phys: current.phys.clone(),
synced_var: current.synced_var.clone(),
}));
} else {
self.upload.insert(lid);
}
}
}
@ -407,18 +406,17 @@ impl LocalDiffModelTracker {
(info.vx, info.vy) = vel.m_velocity()?;
}
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") }) {
if let Some(vel) =
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") })
&& let Some(vel) =
entity_manager.try_get_first_component::<VelocityComponent>(ComponentTag::None)
{
let (cx, cy) = entity_manager.camera_pos();
if ((cx - x) as f32).powi(2) + ((cy - y) as f32).powi(2) > 512.0 * 512.0 {
vel.set_gravity_y(0.0)?;
vel.set_air_friction(10.0)?;
} else {
vel.set_gravity_y(400.0)?;
vel.set_air_friction(0.55)?;
}
{
let (cx, cy) = entity_manager.camera_pos();
if ((cx - x) as f32).powi(2) + ((cy - y) as f32).powi(2) > 512.0 * 512.0 {
vel.set_gravity_y(0.0)?;
vel.set_air_friction(10.0)?;
} else {
vel.set_gravity_y(400.0)?;
vel.set_air_friction(0.55)?;
}
}
@ -559,25 +557,25 @@ impl LocalDiffModelTracker {
.collect();
if let Some(ai) =
entity_manager.try_get_first_component::<AnimalAIComponent>(ComponentTag::None)
&& ai.attack_ranged_use_laser_sight()?
&& !ai.is_static_turret()?
{
if ai.attack_ranged_use_laser_sight()? && !ai.is_static_turret()? {
info.laser = if let Some(target) = ai.m_greatest_prey()? {
if ![15, 16].contains(&ai.ai_state()?) {
Target::None
} else if let Some(peer) = ctx.player_map.get_by_right(&target) {
Target::Peer(*peer)
} else if let Some(var) = target.get_var("ew_gid_lid") {
if var.value_bool()? {
Target::Gid(Gid(var.value_string()?.parse::<u64>()?))
} else {
Target::None
}
info.laser = if let Some(target) = ai.m_greatest_prey()? {
if ![15, 16].contains(&ai.ai_state()?) {
Target::None
} else if let Some(peer) = ctx.player_map.get_by_right(&target) {
Target::Peer(*peer)
} else if let Some(var) = target.get_var("ew_gid_lid") {
if var.value_bool()? {
Target::Gid(Gid(var.value_string()?.parse::<u64>()?))
} else {
Target::None
}
} else {
Target::None
}
} else {
Target::None
}
}
entity_manager.files = files;
@ -851,16 +849,13 @@ impl LocalDiffModel {
let (x, y) = entity.position()?;
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") }) {
if let Some(cost) =
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") })
&& let Some(cost) =
entity_manager.try_get_first_component::<ItemCostComponent>(ComponentTag::None)
{
if cost.stealable()? {
cost.set_stealable(false)?;
entity_manager
.get_var_or_default(const { VarName::from_str("ew_was_stealable") })?;
}
}
&& cost.stealable()?
{
cost.set_stealable(false)?;
entity_manager.get_var_or_default(const { VarName::from_str("ew_was_stealable") })?;
}
let entity_kind = classify_entity(entity)?;
@ -888,13 +883,12 @@ impl LocalDiffModel {
var.set_value_int(i32::from_le_bytes(lid.0.to_le_bytes()))?;
var.set_value_bool(true)?;
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") }) {
if let Some(vel) =
if entity_manager.has_tag(const { CachedTag::from_tag("card_action") })
&& let Some(vel) =
entity_manager.try_get_first_component::<VelocityComponent>(ComponentTag::None)
{
vel.set_gravity_y(0.0)?;
vel.set_air_friction(10.0)?;
}
{
vel.set_gravity_y(0.0)?;
vel.set_air_friction(10.0)?;
}
if entity_manager
@ -1081,19 +1075,18 @@ impl LocalDiffModel {
mom(entity_manager, entity_data.counter, None)?;
sun(entity_manager, entity_data.counter)?;
if entity_data.hp != -1.0 {
if let Some(damage) = entity_manager
if entity_data.hp != -1.0
&& let Some(damage) = entity_manager
.try_get_first_component::<DamageModelComponent>(ComponentTag::None)
{
noita_api::print(format!("a {:?} {:?}", entity, damage.0));
if entity_data.hp > damage.max_hp_cap()? as f32 {
damage.set_max_hp_cap(entity_data.hp as f64)?;
}
if entity_data.hp > damage.max_hp()? as f32 {
damage.set_max_hp(entity_data.hp as f64)?;
}
damage.set_hp(entity_data.hp as f64)?;
{
noita_api::print(format!("a {:?} {:?}", entity, damage.0));
if entity_data.hp > damage.max_hp_cap()? as f32 {
damage.set_max_hp_cap(entity_data.hp as f64)?;
}
if entity_data.hp > damage.max_hp()? as f32 {
damage.set_max_hp(entity_data.hp as f64)?;
}
damage.set_hp(entity_data.hp as f64)?;
}
if !entity_data.drops_gold {
let n = entity_manager
@ -1563,11 +1556,11 @@ impl RemoteDiffModel {
ent_data = self.entity_infos.get_mut(&lid).unwrap_or(empty_data);
}
EntityUpdate::LocalizeEntity(lid, peer_id) => {
if let Some((_, entity)) = self.tracked.remove_by_left(&lid) {
if peer_id != my_peer_id() {
entity_manager.set_current_entity(entity)?;
safe_entitykill(entity_manager);
}
if let Some((_, entity)) = self.tracked.remove_by_left(&lid)
&& peer_id != my_peer_id()
{
entity_manager.set_current_entity(entity)?;
safe_entitykill(entity_manager);
}
self.entity_infos.remove(&lid);
ent_data = empty_data;
@ -2051,10 +2044,10 @@ impl RemoteDiffModel {
end = Some(i);
}
} else {
if let Some(gid) = self.lid_to_gid.get(lid) {
if ctx.dont_spawn.contains(gid) {
continue;
}
if let Some(gid) = self.lid_to_gid.get(lid)
&& ctx.dont_spawn.contains(gid)
{
continue;
}
let entity = spawn_entity_by_data(
&entity_info.spawn_info,
@ -2170,10 +2163,10 @@ impl RemoteDiffModel {
projectile.target.1 as f64,
deserialized,
);
if let Ok(Some(vel)) = deserialized.try_get_first_component::<VelocityComponent>(None) {
if let Some((vx, vy)) = projectile.vel {
let _ = vel.set_m_velocity((vx, vy));
}
if let Ok(Some(vel)) = deserialized.try_get_first_component::<VelocityComponent>(None)
&& let Some((vx, vy)) = projectile.vel
{
let _ = vel.set_m_velocity((vx, vy));
}
}
}
@ -2255,13 +2248,12 @@ pub fn init_remote_entity(
}
entity_manager.add_tag(const { CachedTag::from_tag(DES_TAG) })?;
entity_manager.add_tag(const { CachedTag::from_tag("polymorphable_NOT") })?;
if lid.is_some() {
if let Some(damage) =
if lid.is_some()
&& let Some(damage) =
entity_manager.try_get_first_component::<DamageModelComponent>(ComponentTag::None)
{
damage.set_wait_for_kill_flag_on_death(true)?;
damage.set_physics_objects_damage(false)?;
}
{
damage.set_wait_for_kill_flag_on_death(true)?;
damage.set_physics_objects_damage(false)?;
}
for pb2 in
@ -2342,10 +2334,10 @@ pub fn init_remote_entity(
immortal.set_script_damage_about_to_be_received(
"mods/quant.ew/files/system/entity_sync_helper/immortal.lua".into(),
)?;
if let Some(var) = entity_manager.get_var(const { VarName::from_str("ghost_id") }) {
if let Ok(ent) = EntityID::try_from(var.value_int()? as isize) {
ent.kill()
}
if let Some(var) = entity_manager.get_var(const { VarName::from_str("ghost_id") })
&& let Ok(ent) = EntityID::try_from(var.value_int()? as isize)
{
ent.kill()
}
if entity_manager.has_tag(const { CachedTag::from_tag("boss_dragon") }) && drops_gold {
let lua = entity_manager.add_component::<LuaComponent>()?;
@ -2370,18 +2362,17 @@ pub fn init_remote_entity(
ghost.set_die_if_no_home(false)?;
}
if entity_manager.has_tag(const { CachedTag::from_tag("egg_item") }) {
if let Some(explosion) = entity_manager
if entity_manager.has_tag(const { CachedTag::from_tag("egg_item") })
&& let Some(explosion) = entity_manager
.try_get_first_component_including_disabled::<ExplodeOnDamageComponent>(
ComponentTag::None,
)
{
explosion.object_set_value::<Cow<'_, str>>(
"config_explosion",
"load_this_entity",
"".into(),
)?
}
{
explosion.object_set_value::<Cow<'_, str>>(
"config_explosion",
"load_this_entity",
"".into(),
)?
}
if let Some(var) = entity_manager.get_var(const { VarName::from_str("ew_gid_lid") }) {
@ -2679,29 +2670,27 @@ fn give_wand(
fn mom(entity: &mut EntityManager, counter: u8, cost: Option<i32>) -> eyre::Result<()> {
if entity.has_tag(const { CachedTag::from_tag("boss_wizard") }) {
for ent in entity.entity().children(None) {
if ent.has_tag("touchmagic_immunity") {
if let Ok(var) = ent
if ent.has_tag("touchmagic_immunity")
&& let Ok(var) = ent
.get_first_component_including_disabled::<VariableStorageComponent>(Some(
"wizard_orb_id".into(),
))
{
if let Ok(n) = var.value_int() {
if (counter & (1 << (n as u8))) == 0 {
ent.kill()
} else if let Ok(damage) = ent.get_first_component::<DamageModelComponent>(None)
{
noita_api::print(format!("c {:?} {:?}", entity.entity(), damage.0));
damage.set_wait_for_kill_flag_on_death(true)?;
damage.set_hp(damage.max_hp()?)?;
}
}
if let Some(cost) = cost
&& let Ok(v) = ent.get_var_or_default("ew_frame_num")
{
if let Ok(n) = var.value_int() {
if (counter & (1 << (n as u8))) == 0 {
ent.kill()
} else if let Ok(damage) =
ent.get_first_component::<DamageModelComponent>(None)
{
noita_api::print(format!("c {:?} {:?}", entity.entity(), damage.0));
damage.set_wait_for_kill_flag_on_death(true)?;
damage.set_hp(damage.max_hp()?)?;
}
}
if let Some(cost) = cost {
if let Ok(v) = ent.get_var_or_default("ew_frame_num") {
let _ = v.add_tag("ew_frame_num");
let _ = v.set_value_int(cost);
}
}
let _ = v.add_tag("ew_frame_num");
let _ = v.set_value_int(cost);
}
}
}

View file

@ -89,7 +89,7 @@ impl NoitaLauncher {
}
}
pub fn launch_token(&mut self) -> LaunchTokenResult {
pub fn launch_token(&mut self) -> LaunchTokenResult<'_> {
if self.check_if_noita_running() {
return LaunchTokenResult::AlreadyStarted;
}

View file

@ -1200,14 +1200,14 @@ impl ImageMap {
}
}
let tile_size = self.zoom * 128.0;
if let Some(peer) = self.centered_on {
if let Some((Some(pos), _, _, _)) = self.players.get(&peer) {
self.offset = Vec2::new(ui.available_width() / 2.0, ui.available_height() / 2.0)
- Vec2::new(
pos.x as f32 * tile_size / 128.0,
(pos.y - 12) as f32 * tile_size / 128.0,
)
}
if let Some(peer) = self.centered_on
&& let Some((Some(pos), _, _, _)) = self.players.get(&peer)
{
self.offset = Vec2::new(ui.available_width() / 2.0, ui.available_height() / 2.0)
- Vec2::new(
pos.x as f32 * tile_size / 128.0,
(pos.y - 12) as f32 * tile_size / 128.0,
)
}
let painter = ui.painter();
for (coord, tex) in &self.textures {
@ -1240,15 +1240,15 @@ impl ImageMap {
Vec2::new(7.0 * tile_size / 128.0, 16.0 * tile_size / 128.0),
);
if *is_dead {
if let Some(tex) = &self.notplayer {
if let Some(id) = tex.texture_id() {
painter.image(
id,
rect,
Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)),
Color32::WHITE,
);
}
if let Some(tex) = &self.notplayer
&& let Some(id) = tex.texture_id()
{
painter.image(
id,
rect,
Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)),
Color32::WHITE,
);
}
} else {
painter.image(
@ -1524,10 +1524,10 @@ impl App {
None
};
let mut my_nickname = self.app_saved_state.nickname.clone().or(steam_nickname);
if let Some(n) = &my_nickname {
if n.trim().is_empty() {
my_nickname = None;
}
if let Some(n) = &my_nickname
&& n.trim().is_empty()
{
my_nickname = None;
}
my_nickname.unwrap_or(default)
@ -1963,11 +1963,11 @@ impl App {
let addr = addr.or(addr2);
ui.add_enabled_ui(addr.is_ok(), |ui| {
if ui.button(tr("ip_connect")).clicked() {
if let Ok(addr) = addr {
self.set_settings();
self.start_connect(addr);
}
if ui.button(tr("ip_connect")).clicked()
&& let Ok(addr) = addr
{
self.set_settings();
self.start_connect(addr);
}
});
}
@ -2220,8 +2220,8 @@ impl App {
}
ui.separator();
}
if let Some(game) = self.modmanager_settings.game_exe_path.parent() {
if let Ok(s) = fs::read_to_string(game.join("logger.txt")) {
if let Some(game) = self.modmanager_settings.game_exe_path.parent()
&& let Ok(s) = fs::read_to_string(game.join("logger.txt")) {
let l = self.noitalog.len();
if l != 0 && s.len() >= self.noitalog[l - 1].len() {
if s.len() != self.noitalog[l - 1].len() {
@ -2232,7 +2232,6 @@ impl App {
self.noitalog.push(s);
}
}
}
match self.connected_menu {
ConnectedMenu::Normal => {
if netman.peer.is_steam() {
@ -2412,11 +2411,10 @@ impl App {
if l > 1 {
ui.add(Slider::new(&mut self.noitalog_number, 0..=l - 1));
}
if let Some(clipboard) = self.clipboard.as_mut() {
if ui.button("save to clipboard").clicked() {
if let Some(clipboard) = self.clipboard.as_mut()
&& ui.button("save to clipboard").clicked() {
let _ = clipboard.set_text(&s);
}
}
});
ScrollArea::vertical()
.auto_shrink([false; 2])
@ -2436,11 +2434,10 @@ impl App {
path.parent().unwrap().join("ew_log.txt")
} else {
"ew_log.txt".into()
}) {
if s.len() > self.proxylog.len() {
})
&& s.len() > self.proxylog.len() {
self.proxylog = s
}
}
let mut s = self.proxylog.clone() + "\n";
ScrollArea::vertical()
.auto_shrink([false; 2])

View file

@ -91,13 +91,13 @@ pub(crate) struct NetInnerState {
impl NetInnerState {
pub(crate) fn try_ms_write(&mut self, data: &NoitaInbound) {
if let Some(ws) = &mut self.ms {
if let Err(err) = ws.write(data) {
error!("Error occured while sending to websocket: {}", err);
self.ms = None;
self.had_a_disconnect = true;
};
}
if let Some(ws) = &mut self.ms
&& let Err(err) = ws.write(data)
{
error!("Error occured while sending to websocket: {}", err);
self.ms = None;
self.had_a_disconnect = true;
};
}
pub(crate) fn try_ws_write_option(&mut self, key: &str, value: impl ProxyOpt) {
let mut buf = Vec::new();
@ -430,12 +430,12 @@ impl NetManager {
);
while self.continue_running.load(Ordering::Relaxed) {
if let Some(k) = kind {
if let Some(n) = self.peer.lobby_id() {
let c = crate::lobby_code::LobbyCode { kind: k, code: n };
info!("Lobby ID: {}", c.serialize());
kind = None
}
if let Some(k) = kind
&& let Some(n) = self.peer.lobby_id()
{
let c = crate::lobby_code::LobbyCode { kind: k, code: n };
info!("Lobby ID: {}", c.serialize());
kind = None
}
if self.end_run.load(Ordering::Relaxed) {
for id in self.peer.iter_peer_ids() {
@ -461,10 +461,10 @@ impl NetManager {
}
}
}
if let Some(ws) = &mut state.ms {
if let Err(err) = ws.flush() {
warn!("Websocket flush not ok: {err}");
}
if let Some(ws) = &mut state.ms
&& let Err(err) = ws.flush()
{
warn!("Websocket flush not ok: {err}");
}
let mut to_kick = self.kick_list.lock().unwrap();
let mut dont_kick = self.dont_kick.lock().unwrap();
@ -810,19 +810,19 @@ impl NetManager {
.lock()
.unwrap()
.insert(src, get_player_skin(player_image.clone(), rgb));
if let Some(id) = pong {
if id != self.peer.my_id() {
self.send(
id,
&NetMsg::PlayerColor(
self.init_settings.player_png_desc,
self.is_host(),
None,
self.init_settings.my_nickname.clone(),
),
Reliability::Reliable,
);
}
if let Some(id) = pong
&& id != self.peer.my_id()
{
self.send(
id,
&NetMsg::PlayerColor(
self.init_settings.player_png_desc,
self.is_host(),
None,
self.init_settings.my_nickname.clone(),
),
Reliability::Reliable,
);
}
}
NetMsg::Kick => self.back_out.store(true, Ordering::Relaxed),

View file

@ -163,10 +163,9 @@ impl AudioManager {
if let Ok(len) = encoder.encode_float(
&resamp.process(&[&extra[..FRAME_SIZE]], None).unwrap()[0],
&mut compressed,
) {
if len != 0 {
v.push(compressed[..len].to_vec())
}
) && len != 0
{
v.push(compressed[..len].to_vec())
}
extra.drain(..FRAME_SIZE);
}
@ -254,18 +253,17 @@ impl AudioManager {
sound_pos: (i32, i32),
iv: f32,
) {
if let std::collections::hash_map::Entry::Vacant(e) = self.per_player.entry(src) {
if let Some(stream_handle) = &self.stream_handle {
if let Ok(s) = Sink::try_new(&stream_handle.1) {
//let (pitch_control, dsp) = make_dsp();
e.insert(PlayerInfo {
sink: s,
//tracker: VelocityTracker::default(),
//pitch_control,
//dsp,
});
}
}
if let std::collections::hash_map::Entry::Vacant(e) = self.per_player.entry(src)
&& let Some(stream_handle) = &self.stream_handle
&& let Ok(s) = Sink::try_new(&stream_handle.1)
{
//let (pitch_control, dsp) = make_dsp();
e.insert(PlayerInfo {
sink: s,
//tracker: VelocityTracker::default(),
//pitch_control,
//dsp,
});
}
self.per_player.entry(src).and_modify(|player_info| {
/*player_info
@ -294,10 +292,10 @@ impl AudioManager {
let mut dec: Vec<f32> = Vec::new();
for data in data {
let mut out = vec![0f32; FRAME_SIZE];
if let Ok(len) = self.decoder.decode_float(&data, &mut out, false) {
if len != 0 {
dec.extend(&out[..len])
}
if let Ok(len) = self.decoder.decode_float(&data, &mut out, false)
&& len != 0
{
dec.extend(&out[..len])
}
}
if !dec.is_empty() {

View file

@ -148,10 +148,10 @@ impl Connections {
}
fn flush(&self) {
for i in &self.peers {
if let Some(c) = i.connection() {
if let Err(err) = c.flush_messages() {
warn!("Error while flushing a message: {err:?}")
}
if let Some(c) = i.connection()
&& let Err(err) = c.flush_messages()
{
warn!("Error while flushing a message: {err:?}")
}
}
}

View file

@ -894,13 +894,13 @@ impl WorldManager {
if world_num != self.world_num {
return;
}
if let Some(state) = self.authority_map.get(&chunk) {
if state.0 != source {
debug!(
"{source} sent RelinquishAuthority for {chunk:?}, but isn't currently an authority"
);
return;
}
if let Some(state) = self.authority_map.get(&chunk)
&& state.0 != source
{
debug!(
"{source} sent RelinquishAuthority for {chunk:?}, but isn't currently an authority"
);
return;
}
self.authority_map.remove(&chunk);
if let Some(chunk_data) = chunk_data {
@ -1743,32 +1743,28 @@ impl WorldManager {
self.is_storage_recent.insert(entry.0);
}
}
if let Some((coord, rays)) = entry.unloaded {
if self.nice_terraforming {
exists = true;
let lst = rays
.iter()
.filter_map(|i| {
if raydata[*i] == 0 {
None
} else if let Some(n) = data.get(i) {
Some(*n)
} else {
let n = self.explosion_data.len();
self.explosion_data.push((
m,
*i,
ExTarget::Ray(raydata[*i]),
0,
));
data.insert(*i, n);
Some(n)
}
})
.collect::<Vec<usize>>();
if !lst.is_empty() {
self.explosion_pointer.entry(coord).or_default().extend(lst)
}
if let Some((coord, rays)) = entry.unloaded
&& self.nice_terraforming
{
exists = true;
let lst = rays
.iter()
.filter_map(|i| {
if raydata[*i] == 0 {
None
} else if let Some(n) = data.get(i) {
Some(*n)
} else {
let n = self.explosion_data.len();
self.explosion_data
.push((m, *i, ExTarget::Ray(raydata[*i]), 0));
data.insert(*i, n);
Some(n)
}
})
.collect::<Vec<usize>>();
if !lst.is_empty() {
self.explosion_pointer.entry(coord).or_default().extend(lst)
}
}
}
@ -2382,14 +2378,14 @@ fn create_image(chunk: ChunkData, materials: &FxHashMap<u16, u32>) -> RgbaImage
let y = i / w as usize;
let p = y * CHUNK_SIZE + x;
let m = working_chunk.pixel(p);
if m.flags != PixelFlags::Unknown {
if let Some(c) = materials.get(&m.material) {
let a = (c >> 24) & 0xFFu32;
let r = (c >> 16) & 0xFFu32;
let g = (c >> 8) & 0xFFu32;
let b = c & 0xFF;
*px = image::Rgba([r as u8, g as u8, b as u8, a as u8])
}
if m.flags != PixelFlags::Unknown
&& let Some(c) = materials.get(&m.material)
{
let a = (c >> 24) & 0xFFu32;
let r = (c >> 16) & 0xFFu32;
let g = (c >> 8) & 0xFFu32;
let b = c & 0xFF;
*px = image::Rgba([r as u8, g as u8, b as u8, a as u8])
}
}
image