renamings and using unstable sort according to a code review

This commit is contained in:
Marcel Märtens 2022-05-11 21:50:14 +02:00
parent 637e63fbe2
commit 1b76874342
7 changed files with 18 additions and 16 deletions

View File

@ -14,7 +14,7 @@ use vek::Vec2;
/// send to MULTIPLE clients
/// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds
#[derive(Debug, PartialEq)]
pub struct ChunkSendQueue {
pub struct ChunkSendEntry {
pub(crate) entity: Entity,
pub(crate) chunk_key: Vec2<i32>,
}

View File

@ -218,7 +218,9 @@ impl Client {
pub(crate) fn terrain_params(&self) -> StreamParams { self.terrain_stream_params.clone() }
pub(crate) fn prepare_terrain(
/// Only used for Serialize Chunks in a SlowJob.
/// TODO: find a more elegant version for this invariant
pub(crate) fn prepare_chunk_update_msg(
terrain_chunk_update: ServerGeneral,
params: &StreamParams,
) -> PreparedMsg {

View File

@ -249,7 +249,7 @@ impl Server {
state.ecs_mut().insert(Vec::<ChunkRequest>::new());
state
.ecs_mut()
.insert(EventBus::<chunk_serialize::ChunkSendQueue>::default());
.insert(EventBus::<chunk_serialize::ChunkSendEntry>::default());
state.ecs_mut().insert(Locations::default());
state.ecs_mut().insert(LoginProvider::new(
settings.auth_server_address.clone(),

View File

@ -1,5 +1,5 @@
use crate::{
chunk_serialize::{ChunkSendQueue, SerializedChunk},
chunk_serialize::{ChunkSendEntry, SerializedChunk},
client::Client,
metrics::NetworkRequestMetrics,
presence::Presence,
@ -23,7 +23,7 @@ impl<'a> System<'a> for Sys {
Read<'a, Tick>,
ReadStorage<'a, Client>,
ReadStorage<'a, Presence>,
ReadExpect<'a, EventBus<ChunkSendQueue>>,
ReadExpect<'a, EventBus<ChunkSendEntry>>,
ReadExpect<'a, NetworkRequestMetrics>,
ReadExpect<'a, SlowJobPool>,
ReadExpect<'a, TerrainGrid>,
@ -119,7 +119,7 @@ impl<'a> System<'a> for Sys {
let chunk_sender = chunk_sender.clone();
slow_jobs.spawn("CHUNK_SERIALIZER", move || {
for (chunk, chunk_key, mut meta) in chunks {
let msg = Client::prepare_terrain(
let msg = Client::prepare_chunk_update_msg(
ServerGeneral::TerrainChunkUpdate {
key: chunk_key,
chunk: Ok(SerializedTerrainChunk::via_heuristic(
@ -129,7 +129,7 @@ impl<'a> System<'a> for Sys {
},
&meta.params,
);
meta.recipients.sort();
meta.recipients.sort_unstable();
meta.recipients.dedup();
if let Err(e) = chunk_sender.send(SerializedChunk {
lossy_compression: meta.lossy_compression,

View File

@ -1,5 +1,5 @@
use crate::{
chunk_serialize::ChunkSendQueue, client::Client, lod::Lod, metrics::NetworkRequestMetrics,
chunk_serialize::ChunkSendEntry, client::Client, lod::Lod, metrics::NetworkRequestMetrics,
presence::Presence, ChunkRequest,
};
use common::{
@ -22,7 +22,7 @@ impl<'a> System<'a> for Sys {
type SystemData = (
Entities<'a>,
Read<'a, EventBus<ServerEvent>>,
ReadExpect<'a, EventBus<ChunkSendQueue>>,
ReadExpect<'a, EventBus<ChunkSendEntry>>,
ReadExpect<'a, TerrainGrid>,
ReadExpect<'a, Lod>,
ReadExpect<'a, NetworkRequestMetrics>,
@ -86,7 +86,7 @@ impl<'a> System<'a> for Sys {
if in_vd {
if terrain.get_key_arc(key).is_some() {
network_metrics.chunks_served_from_memory.inc();
chunk_send_emitter.emit(ChunkSendQueue {
chunk_send_emitter.emit(ChunkSendEntry {
chunk_key: key,
entity,
});

View File

@ -7,7 +7,7 @@ use world::{IndexOwned, World};
use crate::{
chunk_generator::ChunkGenerator,
chunk_serialize::ChunkSendQueue,
chunk_serialize::ChunkSendEntry,
client::Client,
presence::{Presence, RepositionOnChunkLoad},
rtsim::RtSim,
@ -63,7 +63,7 @@ impl<'a> System<'a> for Sys {
ReadExpect<'a, SlowJobPool>,
ReadExpect<'a, IndexOwned>,
ReadExpect<'a, Arc<World>>,
ReadExpect<'a, EventBus<ChunkSendQueue>>,
ReadExpect<'a, EventBus<ChunkSendEntry>>,
WriteExpect<'a, ChunkGenerator>,
WriteExpect<'a, TerrainGrid>,
Write<'a, TerrainChanges>,
@ -268,7 +268,7 @@ impl<'a> System<'a> for Sys {
.magnitude_squared();
if adjusted_dist_sqr <= presence.view_distance.pow(2) {
chunk_send_emitter.emit(ChunkSendQueue {
chunk_send_emitter.emit(ChunkSendEntry {
entity,
chunk_key: key,
});

View File

@ -1,4 +1,4 @@
use crate::{chunk_serialize::ChunkSendQueue, client::Client, presence::Presence};
use crate::{chunk_serialize::ChunkSendEntry, client::Client, presence::Presence};
use common::{comp::Pos, event::EventBus, terrain::TerrainGrid};
use common_ecs::{Job, Origin, Phase, System};
use common_net::msg::{CompressedData, ServerGeneral};
@ -14,7 +14,7 @@ impl<'a> System<'a> for Sys {
Entities<'a>,
ReadExpect<'a, TerrainGrid>,
Read<'a, TerrainChanges>,
ReadExpect<'a, EventBus<ChunkSendQueue>>,
ReadExpect<'a, EventBus<ChunkSendEntry>>,
ReadStorage<'a, Pos>,
ReadStorage<'a, Presence>,
ReadStorage<'a, Client>,
@ -35,7 +35,7 @@ impl<'a> System<'a> for Sys {
for (entity, presence, pos) in (&entities, &presences, &positions).join() {
if super::terrain::chunk_in_vd(pos.0, *chunk_key, &terrain, presence.view_distance)
{
chunk_send_emitter.emit(ChunkSendQueue {
chunk_send_emitter.emit(ChunkSendEntry {
entity,
chunk_key: *chunk_key,
});