Move Specs code to own common_ecs create, put tracy and macros into common_base

This commit is contained in:
Marcel Märtens 2021-03-08 23:40:02 +01:00
parent 8c1ac78ce3
commit 4ebfbdde0f
85 changed files with 282 additions and 193 deletions

31
Cargo.lock generated
View File

@ -5588,6 +5588,7 @@ dependencies = [
"tracing-subscriber",
"vek 0.14.1",
"veloren-common",
"veloren-common-base",
"veloren-common-net",
"veloren-common-sys",
"veloren-network",
@ -5604,10 +5605,8 @@ dependencies = [
"crossbeam-channel",
"crossbeam-utils 0.8.1",
"csv",
"directories-next",
"dot_vox",
"enum-iterator",
"float-cmp",
"hashbrown 0.9.1",
"image",
"indexmap",
@ -5632,6 +5631,26 @@ dependencies = [
"tracy-client",
"uuid",
"vek 0.14.1",
"veloren-common-base",
]
[[package]]
name = "veloren-common-base"
version = "0.8.0"
dependencies = [
"directories-next",
"tracing",
"tracy-client",
]
[[package]]
name = "veloren-common-ecs"
version = "0.8.0"
dependencies = [
"float-cmp",
"specs",
"tracing",
"veloren-common-base",
]
[[package]]
@ -5668,6 +5687,8 @@ dependencies = [
"tracy-client",
"vek 0.14.1",
"veloren-common",
"veloren-common-base",
"veloren-common-ecs",
"veloren-common-net",
"veloren-plugin-api",
"wasmer",
@ -5759,6 +5780,7 @@ dependencies = [
"itertools 0.9.0",
"lazy_static",
"libsqlite3-sys",
"num_cpus",
"portpicker",
"prometheus",
"prometheus-hyper",
@ -5775,6 +5797,8 @@ dependencies = [
"tracing",
"vek 0.14.1",
"veloren-common",
"veloren-common-base",
"veloren-common-ecs",
"veloren-common-net",
"veloren-common-sys",
"veloren-network",
@ -5800,6 +5824,7 @@ dependencies = [
"tracing-tracy",
"tui",
"veloren-common",
"veloren-common-base",
"veloren-common-net",
"veloren-server",
]
@ -5862,6 +5887,8 @@ dependencies = [
"vek 0.14.1",
"veloren-client",
"veloren-common",
"veloren-common-base",
"veloren-common-ecs",
"veloren-common-net",
"veloren-common-sys",
"veloren-server",

View File

@ -3,6 +3,8 @@ cargo-features = ["named-profiles","profile-overrides"]
[workspace]
members = [
"common",
"common/base",
"common/ecs",
"common/net",
"common/sys",
"client",

View File

@ -12,6 +12,7 @@ default = ["simd"]
[dependencies]
common = { package = "veloren-common", path = "../common", features = ["no-assets"] }
common-base = { package = "veloren-common-base", path = "../common/base" }
common-sys = { package = "veloren-common-sys", path = "../common/sys", default-features = false }
common-net = { package = "veloren-common-net", path = "../common/net" }
network = { package = "veloren-network", path = "../network", features = ["compression"], default-features = false }

View File

@ -33,12 +33,12 @@ use common::{
grid::Grid,
outcome::Outcome,
recipe::RecipeBook,
span,
terrain::{block::Block, neighbors, BiomeKind, SitesKind, TerrainChunk, TerrainChunkSize},
trade::{PendingTrade, TradeAction, TradeId, TradeResult},
uid::{Uid, UidAllocator},
vol::RectVolSize,
};
use common_base::span;
use common_net::{
msg::{
self, validate_chat_msg, world_msg::SiteInfo, ChatMsgValidationError, ClientGeneral,

View File

@ -14,6 +14,8 @@ default = ["simd"]
[dependencies]
common-base = { package = "veloren-common-base", path = "base" }
# Serde
serde = { version = "1.0.110", features = ["derive", "rc"] }
@ -36,7 +38,6 @@ uuid = { version = "0.8.1", default-features = false, features = ["serde", "v4"]
rand = "0.8"
# Assets
directories-next = "2.0"
dot_vox = "4.0"
image = { version = "0.23.12", default-features = false, features = ["png"] }
@ -68,7 +69,6 @@ specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "9fab7b3
[dev-dependencies]
#bench
criterion = "0.3"
float-cmp = "0.8.0"
[[bench]]
name = "chonk_benchmark"

16
common/base/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
authors = ["Marcel Märtens <marcel.cochem@googlemail.com>"]
edition = "2018"
name = "veloren-common-base"
description = "minimal dependency for crates to now depend on whole common"
version = "0.8.0"
[features]
tracy = ["tracy-client"]
[dependencies]
tracing = { version = "0.1", default-features = false }
directories-next = "2.0"
# Tracy
tracy-client = { version = "0.10.0", optional = true }

85
common/base/src/lib.rs Normal file
View File

@ -0,0 +1,85 @@
#![feature(fundamental)]
pub mod userdata_dir;
pub use userdata_dir::userdata_dir;
#[cfg(feature = "tracy")] pub use tracy_client;
// https://discordapp.com/channels/676678179678715904/676685797524766720/723358438943621151
#[macro_export]
macro_rules! span {
($guard_name:tt, $level:ident, $name:expr, $($fields:tt)*) => {
let span = tracing::span!(tracing::Level::$level, $name, $($fields)*);
let $guard_name = span.enter();
};
($guard_name:tt, $level:ident, $name:expr) => {
let span = tracing::span!(tracing::Level::$level, $name);
let $guard_name = span.enter();
};
($guard_name:tt, $name:expr) => {
#[cfg(not(feature = "tracy"))]
let span = tracing::span!(tracing::Level::TRACE, $name);
#[cfg(not(feature = "tracy"))]
let $guard_name = span.enter();
// Directly use `tracy_client` to decrease overhead for better timing
#[cfg(feature = "tracy")]
let $guard_name = $crate::tracy_client::Span::new(
$name,
"",
module_path!(),
line!(),
// No callstack since this has significant overhead
0,
);
};
($guard_name:tt, $no_tracy_name:expr, $tracy_name:expr) => {
#[cfg(not(feature = "tracy"))]
$crate::span!($guard_name, $no_tracy_name);
#[cfg(feature = "tracy")]
$crate::span!($guard_name, $tracy_name);
};
}
/// There's no guard, but really this is actually the guard
pub struct GuardlessSpan {
span: tracing::Span,
subscriber: tracing::Dispatch,
}
impl GuardlessSpan {
pub fn new(span: tracing::Span) -> Self {
let subscriber = tracing::dispatcher::get_default(|d| d.clone());
if let Some(id) = span.id() {
subscriber.enter(&id)
}
Self { span, subscriber }
}
}
impl Drop for GuardlessSpan {
fn drop(&mut self) {
if let Some(id) = self.span.id() {
self.subscriber.exit(&id)
}
}
}
#[macro_export]
macro_rules! no_guard_span {
($level:ident, $name:expr, $($fields:tt)*) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::$level, $name, $($fields)*)
)
};
($level:ident, $name:expr) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::$level, $name)
)
};
($name:expr) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::TRACE, $name)
)
};
}

View File

@ -63,7 +63,7 @@ pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str)
#[macro_export]
macro_rules! userdata_dir_workspace {
() => {
$crate::util::userdata_dir::userdata_dir(
$crate::userdata_dir::userdata_dir(
true,
option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"),
@ -74,7 +74,7 @@ macro_rules! userdata_dir_workspace {
#[macro_export]
macro_rules! userdata_dir_no_workspace {
() => {
$crate::util::userdata_dir::userdata_dir(
$crate::userdata_dir::userdata_dir(
false,
option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"),

19
common/ecs/Cargo.toml Normal file
View File

@ -0,0 +1,19 @@
[package]
authors = ["Marcel Märtens <marcel.cochem@googlemail.com>"]
edition = "2018"
name = "veloren-common-ecs"
version = "0.8.0"
[features]
[dependencies]
tracing = { version = "0.1", default-features = false }
common-base = { package = "veloren-common-base", path = "../base" }
# ECS
specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "d4435bdf496cf322c74886ca09dd8795984919b4" }
[dev-dependencies]
#bench
float-cmp = "0.8.0"

7
common/ecs/src/lib.rs Normal file
View File

@ -0,0 +1,7 @@
mod metrics;
mod system;
pub use metrics::{PhysicsMetrics, SysMetrics};
pub use system::{
dispatch, gen_stats, run_now, CpuTimeStats, CpuTimeline, Job, Origin, ParMode, Phase, System,
};

View File

@ -191,7 +191,7 @@ pub fn gen_stats(
///
/// ```
/// use specs::Read;
/// pub use veloren_common::system::{Job, Origin, ParMode, Phase, System};
/// pub use veloren_common_ecs::{Job, Origin, ParMode, Phase, System};
/// # use std::time::Duration;
/// pub struct Sys;
/// impl<'a> System<'a> for Sys {
@ -251,7 +251,7 @@ where
type SystemData = (T::SystemData, ReadExpect<'a, SysMetrics>);
fn run(&mut self, data: Self::SystemData) {
crate::span!(_guard, "run", &format!("{}::Sys::run", T::NAME));
common_base::span!(_guard, "run", &format!("{}::Sys::run", T::NAME));
self.cpu_stats.reset();
T::run(self, data.0);
self.cpu_stats.end();

View File

@ -1,4 +1,4 @@
use crate::span;
use common_base::span;
use ordered_float::NotNan;
use std::{
collections::VecDeque,

View File

@ -42,8 +42,8 @@ pub mod generation;
#[cfg(not(target_arch = "wasm32"))]
pub mod lottery;
#[cfg(not(target_arch = "wasm32"))]
pub mod metrics;
#[cfg(not(target_arch = "wasm32"))] pub mod npc;
#[cfg(not(target_arch = "wasm32"))]
pub mod npc;
#[cfg(not(target_arch = "wasm32"))]
pub mod outcome;
#[cfg(not(target_arch = "wasm32"))] pub mod path;
@ -61,7 +61,6 @@ pub mod spiral;
#[cfg(not(target_arch = "wasm32"))]
pub mod states;
#[cfg(not(target_arch = "wasm32"))] pub mod store;
pub mod system;
#[cfg(not(target_arch = "wasm32"))]
pub mod terrain;
#[cfg(not(target_arch = "wasm32"))] pub mod time;

View File

@ -1,9 +1,9 @@
use crate::{
astar::{Astar, PathResult},
span,
terrain::Block,
vol::{BaseVol, ReadVol},
};
use common_base::span;
use hashbrown::hash_map::DefaultHashBuilder;
use rand::prelude::*;
use std::iter::FromIterator;

View File

@ -1,4 +1,5 @@
use crate::{span, vol::ReadVol};
use crate::vol::ReadVol;
use common_base::span;
use vek::*;
pub trait RayForEach<V> = FnMut(&V, Vec3<i32>);

View File

@ -1,7 +1,5 @@
use crate::{
comp::{Pos, Vel},
span,
};
use crate::comp::{Pos, Vel};
use common_base::span;
use hashbrown::{hash_map::DefaultHashBuilder, HashSet};
use indexmap::IndexMap;
use specs::{hibitset::BitSetLike, BitSet, Entities, Join, ReadStorage};

View File

@ -4,7 +4,6 @@ pub mod find_dist;
mod option;
pub mod plane;
pub mod projection;
pub mod userdata_dir;
pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
pub const GIT_TAG: &str = include_str!(concat!(env!("OUT_DIR"), "/gittag"));
@ -32,77 +31,3 @@ pub use dir::*;
pub use option::*;
pub use plane::*;
pub use projection::*;
#[cfg(feature = "tracy")] pub use tracy_client;
// https://discordapp.com/channels/676678179678715904/676685797524766720/723358438943621151
#[macro_export]
macro_rules! span {
($guard_name:tt, $level:ident, $name:expr, $($fields:tt)*) => {
let span = tracing::span!(tracing::Level::$level, $name, $($fields)*);
let $guard_name = span.enter();
};
($guard_name:tt, $level:ident, $name:expr) => {
let span = tracing::span!(tracing::Level::$level, $name);
let $guard_name = span.enter();
};
($guard_name:tt, $name:expr) => {
#[cfg(not(feature = "tracy"))]
let span = tracing::span!(tracing::Level::TRACE, $name);
#[cfg(not(feature = "tracy"))]
let $guard_name = span.enter();
// Directly use `tracy_client` to decrease overhead for better timing
#[cfg(feature = "tracy")]
let $guard_name = $crate::util::tracy_client::Span::new(
$name,
"",
module_path!(),
line!(),
// No callstack since this has significant overhead
0,
);
};
($guard_name:tt, $no_tracy_name:expr, $tracy_name:expr) => {
#[cfg(not(feature = "tracy"))]
$crate::span!($guard_name, $no_tracy_name);
#[cfg(feature = "tracy")]
$crate::span!($guard_name, $tracy_name);
};
}
/// There's no guard, but really this is actually the guard
pub struct GuardlessSpan {
span: tracing::Span,
subscriber: tracing::Dispatch,
}
impl GuardlessSpan {
pub fn new(span: tracing::Span) -> Self {
let subscriber = tracing::dispatcher::get_default(|d| d.clone());
span.id().map(|id| subscriber.enter(&id));
Self { span, subscriber }
}
}
impl Drop for GuardlessSpan {
fn drop(&mut self) { self.span.id().map(|id| self.subscriber.exit(&id)); }
}
#[macro_export]
macro_rules! no_guard_span {
($level:ident, $name:expr, $($fields:tt)*) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::$level, $name, $($fields)*)
)
};
($level:ident, $name:expr) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::$level, $name)
)
};
($name:expr) => {
GuardlessSpan::new(
tracing::span!(tracing::Level::TRACE, $name)
)
};
}

View File

@ -14,6 +14,8 @@ default = ["simd"]
[dependencies]
common = { package = "veloren-common", path = ".." }
common-net = { package = "veloren-common-net", path = "../net" }
common-ecs = { package = "veloren-common-ecs", path = "../ecs" }
common-base = { package = "veloren-common-base", path = "../base" }
rand = "0.8"
rayon = "1.5"

View File

@ -7,9 +7,9 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::UidAllocator,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData,
World, WriteStorage,

View File

@ -6,10 +6,10 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::{Uid, UidAllocator},
GroupTarget,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData,
World, WriteStorage,

View File

@ -5,9 +5,9 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
Damage, DamageSource,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData, World, WriteStorage,
};

View File

@ -18,9 +18,9 @@ use common::{
self,
behavior::{CharacterBehavior, JoinData, JoinStruct},
},
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use std::time::Duration;
fn incorporate_update(join: &mut JoinStruct, state_update: StateUpdate) {

View File

@ -1,9 +1,9 @@
use common::{
comp::{BuffChange, ControlEvent, Controller},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::UidAllocator,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::{Marker, MarkerAllocator},
shred::ResourceId,

View File

@ -15,7 +15,7 @@ pub mod state;
mod stats;
// External
use common::system::{dispatch, System};
use common_ecs::{dispatch, System};
use specs::DispatcherBuilder;
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {

View File

@ -2,11 +2,11 @@ use common::{
combat::{AttackerInfo, TargetInfo},
comp::{Body, CharacterState, Energy, Group, Health, Inventory, Melee, Ori, Pos, Scale, Stats},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::Uid,
util::Dir,
GroupTarget,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData, World, WriteStorage,
};

View File

@ -1,8 +1,8 @@
use common::{
comp::{Controller, MountState, Mounting, Ori, Pos, Vel},
system::{Job, Origin, Phase, System},
uid::UidAllocator,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::{Marker, MarkerAllocator},
Entities, Join, Read, WriteStorage,

View File

@ -5,14 +5,13 @@ use common::{
},
consts::{FRIC_GROUND, GRAVITY},
event::{EventBus, ServerEvent},
metrics::PhysicsMetrics,
resources::DeltaTime,
span,
system::{Job, Origin, ParMode, Phase, System},
terrain::{Block, TerrainGrid},
uid::Uid,
vol::ReadVol,
};
use common_base::span;
use common_ecs::{Job, Origin, ParMode, Phase, PhysicsMetrics, System};
use rayon::iter::ParallelIterator;
use specs::{Entities, Join, ParJoin, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage};
use std::ops::Range;

View File

@ -6,11 +6,11 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::UidAllocator,
util::Dir,
GroupTarget,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData,
World, WriteStorage,

View File

@ -6,11 +6,11 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::{Uid, UidAllocator},
util::Dir,
GroupTarget,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData,
World, WriteStorage,

View File

@ -5,15 +5,15 @@ use crate::plugin::PluginMgr;
use common::{
comp,
event::{EventBus, LocalEvent, ServerEvent},
metrics::{PhysicsMetrics, SysMetrics},
region::RegionMap,
resources::{DeltaTime, GameMode, Time, TimeOfDay},
span,
terrain::{Block, TerrainChunk, TerrainGrid},
time::DayPeriod,
trade::Trades,
vol::{ReadVol, WriteVol},
};
use common_base::span;
use common_ecs::{PhysicsMetrics, SysMetrics};
use common_net::sync::WorldSyncExt;
use hashbrown::{HashMap, HashSet};
use rayon::{ThreadPool, ThreadPoolBuilder};

View File

@ -7,9 +7,9 @@ use common::{
event::{EventBus, ServerEvent},
outcome::Outcome,
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use hashbrown::HashSet;
use specs::{
shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData, World, Write, WriteStorage,

View File

@ -13,6 +13,7 @@ plugins = ["server/plugins"]
[dependencies]
server = { package = "veloren-server", path = "../server", default-features = false }
common = { package = "veloren-common", path = "../common" }
common-base = { package = "veloren-common-base", path = "../common/base" }
common-net = { package = "veloren-common-net", path = "../common/net" }
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }

View File

@ -14,7 +14,8 @@ use crate::{
tui_runner::{Message, Tui},
};
use clap::{App, Arg, SubCommand};
use common::{clock::Clock, span};
use common::clock::Clock;
use common_base::span;
use server::{Event, Input, Server};
use std::{
io,
@ -85,7 +86,7 @@ fn main() -> io::Result<()> {
// Determine folder to save server data in
let server_data_dir = {
let mut path = common::userdata_dir_workspace!();
let mut path = common_base::userdata_dir_workspace!();
info!("Using userdata folder at {}", path.display());
path.push(server::DEFAULT_DATA_DIR_NAME);
path
@ -207,7 +208,7 @@ fn main() -> io::Result<()> {
// Wait for the next tick.
clock.tick();
#[cfg(feature = "tracy")]
common::util::tracy_client::finish_continuous_frame!();
common_base::finish_continuous_frame!();
}
Ok(())

View File

@ -69,7 +69,7 @@ impl Settings {
}
pub fn data_dir() -> PathBuf {
let mut path = common::userdata_dir_workspace!();
let mut path = common_base::userdata_dir_workspace!();
path.push("server-cli");
path
}

View File

@ -13,6 +13,8 @@ default = ["worldgen", "plugins", "simd"]
[dependencies]
common = { package = "veloren-common", path = "../common" }
common-base = { package = "veloren-common-base", path = "../common/base" }
common-ecs = { package = "veloren-common-ecs", path = "../common/ecs" }
common-sys = { package = "veloren-common-sys", path = "../common/sys" }
common-net = { package = "veloren-common-net", path = "../common/net" }
world = { package = "veloren-world", path = "../world" }
@ -21,6 +23,7 @@ network = { package = "veloren-network", path = "../network", features = ["metri
specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "d4435bdf496cf322c74886ca09dd8795984919b4" }
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", rev = "9fab7b396acd6454585486e50ae4bfe2069858a9" }
num_cpus = "1.0"
tracing = "0.1"
vek = { version = "0.14.1", features = ["serde"] }
futures-util = "0.3.7"

View File

@ -1,8 +1,6 @@
use crate::{state_ext::StateExt, Server};
use common::{
event::{EventBus, ServerEvent},
span,
};
use common::event::{EventBus, ServerEvent};
use common_base::span;
use entity_creation::{
handle_beam, handle_create_npc, handle_create_waypoint, handle_initialize_character,
handle_loaded_character_data, handle_shockwave, handle_shoot,

View File

@ -6,9 +6,9 @@ use crate::{
use common::{
comp,
comp::{group, Player},
span,
uid::{Uid, UidAllocator},
};
use common_base::span;
use common_net::msg::{PlayerListUpdate, PresenceKind, ServerGeneral};
use common_sys::state::State;
use specs::{saveload::MarkerAllocator, Builder, Entity as EcsEntity, WorldExt};

View File

@ -64,10 +64,10 @@ use common::{
recipe::default_recipe_book,
resources::TimeOfDay,
rtsim::RtSimEntity,
system::run_now,
terrain::TerrainChunkSize,
vol::{ReadVol, RectVolSize},
};
use common_ecs::run_now;
use common_net::{
msg::{
CharacterInfo, ClientType, DisconnectReason, PlayerInfo, PlayerListUpdate, ServerGeneral,

View File

@ -1,8 +1,6 @@
use super::*;
use common::{
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
};
use common::event::{EventBus, ServerEvent};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Read, WriteExpect};
#[derive(Default)]

View File

@ -10,10 +10,10 @@ use self::{chunks::Chunks, entity::Entity};
use common::{
comp,
rtsim::{RtSimController, RtSimEntity, RtSimId},
system::{dispatch, System},
terrain::TerrainChunk,
vol::RectRasterableVol,
};
use common_ecs::{dispatch, System};
use common_sys::state::State;
use rand::prelude::*;
use slab::Slab;

View File

@ -6,9 +6,9 @@ use common::{
comp::inventory::loadout_builder::LoadoutBuilder,
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Join, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage};
use std::sync::Arc;

View File

@ -2,9 +2,9 @@ use super::*;
use common::{
comp::Pos,
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Entities, Read, ReadExpect, ReadStorage, WriteExpect};
#[derive(Default)]

View File

@ -17,13 +17,13 @@ use common::{
event::{Emitter, EventBus, ServerEvent},
path::TraversalConfig,
resources::{DeltaTime, TimeOfDay},
system::{Job, Origin, Phase, System},
terrain::{Block, TerrainGrid},
time::DayPeriod,
uid::{Uid, UidAllocator},
util::Dir,
vol::ReadVol,
};
use common_ecs::{Job, Origin, Phase, System};
use rand::{thread_rng, Rng};
use rayon::iter::ParallelIterator;
use specs::{

View File

@ -9,11 +9,11 @@ use common::{
outcome::Outcome,
region::{Event as RegionEvent, RegionMap},
resources::TimeOfDay,
system::{Job, Origin, Phase, System},
terrain::TerrainChunkSize,
uid::Uid,
vol::RectVolSize,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::{msg::ServerGeneral, sync::CompSyncPackage};
use specs::{
Entities, Entity as EcsEntity, Join, Read, ReadExpect, ReadStorage, Write, WriteStorage,

View File

@ -1,9 +1,9 @@
use crate::client::Client;
use common::{
comp::invite::{Invite, PendingInvites},
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{InviteAnswer, ServerGeneral};
use specs::{Entities, Join, ReadStorage, WriteStorage};

View File

@ -2,12 +2,8 @@ use crate::{
metrics::{EcsSystemMetrics, PhysicsMetrics, TickMetrics},
Tick, TickStart,
};
use common::{
metrics::SysMetrics,
resources::TimeOfDay,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
};
use common::{resources::TimeOfDay, terrain::TerrainGrid};
use common_ecs::{Job, Origin, Phase, SysMetrics, System};
use specs::{Entities, Join, Read, ReadExpect};
use std::time::Instant;
@ -23,7 +19,7 @@ impl<'a> System<'a> for Sys {
ReadExpect<'a, TickStart>,
Option<Read<'a, TerrainGrid>>,
Read<'a, SysMetrics>,
Read<'a, common::metrics::PhysicsMetrics>,
Read<'a, common_ecs::PhysicsMetrics>,
ReadExpect<'a, EcsSystemMetrics>,
ReadExpect<'a, TickMetrics>,
ReadExpect<'a, PhysicsMetrics>,
@ -56,7 +52,11 @@ impl<'a> System<'a> for Sys {
//this system hasn't run yet
state.remove(Self::NAME);
for (name, stat) in common::system::gen_stats(&state, tick_start.0, 8, 8) {
lazy_static::lazy_static! {
static ref THREADS: u16 = num_cpus::get() as u16;
}
for (name, stat) in common_ecs::gen_stats(&state, tick_start.0, *THREADS, *THREADS) {
export_ecs
.system_start_time
.with_label_values(&[&name])
@ -65,11 +65,15 @@ impl<'a> System<'a> for Sys {
.system_thread_avg
.with_label_values(&[&name])
.set(stat.avg_threads() as f64);
let len = stat.length_ns() as i64;
let len = stat.length_ns();
export_ecs
.system_length_time
.with_label_values(&[&name])
.set(len);
.set(len as i64);
export_ecs
.system_length_count
.with_label_values(&[&name])
.inc_by(len);
export_ecs
.system_length_hist
.with_label_values(&[&name])
@ -115,11 +119,15 @@ impl<'a> System<'a> for Sys {
.system_thread_avg
.with_label_values(&["metrics"])
.set(1.0);
let len = start.elapsed().as_nanos() as i64;
let len = start.elapsed().as_nanos() as u64;
export_ecs
.system_length_time
.with_label_values(&["metrics"])
.set(len);
.set(len as i64);
export_ecs
.system_length_count
.with_label_values(&["metrics"])
.inc_by(len);
export_ecs
.system_length_hist
.with_label_values(&["metrics"])

View File

@ -11,7 +11,7 @@ pub mod terrain;
pub mod terrain_sync;
pub mod waypoint;
use common::system::{dispatch, run_now};
use common_ecs::{dispatch, run_now};
use specs::DispatcherBuilder;
use std::{
marker::PhantomData,

View File

@ -5,9 +5,9 @@ use crate::{
use common::{
comp::{ChatType, Player, UnresolvedChatMsg},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{ClientGeneral, ServerGeneral};
use specs::{Entities, Join, Read, ReadExpect, ReadStorage};
use std::sync::atomic::Ordering;

View File

@ -3,9 +3,9 @@ use common::{
comp::{ChatMode, Player, UnresolvedChatMsg},
event::{EventBus, ServerEvent},
resources::Time,
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{
validate_chat_msg, ChatMsgValidationError, ClientGeneral, MAX_BYTES_CHAT_MSG,
};

View File

@ -2,10 +2,10 @@ use crate::{client::Client, metrics::NetworkRequestMetrics, presence::Presence,
use common::{
comp::{CanBuild, ControlEvent, Controller, ForceUpdate, Health, Ori, Pos, Stats, Vel},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
terrain::{TerrainChunkSize, TerrainGrid},
vol::{ReadVol, RectVolSize},
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{ClientGeneral, PresenceKind, ServerGeneral};
use common_sys::state::BlockChange;
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, Write, WriteStorage};

View File

@ -2,8 +2,8 @@ use crate::{client::Client, metrics::PlayerMetrics, Settings};
use common::{
event::{EventBus, ServerEvent},
resources::Time,
system::{Job, Origin, Phase, System},
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::PingMsg;
use specs::{Entities, Join, Read, ReadExpect, ReadStorage};
use std::sync::atomic::Ordering;

View File

@ -3,9 +3,9 @@ use common::{
effect::Effect,
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
Damage, DamageSource, Explosion, RadiusEffect,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
/// This system is responsible for handling misc object behaviours

View File

@ -1,8 +1,6 @@
use crate::{persistence::character_updater, presence::Presence, sys::SysScheduler};
use common::{
comp::{Inventory, Stats, Waypoint},
system::{Job, Origin, Phase, System},
};
use common::comp::{Inventory, Stats, Waypoint};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::PresenceKind;
use specs::{Join, ReadExpect, ReadStorage, Write};

View File

@ -4,9 +4,9 @@ use common::{
Gravity, Group, Health, Inventory, Item, LightEmitter, Mass, MountState, Mounting, Ori,
Player, Poise, Pos, Scale, Shockwave, Stats, Sticky, Vel,
},
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::{
msg::EcsCompPacket,
sync::{CompSyncPackage, EntityPackage, EntitySyncPackage, UpdateTracker, WorldSyncExt},

View File

@ -6,11 +6,11 @@ use crate::{
use common::{
comp::{Ori, Pos, Vel},
region::{region_in_vd, regions_in_vd, Event as RegionEvent, RegionMap},
system::{Job, Origin, Phase, System},
terrain::TerrainChunkSize,
uid::Uid,
vol::RectVolSize,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::ServerGeneral;
use specs::{
Entities, Join, ReadExpect, ReadStorage, SystemData, World, WorldExt, Write, WriteStorage,

View File

@ -6,10 +6,10 @@ use common::{
event::{EventBus, ServerEvent},
generation::get_npc_name,
npc::NPC_NAMES,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
LoadoutBuilder, SkillSetBuilder,
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::ServerGeneral;
use common_sys::state::TerrainChanges;
use specs::{Join, Read, ReadStorage, Write, WriteExpect};

View File

@ -1,9 +1,6 @@
use crate::{client::Client, presence::Presence};
use common::{
comp::Pos,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
};
use common::{comp::Pos, terrain::TerrainGrid};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::ServerGeneral;
use common_sys::state::TerrainChanges;
use specs::{Join, Read, ReadExpect, ReadStorage};

View File

@ -2,8 +2,8 @@ use crate::client::Client;
use common::{
comp::{Player, Pos, Waypoint, WaypointArea},
resources::Time,
system::{Job, Origin, Phase, System},
};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{Notification, ServerGeneral};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};

View File

@ -21,6 +21,8 @@ default = ["gl", "singleplayer", "native-dialog", "plugins", "simd"]
[dependencies]
client = {package = "veloren-client", path = "../client"}
common = {package = "veloren-common", path = "../common"}
common-base = {package = "veloren-common-base", path = "../common/base"}
common-ecs = {package = "veloren-common-ecs", path = "../common/ecs"}
common-net = {package = "veloren-common-net", path = "../common/net"}
common-sys = {package = "veloren-common-sys", path = "../common/sys"}

View File

@ -1,7 +1,7 @@
pub mod floater;
mod interpolation;
use common::system::{dispatch, System};
use common_ecs::{dispatch, System};
use specs::DispatcherBuilder;
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {

View File

@ -5,9 +5,9 @@ use crate::ecs::{
use common::{
comp::{Health, HealthSource, Pos},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::Uid,
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, WriteStorage};
// How long floaters last (in seconds)

View File

@ -2,8 +2,8 @@ use crate::ecs::comp::Interpolated;
use common::{
comp::{object, Body, Ori, Pos, Vel},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
};
use common_ecs::{Job, Origin, Phase, System};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
use tracing::warn;
use vek::*;

View File

@ -71,13 +71,13 @@ use common::{
BuffKind,
},
outcome::Outcome,
span,
terrain::TerrainChunk,
trade::TradeAction,
uid::Uid,
util::srgba_to_linear,
vol::RectRasterableVol,
};
use common_base::span;
use common_net::msg::{Notification, PresenceKind};
use conrod_core::{
text::cursor::Index,

View File

@ -40,7 +40,8 @@ use crate::{
settings::Settings,
window::{Event, Window},
};
use common::{assets::AssetHandle, clock::Clock, span};
use common::{assets::AssetHandle, clock::Clock};
use common_base::span;
/// A type used to store state that is shared between all play states.
pub struct GlobalState {

View File

@ -9,7 +9,8 @@ use crate::{
Direction, GlobalState, PlayState, PlayStateResult,
};
use client::{self, Client};
use common::{comp, resources::DeltaTime, span};
use common::{comp, resources::DeltaTime};
use common_base::span;
use specs::WorldExt;
use std::{cell::RefCell, mem, rc::Rc};
use tracing::error;

View File

@ -16,7 +16,8 @@ use client::{
error::{InitProtocolError, NetworkConnectError, NetworkError},
};
use client_init::{ClientConnArgs, ClientInit, Error as InitError, Msg as InitMsg};
use common::{assets::AssetExt, comp, span};
use common::{assets::AssetExt, comp};
use common_base::span;
use std::sync::Arc;
use tokio::runtime;
use tracing::error;

View File

@ -1,5 +1,5 @@
use crate::render::{self, mesh::Quad, ColLightFmt, ColLightInfo, TerrainPipeline};
use common::span;
use common_base::span;
use vek::*;
type TerrainVertex = <TerrainPipeline as render::Pipeline>::Vertex;

View File

@ -7,12 +7,12 @@ use crate::{
scene::terrain::BlocksOfInterest,
};
use common::{
span,
terrain::Block,
util::either_with,
vol::{ReadVol, RectRasterableVol},
volumes::vol_grid_2d::{CachedVolGrid2d, VolGrid2d},
};
use common_base::span;
use std::{collections::VecDeque, fmt::Debug};
use tracing::error;
use vek::*;

View File

@ -12,10 +12,8 @@ use super::{
AaMode, CloudMode, FilterMethod, FluidMode, LightingMode, Pipeline, RenderError, RenderMode,
ShadowMapMode, ShadowMode, WrapMode,
};
use common::{
assets::{self, AssetExt, AssetHandle},
span,
};
use common::assets::{self, AssetExt, AssetHandle};
use common_base::span;
use core::convert::TryFrom;
use gfx::{
self,

View File

@ -5,7 +5,7 @@ use crate::{
window::{Event, EventLoop},
Direction, GlobalState, PlayState, PlayStateResult,
};
use common::{no_guard_span, span, util::GuardlessSpan};
use common_base::{no_guard_span, span, GuardlessSpan};
use std::{mem, time::Duration};
use tracing::debug;

View File

@ -1,4 +1,5 @@
use common::{span, terrain::TerrainGrid, vol::ReadVol};
use common::{terrain::TerrainGrid, vol::ReadVol};
use common_base::span;
use std::f32::consts::PI;
use treeculler::Frustum;
use vek::*;

View File

@ -33,12 +33,12 @@ use common::{
LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel,
},
resources::DeltaTime,
span,
states::utils::StageSection,
terrain::TerrainChunk,
util::Dir,
vol::RectRasterableVol,
};
use common_base::span;
use common_sys::state::State;
use core::{
borrow::Borrow,

View File

@ -28,10 +28,10 @@ use common::{
comp,
outcome::Outcome,
resources::DeltaTime,
span,
terrain::{BlockKind, TerrainChunk},
vol::ReadVol,
};
use common_base::span;
use common_sys::state::State;
use comp::item::Reagent;
use num::traits::{Float, FloatConst};

View File

@ -13,11 +13,11 @@ use common::{
figure::Segment,
outcome::Outcome,
resources::DeltaTime,
span,
spiral::Spiral2d,
terrain::TerrainChunk,
vol::{RectRasterableVol, SizedVol},
};
use common_base::span;
use hashbrown::HashMap;
use rand::prelude::*;
use specs::{Join, WorldExt};

View File

@ -15,12 +15,12 @@ use super::{math, LodData, SceneData};
use common::{
assets::{self, AssetExt, DotVoxAsset},
figure::Segment,
span,
spiral::Spiral2d,
terrain::{sprite, Block, SpriteKind, TerrainChunk},
vol::{BaseVol, ReadVol, RectRasterableVol, SampleVol},
volumes::vol_grid_2d::{VolGrid2d, VolGrid2dError},
};
use common_base::span;
use core::{f32, fmt::Debug, i32, marker::PhantomData, time::Duration};
use crossbeam::channel;
use enum_iterator::IntoEnumIterator;

View File

@ -1,8 +1,8 @@
use common::{
span,
terrain::{BlockKind, SpriteKind, TerrainChunk},
vol::{IntoVolIterator, RectRasterableVol},
};
use common_base::span;
use rand::prelude::*;
use vek::*;

View File

@ -15,7 +15,6 @@ use common::{
},
consts::{MAX_MOUNT_RANGE, MAX_PICKUP_RANGE},
outcome::Outcome,
span,
terrain::{Block, BlockKind},
trade::TradeResult,
util::{
@ -24,6 +23,7 @@ use common::{
},
vol::ReadVol,
};
use common_base::span;
use common_net::{
msg::{server::InviteAnswer, PresenceKind},
sync::WorldSyncExt,

View File

@ -815,7 +815,7 @@ impl Settings {
pub fn voxygen_data_dir() -> PathBuf {
// Note: since voxygen is technically a lib we made need to lift this up to
// run.rs
let mut path = common::userdata_dir_workspace!();
let mut path = common_base::userdata_dir_workspace!();
path.push("voxygen");
path
}

View File

@ -33,7 +33,7 @@ impl Singleplayer {
// Determine folder to save server data in
let server_data_dir = {
let mut path = common::userdata_dir_workspace!();
let mut path = common_base::userdata_dir_workspace!();
path.push("singleplayer");
path
};

View File

@ -1,7 +1,5 @@
use common::{
span,
util::{linear_to_srgba, srgba_to_linear},
};
use common::util::{linear_to_srgba, srgba_to_linear};
use common_base::span;
/// Pixel art scaling
/// Note: The current ui is locked to the pixel grid with little animation, if
/// we want smoothly moving pixel art this should be done in the shaders

View File

@ -15,7 +15,7 @@ use super::{
scale::{Scale, ScaleMode},
};
use crate::{render::Renderer, window::Window, Error};
use common::span;
use common_base::span;
use iced::{mouse, Cache, Size, UserInterface};
use iced_winit::Clipboard;
use vek::*;

View File

@ -20,7 +20,8 @@ use crate::{
},
Error,
};
use common::{span, util::srgba_to_linear};
use common::util::srgba_to_linear;
use common_base::span;
use std::{convert::TryInto, ops::Range};
use vek::*;

View File

@ -33,7 +33,8 @@ use crate::{
#[rustfmt::skip]
use ::image::GenericImageView;
use cache::Cache;
use common::{span, util::srgba_to_linear};
use common::util::srgba_to_linear;
use common_base::span;
use conrod_core::{
event::Input,
graph::{self, Graph},

View File

@ -4,7 +4,7 @@ use crate::{
settings::{ControlSettings, Settings},
ui, Error,
};
use common::span;
use common_base::span;
use crossbeam::channel;
use gilrs::{EventType, Gilrs};
use hashbrown::HashMap;