Skip to content

Commit

Permalink
write_bytes fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jabuwu committed Dec 26, 2023
1 parent 8bc82e0 commit f08ae6a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/c/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ pub(crate) unsafe fn enet_host_connect<S: Socket>(
enet_list_clear(&mut (*channel).incoming_reliable_commands);
enet_list_clear(&mut (*channel).incoming_unreliable_commands);
(*channel).used_reliable_windows = 0_i32 as u16;
write_bytes(
((*channel).reliable_windows).as_mut_ptr().cast::<u8>(),
0,
1,
);
write_bytes(((*channel).reliable_windows).as_mut_ptr(), 0, 16);
channel = channel.offset(1);
}
command.header.command = (ENET_PROTOCOL_COMMAND_CONNECT as i32
Expand Down
2 changes: 1 addition & 1 deletion src/c/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub(crate) unsafe fn enet_peer_reset<S: Socket>(peer: *mut ENetPeer<S>) {
(*peer).event_data = 0_i32 as u32;
(*peer).total_waiting_data = 0_i32 as usize;
(*peer).flags = 0_i32 as u16;
write_bytes(((*peer).unsequenced_window).as_mut_ptr(), 0, 1);
write_bytes(((*peer).unsequenced_window).as_mut_ptr(), 0, 32);
enet_peer_reset_queues(peer);
}
pub(crate) unsafe fn enet_peer_ping<S: Socket>(peer: *mut ENetPeer<S>) {
Expand Down
4 changes: 2 additions & 2 deletions src/c/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ unsafe fn enet_protocol_handle_connect<S: Socket>(
enet_list_clear(&mut (*channel).incoming_reliable_commands);
enet_list_clear(&mut (*channel).incoming_unreliable_commands);
(*channel).used_reliable_windows = 0_i32 as u16;
write_bytes(((*channel).reliable_windows).as_mut_ptr(), 0, 1);
write_bytes(((*channel).reliable_windows).as_mut_ptr(), 0, 16);
channel = channel.offset(1);
}
mtu = u32::from_be((*command).connect.mtu);
Expand Down Expand Up @@ -753,7 +753,7 @@ unsafe fn enet_protocol_handle_send_unsequenced<S: Socket>(
unsequenced_group &= 0xffff_i32 as u32;
if unsequenced_group.wrapping_sub(index) != (*peer).incoming_unsequenced_group as u32 {
(*peer).incoming_unsequenced_group = unsequenced_group.wrapping_sub(index) as u16;
write_bytes((*peer).unsequenced_window.as_mut_ptr(), 0, 1);
write_bytes((*peer).unsequenced_window.as_mut_ptr(), 0, 32);
} else if (*peer).unsequenced_window[index.wrapping_div(32_i32 as u32) as usize]
& (1_i32 << index.wrapping_rem(32_i32 as u32)) as u32
!= 0
Expand Down

0 comments on commit f08ae6a

Please sign in to comment.