mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
make clippy happy(nightly)
This commit is contained in:
parent
79c4a9a15e
commit
5c1dafb239
10 changed files with 267 additions and 296 deletions
|
@ -162,13 +162,12 @@ 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") {
|
||||
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,
|
||||
)
|
||||
e.try_get_first_component_including_disabled::<TelekinesisComponent>(None)
|
||||
.ok()
|
||||
})
|
||||
.flatten()
|
||||
|
@ -179,7 +178,6 @@ impl EntityID {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = raw::entity_kill(self);
|
||||
}
|
||||
pub fn get_with_tag(tag: &str) -> eyre::Result<impl Iterator<Item = EntityID>> {
|
||||
|
@ -367,10 +365,10 @@ impl EntityID {
|
|||
let name = effect.effect()?;
|
||||
match name {
|
||||
GameEffectEnum::Custom => {
|
||||
if let Ok(file) = ent.filename() {
|
||||
if !file.is_empty() {
|
||||
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,32 +397,29 @@ 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)?;
|
||||
}
|
||||
}
|
||||
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)?;
|
||||
}
|
||||
}
|
||||
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
|
||||
|| *e1 == GameEffectEnum::PolymorphCessation)
|
||||
{
|
||||
ent.kill();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (j, (e2, _)) in local_effects.iter().enumerate() {
|
||||
if i < j && e1 == e2 {
|
||||
ent.kill()
|
||||
|
@ -1610,12 +1605,11 @@ 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)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn remove_component<C: Component>(&mut self, component: C) -> eyre::Result<()> {
|
||||
|
|
|
@ -229,11 +229,11 @@ 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) {
|
||||
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 {
|
||||
source,
|
||||
|
|
|
@ -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") },
|
||||
)?;
|
||||
}
|
||||
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();
|
||||
|
|
|
@ -142,8 +142,8 @@ 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,
|
||||
|
@ -163,7 +163,6 @@ impl LocalDiffModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
|
@ -407,8 +406,8 @@ 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();
|
||||
|
@ -420,7 +419,6 @@ impl LocalDiffModelTracker {
|
|||
vel.set_air_friction(0.55)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(damage) =
|
||||
entity_manager.try_get_first_component::<DamageModelComponent>(ComponentTag::None)
|
||||
|
@ -559,8 +557,9 @@ 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
|
||||
|
@ -579,7 +578,6 @@ impl LocalDiffModelTracker {
|
|||
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)
|
||||
&& cost.stealable()?
|
||||
{
|
||||
if cost.stealable()? {
|
||||
cost.set_stealable(false)?;
|
||||
entity_manager
|
||||
.get_var_or_default(const { VarName::from_str("ew_was_stealable") })?;
|
||||
}
|
||||
}
|
||||
entity_manager.get_var_or_default(const { VarName::from_str("ew_was_stealable") })?;
|
||||
}
|
||||
|
||||
let entity_kind = classify_entity(entity)?;
|
||||
|
@ -888,14 +883,13 @@ 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)?;
|
||||
}
|
||||
}
|
||||
|
||||
if entity_manager
|
||||
.try_get_first_component::<BossDragonComponent>(ComponentTag::None)
|
||||
|
@ -1081,8 +1075,8 @@ 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));
|
||||
|
@ -1094,7 +1088,6 @@ impl LocalDiffModel {
|
|||
}
|
||||
damage.set_hp(entity_data.hp as f64)?;
|
||||
}
|
||||
}
|
||||
if !entity_data.drops_gold {
|
||||
let n = entity_manager
|
||||
.iter_all_components_of_type::<LuaComponent>(ComponentTag::None)
|
||||
|
@ -1563,12 +1556,12 @@ 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() {
|
||||
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,11 +2044,11 @@ impl RemoteDiffModel {
|
|||
end = Some(i);
|
||||
}
|
||||
} else {
|
||||
if let Some(gid) = self.lid_to_gid.get(lid) {
|
||||
if ctx.dont_spawn.contains(gid) {
|
||||
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,
|
||||
entity_info.x,
|
||||
|
@ -2170,13 +2163,13 @@ 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 {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*pub(crate) fn drain_backtrack(&mut self) -> impl Iterator<Item = EntityID> + '_ {
|
||||
self.backtrack.drain(..)
|
||||
|
@ -2255,14 +2248,13 @@ 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)?;
|
||||
}
|
||||
}
|
||||
|
||||
for pb2 in
|
||||
entity_manager.iter_all_components_of_type::<PhysicsBody2Component>(ComponentTag::None)
|
||||
|
@ -2342,11 +2334,11 @@ 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) {
|
||||
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>()?;
|
||||
lua.set_script_death("data/scripts/animals/boss_dragon_death.lua".into())?;
|
||||
|
@ -2370,8 +2362,8 @@ 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,
|
||||
)
|
||||
|
@ -2382,7 +2374,6 @@ pub fn init_remote_entity(
|
|||
"".into(),
|
||||
)?
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(var) = entity_manager.get_var(const { VarName::from_str("ew_gid_lid") }) {
|
||||
entity_manager.remove_component(var)?;
|
||||
|
@ -2679,8 +2670,8 @@ 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(),
|
||||
))
|
||||
|
@ -2688,24 +2679,22 @@ fn mom(entity: &mut EntityManager, counter: u8, cost: Option<i32>) -> eyre::Resu
|
|||
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)
|
||||
} 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") {
|
||||
if let Some(cost) = cost
|
||||
&& let Ok(v) = ent.get_var_or_default("ew_frame_num")
|
||||
{
|
||||
let _ = v.add_tag("ew_frame_num");
|
||||
let _ = v.set_value_int(cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn sun(entity: &mut EntityManager, counter: u8) -> eyre::Result<()> {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1200,15 +1200,15 @@ 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) {
|
||||
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 {
|
||||
let pos =
|
||||
|
@ -1240,8 +1240,9 @@ 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() {
|
||||
if let Some(tex) = &self.notplayer
|
||||
&& let Some(id) = tex.texture_id()
|
||||
{
|
||||
painter.image(
|
||||
id,
|
||||
rect,
|
||||
|
@ -1249,7 +1250,6 @@ impl ImageMap {
|
|||
Color32::WHITE,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
painter.image(
|
||||
tex.id(),
|
||||
|
@ -1524,11 +1524,11 @@ 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() {
|
||||
if let Some(n) = &my_nickname
|
||||
&& n.trim().is_empty()
|
||||
{
|
||||
my_nickname = None;
|
||||
}
|
||||
}
|
||||
|
||||
my_nickname.unwrap_or(default)
|
||||
}
|
||||
|
@ -1963,12 +1963,12 @@ 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 {
|
||||
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])
|
||||
|
|
|
@ -91,14 +91,14 @@ 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) {
|
||||
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();
|
||||
buf.push(2);
|
||||
|
@ -430,13 +430,13 @@ impl NetManager {
|
|||
);
|
||||
|
||||
while self.continue_running.load(Ordering::Relaxed) {
|
||||
if let Some(k) = kind {
|
||||
if let Some(n) = self.peer.lobby_id() {
|
||||
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() {
|
||||
self.send(id, &NetMsg::EndRun, Reliability::Reliable);
|
||||
|
@ -461,11 +461,11 @@ impl NetManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(ws) = &mut state.ms {
|
||||
if let Err(err) = ws.flush() {
|
||||
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();
|
||||
if self.no_more_players.load(Ordering::Relaxed) {
|
||||
|
@ -810,8 +810,9 @@ impl NetManager {
|
|||
.lock()
|
||||
.unwrap()
|
||||
.insert(src, get_player_skin(player_image.clone(), rgb));
|
||||
if let Some(id) = pong {
|
||||
if id != self.peer.my_id() {
|
||||
if let Some(id) = pong
|
||||
&& id != self.peer.my_id()
|
||||
{
|
||||
self.send(
|
||||
id,
|
||||
&NetMsg::PlayerColor(
|
||||
|
@ -824,7 +825,6 @@ impl NetManager {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
NetMsg::Kick => self.back_out.store(true, Ordering::Relaxed),
|
||||
NetMsg::RemoteMsg(remote_message) => self.handle_remote_msg(state, src, remote_message),
|
||||
NetMsg::ForwardDesToProxy(des_to_proxy) => {
|
||||
|
|
|
@ -163,11 +163,10 @@ impl AudioManager {
|
|||
if let Ok(len) = encoder.encode_float(
|
||||
&resamp.process(&[&extra[..FRAME_SIZE]], None).unwrap()[0],
|
||||
&mut compressed,
|
||||
) {
|
||||
if len != 0 {
|
||||
) && len != 0
|
||||
{
|
||||
v.push(compressed[..len].to_vec())
|
||||
}
|
||||
}
|
||||
extra.drain(..FRAME_SIZE);
|
||||
}
|
||||
for v in v {
|
||||
|
@ -254,9 +253,10 @@ 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) {
|
||||
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,
|
||||
|
@ -265,8 +265,6 @@ impl AudioManager {
|
|||
//dsp,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
self.per_player.entry(src).and_modify(|player_info| {
|
||||
/*player_info
|
||||
.tracker
|
||||
|
@ -294,12 +292,12 @@ 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 {
|
||||
if let Ok(len) = self.decoder.decode_float(&data, &mut out, false)
|
||||
&& len != 0
|
||||
{
|
||||
dec.extend(&out[..len])
|
||||
}
|
||||
}
|
||||
}
|
||||
if !dec.is_empty() {
|
||||
/*let speed = player_info.tracker.calc_speed_toward_player();
|
||||
let pitch_change = (1.0 / (1.0 + speed / SPEED_OF_SOUND)).clamp(0.01, 3.00);
|
||||
|
|
|
@ -148,13 +148,13 @@ impl Connections {
|
|||
}
|
||||
fn flush(&self) {
|
||||
for i in &self.peers {
|
||||
if let Some(c) = i.connection() {
|
||||
if let Err(err) = c.flush_messages() {
|
||||
if let Some(c) = i.connection()
|
||||
&& let Err(err) = c.flush_messages()
|
||||
{
|
||||
warn!("Error while flushing a message: {err:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_listener(&self) {
|
||||
while let Some(event) = self.listen_socket.try_receive_event() {
|
||||
|
|
|
@ -894,14 +894,14 @@ impl WorldManager {
|
|||
if world_num != self.world_num {
|
||||
return;
|
||||
}
|
||||
if let Some(state) = self.authority_map.get(&chunk) {
|
||||
if state.0 != source {
|
||||
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 {
|
||||
let _ = self.tx.send((chunk, chunk_data.clone()));
|
||||
|
@ -1743,8 +1743,9 @@ impl WorldManager {
|
|||
self.is_storage_recent.insert(entry.0);
|
||||
}
|
||||
}
|
||||
if let Some((coord, rays)) = entry.unloaded {
|
||||
if self.nice_terraforming {
|
||||
if let Some((coord, rays)) = entry.unloaded
|
||||
&& self.nice_terraforming
|
||||
{
|
||||
exists = true;
|
||||
let lst = rays
|
||||
.iter()
|
||||
|
@ -1755,12 +1756,8 @@ impl WorldManager {
|
|||
Some(*n)
|
||||
} else {
|
||||
let n = self.explosion_data.len();
|
||||
self.explosion_data.push((
|
||||
m,
|
||||
*i,
|
||||
ExTarget::Ray(raydata[*i]),
|
||||
0,
|
||||
));
|
||||
self.explosion_data
|
||||
.push((m, *i, ExTarget::Ray(raydata[*i]), 0));
|
||||
data.insert(*i, n);
|
||||
Some(n)
|
||||
}
|
||||
|
@ -1771,7 +1768,6 @@ impl WorldManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
self.explosion_heap.pop();
|
||||
}
|
||||
|
@ -2382,8 +2378,9 @@ 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) {
|
||||
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;
|
||||
|
@ -2391,7 +2388,6 @@ fn create_image(chunk: ChunkData, materials: &FxHashMap<u16, u32>) -> RgbaImage
|
|||
*px = image::Rgba([r as u8, g as u8, b as u8, a as u8])
|
||||
}
|
||||
}
|
||||
}
|
||||
image
|
||||
}
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue