You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to speed up the initial player join, chunks surrounding the level's spawn coordinates should be loaded in memory at start-up. It would leverage chunkworker and likely be called in the level initialization.
A likely solution is to register an Entity representing the server and then add a chunk hold on spawn chunks for that entity. This will prevent the chunks from being unloaded.
Note that you wouldn't call the chunk worker directly, since it runs on a separate thread. You have to use ChunkWorkerHandle to communicate with it.
Something like this:
let server_entity = world.create_entity().build();letmut chunk_holders = world.fetch_mut::<ChunkHolders>();let chunk_worker_handle = world.fetch::<ChunkWorkerHandler>();// Pre-load spawn area and prevent it from being unloaded.let view_distance = i32::from(world.fetch::<Arc<Config>>().server.view_distance);for x in -view_distance..=view_distance {for z in -view_distance..=view_distance {let chunk = ChunkPosition::new(x, z);
chunk_logic::load_chunk(chunk_worker_handle, chunk);
chunk_holders.add_for_chunk(chunk, server_entity);}}
Although it's not like joining takes all that long, at least in release mode. The main overhead for join times is chunk sending, not loading, according to my profile tests.
Activity
caelunshun commentedon Sep 3, 2019
A likely solution is to register an
Entityrepresenting the server and then add a chunk hold on spawn chunks for that entity. This will prevent the chunks from being unloaded.Note that you wouldn't call the chunk worker directly, since it runs on a separate thread. You have to use
ChunkWorkerHandleto communicate with it.Something like this:
caelunshun commentedon Sep 3, 2019
Although it's not like joining takes all that long, at least in release mode. The main overhead for join times is chunk sending, not loading, according to my profile tests.