This commit is contained in:
Robin Appelman 2022-04-10 22:59:30 +02:00
commit faa0fe1db7
2 changed files with 19 additions and 13 deletions

View file

@ -151,11 +151,11 @@ pub fn cut(input: &[u8], start_tick: u32, end_tick: u32) -> Vec<u8> {
let ty = packet.packet_type();
let original_tick = packet.tick();
packet.set_tick(original_tick - start_tick);
if ty != PacketType::ConsoleCmd {
packet
.encode(&mut out_stream, &handler.state_handler)
.unwrap();
}
// if ty != PacketType::ConsoleCmd {
packet
.encode(&mut out_stream, &handler.state_handler)
.unwrap();
// }
handler.handle_packet(packet).unwrap();
if original_tick >= end_tick {
@ -163,9 +163,11 @@ pub fn cut(input: &[u8], start_tick: u32, end_tick: u32) -> Vec<u8> {
}
}
PacketType::Stop.write(&mut out_stream).unwrap();
StopPacket { tick: end_tick }
.encode(&mut out_stream, &handler.state_handler)
.unwrap();
StopPacket {
tick: end_tick - start_tick,
}
.encode(&mut out_stream, &handler.state_handler)
.unwrap();
}
out_buffer
}

View file

@ -46,8 +46,10 @@ fn test_reparse_with_analyser<A: BorrowMessageHandler + Default, F: Fn(&A::Outpu
while let (Some(original_tick), Some(cut_tick)) =
(original_ticks.next().unwrap(), cut_ticks.next().unwrap())
{
if original_tick.tick >= 50000 {
break;
}
assert_eq!(original_tick.tick, cut_tick.tick + 30000);
// dbg!(original_tick.tick);
let original_state = &original_tick.state;
let cut_state = &cut_tick.state;
@ -57,11 +59,11 @@ fn test_reparse_with_analyser<A: BorrowMessageHandler + Default, F: Fn(&A::Outpu
#[derive(Default)]
struct EntityDumper {
entities: Vec<(EntityId, Vec<SendProp>)>,
entities: Vec<(EntityId, (Vec<SendProp>, Vec<SendProp>))>,
}
impl MessageHandler for EntityDumper {
type Output = Vec<(EntityId, Vec<SendProp>)>;
type Output = Vec<(EntityId, (Vec<SendProp>, Vec<SendProp>))>;
fn does_handle(message_type: MessageType) -> bool {
match message_type {
@ -74,8 +76,10 @@ impl MessageHandler for EntityDumper {
match message {
Message::PacketEntities(entity_message) => {
for entity in &entity_message.entities {
self.entities
.push((entity.entity_index, entity.props().cloned().collect()));
self.entities.push((
entity.entity_index,
(entity.baseline_props.clone(), entity.props.clone()),
));
}
}
_ => {}