diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b10b67..ba855c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Games: Protocols: - Valve: Players with no name are no more added to the `players_details` field. +- Valve: Split packets are now appending in the correct order. Crate: - `MSRV` is now `1.56.1` (was `1.58.1`) diff --git a/src/protocols/valve/protocol.rs b/src/protocols/valve/protocol.rs index 231f4be..d2c8c5c 100644 --- a/src/protocols/valve/protocol.rs +++ b/src/protocols/valve/protocol.rs @@ -163,11 +163,18 @@ impl ValveProtocol { buffer.move_position_backward(1); if header == 0xFE { //the packet is split let mut main_packet = SplitPacket::new(&app, protocol, &mut buffer)?; + let mut chunk_packets = Vec::with_capacity((main_packet.total - 1) as usize); for _ in 1..main_packet.total { let new_data = self.socket.receive(Some(buffer_size))?; buffer = Bufferer::new_with_data(Endianess::Little, &new_data); let chunk_packet = SplitPacket::new(&app, protocol, &mut buffer)?; + chunk_packets.push(chunk_packet); + } + + chunk_packets.sort_by(|a, b| a.number.cmp(&b.number)); + + for chunk_packet in chunk_packets { main_packet.payload.extend(chunk_packet.payload); }