Skip to content

Commit dd21c2f

Browse files
committed
Rename ranges struct
Just an internal rename. I think it makes the intent clearer. This will better fit the upcoming relationships support.
1 parent c86d73e commit dd21c2f

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/server/replication_messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod component_changes;
1+
mod change_ranges;
22
pub(super) mod mutate_message;
33
pub(super) mod serialized_data;
44
pub(super) mod update_message;

src/server/replication_messages/component_changes.rs renamed to src/server/replication_messages/change_ranges.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use postcard::experimental::serialized_size;
99
///
1010
/// Used inside [`UpdateMessage`](super::update_message::UpdateMessage) and
1111
/// [`MutateMessage`](super::mutate_message::MutateMessage).
12-
pub(super) struct ComponentChanges {
12+
pub(super) struct ChangeRanges {
1313
pub(super) entity: Range<usize>,
1414
pub(super) components_len: usize,
1515
pub(super) components: Vec<Range<usize>>,
1616
}
1717

18-
impl ComponentChanges {
18+
impl ChangeRanges {
1919
/// Returns serialized size.
2020
pub(super) fn size(&self) -> Result<usize> {
2121
let len_size = serialized_size(&self.components_len)?;

src/server/replication_messages/mutate_message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::{ops::Range, time::Duration};
33
use bevy::{ecs::component::Tick, prelude::*};
44
use postcard::experimental::{max_size::MaxSize, serialized_size};
55

6-
use super::{component_changes::ComponentChanges, serialized_data::SerializedData};
6+
use super::{change_ranges::ChangeRanges, serialized_data::SerializedData};
77
use crate::shared::{
88
backend::{replicon_channels::ReplicationChannel, replicon_server::RepliconServer},
99
postcard_utils,
@@ -50,7 +50,7 @@ pub(crate) struct MutateMessage {
5050
/// of chunk bytes instead of the number of components. This is because, during deserialization,
5151
/// some entities may be skipped if they have already been updated (as mutations are sent until
5252
/// the client acknowledges them).
53-
mutations: Vec<ComponentChanges>,
53+
mutations: Vec<ChangeRanges>,
5454

5555
/// Indicates that an entity has been written since the
5656
/// last call of [`Self::start_entity_mutations`].
@@ -83,7 +83,7 @@ impl MutateMessage {
8383
/// Adds an entity chunk.
8484
pub(crate) fn add_mutated_entity(&mut self, entity: Entity, entity_range: Range<usize>) {
8585
let components = self.buffer.pop().unwrap_or_default();
86-
self.mutations.push(ComponentChanges {
86+
self.mutations.push(ChangeRanges {
8787
entity: entity_range,
8888
components_len: 0,
8989
components,
@@ -103,7 +103,7 @@ impl MutateMessage {
103103
}
104104

105105
/// Returns written mutations for the last entity from [`Self::add_mutated_entity`].
106-
pub(super) fn last_mutations(&mut self) -> Option<&ComponentChanges> {
106+
pub(super) fn last_mutations(&mut self) -> Option<&ChangeRanges> {
107107
self.mutations.last()
108108
}
109109

src/server/replication_messages/update_message.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use bevy::prelude::*;
44
use postcard::experimental::serialized_size;
55

66
use super::{
7-
component_changes::ComponentChanges, mutate_message::MutateMessage,
8-
serialized_data::SerializedData,
7+
change_ranges::ChangeRanges, mutate_message::MutateMessage, serialized_data::SerializedData,
98
};
109
use crate::server::client_visibility::Visibility;
1110
use crate::shared::{
@@ -66,7 +65,7 @@ pub(crate) struct UpdateMessage {
6665
/// Serialized as a list of pairs of entity chunk and a list of
6766
/// [`FnsId`](crate::shared::replication::replication_registry::FnsId)
6867
/// serialized as a single chunk.
69-
removals: Vec<ComponentRemovals>,
68+
removals: Vec<RemovalRanges>,
7069

7170
/// Component insertions or mutations that happened in this tick.
7271
///
@@ -76,7 +75,7 @@ pub(crate) struct UpdateMessage {
7675
///
7776
/// Usually mutations are stored in [`MutateMessage`], but if an entity has any insertions or removal,
7877
/// or the entity just became visible for a client, we serialize it as part of the update message to keep entity updates atomic.
79-
changes: Vec<ComponentChanges>,
78+
changes: Vec<ChangeRanges>,
8079

8180
/// Visibility of the entity for which component changes are being written.
8281
///
@@ -115,7 +114,7 @@ impl UpdateMessage {
115114
ids_len: usize,
116115
fn_ids: Range<usize>,
117116
) {
118-
self.removals.push(ComponentRemovals {
117+
self.removals.push(RemovalRanges {
119118
entity,
120119
ids_len,
121120
fn_ids,
@@ -145,7 +144,7 @@ impl UpdateMessage {
145144
/// Adds an entity chunk.
146145
pub(crate) fn add_changed_entity(&mut self, entity: Range<usize>) {
147146
let components = self.buffer.pop().unwrap_or_default();
148-
self.changes.push(ComponentChanges {
147+
self.changes.push(ChangeRanges {
149148
entity,
150149
components_len: 0,
151150
components,
@@ -175,7 +174,7 @@ impl UpdateMessage {
175174

176175
if !self.entity_written {
177176
let components = self.buffer.pop().unwrap_or_default();
178-
let changes = ComponentChanges {
177+
let changes = ChangeRanges {
179178
entity: mutations.entity.clone(),
180179
components_len: 0,
181180
components,
@@ -229,15 +228,15 @@ impl UpdateMessage {
229228
message_size += self
230229
.removals
231230
.iter()
232-
.map(ComponentRemovals::size)
231+
.map(RemovalRanges::size)
233232
.sum::<Result<usize>>()?;
234233
}
235234
UpdateMessageFlags::CHANGES => {
236235
debug_assert_eq!(flag, last_flag);
237236
message_size += self
238237
.changes
239238
.iter()
240-
.map(ComponentChanges::size)
239+
.map(ChangeRanges::size)
241240
.sum::<Result<usize>>()?;
242241
}
243242
_ => unreachable!("iteration should yield only named flags"),
@@ -330,13 +329,13 @@ impl UpdateMessage {
330329
}
331330
}
332331

333-
struct ComponentRemovals {
332+
struct RemovalRanges {
334333
entity: Range<usize>,
335334
ids_len: usize,
336335
fn_ids: Range<usize>,
337336
}
338337

339-
impl ComponentRemovals {
338+
impl RemovalRanges {
340339
fn size(&self) -> Result<usize> {
341340
let len_size = serialized_size(&self.ids_len)?;
342341
Ok(self.entity.len() + len_size + self.fn_ids.len())

0 commit comments

Comments
 (0)