Skip to content

Commit 42c7904

Browse files
committed
don't send game packets when outside of the game state
1 parent 28a17f3 commit 42c7904

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

azalea-client/src/plugins/packet/game/events.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,18 @@ impl SendPacketEvent {
6363

6464
pub fn handle_outgoing_packets(
6565
mut send_packet_events: EventReader<SendPacketEvent>,
66-
mut query: Query<&mut RawConnection>,
66+
mut query: Query<(&mut RawConnection, Option<&InGameState>)>,
6767
) {
6868
for event in send_packet_events.read() {
69-
if let Ok(raw_connection) = query.get_mut(event.sent_by) {
69+
if let Ok((raw_connection, in_game_state)) = query.get_mut(event.sent_by) {
70+
if in_game_state.is_none() {
71+
error!(
72+
"Tried to send a game packet {:?} while not in game state",
73+
event.packet
74+
);
75+
continue;
76+
}
77+
7078
// debug!("Sending packet: {:?}", event.packet);
7179
if let Err(e) = raw_connection.write_packet(event.packet.clone()) {
7280
error!("Failed to send packet: {e}");

azalea-client/src/plugins/packet/game/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,10 +1503,12 @@ impl GamePacketHandler<'_> {
15031503
}
15041504

15051505
pub fn start_configuration(&mut self, _p: &ClientboundStartConfiguration) {
1506+
debug!("Got start configuration packet");
1507+
15061508
as_system::<(Commands, EventWriter<_>)>(self.ecs, |(mut commands, mut events)| {
15071509
events.send(SendPacketEvent::new(
15081510
self.player,
1509-
ServerboundConfigurationAcknowledged {},
1511+
ServerboundConfigurationAcknowledged,
15101512
));
15111513

15121514
commands

0 commit comments

Comments
 (0)