diff --git a/Cargo.lock b/Cargo.lock index 5fe17155d8..ad357b9cde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,17 +995,6 @@ dependencies = [ "byteorder 1.3.4", ] -[[package]] -name = "derivative" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6d883546668a3e2011b6a716a7330b82eabb0151b138217f632c8243e17135" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.15.44", -] - [[package]] name = "deunicode" version = "1.1.1" @@ -1856,6 +1845,16 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" +dependencies = [ + "ahash 0.3.8", + "autocfg 1.0.0", +] + [[package]] name = "hermit-abi" version = "0.1.13" @@ -3698,16 +3697,17 @@ checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" [[package]] name = "shred" -version = "0.9.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92472b9bafafbcba21935c6444d924e5332742f6778c49504a49a97eaeff6ccc" +checksum = "c5f08237e667ac94ad20f8878b5943d91a93ccb231428446c57c21c57779016d" dependencies = [ - "arrayvec 0.4.12", - "hashbrown", + "arrayvec 0.5.1", + "hashbrown 0.7.2", "mopa", "rayon", "shred-derive", - "smallvec 0.6.13", + "smallvec 1.4.0", + "tynm", ] [[package]] @@ -3793,13 +3793,11 @@ dependencies = [ [[package]] name = "specs" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4943fde8c5d3d14c3d19d2a4c7abbd7b626c270a19e6cd35252294a48feb698c" +version = "0.16.1" +source = "git+https://github.com/amethyst/specs.git?rev=7a2e348ab2223818bad487695c66c43db88050a5#7a2e348ab2223818bad487695c66c43db88050a5" dependencies = [ - "crossbeam-queue 0.1.2", - "derivative", - "hashbrown", + "crossbeam-queue 0.2.3", + "hashbrown 0.7.2", "hibitset", "log", "rayon", @@ -3812,7 +3810,7 @@ dependencies = [ [[package]] name = "specs-idvs" version = "0.1.0" -source = "git+https://gitlab.com/veloren/specs-idvs.git#111548cf44e9bb4c43feb12aa3fc253953ac6e4a" +source = "git+https://gitlab.com/veloren/specs-idvs.git?branch=specs-16#349153d18c19d238523e4eddd5bec179d38c59c5" dependencies = [ "specs", ] @@ -4300,6 +4298,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44834418e2c5b16f47bedf35c28e148db099187dd5feee6367fb2525863af4f1" +[[package]] +name = "tynm" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "367fb781963961b4a90a3362c54b1871caaecb081f011005778242230f39d34e" +dependencies = [ + "nom 5.1.1", +] + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -4457,7 +4464,7 @@ dependencies = [ "futures-executor", "futures-timer 3.0.2", "futures-util", - "hashbrown", + "hashbrown 0.6.3", "image", "num_cpus", "specs", @@ -4478,7 +4485,7 @@ dependencies = [ "crossbeam", "dot_vox", "find_folder", - "hashbrown", + "hashbrown 0.6.3", "image", "indexmap", "lazy_static", @@ -4512,7 +4519,7 @@ dependencies = [ "futures-executor", "futures-timer 3.0.2", "futures-util", - "hashbrown", + "hashbrown 0.6.3", "lazy_static", "libsqlite3-sys", "portpicker", @@ -4573,7 +4580,7 @@ dependencies = [ "glsl-include", "glutin", "guillotiere", - "hashbrown", + "hashbrown 0.6.3", "image", "msgbox", "num 0.2.1", @@ -4621,7 +4628,7 @@ dependencies = [ "bincode", "bitvec", "fxhash", - "hashbrown", + "hashbrown 0.6.3", "image", "itertools 0.8.2", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 277aa6d984..589b53ea65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,3 +72,7 @@ debug = false [profile.releasedebuginfo] inherits = 'release' debug = 1 + +# living on the edge +[patch.crates-io] +specs = { git = "https://github.com/amethyst/specs.git", rev = "7a2e348ab2223818bad487695c66c43db88050a5" } diff --git a/client/Cargo.toml b/client/Cargo.toml index 7a3c36edfa..82e21c72d3 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -16,7 +16,7 @@ futures-timer = "3.0" image = { version = "0.22.3", default-features = false, features = ["png"] } num_cpus = "1.10.1" tracing = { version = "0.1", default-features = false } -specs = "0.15.1" +specs = "0.16.1" vek = { version = "0.11.0", features = ["serde"] } hashbrown = { version = "0.6", features = ["rayon", "serde", "nightly"] } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "223a4097f7ebc8d451936dccb5e6517194bbf086" } diff --git a/common/Cargo.toml b/common/Cargo.toml index 7773463a68..e59ffa78c0 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -8,9 +8,9 @@ edition = "2018" no-assets = [] [dependencies] -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "specs-16" } -specs = { version = "0.15.1", features = ["serde", "nightly", "storage-event-control"] } +specs = { version = "0.16.1", features = ["serde", "storage-event-control"] } vek = { version = "0.11.0", features = ["serde"] } dot_vox = "4.0" image = { version = "0.22.3", default-features = false, features = ["png"] } diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index b1068ed928..2eadd81053 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -7,7 +7,7 @@ use crate::{ sys::character_behavior::JoinData, }; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::time::Duration; #[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] @@ -243,5 +243,5 @@ impl From<&CharacterAbility> for CharacterState { } impl Component for Loadout { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/agent.rs b/common/src/comp/agent.rs index 59edb06269..c9679e6b02 100644 --- a/common/src/comp/agent.rs +++ b/common/src/comp/agent.rs @@ -1,6 +1,6 @@ use crate::path::Chaser; use specs::{Component, Entity as EcsEntity}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; #[derive(Copy, Clone, Debug, PartialEq)] @@ -43,7 +43,7 @@ impl Alignment { } impl Component for Alignment { - type Storage = IDVStorage; + type Storage = IdvStorage; } #[derive(Clone, Debug, Default)] @@ -72,7 +72,7 @@ impl Agent { } impl Component for Agent { - type Storage = IDVStorage; + type Storage = IdvStorage; } #[derive(Clone, Debug)] diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index c8af418f7a..f25d0a6b65 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -17,7 +17,7 @@ use crate::{ npc::NpcKind, }; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::{fs::File, io::BufReader}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -132,5 +132,5 @@ impl Body { } impl Component for Body { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 5cde7824ca..3b6c5ba2e0 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,11 +1,12 @@ use crate::{ - comp::{Energy, Loadout, Ori, Pos, Vel}, + comp::{Energy, Ori, Pos, Vel}, event::{LocalEvent, ServerEvent}, states::*, sys::character_behavior::JoinData, }; use serde::{Deserialize, Serialize}; -use specs::{Component, FlaggedStorage, HashMapStorage, VecStorage}; +use specs::{Component, FlaggedStorage, VecStorage}; +use specs_idvs::IdvStorage; use std::collections::VecDeque; /// Data returned from character behavior fn's to Character Behavior System. @@ -15,7 +16,7 @@ pub struct StateUpdate { pub vel: Vel, pub ori: Ori, pub energy: Energy, - pub loadout: Loadout, + pub swap_loadout: bool, pub local_events: VecDeque, pub server_events: VecDeque, } @@ -27,7 +28,7 @@ impl From<&JoinData<'_>> for StateUpdate { vel: *data.vel, ori: *data.ori, energy: *data.energy, - loadout: data.loadout.clone(), + swap_loadout: false, character: data.character.clone(), local_events: VecDeque::new(), server_events: VecDeque::new(), @@ -128,7 +129,7 @@ impl Default for CharacterState { } impl Component for CharacterState { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] diff --git a/common/src/comp/chat.rs b/common/src/comp/chat.rs index 17cd3987f4..3bbd3014bc 100644 --- a/common/src/comp/chat.rs +++ b/common/src/comp/chat.rs @@ -1,6 +1,6 @@ use crate::{msg::ServerMsg, sync::Uid}; use specs::Component; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::time::{Duration, Instant}; /// A player's current chat mode. These are chat types that can only be sent by @@ -22,7 +22,7 @@ pub enum ChatMode { } impl Component for ChatMode { - type Storage = IDVStorage; + type Storage = IdvStorage; } impl ChatMode { @@ -180,7 +180,7 @@ impl ChatMsg { #[derive(Clone, Debug)] pub struct Group(pub String); impl Component for Group { - type Storage = IDVStorage; + type Storage = IdvStorage; } impl From for Group { fn from(s: String) -> Self { Group(s) } @@ -193,7 +193,7 @@ impl From for Group { #[derive(Clone, Debug)] pub struct Faction(pub String); impl Component for Faction { - type Storage = IDVStorage; + type Storage = IdvStorage; } impl From for Faction { fn from(s: String) -> Self { Faction(s) } diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index b77cd9506f..606fcd9c14 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -1,6 +1,6 @@ use crate::{comp::inventory::slot::Slot, sync::Uid, util::Dir}; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::time::Duration; use vek::*; @@ -227,7 +227,7 @@ impl Controller { } impl Component for Controller { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -237,12 +237,12 @@ pub enum MountState { } impl Component for MountState { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Mounting(pub Uid); impl Component for Mounting { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/energy.rs b/common/src/comp/energy.rs index bbc481daca..66e05b4faa 100644 --- a/common/src/comp/energy.rs +++ b/common/src/comp/energy.rs @@ -1,7 +1,7 @@ use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub struct Energy { current: u32, maximum: u32, @@ -9,7 +9,7 @@ pub struct Energy { pub last_change: Option<(i32, f64, EnergySource)>, } -#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pub enum EnergySource { Ability, Climb, @@ -73,5 +73,5 @@ impl Energy { } impl Component for Energy { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 72218b795b..e47ec5c533 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -11,7 +11,7 @@ use crate::{ terrain::{Block, BlockKind}, }; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::{fs::File, io::BufReader}; use vek::Rgb; @@ -197,12 +197,12 @@ impl Item { } impl Component for Item { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct ItemDrop(pub Item); impl Component for ItemDrop { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/inventory/mod.rs b/common/src/comp/inventory/mod.rs index 0bbfa14d1e..2a0586eb9b 100644 --- a/common/src/comp/inventory/mod.rs +++ b/common/src/comp/inventory/mod.rs @@ -4,7 +4,7 @@ pub mod slot; use crate::assets; use item::{Consumable, Item, ItemKind}; use specs::{Component, FlaggedStorage, HashMapStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::ops::Not; // The limit on distance between the entity and a collectible (squared) @@ -388,7 +388,7 @@ impl InventoryUpdate { } impl Component for InventoryUpdate { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[cfg(test)] mod test; diff --git a/common/src/comp/location.rs b/common/src/comp/location.rs index 97a48e547a..2bd3b48c6f 100644 --- a/common/src/comp/location.rs +++ b/common/src/comp/location.rs @@ -1,6 +1,6 @@ use crate::state::Time; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; #[derive(Copy, Clone, Debug, Serialize, Deserialize)] @@ -19,7 +19,7 @@ impl Waypoint { } impl Component for Waypoint { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Debug, PartialEq)] @@ -30,7 +30,7 @@ impl WaypointArea { } impl Component for WaypointArea { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } impl Default for WaypointArea { diff --git a/common/src/comp/misc.rs b/common/src/comp/misc.rs index 5135ec67d7..5e27c698b0 100644 --- a/common/src/comp/misc.rs +++ b/common/src/comp/misc.rs @@ -1,6 +1,6 @@ use crate::sync::Uid; use specs::Component; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum Object { @@ -8,5 +8,5 @@ pub enum Object { } impl Component for Object { - type Storage = IDVStorage; + type Storage = IdvStorage; } diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index 61ceaaaf90..34fc9a2c3e 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -1,6 +1,6 @@ use crate::{sync::Uid, util::Dir}; use specs::{Component, FlaggedStorage, NullStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; // Position @@ -8,7 +8,7 @@ use vek::*; pub struct Pos(pub Vec3); impl Component for Pos { - type Storage = IDVStorage; + type Storage = IdvStorage; } // Velocity @@ -16,7 +16,7 @@ impl Component for Pos { pub struct Vel(pub Vec3); impl Component for Vel { - type Storage = IDVStorage; + type Storage = IdvStorage; } // Orientation @@ -24,7 +24,7 @@ impl Component for Vel { pub struct Ori(pub Dir); impl Component for Ori { - type Storage = IDVStorage; + type Storage = IdvStorage; } // Scale @@ -32,7 +32,7 @@ impl Component for Ori { pub struct Scale(pub f32); impl Component for Scale { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } // Mass @@ -40,7 +40,7 @@ impl Component for Scale { pub struct Mass(pub f32); impl Component for Mass { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } // Mass @@ -51,14 +51,14 @@ pub enum Collider { } impl Component for Collider { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Gravity(pub f32); impl Component for Gravity { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] @@ -88,7 +88,7 @@ impl PhysicsState { } impl Component for PhysicsState { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } // ForceUpdate diff --git a/common/src/comp/player.rs b/common/src/comp/player.rs index d75a4c7069..28f665d434 100644 --- a/common/src/comp/player.rs +++ b/common/src/comp/player.rs @@ -1,6 +1,6 @@ use authc::Uuid; use specs::{Component, FlaggedStorage, NullStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; const MAX_ALIAS_LEN: usize = 32; @@ -38,7 +38,7 @@ impl Player { } impl Component for Player { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Clone, Debug, Default, Serialize, Deserialize)] diff --git a/common/src/comp/projectile.rs b/common/src/comp/projectile.rs index 741a6004a0..9bfd5aeb81 100644 --- a/common/src/comp/projectile.rs +++ b/common/src/comp/projectile.rs @@ -1,6 +1,6 @@ use crate::{comp, sync::Uid}; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::time::Duration; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -40,5 +40,5 @@ impl Projectile { } impl Component for Projectile { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/comp/stats.rs b/common/src/comp/stats.rs index bed12234f1..ff3c370d16 100644 --- a/common/src/comp/stats.rs +++ b/common/src/comp/stats.rs @@ -4,7 +4,7 @@ use crate::{ sync::Uid, }; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use std::{error::Error, fmt}; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)] @@ -204,7 +204,7 @@ impl Stats { } impl Component for Stats { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Debug, Serialize, Deserialize)] @@ -213,5 +213,5 @@ pub struct Dying { } impl Component for Dying { - type Storage = IDVStorage; + type Storage = IdvStorage; } diff --git a/common/src/comp/visual.rs b/common/src/comp/visual.rs index 29cd1efd30..7d4f4c59f5 100644 --- a/common/src/comp/visual.rs +++ b/common/src/comp/visual.rs @@ -1,5 +1,5 @@ use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -22,7 +22,7 @@ impl Default for LightEmitter { } impl Component for LightEmitter { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -43,5 +43,5 @@ impl Default for LightAnimation { } impl Component for LightAnimation { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 63920ba5c3..597eaaf5a8 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -155,12 +155,9 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { } /// Checks that player can Swap Weapons and updates `Loadout` if so -pub fn attempt_swap_loadout(_data: &JoinData, update: &mut StateUpdate) { - if update.loadout.second_item.is_some() { - std::mem::swap( - &mut update.loadout.active_item, - &mut update.loadout.second_item, - ); +pub fn attempt_swap_loadout(data: &JoinData, update: &mut StateUpdate) { + if data.loadout.second_item.is_some() { + update.swap_loadout = true; } } diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index fb6e71884e..586dc239ba 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -9,7 +9,12 @@ use crate::{ sync::{Uid, UidAllocator}, }; -use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage}; +use specs::{ + hibitset, + storage::{PairedStorage, SequentialRestriction}, + Entities, Entity, FlaggedStorage, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage, +}; +use specs_idvs::IdvStorage; // use std::collections::VecDeque; @@ -37,7 +42,7 @@ pub trait CharacterBehavior { // fn init(data: &JoinData) -> CharacterState; } -/// Read-Only Data sent from Character Behavior System to bahvior fn's +/// Read-Only Data sent from Character Behavior System to behavior fn's pub struct JoinData<'a> { pub entity: Entity, pub uid: &'a Uid, @@ -57,15 +62,23 @@ pub struct JoinData<'a> { pub updater: &'a LazyUpdate, } +type RestrictedMut<'a, C> = PairedStorage< + 'a, + 'a, + C, + &'a mut FlaggedStorage>, + &'a hibitset::BitSet, + SequentialRestriction, +>; pub type JoinTuple<'a> = ( Entity, &'a Uid, - &'a mut CharacterState, + RestrictedMut<'a, CharacterState>, &'a mut Pos, &'a mut Vel, &'a mut Ori, - &'a mut Energy, - &'a mut Loadout, + RestrictedMut<'a, Energy>, + RestrictedMut<'a, Loadout>, &'a mut Controller, &'a Stats, &'a Body, @@ -74,12 +87,21 @@ pub type JoinTuple<'a> = ( ); fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) { - *tuple.2 = state_update.character; + // TODO: if checking equality is expensive use optional field in StateUpdate + if tuple.2.get_unchecked() != &state_update.character { + *tuple.2.get_mut_unchecked() = state_update.character + }; *tuple.3 = state_update.pos; *tuple.4 = state_update.vel; *tuple.5 = state_update.ori; - *tuple.6 = state_update.energy; - *tuple.7 = state_update.loadout; + // Note: might be changed every tick by timer anyway + if tuple.6.get_unchecked() != &state_update.energy { + *tuple.6.get_mut_unchecked() = state_update.energy + }; + if state_update.swap_loadout { + let loadout = tuple.7.get_mut_unchecked(); + std::mem::swap(&mut loadout.active_item, &mut loadout.second_item); + } } impl<'a> JoinData<'a> { @@ -87,12 +109,12 @@ impl<'a> JoinData<'a> { Self { entity: j.0, uid: j.1, - character: j.2, + character: j.2.get_unchecked(), pos: j.3, vel: j.4, ori: j.5, - energy: j.6, - loadout: j.7, + energy: j.6.get_unchecked(), + loadout: j.7.get_unchecked(), controller: j.8, inputs: &j.8.inputs, stats: j.9, @@ -162,24 +184,23 @@ impl<'a> System<'a> for Sys { let mut server_emitter = server_bus.emitter(); let mut local_emitter = local_bus.emitter(); - let mut join_iter = ( + for mut tuple in ( &entities, &uids, - &mut character_states, + &mut character_states.restrict_mut(), &mut positions, &mut velocities, &mut orientations, - &mut energies, - &mut loadouts, + &mut energies.restrict_mut(), + &mut loadouts.restrict_mut(), &mut controllers, &stats, &bodies, &physics_states, attacking_storage.maybe(), ) - .join(); - - while let Some(mut tuple) = join_iter.next() { + .join() + { // Being dead overrides all other states if tuple.9.is_dead { // Do nothing @@ -188,7 +209,10 @@ impl<'a> System<'a> for Sys { // If mounted, character state is controlled by mount // TODO: Make mounting a state if let Some(Mounting(_)) = mountings.get(tuple.0) { - *tuple.2 = CharacterState::Sit {}; + let sit_state = CharacterState::Sit {}; + if tuple.2.get_unchecked() != &sit_state { + *tuple.2.get_mut_unchecked() = sit_state; + } continue; } diff --git a/server/Cargo.toml b/server/Cargo.toml index ade46b9c6c..9c9de666a3 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -13,10 +13,10 @@ common = { package = "veloren-common", path = "../common" } world = { package = "veloren-world", path = "../world" } network = { package = "veloren_network", path = "../network", default-features = false } -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "specs-16" } tracing = "0.1" -specs = { version = "0.15.1", features = ["shred-derive"] } +specs = { version = "0.16.1", features = ["shred-derive"] } vek = "0.11.0" uvth = "3.1.1" futures-util = "0.3" diff --git a/server/src/client.rs b/server/src/client.rs index 6de7d502b3..412d36a7d1 100644 --- a/server/src/client.rs +++ b/server/src/client.rs @@ -2,7 +2,7 @@ use common::msg::{ClientState, RequestStateError, ServerMsg}; use hashbrown::HashSet; use network::Stream; use specs::{Component, FlaggedStorage}; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; pub struct Client { @@ -13,7 +13,7 @@ pub struct Client { } impl Component for Client { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } impl Client { @@ -59,5 +59,5 @@ pub struct RegionSubscription { } impl Component for RegionSubscription { - type Storage = FlaggedStorage>; + type Storage = FlaggedStorage>; } diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 7118185adb..9072812984 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -33,8 +33,8 @@ conrod_winit = { git = "https://gitlab.com/veloren/conrod.git", branch = "pre-wi euc = { git = "https://github.com/zesterer/euc.git" } # ECS -specs = "0.15.1" -specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git" } +specs = "0.16.1" +specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "specs-16" } # Mathematics vek = { version = "0.11.0", features = ["serde"] } diff --git a/voxygen/src/ecs/comp.rs b/voxygen/src/ecs/comp.rs index 8d051f0588..fbeb915a65 100644 --- a/voxygen/src/ecs/comp.rs +++ b/voxygen/src/ecs/comp.rs @@ -1,6 +1,6 @@ use common::util::Dir; use specs::Component; -use specs_idvs::IDVStorage; +use specs_idvs::IdvStorage; use vek::*; // Floats over entity that has had a health change, rising up over time until it @@ -25,7 +25,7 @@ pub struct HpFloaterList { pub time_since_last_dmg_by_me: Option, } impl Component for HpFloaterList { - type Storage = IDVStorage; + type Storage = IdvStorage; } // Used for smooth interpolation of visual elements that are tied to entity @@ -36,5 +36,5 @@ pub struct Interpolated { pub ori: Dir, } impl Component for Interpolated { - type Storage = IDVStorage; + type Storage = IdvStorage; }