Added feature flag for client/server is common-state

This commit is contained in:
Forest Anderson 2023-07-29 13:31:00 -04:00
parent 026b61baee
commit 6a8ea80357
6 changed files with 45 additions and 37 deletions

View File

@ -16,7 +16,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-base = { package = "veloren-common-base", path = "../common/base" }
common-state = { package = "veloren-common-state", path = "../common/state", default-features = false } common-state = { package = "veloren-common-state", path = "../common/state", default-features = false, features = ["client"] }
common-systems = { package = "veloren-common-systems", path = "../common/systems", default-features = false } common-systems = { package = "veloren-common-systems", path = "../common/systems", 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","quic"], default-features = false } network = { package = "veloren-network", path = "../network", features = ["compression","quic"], default-features = false }

View File

@ -7,6 +7,8 @@ version = "0.10.0"
[features] [features]
simd = ["vek/platform_intrinsics"] simd = ["vek/platform_intrinsics"]
plugins = ["toml", "tar", "wasmer", "wasmer-wasix-types", "bincode", "plugin-api", "serde"] plugins = ["toml", "tar", "wasmer", "wasmer-wasix-types", "bincode", "plugin-api", "serde"]
server = []
client = []
default = ["simd"] default = ["simd"]

View File

@ -237,32 +237,36 @@ impl State {
ecs.register::<comp::PosVelOriDefer>(); ecs.register::<comp::PosVelOriDefer>();
// Register client-local components // Register client-local components
// TODO: only register on the client #[cfg(feature = "client")]
ecs.register::<comp::LightAnimation>(); {
ecs.register::<sync_interp::InterpBuffer<comp::Pos>>(); ecs.register::<comp::LightAnimation>();
ecs.register::<sync_interp::InterpBuffer<comp::Vel>>(); ecs.register::<sync_interp::InterpBuffer<comp::Pos>>();
ecs.register::<sync_interp::InterpBuffer<comp::Ori>>(); ecs.register::<sync_interp::InterpBuffer<comp::Vel>>();
ecs.register::<sync_interp::InterpBuffer<comp::Ori>>();
}
// Register server-local components // Register server-local components
// TODO: only register on the server #[cfg(feature = "server")]
ecs.register::<comp::Last<comp::Pos>>(); {
ecs.register::<comp::Last<comp::Vel>>(); ecs.register::<comp::Last<comp::Pos>>();
ecs.register::<comp::Last<comp::Ori>>(); ecs.register::<comp::Last<comp::Vel>>();
ecs.register::<comp::Agent>(); ecs.register::<comp::Last<comp::Ori>>();
ecs.register::<comp::WaypointArea>(); ecs.register::<comp::Agent>();
ecs.register::<comp::ForceUpdate>(); ecs.register::<comp::WaypointArea>();
ecs.register::<comp::InventoryUpdate>(); ecs.register::<comp::ForceUpdate>();
ecs.register::<comp::Waypoint>(); ecs.register::<comp::InventoryUpdate>();
ecs.register::<comp::MapMarker>(); ecs.register::<comp::Waypoint>();
ecs.register::<comp::Projectile>(); ecs.register::<comp::MapMarker>();
ecs.register::<comp::Melee>(); ecs.register::<comp::Projectile>();
ecs.register::<comp::ItemDrops>(); ecs.register::<comp::Melee>();
ecs.register::<comp::ChatMode>(); ecs.register::<comp::ItemDrops>();
ecs.register::<comp::Faction>(); ecs.register::<comp::ChatMode>();
ecs.register::<comp::invite::Invite>(); ecs.register::<comp::Faction>();
ecs.register::<comp::invite::PendingInvites>(); ecs.register::<comp::invite::Invite>();
ecs.register::<comp::Beam>(); ecs.register::<comp::invite::PendingInvites>();
ecs.register::<VolumeRiders>(); ecs.register::<comp::Beam>();
ecs.register::<VolumeRiders>();
}
// Register synced resources used by the ECS. // Register synced resources used by the ECS.
ecs.insert(TimeOfDay(0.0)); ecs.insert(TimeOfDay(0.0));
@ -291,15 +295,17 @@ impl State {
tracing::trace!(?slow_limit, "Slow Thread limit"); tracing::trace!(?slow_limit, "Slow Thread limit");
ecs.insert(SlowJobPool::new(slow_limit, 10_000, thread_pool)); ecs.insert(SlowJobPool::new(slow_limit, 10_000, thread_pool));
// TODO: only register on the server #[cfg(feature = "server")]
ecs.insert(EventBus::<ServerEvent>::default()); {
ecs.insert(comp::group::GroupManager::default()); ecs.insert(EventBus::<ServerEvent>::default());
ecs.insert(RegionMap::new()); ecs.insert(comp::group::GroupManager::default());
ecs.insert(SysMetrics::default()); ecs.insert(RegionMap::new());
ecs.insert(PhysicsMetrics::default()); ecs.insert(SysMetrics::default());
ecs.insert(Trades::default()); ecs.insert(PhysicsMetrics::default());
ecs.insert(PlayerPhysicsSettings::default()); ecs.insert(Trades::default());
ecs.insert(VolumeRiders::default()); ecs.insert(PlayerPhysicsSettings::default());
ecs.insert(VolumeRiders::default());
}
// Load plugins from asset directory // Load plugins from asset directory
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]

View File

@ -35,4 +35,4 @@ specs = { workspace = true, features = ["serde", "storage-event-control", "deriv
[dev-dependencies] [dev-dependencies]
# Setup a State # Setup a State
common-state = { package = "veloren-common-state", path = "../state" } common-state = { package = "veloren-common-state", path = "../state", features = ["server"] }

View File

@ -19,7 +19,7 @@ default = ["worldgen", "plugins", "persistent_world", "simd"]
common = { package = "veloren-common", path = "../common" } common = { package = "veloren-common", path = "../common" }
common-base = { package = "veloren-common-base", path = "../common/base" } common-base = { package = "veloren-common-base", path = "../common/base" }
common-ecs = { package = "veloren-common-ecs", path = "../common/ecs" } common-ecs = { package = "veloren-common-ecs", path = "../common/ecs" }
common-state = { package = "veloren-common-state", path = "../common/state" } common-state = { package = "veloren-common-state", path = "../common/state", features = ["server"] }
common-systems = { package = "veloren-common-systems", path = "../common/systems" } common-systems = { package = "veloren-common-systems", path = "../common/systems" }
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" }

View File

@ -47,7 +47,7 @@ common-base = {package = "veloren-common-base", path = "../common/base"}
common-ecs = {package = "veloren-common-ecs", path = "../common/ecs"} common-ecs = {package = "veloren-common-ecs", path = "../common/ecs"}
common-frontend = {package = "veloren-common-frontend", path = "../common/frontend"} common-frontend = {package = "veloren-common-frontend", path = "../common/frontend"}
common-net = {package = "veloren-common-net", path = "../common/net"} common-net = {package = "veloren-common-net", path = "../common/net"}
common-state = {package = "veloren-common-state", path = "../common/state"} common-state = {package = "veloren-common-state", path = "../common/state", features = ["client"]}
common-systems = {package = "veloren-common-systems", path = "../common/systems"} common-systems = {package = "veloren-common-systems", path = "../common/systems"}
anim = {package = "veloren-voxygen-anim", path = "anim"} anim = {package = "veloren-voxygen-anim", path = "anim"}