diff --git a/CHANGELOG.md b/CHANGELOG.md index e2f4374bed..9f8279eda9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Portals that spawn in place of the last staircase at old style dungeons to prevent stair cheesing - Mutliple singleplayer worlds and map generation UI. - New arena building in desert cities, suitable for PVP, also NPCs like to watch the fights too +- The loading screen now displays status updates for singleplayer server and client initialization progress ### Changed diff --git a/Cargo.lock b/Cargo.lock index 543bfe3b2f..46ea56fcca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6785,7 +6785,6 @@ dependencies = [ "authc", "byteorder", "clap", - "crossbeam-channel", "hashbrown 0.13.2", "image", "num 0.4.1", diff --git a/assets/voxygen/i18n/en/hud/misc.ftl b/assets/voxygen/i18n/en/hud/misc.ftl index 9dfc2a1254..4365dfc75f 100644 --- a/assets/voxygen/i18n/en/hud/misc.ftl +++ b/assets/voxygen/i18n/en/hud/misc.ftl @@ -61,18 +61,18 @@ hud-sit = Sit hud-steer = Steer hud-portal = Portal hud-init-stage-singleplayer = Starting singleplayer server... -hud-init-stage-server-db-migrations = [{ common-server }]: Applying database migrations -hud-init-stage-server-db-vacuum = [{ common-server }]: Cleaning up database +hud-init-stage-server-db-migrations = [{ common-server }]: Applying database migrations... +hud-init-stage-server-db-vacuum = [{ common-server }]: Cleaning up database... hud-init-stage-server-worldsim-erosion = [{ common-server }]: Erosion { $percentage }% hud-init-stage-server-worldciv-civcreate = [{ common-server }]: Generated { $generated } out of { $total } civilizations -hud-init-stage-server-worldciv-site = [{ common-server }]: Generating sites -hud-init-stage-server-economysim = [{ common-server }]: Simulating economy -hud-init-stage-server-spotgen = [{ common-server }]: Generating spots +hud-init-stage-server-worldciv-site = [{ common-server }]: Generating sites... +hud-init-stage-server-economysim = [{ common-server }]: Simulating economy... +hud-init-stage-server-spotgen = [{ common-server }]: Generating spots... hud-init-stage-server-starting = [{ common-server }]: Starting server... hud-init-stage-multiplayer = Starting multiplayer -hud-init-stage-client-connection-establish = [{ common-client }]: Establishing connection to server -hud-init-stage-client-request-server-version = [{ common-client }]: Wating for server version -hud-init-stage-client-authentication = [{ common-client }]: Authenticating -hud-init-stage-client-load-init-data = [{ common-client }]: Loading initialization data from server +hud-init-stage-client-connection-establish = [{ common-client }]: Establishing connection to server... +hud-init-stage-client-request-server-version = [{ common-client }]: Waiting for server version... +hud-init-stage-client-authentication = [{ common-client }]: Authenticating... +hud-init-stage-client-load-init-data = [{ common-client }]: Loading initialization data from server... hud-init-stage-client-starting-client = [{ common-client }]: Preparing Client... hud-init-stage-render-pipeline = Creating render pipeline ({ $done }/{ $total }) diff --git a/client/Cargo.toml b/client/Cargo.toml index 30c94e5e23..f459225045 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -30,7 +30,6 @@ tracing = { workspace = true } rayon = { workspace = true } specs = { workspace = true, features = ["serde", "storage-event-control", "derive"] } vek = { workspace = true } -crossbeam-channel = { workspace = true } hashbrown = { workspace = true } authc = { git = "https://gitlab.com/veloren/auth.git", rev = "abb1a705827984e11706d7bb97fb7a459e1e6533" } # xMAC94x/current_master_till_refactored branch diff --git a/client/src/bin/bot/main.rs b/client/src/bin/bot/main.rs index ca7298d81b..473aef4219 100644 --- a/client/src/bin/bot/main.rs +++ b/client/src/bin/bot/main.rs @@ -72,6 +72,7 @@ pub fn make_client( username, password, |_| true, + Arc::new(|_| {}) )) .ok() } diff --git a/client/src/lib.rs b/client/src/lib.rs index d5bfcbe50b..5ab3b6678e 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -66,7 +66,6 @@ use common_net::{ use common_state::State; use common_systems::add_local_systems; use comp::BuffKind; -use crossbeam_channel::Sender; use hashbrown::{HashMap, HashSet}; use image::DynamicImage; use network::{ConnectAddr, Network, Participant, Pid, Stream}; @@ -307,17 +306,11 @@ impl Client { username: &str, password: &str, auth_trusted: impl FnMut(&str) -> bool, - init_stage_update: Option>, + init_stage_update: Arc, ) -> Result { - let update_stage = |stage: ClientInitStage| { - if let Some(updater) = &init_stage_update { - let _ = updater.send(stage); - } - }; - let network = Network::new(Pid::new(), &runtime); - update_stage(ClientInitStage::ConnectionEstablish); + init_stage_update(ClientInitStage::ConnectionEstablish); let mut participant = match addr { ConnectionArgs::Tcp { hostname, @@ -347,7 +340,7 @@ impl Client { let in_game_stream = participant.opened().await?; let terrain_stream = participant.opened().await?; - update_stage(ClientInitStage::WatingForServerVersion); + init_stage_update(ClientInitStage::WatingForServerVersion); register_stream.send(ClientType::Game)?; let server_info: ServerInfo = register_stream.recv().await?; if server_info.git_hash != *common::util::GIT_HASH { @@ -366,7 +359,7 @@ impl Client { ping_stream.send(PingMsg::Ping)?; - update_stage(ClientInitStage::Authentication); + init_stage_update(ClientInitStage::Authentication); // Register client Self::register( username, @@ -377,7 +370,7 @@ impl Client { ) .await?; - update_stage(ClientInitStage::LoadingInitData); + init_stage_update(ClientInitStage::LoadingInitData); // Wait for initial sync let mut ping_interval = tokio::time::interval(Duration::from_secs(1)); let ServerInit::GameSync { @@ -401,7 +394,7 @@ impl Client { } }; - update_stage(ClientInitStage::StartingClient); + init_stage_update(ClientInitStage::StartingClient); // Spawn in a blocking thread (leaving the network thread free). This is mostly // useful for bots. let mut task = tokio::task::spawn_blocking(move || { @@ -3007,7 +3000,7 @@ mod tests { username, password, |suggestion: &str| suggestion == auth_server, - None, + Arc::new(|_| {}), )); let localisation = LocalizationHandle::load_expect("en"); diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 1a26846b3e..aa2803d2e2 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -192,7 +192,7 @@ fn main() -> io::Result<()> { editable_settings, database_settings, &server_data_dir, - None, + Arc::new(|_| {}), runtime, ) .expect("Failed to create server instance!"); diff --git a/server/src/lib.rs b/server/src/lib.rs index a86271834b..8264bd3128 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -118,7 +118,6 @@ use crate::{ persistence::{DatabaseSettings, SqlLogMode}, sys::terrain, }; -use crossbeam_channel::Sender; use hashbrown::HashMap; use std::sync::RwLock; @@ -200,6 +199,7 @@ pub struct ChunkRequest { key: Vec2, } +#[derive(Debug)] pub enum ServerInitStage { DbMigrations, DbVacuum, @@ -230,7 +230,7 @@ impl Server { editable_settings: EditableSettings, database_settings: DatabaseSettings, data_dir: &std::path::Path, - stage_report_tx: Option>, + report_stage: Arc, runtime: Arc, ) -> Result { prof_span!("Server::new"); @@ -239,12 +239,6 @@ impl Server { info!("Authentication is disabled"); } - let report_stage = |stage: ServerInitStage| { - if let Some(stage_report_tx) = &stage_report_tx { - let _ = stage_report_tx.send(stage); - } - }; - report_stage(ServerInitStage::DbMigrations); // Run pending DB migrations (if any) debug!("Running DB migrations..."); @@ -271,7 +265,6 @@ impl Server { let pools = State::pools(GameMode::Server); - let world_generate_status_tx = stage_report_tx.clone(); #[cfg(feature = "worldgen")] let (world, index) = World::generate( settings.world_seed, @@ -286,11 +279,12 @@ impl Server { calendar: Some(settings.calendar_mode.calendar_now()), }, &pools, - Arc::new(move |stage| { - if let Some(stage_report_tx) = &world_generate_status_tx { - let _ = stage_report_tx.send(ServerInitStage::WorldGen(stage)); - } - }), + { + let report_stage = Arc::clone(&report_stage); + Arc::new(move |stage| { + report_stage(ServerInitStage::WorldGen(stage)); + }) + }, ); #[cfg(not(feature = "worldgen"))] let (world, index) = World::generate(settings.world_seed); diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index 55720bfcc8..1e73832a0a 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -52,7 +52,7 @@ impl ClientInit { ) -> Self { let (tx, rx) = unbounded(); let (trust_tx, trust_rx) = unbounded(); - let (init_stage_tx, init_stare_rx) = unbounded(); + let (init_stage_tx, init_stage_rx) = unbounded(); let cancel = Arc::new(AtomicBool::new(false)); let cancel2 = Arc::clone(&cancel); @@ -69,13 +69,17 @@ impl ClientInit { let mut last_err = None; + let client_stage_reporter: Arc = + Arc::new(move |stage| { + let _ = init_stage_tx.send(stage); + }); + const FOUR_MINUTES_RETRIES: u64 = 48; 'tries: for _ in 0..FOUR_MINUTES_RETRIES { if cancel2.load(Ordering::Relaxed) { break; } let mut mismatched_server_info = None; - let new_init_tx = init_stage_tx.clone(); match Client::new( connection_args.clone(), Arc::clone(&runtime2), @@ -83,7 +87,7 @@ impl ClientInit { &username, &password, trust_fn, - Some(new_init_tx), + Arc::clone(&client_stage_reporter), ) .await { @@ -120,7 +124,7 @@ impl ClientInit { ClientInit { rx, - stage_rx: init_stare_rx, + stage_rx: init_stage_rx, trust_tx, cancel, } diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index be1e9833a1..74ebb0a4e4 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -27,8 +27,8 @@ use tokio::runtime; use tracing::error; use ui::{Event as MainMenuEvent, MainMenuUi}; +#[derive(Debug)] pub enum DetailedInitializationStage { - // TODO: Map generation and server startup progress Singleplayer, SingleplayerServer(ServerInitStage), StartingMultiplayer, diff --git a/voxygen/src/menu/main/ui/connecting.rs b/voxygen/src/menu/main/ui/connecting.rs index 8db3fb3efd..b57500ee3e 100644 --- a/voxygen/src/menu/main/ui/connecting.rs +++ b/voxygen/src/menu/main/ui/connecting.rs @@ -206,11 +206,11 @@ impl Screen { ), }; - Container::new(Text::new(stage_message).size(fonts.cyri.scale(25))) + Container::new(Text::new(stage_message).size(fonts.cyri.scale(20))) .width(Length::Fill) .height(Length::Fill) .padding(10) - .align_y(Align::End) + .align_x(Align::Start) .into() }; diff --git a/voxygen/src/menu/main/ui/mod.rs b/voxygen/src/menu/main/ui/mod.rs index e2b65c8457..2668ad2c7e 100644 --- a/voxygen/src/menu/main/ui/mod.rs +++ b/voxygen/src/menu/main/ui/mod.rs @@ -728,6 +728,7 @@ impl MainMenuUi { pub fn show_info(&mut self, msg: String) { self.controls.connection_error(msg); } pub fn update_stage(&mut self, stage: DetailedInitializationStage) { + tracing::trace!(?stage, "Updating stage"); self.controls.init_stage(stage); } diff --git a/voxygen/src/singleplayer/mod.rs b/voxygen/src/singleplayer/mod.rs index 7d6fa7f84d..2682fe64a2 100644 --- a/voxygen/src/singleplayer/mod.rs +++ b/voxygen/src/singleplayer/mod.rs @@ -122,7 +122,9 @@ impl SingleplayerState { editable_settings, database_settings, &server_data_dir, - Some(server_stage_tx), + Arc::new(move |init_stage| { + let _ = server_stage_tx.send(init_stage); + }), runtime, ) { Ok(server) => (Some(server), Ok(())), diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index c02a04ac76..81fc1e4db4 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -224,6 +224,7 @@ impl<'a, R: Rng> GenCtx<'a, R> { } } +#[derive(Debug)] pub enum WorldCivStage { /// Civilization creation, how many out of how many civilizations have been /// generated yet diff --git a/world/src/lib.rs b/world/src/lib.rs index f0fd5f266d..74c86e7145 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -87,6 +87,7 @@ pub enum Error { Other(String), } +#[derive(Debug)] pub enum WorldGenerateStage { WorldSimGenerate(WorldSimStage), WorldCivGenerate(WorldCivStage), diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 460da29b8b..cf9e0ff93c 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -646,6 +646,7 @@ impl WorldFile { } } +#[derive(Debug)] pub enum WorldSimStage { // TODO: Add more stages Erosion(f64),