mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improvements to swarm clients: space properly for the unclustered case so that regions don't overlap, advance time manually within Client::tick_network since State::tick isn't being called
This commit is contained in:
parent
972c8ba41d
commit
6023670467
@ -123,7 +123,6 @@ fn run_client(
|
||||
|
||||
let mut tick = |client: &mut Client| -> Result<(), veloren_client::Error> {
|
||||
clock.tick();
|
||||
// TODO make sure this includes terrain loading requests
|
||||
client.tick_network(clock.dt())?;
|
||||
Ok(())
|
||||
};
|
||||
@ -199,6 +198,11 @@ fn run_client(
|
||||
tick(&mut client)?;
|
||||
}
|
||||
|
||||
// Use this check so this is only printed once
|
||||
if !to_adminify.is_empty() {
|
||||
println!("Initialization of all clients finished!");
|
||||
}
|
||||
|
||||
// Main loop
|
||||
let chunk_size = 32.0; // TODO: replace with the actual constant
|
||||
let world_center = client
|
||||
@ -207,6 +211,8 @@ fn run_client(
|
||||
.map(|e| e as f32 * chunk_size)
|
||||
/ 2.0;
|
||||
loop {
|
||||
// TODO: doesn't seem to produce an error when server is shutdown (process keeps
|
||||
// running)
|
||||
tick(&mut client)?;
|
||||
let entity = client.entity();
|
||||
// Move or stay still depending on specified options
|
||||
@ -232,7 +238,9 @@ fn position(index: u32, opt: Opt) -> Vec3<f32> {
|
||||
let spacing = if opt.clustered {
|
||||
5.0
|
||||
} else {
|
||||
opt.vd as f32 * 3.0 * chunk_size
|
||||
use common::region::REGION_SIZE;
|
||||
// Attempt to make regions subscribed to by each client not overlapping
|
||||
opt.vd as f32 * 2.0 * chunk_size + 2.0 * REGION_SIZE as f32
|
||||
};
|
||||
|
||||
// Offset to center the grid of clients
|
||||
|
@ -2486,9 +2486,11 @@ impl Client {
|
||||
/// This method is for use in testing a server with many clients connected.
|
||||
pub fn tick_network(
|
||||
&mut self,
|
||||
_dt: Duration,
|
||||
dt: Duration,
|
||||
) -> Result<(), Error> {
|
||||
span!(_guard, "tick_network", "Client::tick_network");
|
||||
// Advance state time manually since we aren't calling `State::tick`
|
||||
self.state.ecs().write_resource::<common::resources::Time>().0 += dt.as_secs_f64();
|
||||
|
||||
// Handle new messages from the server.
|
||||
self.handle_new_messages()?;
|
||||
@ -2503,7 +2505,6 @@ impl Client {
|
||||
drop(terrain);
|
||||
|
||||
// Send a ping to the server once every second
|
||||
// TODO: advance state time?
|
||||
if self.state.get_time() - self.last_server_ping > 1. {
|
||||
self.send_msg_err(PingMsg::Ping)?;
|
||||
self.last_server_ping = self.state.get_time();
|
||||
|
Loading…
Reference in New Issue
Block a user