@@ -4,8 +4,7 @@ use bevy::prelude::*;
44use postcard:: experimental:: serialized_size;
55
66use super :: {
7- component_changes:: ComponentChanges , mutate_message:: MutateMessage ,
8- serialized_data:: SerializedData ,
7+ change_ranges:: ChangeRanges , mutate_message:: MutateMessage , serialized_data:: SerializedData ,
98} ;
109use crate :: server:: client_visibility:: Visibility ;
1110use 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