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

View File

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

View File

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

View File

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

View File

@ -14,6 +14,8 @@ default = ["simd"]
[dependencies] [dependencies]
common-base = { package = "veloren-common-base", path = "base" }
# Serde # Serde
serde = { version = "1.0.110", features = ["derive", "rc"] } 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" rand = "0.8"
# Assets # Assets
directories-next = "2.0"
dot_vox = "4.0" dot_vox = "4.0"
image = { version = "0.23.12", default-features = false, features = ["png"] } 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] [dev-dependencies]
#bench #bench
criterion = "0.3" criterion = "0.3"
float-cmp = "0.8.0"
[[bench]] [[bench]]
name = "chonk_benchmark" 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_export]
macro_rules! userdata_dir_workspace { macro_rules! userdata_dir_workspace {
() => { () => {
$crate::util::userdata_dir::userdata_dir( $crate::userdata_dir::userdata_dir(
true, true,
option_env!("VELOREN_USERDATA_STRATEGY"), option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"), env!("CARGO_MANIFEST_DIR"),
@ -74,7 +74,7 @@ macro_rules! userdata_dir_workspace {
#[macro_export] #[macro_export]
macro_rules! userdata_dir_no_workspace { macro_rules! userdata_dir_no_workspace {
() => { () => {
$crate::util::userdata_dir::userdata_dir( $crate::userdata_dir::userdata_dir(
false, false,
option_env!("VELOREN_USERDATA_STRATEGY"), option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"), 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; /// 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; /// # use std::time::Duration;
/// pub struct Sys; /// pub struct Sys;
/// impl<'a> System<'a> for Sys { /// impl<'a> System<'a> for Sys {
@ -251,7 +251,7 @@ where
type SystemData = (T::SystemData, ReadExpect<'a, SysMetrics>); type SystemData = (T::SystemData, ReadExpect<'a, SysMetrics>);
fn run(&mut self, data: Self::SystemData) { 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(); self.cpu_stats.reset();
T::run(self, data.0); T::run(self, data.0);
self.cpu_stats.end(); self.cpu_stats.end();

View File

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

View File

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

View File

@ -1,9 +1,9 @@
use crate::{ use crate::{
astar::{Astar, PathResult}, astar::{Astar, PathResult},
span,
terrain::Block, terrain::Block,
vol::{BaseVol, ReadVol}, vol::{BaseVol, ReadVol},
}; };
use common_base::span;
use hashbrown::hash_map::DefaultHashBuilder; use hashbrown::hash_map::DefaultHashBuilder;
use rand::prelude::*; use rand::prelude::*;
use std::iter::FromIterator; 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::*; use vek::*;
pub trait RayForEach<V> = FnMut(&V, Vec3<i32>); pub trait RayForEach<V> = FnMut(&V, Vec3<i32>);

View File

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

View File

@ -4,7 +4,6 @@ pub mod find_dist;
mod option; mod option;
pub mod plane; pub mod plane;
pub mod projection; pub mod projection;
pub mod userdata_dir;
pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash")); pub const GIT_VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
pub const GIT_TAG: &str = include_str!(concat!(env!("OUT_DIR"), "/gittag")); pub const GIT_TAG: &str = include_str!(concat!(env!("OUT_DIR"), "/gittag"));
@ -32,77 +31,3 @@ pub use dir::*;
pub use option::*; pub use option::*;
pub use plane::*; pub use plane::*;
pub use projection::*; 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] [dependencies]
common = { package = "veloren-common", path = ".." } common = { package = "veloren-common", path = ".." }
common-net = { package = "veloren-common-net", path = "../net" } 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" rand = "0.8"
rayon = "1.5" rayon = "1.5"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -69,7 +69,7 @@ impl Settings {
} }
pub fn data_dir() -> PathBuf { 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.push("server-cli");
path path
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,9 @@ use common::{
comp::{ChatMode, Player, UnresolvedChatMsg}, comp::{ChatMode, Player, UnresolvedChatMsg},
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
resources::Time, resources::Time,
system::{Job, Origin, Phase, System},
uid::Uid, uid::Uid,
}; };
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{ use common_net::msg::{
validate_chat_msg, ChatMsgValidationError, ClientGeneral, MAX_BYTES_CHAT_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::{ use common::{
comp::{CanBuild, ControlEvent, Controller, ForceUpdate, Health, Ori, Pos, Stats, Vel}, comp::{CanBuild, ControlEvent, Controller, ForceUpdate, Health, Ori, Pos, Stats, Vel},
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
terrain::{TerrainChunkSize, TerrainGrid}, terrain::{TerrainChunkSize, TerrainGrid},
vol::{ReadVol, RectVolSize}, vol::{ReadVol, RectVolSize},
}; };
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{ClientGeneral, PresenceKind, ServerGeneral}; use common_net::msg::{ClientGeneral, PresenceKind, ServerGeneral};
use common_sys::state::BlockChange; use common_sys::state::BlockChange;
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, Write, WriteStorage}; use specs::{Entities, Join, Read, ReadExpect, ReadStorage, Write, WriteStorage};

View File

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

View File

@ -3,9 +3,9 @@ use common::{
effect::Effect, effect::Effect,
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
resources::DeltaTime, resources::DeltaTime,
system::{Job, Origin, Phase, System},
Damage, DamageSource, Explosion, RadiusEffect, Damage, DamageSource, Explosion, RadiusEffect,
}; };
use common_ecs::{Job, Origin, Phase, System};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage}; use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
/// This system is responsible for handling misc object behaviours /// 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 crate::{persistence::character_updater, presence::Presence, sys::SysScheduler};
use common::{ use common::comp::{Inventory, Stats, Waypoint};
comp::{Inventory, Stats, Waypoint}, use common_ecs::{Job, Origin, Phase, System};
system::{Job, Origin, Phase, System},
};
use common_net::msg::PresenceKind; use common_net::msg::PresenceKind;
use specs::{Join, ReadExpect, ReadStorage, Write}; use specs::{Join, ReadExpect, ReadStorage, Write};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,6 +21,8 @@ default = ["gl", "singleplayer", "native-dialog", "plugins", "simd"]
[dependencies] [dependencies]
client = {package = "veloren-client", path = "../client"} client = {package = "veloren-client", path = "../client"}
common = {package = "veloren-common", path = "../common"} 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-net = {package = "veloren-common-net", path = "../common/net"}
common-sys = {package = "veloren-common-sys", path = "../common/sys"} common-sys = {package = "veloren-common-sys", path = "../common/sys"}

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,8 @@ use crate::{
settings::Settings, settings::Settings,
window::{Event, Window}, 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. /// A type used to store state that is shared between all play states.
pub struct GlobalState { pub struct GlobalState {

View File

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

View File

@ -16,7 +16,8 @@ use client::{
error::{InitProtocolError, NetworkConnectError, NetworkError}, error::{InitProtocolError, NetworkConnectError, NetworkError},
}; };
use client_init::{ClientConnArgs, ClientInit, Error as InitError, Msg as InitMsg}; 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 std::sync::Arc;
use tokio::runtime; use tokio::runtime;
use tracing::error; use tracing::error;

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ use crate::{
window::{Event, EventLoop}, window::{Event, EventLoop},
Direction, GlobalState, PlayState, PlayStateResult, 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 std::{mem, time::Duration};
use tracing::debug; 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 std::f32::consts::PI;
use treeculler::Frustum; use treeculler::Frustum;
use vek::*; use vek::*;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,8 @@ use crate::{
}, },
Error, 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 std::{convert::TryInto, ops::Range};
use vek::*; use vek::*;

View File

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

View File

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