From 0a56ebc381389eb63ab5cb3c3522d9ea2475e9d8 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 1 Dec 2025 21:21:36 -0500 Subject: [PATCH] aaa ??? ?? ? ?? ???????????????????????????????????????????? i would like to explosion --- Cargo.lock | 78 +++++++------ crates/unified/Cargo.toml | 135 +++++++++++++++-------- crates/unified/src/build_meta.rs | 10 +- crates/unified/src/cli.rs | 45 ++++---- crates/unified/src/client/key_input.rs | 5 - crates/unified/src/client/mod.rs | 21 ++-- crates/unified/src/client_plugins.rs | 16 ++- crates/unified/src/main.rs | 38 ++++--- crates/unified/src/server/player/join.rs | 2 - crates/xtask/src/main.rs | 17 ++- crates/xtask/src/unified.rs | 37 +++++-- 11 files changed, 244 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 822904ebe3c43347e4751909fa369dc50c4e3fd8..0b35cf53eedd3584416b1fe4c68741dfca970f76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,7 +834,7 @@ dependencies = [ "js-sys", "notify-debouncer-full", "parking_lot", - "ron 0.10.1", + "ron", "serde", "stackfuture", "thiserror 2.0.17", @@ -994,6 +994,7 @@ dependencies = [ "const-fnv1a-hash", "log", "serde", + "sysinfo", ] [[package]] @@ -1190,7 +1191,6 @@ dependencies = [ "guillotiere", "half", "image", - "ktx2", "rectangle-pack", "ruzstd", "serde", @@ -1852,6 +1852,7 @@ dependencies = [ "bevy_image", "bevy_input", "bevy_math", + "bevy_picking", "bevy_platform", "bevy_reflect", "bevy_sprite", @@ -1865,6 +1866,7 @@ dependencies = [ "taffy", "thiserror 2.0.17", "tracing", + "uuid", ] [[package]] @@ -4563,15 +4565,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ktx2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7f53bdf698e7aa7ec916411bbdc8078135da11b66db5182675b2227f6c0d07" -dependencies = [ - "bitflags 2.10.0", -] - [[package]] name = "kurbo" version = "0.11.3" @@ -5118,6 +5111,15 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -5393,6 +5395,16 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-io-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "objc2-io-surface" version = "0.3.2" @@ -6318,20 +6330,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "ron" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd490c5b18261893f14449cbd28cb9c0b637aebf161cd77900bfdedaff21ec32" -dependencies = [ - "bitflags 2.10.0", - "once_cell", - "serde", - "serde_derive", - "typeid", - "unicode-ident", -] - [[package]] name = "roxmltree" version = "0.20.0" @@ -6893,13 +6891,11 @@ dependencies = [ "ordered-float 5.1.0", "pico-args", "rand 0.9.2", - "ron 0.12.0", "serde", "tracing-subscriber", "tracing-wasm", "url", "wasm-bindgen", - "wgpu 26.0.1", ] [[package]] @@ -7048,6 +7044,20 @@ dependencies = [ "libc", ] +[[package]] +name = "sysinfo" +version = "0.37.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" +dependencies = [ + "libc", + "memchr", + "ntapi", + "objc2-core-foundation", + "objc2-io-kit", + "windows 0.61.3", +] + [[package]] name = "taffy" version = "0.7.7" @@ -8065,14 +8075,12 @@ dependencies = [ "js-sys", "log", "naga 26.0.0", - "parking_lot", "portable-atomic", "profiling", "raw-window-handle", "smallvec", "static_assertions", "wasm-bindgen", - "wasm-bindgen-futures", "web-sys", "wgpu-core 26.0.1", "wgpu-hal 26.0.6", @@ -8104,7 +8112,7 @@ dependencies = [ "smallvec", "thiserror 2.0.17", "wgpu-core-deps-apple 25.0.0", - "wgpu-core-deps-emscripten 25.0.0", + "wgpu-core-deps-emscripten", "wgpu-core-deps-windows-linux-android 25.0.0", "wgpu-hal 25.0.2", "wgpu-types 25.0.0", @@ -8135,7 +8143,6 @@ dependencies = [ "smallvec", "thiserror 2.0.17", "wgpu-core-deps-apple 26.0.0", - "wgpu-core-deps-emscripten 26.0.0", "wgpu-core-deps-wasm", "wgpu-core-deps-windows-linux-android 26.0.0", "wgpu-hal 26.0.6", @@ -8169,15 +8176,6 @@ dependencies = [ "wgpu-hal 25.0.2", ] -[[package]] -name = "wgpu-core-deps-emscripten" -version = "26.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7670e390f416006f746b4600fdd9136455e3627f5bd763abf9a65daa216dd2d" -dependencies = [ - "wgpu-hal 26.0.6", -] - [[package]] name = "wgpu-core-deps-wasm" version = "26.0.0" diff --git a/crates/unified/Cargo.toml b/crates/unified/Cargo.toml index 1334e30b8541886649a205c7e3a9651d334d6e9c..9331ba37143d7d71587c25b7a6bc49ce6868a177 100644 --- a/crates/unified/Cargo.toml +++ b/crates/unified/Cargo.toml @@ -7,33 +7,12 @@ version = "0.1.0" [dependencies] bevy = { version = "0.17", default-features = false, features = [ - "serialize", - "tonemapping_luts", - "bevy_window", "bevy_asset", - "bevy_winit", - "bevy_render", - "bevy_core_pipeline", - "bevy_sprite", - "bevy_text", - "bevy_ui", - "bevy_color", - "bevy_input_focus", "bevy_log", - "multi_threaded", - "bevy_dev_tools", - "bevy_sprite_picking_backend", - "bevy_mesh_picking_backend", - "default_font", - "png", - "bevy_gizmos", - "bevy_post_process", - "bevy_anti_alias", - "bevy_sprite_render", - "bevy_ui_render", - "zstd_rust", - "debug" -] } + "bevy_mesh", + "bevy_state", + "multi_threaded" +]} avian2d = { version = "0.4", default-features = false, features = [ "2d", @@ -60,15 +39,12 @@ serde = { version = "1", features = ["derive"] } rand = "0.9" getrandom = { version = "0.3", features = [] } -aeronet = "0.17" -aeronet_replicon = { version = "0.17", features = ["client"] } -aeronet_websocket = { version = "0.17", features = ["client"] } -aeronet_transport = "0.17" +aeronet = { version = "0.17", optional = true } +aeronet_replicon = { version = "0.17", optional = true } +aeronet_websocket = { version = "0.17", optional = true } +aeronet_transport = { version = "0.17", optional = true } ordered-float = { version = "5", features = ["serde"] } -ron = "0.12" - -wgpu = "*" pico-args = "0.5" @@ -81,27 +57,98 @@ good_lp = { version = "1.14", default-features = false, features = ["clarabel"], built = { version = "0.8", features = ["git2", "chrono"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -ctrlc = { version = "3.5", optional = true } +ctrlc = { version = "3.5" } [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { version = "0.2" } tracing-wasm = "0.2" console_error_panic_hook = "0.1" +# This is a chaotic mess of conditional compilation, but it significantly slims build times. +# So, sorry not sorry /shrug [features] -native = [ +default = [] + +# enabled when compiling to the native platform +platform_native = [ + +] +# enabled when compiling to the web platform +platform_wasm = [ + "getrandom/wasm_js", + "bevy/webgl2" +] + +# include code required to actually make connections over the network +# compiled out during development for compile time +network = [ + "dep:aeronet", + "dep:aeronet_replicon", + "dep:aeronet_transport", + "dep:aeronet_websocket" +] + +# include server code +target_server = [ +] +# include networking server code +target_net_server = [ + "network", + "aeronet_websocket/server", + "aeronet_replicon/server" +] + +# include client code +target_client = [ + "dep:leafwing-input-manager", + "dep:good_lp", + "bevy/bevy_anti_alias", + "bevy/bevy_camera", + "bevy/bevy_color", + "bevy/bevy_core_pipeline", + "bevy/bevy_gizmos", + "bevy/bevy_mesh_picking_backend", + "bevy/bevy_picking", + "bevy/bevy_post_process", + "bevy/bevy_render", + "bevy/bevy_sprite", + "bevy/bevy_sprite_picking_backend", + "bevy/bevy_picking", + "bevy/bevy_sprite_render", + "bevy/bevy_text", + "bevy/bevy_ui", + "bevy/bevy_ui_picking_backend", + "bevy/bevy_ui_render", + "bevy/bevy_window", + "bevy/bevy_winit", + "bevy/default_font", + "bevy/png", + "bevy/std", + "bevy/wayland", + "bevy/x11", + "bevy/bevy_dev_tools" +] +# include networking client code +target_net_client = [ + "network", + "aeronet_websocket/client", + "aeronet_replicon/client", +] + +# particle editor +target_particle_editor = [ + "dep:bevy_egui" +] + +# enabled in development +dev = [ + "bevy/debug", "bevy/file_watcher", - "bevy/hotpatching", "bevy/dynamic_linking", - "bevy/x11", - "bevy/wayland", - "dep:ctrlc" + "bevy/sysinfo_plugin" ] -wasm = ["getrandom/wasm_js", "bevy/webgl2"] -particle_editor = ["dep:bevy_egui"] -server = ["aeronet_websocket/server", "aeronet_replicon/server"] -client = [ - "dep:leafwing-input-manager", - "dep:good_lp" +# enable hotpatching +hotpatching = [ + "bevy/hotpatching" ] \ No newline at end of file diff --git a/crates/unified/src/build_meta.rs b/crates/unified/src/build_meta.rs index 4c25a0fa8f1a4bdc2045b562297390835c2ee204..3fd7f6f62521d5e39290b90f5c8dc2f8ae24e1e5 100644 --- a/crates/unified/src/build_meta.rs +++ b/crates/unified/src/build_meta.rs @@ -12,19 +12,19 @@ pub fn version_and_features_line() -> String { let commit = format!("{}{}", built_info::GIT_COMMIT_HASH_SHORT.unwrap_or(""), if let Some(d) = built_info::GIT_DIRTY && d { "-dirty" } else { "" }); // TODO let mut line = format!("starkingdoms v{} {commit}", env!("CARGO_PKG_VERSION")); - if cfg!(feature = "native") { + if cfg!(feature = "platform_native") { line += " +native"; } - if cfg!(feature = "wasm") { + if cfg!(feature = "platform_wasm") { line += " +wasm"; } - if cfg!(feature = "server") { + if cfg!(feature = "target_server") { line += " +server"; } - if cfg!(feature = "client") { + if cfg!(feature = "target_client") { line += " +client"; } - if cfg!(feature = "particle_editor") { + if cfg!(feature = "target_particle_editor") { line += " +particle_editor"; } diff --git a/crates/unified/src/cli.rs b/crates/unified/src/cli.rs index 73bc700bd79094f235cfcc82a9f66ed3ef504f47..baca3732165158697b0670d21d2e1a9a42ba8c44 100644 --- a/crates/unified/src/cli.rs +++ b/crates/unified/src/cli.rs @@ -1,27 +1,32 @@ use crate::build_meta::built_info::{BUILT_TIME_UTC, HOST, RUSTC_VERSION, TARGET}; use crate::build_meta::version_and_features_line; -#[cfg(not(any(feature = "client", feature = "server", feature = "particle_editor")))] +#[cfg(not(any(feature = "target_client", feature = "target_server", feature = "target_particle_editor")))] compile_error!("You need to enable one or more of client, server, particle_editor features"); -#[cfg(not(any(feature = "native", feature = "wasm")))] -compile_error!("You need to enable one of native, wasm features"); -#[cfg(all(feature = "native", feature = "wasm"))] -compile_error!("You cannot enable both native and wasm features"); +#[cfg(not(any(feature = "platform_native", feature = "platform_wasm")))] +compile_error!("You need to enable one of platform_native, platform_wasm features"); +#[cfg(all(feature = "platform_native", feature = "platform_wasm"))] +compile_error!("You cannot enable both platform_native and platform_wasm features"); + +#[cfg(all(feature = "target_server", not(feature = "target_net_server"), not(feature = "target_client")))] +compile_error!("You have disabled server networking but are not including client code. This binary will do nothing"); pub enum StkArgs { - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] Client { + #[cfg(feature = "target_net_client")] server: String, }, - #[cfg(feature = "server")] + #[cfg(feature = "target_server")] Server { + #[cfg(feature = "target_net_server")] bind_to: std::net::SocketAddr, max_clients: std::num::NonZeroUsize, tick_rate: f32, - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] with_client: bool }, - #[cfg(feature = "particle_editor")] + #[cfg(feature = "target_particle_editor")] ParticleEditor } @@ -48,23 +53,25 @@ pub fn parse_args() -> StkArgs { match subcommand.as_str() { - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] "client" => { StkArgs::Client { + #[cfg(feature = "target_net_client")] server: pargs.value_from_str(["-s", "--server"]).unwrap(), } }, - #[cfg(feature = "server")] + #[cfg(feature = "target_server")] "server" => { StkArgs::Server { + #[cfg(feature = "target_net_server")] bind_to: pargs.value_from_str(["-b", "--bind-to"]).unwrap(), max_clients: pargs.value_from_str(["-c", "--max-clients"]).unwrap(), tick_rate: pargs.value_from_str(["-r", "--tick-rate"]).unwrap(), - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] with_client: pargs.contains("--with-client"), } }, - #[cfg(feature = "particle_editor")] + #[cfg(feature = "target_particle_editor")] "particle_editor" => { StkArgs::ParticleEditor }, @@ -90,31 +97,31 @@ FLAGS: SUBCOMMANDS: "); - if cfg!(feature = "client") { + if cfg!(feature = "target_client") { println!(" client Run the client (see CLIENT for options)"); } - if cfg!(feature = "server") { + if cfg!(feature = "target_server") { println!(" server Run the server (see SERVER for options)"); } - if cfg!(feature = "particle_editor") { + if cfg!(feature = "target_particle_editor") { println!("particle_editor Run the particle editor"); } println!("\n"); - if cfg!(feature = "client") { + if cfg!(feature = "target_client") { println!("\ CLIENT: -s, --server WebSocket URL to connect to "); } - if cfg!(feature = "server") { + if cfg!(feature = "target_server") { print!("\ SERVER: -b, --bind-to Socket address to bind to -c, --max-clients Maximum number of clients to accept -r, --tick-rate Tick rate\n"); - if cfg!(feature = "client") { + if cfg!(feature = "target_client") { println!(" --with-client Start a client connected to this server"); } else { println!(); diff --git a/crates/unified/src/client/key_input.rs b/crates/unified/src/client/key_input.rs index 0fd8e696ceefe079a12107141491659da66d9142..6cb0d854432767ab0e9ab53f9e7d0cbfbed32e6c 100644 --- a/crates/unified/src/client/key_input.rs +++ b/crates/unified/src/client/key_input.rs @@ -1,4 +1,3 @@ -use bevy::dev_tools::picking_debug::DebugPickingMode; use crate::prelude::*; use bevy::{ app::{App, Update}, @@ -28,13 +27,9 @@ impl Deref for PhysicsDebugRes { fn debug_render_keybind( keys: Res>, - mut picking_debug_mode: ResMut, mut attachment_debug: ResMut, mut thruster_debug: ResMut, ) { - if keys.just_pressed(KeyCode::F4) { - *picking_debug_mode = DebugPickingMode::Noisy; - } if keys.just_pressed(KeyCode::F5) { attachment_debug.0 = !attachment_debug.0; } diff --git a/crates/unified/src/client/mod.rs b/crates/unified/src/client/mod.rs index fab47d082649c1923eb761e500118acd5d85b978..775370e36d4a8c2fc35f1fe0b2ae1ebef947837d 100644 --- a/crates/unified/src/client/mod.rs +++ b/crates/unified/src/client/mod.rs @@ -8,8 +8,8 @@ use crate::client::zoom::zoom_plugin; use crate::client::starguide::init::starguide_init_plugin; use crate::client::starguide::input::starguide_input_plugin; use crate::ecs::{Hi, StarguideGizmos}; +#[cfg(feature = "target_net_client")] use aeronet_websocket::client::WebSocketClient; -use bevy::dev_tools::picking_debug::DebugPickingMode; use crate::prelude::*; use planet::incoming_planets::incoming_planets_plugin; use crate::client::ship::attachment::client_attachment_plugin; @@ -17,6 +17,7 @@ use crate::ecs::{Me, GameplayState}; pub mod colors; pub mod key_input; +#[cfg(feature = "target_net_client")] pub mod net; pub mod particles; pub mod parts; @@ -35,8 +36,8 @@ pub struct ClientPlugin { impl Plugin for ClientPlugin { fn build(&self, app: &mut App) { let server = self.server.clone(); + #[cfg(feature = "target_net_client")] app - .add_systems(Startup, move |mut commands: Commands| { let Some(server) = server.as_ref() else { return }; let config = net::websocket_config(); @@ -44,14 +45,19 @@ impl Plugin for ClientPlugin { commands .spawn(Name::new("default-session")) .queue(WebSocketClient::connect(config, server.clone())); - }) + }); + + app .init_gizmo_group::() .add_plugins(rendering::render_plugin) .add_plugins(input::input_plugin) .add_plugins(ship::thrusters::client_thrusters_plugin) - .add_systems(Update, find_me) - .add_systems(Update, net::set_config) - .add_plugins((incoming_planets_plugin, indicators_plugin)) + .add_systems(Update, find_me); + + #[cfg(feature = "target_net_client")] + app.add_systems(Update, net::set_config); + + app.add_plugins((incoming_planets_plugin, indicators_plugin)) .add_plugins(parts_plugin) .add_plugins(key_input_plugin) .add_plugins(starfield_plugin) @@ -62,9 +68,10 @@ impl Plugin for ClientPlugin { .add_plugins(starguide_input_plugin) .add_plugins(starguide_orbit_plugin) .insert_state(GameplayState::Main) - .insert_resource(DebugPickingMode::Disabled); + .insert_resource(bevy::dev_tools::picking_debug::DebugPickingMode::Normal); // These are only needed if we're actually doing network things + #[cfg(feature = "target_net_client")] if self.server.is_some() { app.add_observer(net::on_connecting) .add_observer(net::on_connected) diff --git a/crates/unified/src/client_plugins.rs b/crates/unified/src/client_plugins.rs index 17e2cfd8fe132157ed5b841e7b3e1d8221aa636a..2d35dda527b0e72098e13081a3cc7f6bb9bc9f3e 100644 --- a/crates/unified/src/client_plugins.rs +++ b/crates/unified/src/client_plugins.rs @@ -1,8 +1,9 @@ use crate::client::ClientPlugin; +#[cfg(feature = "target_net_client")] use aeronet_replicon::client::AeronetRepliconClientPlugin; +#[cfg(feature = "target_net_client")] use aeronet_websocket::client::WebSocketClientPlugin; use bevy::app::{PluginGroup, PluginGroupBuilder}; -use bevy::dev_tools::picking_debug::DebugPickingPlugin; use bevy::ecs::schedule::ScheduleLabel; use crate::prelude::*; use bevy::ui::UiPlugin; @@ -13,11 +14,16 @@ pub struct ClientPluginGroup { } impl PluginGroup for ClientPluginGroup { fn build(self) -> PluginGroupBuilder { - PluginGroupBuilder::start::() - .add(WebSocketClientPlugin) - .add(AeronetRepliconClientPlugin) + let mut b = PluginGroupBuilder::start::(); + + #[cfg(feature = "target_net_client")] { + b = b.add(WebSocketClientPlugin); + b = b.add(AeronetRepliconClientPlugin); + } + + b + .add(bevy::dev_tools::picking_debug::DebugPickingPlugin) .add(MeshPickingPlugin) - .add(DebugPickingPlugin) .add(ClientPlugin { server: self.server, }) diff --git a/crates/unified/src/main.rs b/crates/unified/src/main.rs index b3272fc00898d9cfbaa1e6a11f0c07e663ae7815..bd2c82e199b087ec9cc1047c7bcbab684df06bdc 100644 --- a/crates/unified/src/main.rs +++ b/crates/unified/src/main.rs @@ -20,18 +20,18 @@ )] pub mod attachment; -#[cfg(feature = "client")] +#[cfg(feature = "target_client")] pub mod client; -#[cfg(feature = "client")] +#[cfg(feature = "target_client")] pub mod client_plugins; pub mod config; pub mod ecs; -#[cfg(feature = "particle_editor")] +#[cfg(feature = "target_particle_editor")] pub mod particle_editor; pub mod particles; -#[cfg(feature = "server")] +#[cfg(feature = "target_server")] pub mod server; -#[cfg(feature = "server")] +#[cfg(feature = "target_server")] pub mod server_plugins; pub mod shared_plugins; pub mod world_config; @@ -51,9 +51,9 @@ pub use wasm_entrypoint::*; use crate::cli::StkArgs; use crate::prelude::*; -#[cfg(feature = "client")] +#[cfg(feature = "target_client")] use crate::client_plugins::ClientPluginGroup; -#[cfg(feature = "server")] +#[cfg(feature = "target_server")] use crate::server_plugins::ServerPluginGroup; @@ -62,26 +62,32 @@ fn run(cli: StkArgs) -> AppExit { let mut app = App::new(); match cli { - #[cfg(feature = "client")] - StkArgs::Client { server } => { + #[cfg(feature = "target_client")] + StkArgs::Client { + #[cfg(feature = "target_net_client")] + server + } => { app.add_plugins( DefaultPlugins.build() .disable::() .disable::() ); + + #[cfg(feature = "target_net_client")] app.add_plugins(ClientPluginGroup { server: Some(server) }); + app.add_plugins(ClientPluginGroup { server: None }); app.add_plugins(shared_plugins::SharedPluginGroup); } - #[cfg(feature = "server")] + #[cfg(feature = "target_server")] StkArgs::Server { bind_to, tick_rate, max_clients, - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] with_client } => { let mut with_client_all = false; - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] if with_client { with_client_all = true; app.add_plugins( @@ -113,7 +119,7 @@ fn run(cli: StkArgs) -> AppExit { max_clients: max_clients.into(), }.build(); - #[cfg(feature = "client")] + #[cfg(feature = "target_client")] if with_client { pg = pg.add_group(ClientPluginGroup { server: None @@ -122,7 +128,7 @@ fn run(cli: StkArgs) -> AppExit { app.add_plugins(pg); } - #[cfg(feature = "particle_editor")] + #[cfg(feature = "target_particle_editor")] StkArgs::ParticleEditor {} => { app.add_plugins(crate::particle_editor::particle_editor_plugin); } @@ -131,12 +137,12 @@ fn run(cli: StkArgs) -> AppExit { app.run() } -#[cfg(feature = "wasm")] +#[cfg(feature = "platform_wasm")] fn main() { // noop on webassembly } -#[cfg(feature = "native")] +#[cfg(feature = "platform_native")] fn main() -> AppExit { use tracing_subscriber::util::SubscriberInitExt; use bevy::log::{tracing_subscriber}; diff --git a/crates/unified/src/server/player/join.rs b/crates/unified/src/server/player/join.rs index 8f20bc7401ced1d794656bf06d859dd5e09d626b..de2fe4540611b6985c56714f6451e60c9da8f59c 100644 --- a/crates/unified/src/server/player/join.rs +++ b/crates/unified/src/server/player/join.rs @@ -71,7 +71,6 @@ pub fn handle_new_players( }); } let Some(wc) = &world_config.config else { - warn!("got a joined player, but world config is not loaded! waiting until it is..."); for joined_player in &q_new_clients { commands.entity(joined_player.0).insert(PendingPlayer); } @@ -90,7 +89,6 @@ pub fn handle_pending_players( asset_server: Res, ) { let Some(wc) = &world_config.config else { - warn!("there are pending players, but world config is not loaded! waiting until it is..."); return; }; diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 61bb03a4afa82cd6e988ed03aa71058b2acad920..27d89e4769b682afd07452e905c81a9797558618 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -1,7 +1,7 @@ use std::io::{stdout, Write}; use colored::Colorize; use qsv_tabwriter::TabWriter; -use crate::unified::{RunClientNative, RunListenServerNative, RunServerNative}; +use crate::unified::{RunClientNative, RunListenServerNative, RunServerNative, RunSingleplayerNative}; use crate::unified_web::RunClientWeb; mod unified; @@ -34,14 +34,13 @@ pub trait Task { } fn tasks() -> Vec> { - let mut v: Vec> = vec![]; - - v.push(Box::new(RunClientNative)); - v.push(Box::new(RunServerNative)); - v.push(Box::new(RunClientWeb)); - v.push(Box::new(RunListenServerNative)); - - v + vec![ + Box::new(RunClientNative), + Box::new(RunServerNative), + Box::new(RunClientWeb), + Box::new(RunListenServerNative), + Box::new(RunSingleplayerNative) + ] } fn print_tasks() { diff --git a/crates/xtask/src/unified.rs b/crates/xtask/src/unified.rs index c058b73a27113d06b48e0e116fbecf3e4ce3b537..a04407b2d4b43f4c6022f2dd52292c21a073221f 100644 --- a/crates/xtask/src/unified.rs +++ b/crates/xtask/src/unified.rs @@ -19,7 +19,28 @@ impl Task for RunServerNative { args.join(" ") }; set_current_dir(workspace_dir().join("crates/unified/")).unwrap(); - cargo(format!("run -F native -F server --package starkingdoms -- server {args}")); + cargo(format!("run -F platform_native -F target_net_server -F target_server -F dev --package starkingdoms -- server {args}")); + } +} + +#[derive(Default)] +pub struct RunClientNative; +impl Task for RunClientNative { + fn name(&self) -> &'static str { + "unified:client" + } + fn help(&self) -> &'static str { + "Run the client (native)" + } + + fn run(&self, args: Vec) { + let args = if args.is_empty() { + "-s ws://[::1]:5151".to_string() + } else { + args.join(" ") + }; + set_current_dir(workspace_dir().join("crates/unified/")).unwrap(); + cargo(format!("run -F platform_native -F target_client -F target_net_client -F dev --package starkingdoms -- client {args}")); } } @@ -40,27 +61,27 @@ impl Task for RunListenServerNative { args.join(" ") }; set_current_dir(workspace_dir().join("crates/unified/")).unwrap(); - cargo(format!("run -F native -F server -F client --package starkingdoms -- server {args}")); + cargo(format!("run -F platform_native -F target_net_server -F target_server -F target_client -F dev --package starkingdoms -- server {args}")); } } #[derive(Default)] -pub struct RunClientNative; -impl Task for RunClientNative { +pub struct RunSingleplayerNative; +impl Task for RunSingleplayerNative { fn name(&self) -> &'static str { - "unified:client" + "unified:singleplayer" } fn help(&self) -> &'static str { - "Run the client (native)" + "Run a singleplayer game with networking disabled (native)" } fn run(&self, args: Vec) { let args = if args.is_empty() { - "-s [::]:5151".to_string() + "-r 60 -c 10 --with-client".to_string() } else { args.join(" ") }; set_current_dir(workspace_dir().join("crates/unified/")).unwrap(); - cargo(format!("run -F native -F client --package starkingdoms -- client {args}")); + cargo(format!("run -F target_server -F target_client -F dev --package starkingdoms -- server {args}")); } } \ No newline at end of file