From ad48b85d6839f5f39e68b19cf58933f731b48708 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 7 Jan 2021 20:25:12 +0000 Subject: [PATCH] fixed Cargo.lock conflict Fixed `crossbeam-queue` being referenced twice in the lockfile --- Cargo.lock | 2 +- common/Cargo.toml | 5 ++--- common/net/src/sync/packet.rs | 2 +- common/src/comp/ability.rs | 4 ++-- common/src/comp/aura.rs | 4 ++-- common/src/comp/beam.rs | 4 ++-- common/src/comp/body.rs | 4 ++-- common/src/comp/buff.rs | 4 ++-- common/src/comp/character_state.rs | 4 ++-- common/src/comp/controller.rs | 6 ++--- common/src/comp/energy.rs | 4 ++-- common/src/comp/group.rs | 4 ++-- common/src/comp/health.rs | 4 ++-- common/src/comp/inputs.rs | 4 ++-- common/src/comp/inventory/item/mod.rs | 6 ++--- common/src/comp/inventory/mod.rs | 4 ++-- common/src/comp/location.rs | 6 ++--- common/src/comp/phys.rs | 12 +++++----- common/src/comp/player.rs | 4 ++-- common/src/comp/projectile.rs | 4 ++-- common/src/comp/shockwave.rs | 4 ++-- common/src/comp/stats.rs | 4 ++-- common/src/comp/visual.rs | 6 ++--- common/src/states/behavior.rs | 4 ++-- common/sys/src/aura.rs | 2 +- common/sys/src/beam.rs | 2 +- common/sys/src/buff.rs | 9 ++++++-- common/sys/src/character_behavior.rs | 3 ++- common/sys/src/controller.rs | 2 +- common/sys/src/projectile.rs | 4 +++- common/sys/src/shockwave.rs | 2 +- common/sys/src/stats.rs | 11 ++++++---- server/Cargo.toml | 2 +- server/src/cmd.rs | 17 +++++++------- server/src/events/entity_manipulation.rs | 23 ++++++++++--------- server/src/events/interaction.rs | 5 +++-- server/src/events/inventory_manip.rs | 28 ++++++++++++++---------- server/src/presence.rs | 6 ++--- server/src/state_ext.rs | 8 +++---- server/src/sys/msg/in_game.rs | 8 +++---- server/src/sys/subscription.rs | 2 +- voxygen/Cargo.toml | 2 +- voxygen/src/scene/figure/mod.rs | 2 +- 43 files changed, 134 insertions(+), 113 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fba4c4c2d..b81e5f29ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5074,7 +5074,7 @@ dependencies = [ [[package]] name = "specs-idvs" version = "0.1.1" -source = "git+https://gitlab.com/veloren/specs-idvs.git?rev=77048eefa5df750f44bbd1b9a13402a9f7a6cfc8#77048eefa5df750f44bbd1b9a13402a9f7a6cfc8" +source = "git+https://gitlab.com/veloren/specs-idvs.git?rev=9fab7b396acd6454585486e50ae4bfe2069858a9#9fab7b396acd6454585486e50ae4bfe2069858a9" dependencies = [ "specs", ] diff --git a/common/Cargo.toml b/common/Cargo.toml index 9260c640a9..b4a79f060f 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -42,9 +42,8 @@ indexmap = "1.3.0" slab = "0.4.2" # ECS -specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "d4435bdf496cf322c74886ca09dd8795984919b4" } -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "77048eefa5df750f44bbd1b9a13402a9f7a6cfc8" } - +specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control", "nightly"], rev = "d4435bdf496cf322c74886ca09dd8795984919b4" } +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "9fab7b396acd6454585486e50ae4bfe2069858a9" } # Serde ron = { version = "0.6", default-features = false } serde = { version = "1.0.110", features = ["derive", "rc"] } diff --git a/common/net/src/sync/packet.rs b/common/net/src/sync/packet.rs index 9085a23bd7..e86dfb30fa 100644 --- a/common/net/src/sync/packet.rs +++ b/common/net/src/sync/packet.rs @@ -28,7 +28,7 @@ pub fn handle_insert(comp: C, entity: Entity, world: &World) { } /// Useful for implementing CompPacket trait pub fn handle_modify(comp: C, entity: Entity, world: &World) { - if let Some(c) = world.write_storage::().get_mut(entity) { + if let Some(mut c) = world.write_storage::().get_mut(entity) { *c = comp } else { error!( diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index f3b57ce606..0afd6067c0 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -14,7 +14,7 @@ use crate::{ }; use arraygen::Arraygen; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::time::Duration; use vek::Vec3; @@ -977,5 +977,5 @@ impl From<(&CharacterAbility, AbilityKey)> for CharacterState { } impl Component for Loadout { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/aura.rs b/common/src/comp/aura.rs index a3ed6753dd..8d036c49c9 100644 --- a/common/src/comp/aura.rs +++ b/common/src/comp/aura.rs @@ -1,7 +1,7 @@ use crate::comp::buff::{BuffCategory, BuffData, BuffKind, BuffSource}; use serde::{Deserialize, Serialize}; use slotmap::{new_key_type, SlotMap}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::time::Duration; @@ -79,5 +79,5 @@ impl Auras { } impl Component for Auras { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/beam.rs b/common/src/comp/beam.rs index 433d9f1f55..7aafcedffd 100644 --- a/common/src/comp/beam.rs +++ b/common/src/comp/beam.rs @@ -1,6 +1,6 @@ use crate::{uid::Uid, Damage, GroupTarget}; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::time::Duration; @@ -27,7 +27,7 @@ pub struct BeamSegment { } impl Component for BeamSegment { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } impl std::ops::Deref for BeamSegment { diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 8300464336..151efdfe94 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -18,7 +18,7 @@ use crate::{ npc::NpcKind, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use vek::*; @@ -615,5 +615,5 @@ impl Body { } impl Component for Body { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/buff.rs b/common/src/comp/buff.rs index b5f778a438..8b31c3557f 100644 --- a/common/src/comp/buff.rs +++ b/common/src/comp/buff.rs @@ -1,7 +1,7 @@ use crate::uid::Uid; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::{cmp::Ordering, time::Duration}; @@ -312,5 +312,5 @@ impl Buffs { pub type BuffId = u64; impl Component for Buffs { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index ff5ebb55a8..f65e572d25 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -5,7 +5,7 @@ use crate::{ Damage, GroupTarget, Knockback, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, VecStorage}; +use specs::{Component, DerefFlaggedStorage, VecStorage}; use specs_idvs::IdvStorage; use std::collections::VecDeque; @@ -155,7 +155,7 @@ impl Default for CharacterState { } impl Component for CharacterState { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 4ac54fbaaa..9a2a797b0e 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -4,7 +4,7 @@ use crate::{ util::Dir, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::time::Duration; use vek::*; @@ -261,12 +261,12 @@ pub enum MountState { } impl Component for MountState { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Mounting(pub Uid); impl Component for Mounting { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index 87959ab281..bb7d9374cb 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] @@ -83,5 +83,5 @@ pub struct EnergyChange { } impl Component for Energy { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/group.rs b/common/src/comp/group.rs index 164d491e95..f137f3a829 100644 --- a/common/src/comp/group.rs +++ b/common/src/comp/group.rs @@ -2,7 +2,7 @@ use crate::{comp::Alignment, uid::Uid}; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; use slab::Slab; -use specs::{Component, FlaggedStorage, Join}; +use specs::{Component, DerefFlaggedStorage, Join}; use specs_idvs::IdvStorage; use tracing::{error, warn}; @@ -25,7 +25,7 @@ pub const ENEMY: Group = Group(u32::MAX); pub const NPC: Group = Group(u32::MAX - 1); impl Component for Group { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } pub struct Invite(pub specs::Entity); diff --git a/common/src/comp/health.rs b/common/src/comp/health.rs index f44cdf3972..43f4a1407d 100644 --- a/common/src/comp/health.rs +++ b/common/src/comp/health.rs @@ -1,6 +1,6 @@ use crate::{comp::Body, uid::Uid, DamageSource}; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; /// Specifies what and how much changed current health @@ -118,7 +118,7 @@ impl Health { } impl Component for Health { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Copy, Clone, Debug, Serialize, Deserialize)] diff --git a/common/src/comp/inputs.rs b/common/src/comp/inputs.rs index 27b2a02907..89e2b0b8b2 100644 --- a/common/src/comp/inputs.rs +++ b/common/src/comp/inputs.rs @@ -1,8 +1,8 @@ use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, NullStorage}; +use specs::{Component, DerefFlaggedStorage, NullStorage}; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct CanBuild; impl Component for CanBuild { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index ec232344df..60e87e784f 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -13,7 +13,7 @@ use crate::{ use crossbeam_utils::atomic::AtomicCell; use rand::prelude::*; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::{ num::{NonZeroU32, NonZeroU64}, @@ -444,12 +444,12 @@ impl ItemDesc for ItemDef { } impl Component for Item { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct ItemDrop(pub Item); impl Component for ItemDrop { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 53804f81ee..5425667dd0 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -5,7 +5,7 @@ use crate::{comp::inventory::item::ItemDef, recipe::Recipe}; use core::ops::Not; use item::Item; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, HashMapStorage}; +use specs::{Component, HashMapStorage}; use specs_idvs::IdvStorage; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -304,7 +304,7 @@ impl InventoryUpdate { } impl Component for InventoryUpdate { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } #[cfg(test)] mod test; diff --git a/common/src/comp/location.rs b/common/src/comp/location.rs index c4841f1c09..7ecef35163 100644 --- a/common/src/comp/location.rs +++ b/common/src/comp/location.rs @@ -1,6 +1,6 @@ use crate::resources::Time; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::Component; use specs_idvs::IdvStorage; use vek::*; @@ -28,7 +28,7 @@ impl Waypoint { } impl Component for Waypoint { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } #[derive(Copy, Clone, Debug, PartialEq)] @@ -39,7 +39,7 @@ impl WaypointArea { } impl Component for WaypointArea { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } impl Default for WaypointArea { diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index 44fe4614d1..ae9e3bca3c 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -1,6 +1,6 @@ use crate::{uid::Uid, util::Dir}; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, NullStorage}; +use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs_idvs::IdvStorage; use vek::*; @@ -47,7 +47,7 @@ impl Component for PreviousVelDtCache { pub struct Scale(pub f32); impl Component for Scale { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } // Mass @@ -55,7 +55,7 @@ impl Component for Scale { pub struct Mass(pub f32); impl Component for Mass { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } // Mass @@ -82,21 +82,21 @@ impl Collider { } impl Component for Collider { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Gravity(pub f32); impl Component for Gravity { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Sticky; impl Component for Sticky { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } // PhysicsState diff --git a/common/src/comp/player.rs b/common/src/comp/player.rs index 55f8439846..17a1a07b4b 100644 --- a/common/src/comp/player.rs +++ b/common/src/comp/player.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, NullStorage}; +use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs_idvs::IdvStorage; use uuid::Uuid; @@ -30,7 +30,7 @@ impl Player { } impl Component for Player { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Clone, Debug, Default, Serialize, Deserialize)] diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 5df64d2d0d..3927ea0638 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -5,7 +5,7 @@ use crate::{ Damage, DamageSource, Explosion, GroupTarget, Knockback, RadiusEffect, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::Component; use specs_idvs::IdvStorage; use std::time::Duration; @@ -38,7 +38,7 @@ pub struct Projectile { } impl Component for Projectile { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/comp/shockwave.rs b/common/src/comp/shockwave.rs index 93707cc826..041d53302a 100644 --- a/common/src/comp/shockwave.rs +++ b/common/src/comp/shockwave.rs @@ -1,6 +1,6 @@ use crate::{uid::Uid, Damage, GroupTarget, Knockback}; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::time::Duration; @@ -27,7 +27,7 @@ pub struct Shockwave { } impl Component for Shockwave { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } impl std::ops::Deref for Shockwave { diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index a30ea0db20..31887401ca 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -3,7 +3,7 @@ use crate::{ comp::{body::humanoid::Species, skills::SkillSet, Body}, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use std::{error::Error, fmt}; @@ -141,5 +141,5 @@ impl Stats { } impl Component for Stats { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/common/src/comp/visual.rs b/common/src/comp/visual.rs index 013f27aa2c..68877bde5f 100644 --- a/common/src/comp/visual.rs +++ b/common/src/comp/visual.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use vek::*; @@ -23,7 +23,7 @@ impl Default for LightEmitter { } impl Component for LightEmitter { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -44,5 +44,5 @@ impl Default for LightAnimation { } impl Component for LightAnimation { - type Storage = FlaggedStorage>; + type Storage = IdvStorage; } diff --git a/common/src/states/behavior.rs b/common/src/states/behavior.rs index aa4b4d7f7c..0af73ec436 100644 --- a/common/src/states/behavior.rs +++ b/common/src/states/behavior.rs @@ -9,7 +9,7 @@ use crate::{ use specs::{ hibitset, storage::{PairedStorage, SequentialRestriction}, - Entity, FlaggedStorage, LazyUpdate, + DerefFlaggedStorage, Entity, LazyUpdate, }; use specs_idvs::IdvStorage; @@ -63,7 +63,7 @@ type RestrictedMut<'a, C> = PairedStorage< 'a, 'a, C, - &'a mut FlaggedStorage>, + &'a mut DerefFlaggedStorage>, &'a hibitset::BitSet, SequentialRestriction, >; diff --git a/common/sys/src/aura.rs b/common/sys/src/aura.rs index f77c1aa062..a20361d3f3 100644 --- a/common/sys/src/aura.rs +++ b/common/sys/src/aura.rs @@ -30,7 +30,7 @@ impl<'a> System<'a> for Sys { auras.set_event_emission(false); // Iterate through all entities with an aura - for (entity, pos, auras_comp) in (&entities, &positions, &mut auras).join() { + for (entity, pos, mut auras_comp) in (&entities, &positions, &mut auras).join() { let mut expired_auras = Vec::::new(); // Iterate through the auras attached to this entity for (key, aura) in auras_comp.auras.iter_mut() { diff --git a/common/sys/src/beam.rs b/common/sys/src/beam.rs index 4728b96c70..49844c75b7 100644 --- a/common/sys/src/beam.rs +++ b/common/sys/src/beam.rs @@ -233,7 +233,7 @@ impl<'a> System<'a> for Sys { // Set start time on new beams // This change doesn't need to be recorded as it is not sent to the client beam_segments.set_event_emission(false); - (&mut beam_segments).join().for_each(|beam_segment| { + (&mut beam_segments).join().for_each(|mut beam_segment| { if beam_segment.creation.is_none() { beam_segment.creation = Some(time); } diff --git a/common/sys/src/buff.rs b/common/sys/src/buff.rs index 871d6687b9..3570493e98 100644 --- a/common/sys/src/buff.rs +++ b/common/sys/src/buff.rs @@ -30,7 +30,7 @@ impl<'a> System<'a> for Sys { // Set to false to avoid spamming server buffs.set_event_emission(false); healths.set_event_emission(false); - for (entity, buff_comp, health) in (&entities, &mut buffs, &mut healths).join() { + for (entity, mut buff_comp, mut health) in (&entities, &mut buffs, &mut healths).join() { let mut expired_buffs = Vec::::new(); for (id, buff) in buff_comp.buffs.iter_mut() { // Tick the buff and subtract delta from it @@ -66,6 +66,7 @@ impl<'a> System<'a> for Sys { health.reset_max(); // Iterator over the lists of buffs by kind + let buff_comp = &mut *buff_comp; for buff_ids in buff_comp.kinds.values() { // Get the strongest of this buff kind if let Some(buff) = buff_comp.buffs.get_mut(&buff_ids[0]) { @@ -113,9 +114,13 @@ impl<'a> System<'a> for Sys { }, BuffEffect::MaxHealthModifier { value, kind } => match kind { ModifierKind::Additive => { - health.set_maximum((health.maximum() as f32 + *value) as u32); + let health = &mut *health; + let buffed_health_max = + (health.maximum() as f32 + *value) as u32; + health.set_maximum(buffed_health_max); }, ModifierKind::Fractional => { + let health = &mut *health; health.set_maximum((health.maximum() as f32 * *value) as u32); }, }, diff --git a/common/sys/src/character_behavior.rs b/common/sys/src/character_behavior.rs index 395da28806..337b49bd57 100644 --- a/common/sys/src/character_behavior.rs +++ b/common/sys/src/character_behavior.rs @@ -29,7 +29,8 @@ fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { *tuple.6.get_mut_unchecked() = state_update.energy }; if state_update.swap_loadout { - let loadout = tuple.7.get_mut_unchecked(); + let mut loadout = tuple.7.get_mut_unchecked(); + let loadout = &mut *loadout; std::mem::swap(&mut loadout.active_item, &mut loadout.second_item); } } diff --git a/common/sys/src/controller.rs b/common/sys/src/controller.rs index 283bd7530e..82afd64f4f 100644 --- a/common/sys/src/controller.rs +++ b/common/sys/src/controller.rs @@ -52,7 +52,7 @@ impl<'a> System<'a> for Sys { span!(_guard, "run", "controller::Sys::run"); let mut server_emitter = server_bus.emitter(); - for (entity, _uid, controller, character_state) in + for (entity, _uid, controller, mut character_state) in (&entities, &uids, &mut controllers, &mut character_states).join() { let mut inputs = &mut controller.inputs; diff --git a/common/sys/src/projectile.rs b/common/sys/src/projectile.rs index 2072858e10..4fe3d4f63c 100644 --- a/common/sys/src/projectile.rs +++ b/common/sys/src/projectile.rs @@ -58,7 +58,7 @@ impl<'a> System<'a> for Sys { let mut server_emitter = server_bus.emitter(); // Attacks - for (entity, pos, physics, ori, projectile) in ( + for (entity, pos, physics, ori, mut projectile) in ( &entities, &positions, &physics_states, @@ -99,6 +99,7 @@ impl<'a> System<'a> for Sys { continue; } + let projectile = &mut *projectile; for effect in projectile.hit_entity.drain(..) { match effect { projectile::Effect::Damage(target, damage) => { @@ -197,6 +198,7 @@ impl<'a> System<'a> for Sys { // Hit something solid if physics.on_wall.is_some() || physics.on_ground || physics.on_ceiling { + let projectile = &mut *projectile; for effect in projectile.hit_solid.drain(..) { match effect { projectile::Effect::Explode(e) => { diff --git a/common/sys/src/shockwave.rs b/common/sys/src/shockwave.rs index 2f2df564ff..04ace531ba 100644 --- a/common/sys/src/shockwave.rs +++ b/common/sys/src/shockwave.rs @@ -217,7 +217,7 @@ impl<'a> System<'a> for Sys { // Set start time on new shockwaves // This change doesn't need to be recorded as it is not sent to the client shockwaves.set_event_emission(false); - (&mut shockwaves).join().for_each(|shockwave| { + (&mut shockwaves).join().for_each(|mut shockwave| { if shockwave.creation.is_none() { shockwave.creation = Some(time); } diff --git a/common/sys/src/stats.rs b/common/sys/src/stats.rs index ad7321b4de..0ce26b9b80 100644 --- a/common/sys/src/stats.rs +++ b/common/sys/src/stats.rs @@ -43,7 +43,7 @@ impl<'a> System<'a> for Sys { // Increment last change timer healths.set_event_emission(false); // avoid unnecessary syncing - for health in (&mut healths).join() { + for mut health in (&mut healths).join() { health.last_change.0 += f64::from(dt.0); } healths.set_event_emission(true); @@ -66,7 +66,7 @@ impl<'a> System<'a> for Sys { }; if set_dead { - let health = health.get_mut_unchecked(); + let mut health = health.get_mut_unchecked(); server_event_emitter.emit(ServerEvent::Destroy { entity, cause: health.last_change.1.cause, @@ -76,7 +76,8 @@ impl<'a> System<'a> for Sys { } if level_up { - let stat = stats.get_mut_unchecked(); + let mut stat = stats.get_mut_unchecked(); + let stat = &mut *stat; while stat.exp.current() >= stat.exp.maximum() { stat.exp.change_by(-(stat.exp.maximum() as i64)); stat.level.change_by(1); @@ -84,7 +85,8 @@ impl<'a> System<'a> for Sys { server_event_emitter.emit(ServerEvent::LevelUp(entity, stat.level.level())); } - let health = health.get_mut_unchecked(); + let mut health = health.get_mut_unchecked(); + let health = &mut *health; health.update_max_hp(Some(stat.body_type), stat.level.level()); health.set_to(health.maximum(), HealthSource::LevelUp); } @@ -111,6 +113,7 @@ impl<'a> System<'a> for Sys { if res { let mut energy = energy.get_mut_unchecked(); + let energy = &mut *energy; // Have to account for Calc I differential equations due to acceleration energy.change_by(EnergyChange { amount: (energy.regen_rate * dt.0 diff --git a/server/Cargo.toml b/server/Cargo.toml index 7374ffb84e..f62bdd7863 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -19,7 +19,7 @@ world = { package = "veloren-world", path = "../world" } network = { package = "veloren_network", path = "../network", features = ["metrics", "compression"], default-features = false } specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "d4435bdf496cf322c74886ca09dd8795984919b4" } -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "77048eefa5df750f44bbd1b9a13402a9f7a6cfc8" } +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "9fab7b396acd6454585486e50ae4bfe2069858a9" } tracing = "0.1" vek = { version = "0.12.0", features = ["serde"] } diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 8c42ee1b49..fc91fc18b3 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -456,7 +456,7 @@ fn handle_kill( .ecs_mut() .write_storage::() .get_mut(target) - .map(|h| h.set_to(0, reason)); + .map(|mut h| h.set_to(0, reason)); } fn handle_time( @@ -582,7 +582,7 @@ fn handle_health( action: &ChatCommand, ) { if let Ok(hp) = scan_fmt!(&args, &action.arg_fmt(), u32) { - if let Some(health) = server + if let Some(mut health) = server .state .ecs() .write_storage::() @@ -632,7 +632,7 @@ fn handle_alias( .ecs_mut() .write_storage::() .get_mut(target) - .map(|player| std::mem::replace(&mut player.alias, alias)); + .map(|mut player| std::mem::replace(&mut player.alias, alias)); // Update name on client player lists let ecs = server.state.ecs(); @@ -1074,7 +1074,7 @@ fn handle_kill_npcs( let mut healths = ecs.write_storage::(); let players = ecs.read_storage::(); let mut count = 0; - for (health, ()) in (&mut healths, !&players).join() { + for (mut health, ()) in (&mut healths, !&players).join() { count += 1; health.set_to(0, comp::HealthSource::Command); } @@ -1240,7 +1240,7 @@ fn handle_lantern( action: &ChatCommand, ) { if let (Some(s), r, g, b) = scan_fmt_some!(&args, &action.arg_fmt(), f32, f32, f32, f32) { - if let Some(light) = server + if let Some(mut light) = server .state .ecs() .write_storage::() @@ -1994,7 +1994,7 @@ fn handle_give_exp( match target { Ok(player) => { - if let Some(stats) = ecs.write_storage::().get_mut(player) { + if let Some(mut stats) = ecs.write_storage::().get_mut(player) { stats.exp.change_by(exp); } else { error_msg = Some(ServerGeneral::server_msg( @@ -2042,7 +2042,7 @@ fn handle_set_level( let body_type: Option; - if let Some(stats) = server + if let Some(mut stats) = server .state .ecs_mut() .write_storage::() @@ -2058,12 +2058,13 @@ fn handle_set_level( body_type = None; } - if let Some(health) = server + if let Some(mut health) = server .state .ecs_mut() .write_storage::() .get_mut(player) { + let health = &mut *health; health.update_max_hp(body_type, lvl); health.set_to(health.maximum(), comp::HealthSource::LevelUp); } diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index 1650d6c6fd..f0a382f31c 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -34,7 +34,7 @@ use vek::Vec3; pub fn handle_damage(server: &Server, entity: EcsEntity, change: HealthChange) { let ecs = &server.state.ecs(); - if let Some(health) = ecs.write_storage::().get_mut(entity) { + if let Some(mut health) = ecs.write_storage::().get_mut(entity) { health.change_by(change); } } @@ -219,13 +219,13 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc let exp = exp_reward / (num_not_pets_in_range as f32 + ATTACKER_EXP_WEIGHT); exp_reward = exp * ATTACKER_EXP_WEIGHT; members_in_range.into_iter().for_each(|e| { - if let Some(stats) = stats.get_mut(e) { + if let Some(mut stats) = stats.get_mut(e) { stats.exp.change_by(exp.ceil() as i64); } }); } - if let Some(attacker_stats) = stats.get_mut(attacker) { + if let Some(mut attacker_stats) = stats.get_mut(attacker) { // TODO: Discuss whether we should give EXP by Player // Killing or not. attacker_stats.exp.change_by(exp_reward.ceil() as i64); @@ -258,7 +258,10 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc .ecs() .write_storage::() .get_mut(entity) - .map(|energy| energy.set_to(energy.maximum(), comp::EnergySource::Revive)); + .map(|mut energy| { + let energy = &mut *energy; + energy.set_to(energy.maximum(), comp::EnergySource::Revive) + }); let _ = state .ecs() .write_storage::() @@ -429,7 +432,7 @@ pub fn handle_delete(server: &mut Server, entity: EcsEntity) { pub fn handle_land_on_ground(server: &Server, entity: EcsEntity, vel: Vec3) { let state = &server.state; if vel.z <= -30.0 { - if let Some(health) = state.ecs().write_storage::().get_mut(entity) { + if let Some(mut health) = state.ecs().write_storage::().get_mut(entity) { let falldmg = (vel.z.powi(2) / 20.0 - 40.0) * 10.0; let damage = Damage { source: DamageSource::Falling, @@ -461,7 +464,7 @@ pub fn handle_respawn(server: &Server, entity: EcsEntity) { .ecs() .write_storage::() .get_mut(entity) - .map(|health| health.revive()); + .map(|mut health| health.revive()); state .ecs() .write_storage::() @@ -641,7 +644,7 @@ pub fn handle_explosion( server.state().apply_effect(entity_b, effect.clone(), owner); // Apply energy change if let Some(owner) = owner_entity { - if let Some(energy) = + if let Some(mut energy) = ecs.write_storage::().get_mut(owner) { energy.change_by(EnergyChange { @@ -677,7 +680,7 @@ pub fn handle_level_up(server: &mut Server, entity: EcsEntity, new_level: u32) { pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::AuraChange) { let ecs = &server.state.ecs(); let mut auras_all = ecs.write_storage::(); - if let Some(auras) = auras_all.get_mut(entity) { + if let Some(mut auras) = auras_all.get_mut(entity) { use aura::AuraChange; match aura_change { AuraChange::Add(new_aura) => { @@ -695,7 +698,7 @@ pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::Au pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::BuffChange) { let ecs = &server.state.ecs(); let mut buffs_all = ecs.write_storage::(); - if let Some(buffs) = buffs_all.get_mut(entity) { + if let Some(mut buffs) = buffs_all.get_mut(entity) { use buff::BuffChange; match buff_change { BuffChange::Add(new_buff) => { @@ -756,7 +759,7 @@ pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::Bu pub fn handle_energy_change(server: &Server, entity: EcsEntity, change: EnergyChange) { let ecs = &server.state.ecs(); - if let Some(energy) = ecs.write_storage::().get_mut(entity) { + if let Some(mut energy) = ecs.write_storage::().get_mut(entity) { energy.change_by(change); } } diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index 1f52413494..d52ae57eee 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -100,7 +100,7 @@ pub fn handle_unmount(server: &mut Server, mounter: EcsEntity) { .ecs() .write_storage::() .get_mut(mountee_entity) - .map(|ms| *ms = comp::MountState::Unmounted); + .map(|mut ms| *ms = comp::MountState::Unmounted); } state.delete_component::(mounter); } @@ -174,7 +174,7 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { // Put possess item into loadout let mut loadouts = ecs.write_storage::(); - let loadout = loadouts + let mut loadout = loadouts .entry(possesse) .expect("Could not read loadouts component while possessing") .or_insert(comp::Loadout::default()); @@ -182,6 +182,7 @@ pub fn handle_possess(server: &Server, possessor_uid: Uid, possesse_uid: Uid) { let item = comp::Item::new_from_asset_expect("common.items.debug.possess"); if let item::ItemKind::Tool(_) = item.kind() { let debug_item = comp::ItemConfig::from((item, &*ability_map)); + let loadout = &mut *loadout; std::mem::swap(&mut loadout.active_item, &mut loadout.second_item); loadout.active_item = Some(debug_item); } diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index 1cdc97c897..6efd49f8d5 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -23,7 +23,7 @@ pub fn swap_lantern( entity: EcsEntity, lantern: &item::Lantern, ) { - if let Some(light) = storage.get_mut(entity) { + if let Some(mut light) = storage.get_mut(entity) { light.strength = lantern.strength(); light.col = lantern.color(); } @@ -224,12 +224,14 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv _ => (false, None), }); if is_equippable { - if let Some(loadout) = state.ecs().write_storage().get_mut(entity) { + if let Some(mut loadout) = + state.ecs().write_storage::().get_mut(entity) + { if let Some(lantern) = lantern_opt { swap_lantern(&mut state.ecs().write_storage(), entity, &lantern); } let ability_map = state.ability_map(); - slot::equip(slot, inventory, loadout, &ability_map); + slot::equip(slot, inventory, &mut loadout, &ability_map); Some(comp::InventoryUpdateEvent::Used) } else { None @@ -359,12 +361,14 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv } }, Slot::Equip(slot) => { - if let Some(loadout) = state.ecs().write_storage().get_mut(entity) { + if let Some(mut loadout) = + state.ecs().write_storage::().get_mut(entity) + { if slot == slot::EquipSlot::Lantern { snuff_lantern(&mut state.ecs().write_storage(), entity); } let ability_map = state.ability_map(); - slot::unequip(slot, inventory, loadout, &ability_map); + slot::unequip(slot, inventory, &mut loadout, &ability_map); Some(comp::InventoryUpdateEvent::Used) } else { error!(?entity, "Entity doesn't have a loadout, can't unequip..."); @@ -386,13 +390,15 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv comp::InventoryManip::Swap(a, b) => { let ecs = state.ecs(); - let mut inventories = ecs.write_storage(); - let mut loadouts = ecs.write_storage(); + let mut inventories = ecs.write_storage::(); + let mut loadouts = ecs.write_storage::(); let inventory = inventories.get_mut(entity); - let loadout = loadouts.get_mut(entity); + let mut loadout = loadouts.get_mut(entity); let ability_map = state.ability_map(); - slot::swap(a, b, inventory, loadout, &ability_map); + slot::swap(a, b, inventory, loadout.as_deref_mut(), &ability_map); + // slot::swap(a, b, inventory, loadout.as_mut().map(|x| &mut **x), + // &ability_map); // :/ drop(loadouts); @@ -415,9 +421,9 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv .and_then(|inv| inv.remove(slot)), Slot::Equip(slot) => state .ecs() - .write_storage() + .write_storage::() .get_mut(entity) - .and_then(|ldt| slot::loadout_remove(slot, ldt, &ability_map)), + .and_then(|mut ldt| slot::loadout_remove(slot, &mut ldt, &ability_map)), }; drop(ability_map); diff --git a/server/src/presence.rs b/server/src/presence.rs index c15f9157db..08ea3c7598 100644 --- a/server/src/presence.rs +++ b/server/src/presence.rs @@ -1,7 +1,7 @@ use common_net::msg::PresenceKind; use hashbrown::HashSet; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage}; +use specs::{Component, DerefFlaggedStorage}; use specs_idvs::IdvStorage; use vek::*; @@ -21,7 +21,7 @@ impl Presence { } impl Component for Presence { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } // Distance from fuzzy_chunk before snapping to current chunk @@ -36,5 +36,5 @@ pub struct RegionSubscription { } impl Component for RegionSubscription { - type Storage = FlaggedStorage>; + type Storage = DerefFlaggedStorage>; } diff --git a/server/src/state_ext.rs b/server/src/state_ext.rs index 02c66ca76a..318b94f7d6 100644 --- a/server/src/state_ext.rs +++ b/server/src/state_ext.rs @@ -81,13 +81,13 @@ impl StateExt for State { self.ecs() .write_storage::() .get_mut(entity) - .map(|health| health.change_by(change)); + .map(|mut health| health.change_by(change)); }, Effect::Xp(xp) => { self.ecs() .write_storage::() .get_mut(entity) - .map(|stats| stats.exp.change_by(xp)); + .map(|mut stats| stats.exp.change_by(xp)); }, Effect::Damage(damage) => { let loadouts = self.ecs().read_storage::(); @@ -95,13 +95,13 @@ impl StateExt for State { self.ecs() .write_storage::() .get_mut(entity) - .map(|health| health.change_by(change)); + .map(|mut health| health.change_by(change)); }, Effect::Buff(buff) => { self.ecs() .write_storage::() .get_mut(entity) - .map(|buffs| { + .map(|mut buffs| { buffs.insert(comp::Buff::new( buff.kind, buff.data, diff --git a/server/src/sys/msg/in_game.rs b/server/src/sys/msg/in_game.rs index d07881725c..1e20a0aaa5 100644 --- a/server/src/sys/msg/in_game.rs +++ b/server/src/sys/msg/in_game.rs @@ -146,17 +146,17 @@ impl Sys { ClientGeneral::UnlockSkill(skill) => { stats .get_mut(entity) - .map(|s| s.skill_set.unlock_skill(skill)); + .map(|mut s| s.skill_set.unlock_skill(skill)); }, ClientGeneral::RefundSkill(skill) => { stats .get_mut(entity) - .map(|s| s.skill_set.refund_skill(skill)); + .map(|mut s| s.skill_set.refund_skill(skill)); }, ClientGeneral::UnlockSkillGroup(skill_group_type) => { stats .get_mut(entity) - .map(|s| s.skill_set.unlock_skill_group(skill_group_type)); + .map(|mut s| s.skill_set.unlock_skill_group(skill_group_type)); }, _ => unreachable!("not a client_in_game msg"), } @@ -223,7 +223,7 @@ impl<'a> System<'a> for Sys { &mut server_emitter, entity, client, - &mut maybe_presence, + &mut maybe_presence.as_deref_mut(), &terrain, &network_metrics, &can_build, diff --git a/server/src/sys/subscription.rs b/server/src/sys/subscription.rs index d6320b2a3c..66ac09ff48 100644 --- a/server/src/sys/subscription.rs +++ b/server/src/sys/subscription.rs @@ -74,7 +74,7 @@ impl<'a> System<'a> for Sys { // 7. Determine list of regions that are in range and iterate through it // - check if in hashset (hash calc) if not add it let mut regions_to_remove = Vec::new(); - for (subscription, pos, presence, client_entity, client) in ( + for (mut subscription, pos, presence, client_entity, client) in ( &mut subscriptions, &positions, &presences, diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index e791f672a7..539089107f 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -46,7 +46,7 @@ glyph_brush = "0.7.0" # ECS specs = {git = "https://github.com/amethyst/specs.git", rev = "d4435bdf496cf322c74886ca09dd8795984919b4"} -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "77048eefa5df750f44bbd1b9a13402a9f7a6cfc8" } +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "9fab7b396acd6454585486e50ae4bfe2069858a9" } # Mathematics vek = {version = "0.12.0", features = ["serde"]} diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index c51fe1c05f..d25306bdf6 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -394,7 +394,7 @@ impl FigureMgr { } let dt = ecs.fetch::().0; let updater = ecs.read_resource::(); - for (entity, light_emitter_opt, body, light_anim) in ( + for (entity, light_emitter_opt, body, mut light_anim) in ( &ecs.entities(), ecs.read_storage::().maybe(), ecs.read_storage::().maybe(),