Valve Protocol: Extend split packets correctly

This commit is contained in:
CosminPerRam 2023-01-16 22:44:55 +02:00
parent f03a1de035
commit 9c9a096b16
2 changed files with 8 additions and 0 deletions

View file

@ -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`)

View file

@ -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);
}