Skip to content

Commit fe0a8be

Browse files
committed
fix: xp being properly set
1 parent a5620ae commit fe0a8be

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

crates/hyperion/src/egress/sync_entity_state.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ impl Module for EntityStateSyncModule {
4242
.kind::<flecs::pipeline::OnStore>()
4343
.run(|mut table| {
4444
while table.next() {
45-
let count = table.count();
4645
let world = table.world();
4746

4847
unsafe {
@@ -57,30 +56,17 @@ impl Module for EntityStateSyncModule {
5756

5857
let mut prev_xp = table.field_unchecked::<Xp>(2);
5958
let prev_xp = prev_xp.get_mut(..).unwrap();
60-
let prev_xp: &mut [u16] =
61-
core::slice::from_raw_parts_mut(prev_xp.as_mut_ptr().cast(), count);
62-
63-
// debug_assert_eq!(
64-
// prev_xp.as_ptr() as usize & 63,
65-
// 0,
66-
// "prev_xp is not 64-byte aligned"
67-
// );
6859

6960
let mut xp = table.field_unchecked::<Xp>(3);
7061
let xp = xp.get_mut(..).unwrap();
71-
let xp: &mut [u16] =
72-
core::slice::from_raw_parts_mut(xp.as_mut_ptr().cast(), count);
73-
74-
// debug_assert_eq!(xp.as_ptr() as usize & 63, 0, "xp is not 64-byte aligned");
7562

7663
for (idx, (prev, current)) in itertools::zip_eq(prev_xp, xp).enumerate() {
77-
if prev != current {
64+
if prev == current {
7865
continue;
7966
}
8067

8168
let net = net.get(idx).unwrap();
8269

83-
let current = Xp::from(*current);
8470
let visual = current.get_visual();
8571

8672
let packet = play::ExperienceBarUpdateS2c {
@@ -92,6 +78,8 @@ impl Module for EntityStateSyncModule {
9278
compose
9379
.unicast(&packet, *net, SystemId(100), &world)
9480
.unwrap();
81+
82+
*prev = *current;
9583
}
9684
}
9785
}

0 commit comments

Comments
 (0)