veloren_server/
chunk_serialize.rs

1use crate::client::PreparedMsg;
2use specs::Entity;
3use vek::Vec2;
4
5/// Sending a chunk to the user works the following way:
6/// A system like `msg::terrain` `terrain` or `terrain_sync` either decide to
7/// trigger chunk generation, or if the chunk already exists
8/// push a `ChunkSendQueue` to the eventbus.
9/// The `chunk_serialize` system will coordinate serializing via a SlowJob
10/// outside of the tick. On the next tick, the `chunk_send` system will pick up
11/// finished chunks.
12///
13/// Deferring allows us to remove code duplication and maybe serialize ONCE,
14/// send to MULTIPLE clients
15/// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds
16#[derive(Debug, PartialEq, Eq)]
17pub struct ChunkSendEntry {
18    pub(crate) entity: Entity,
19    pub(crate) chunk_key: Vec2<i32>,
20}
21
22pub struct SerializedChunk {
23    pub(crate) lossy_compression: bool,
24    pub(crate) msg: PreparedMsg,
25    pub(crate) recipients: Vec<Entity>,
26}