mirror of
https://github.com/demostf/cutter.git
synced 2026-06-03 11:54:08 +02:00
test fix
This commit is contained in:
parent
57ee813af7
commit
faa0fe1db7
2 changed files with 19 additions and 13 deletions
18
src/lib.rs
18
src/lib.rs
|
|
@ -151,11 +151,11 @@ pub fn cut(input: &[u8], start_tick: u32, end_tick: u32) -> Vec<u8> {
|
||||||
let ty = packet.packet_type();
|
let ty = packet.packet_type();
|
||||||
let original_tick = packet.tick();
|
let original_tick = packet.tick();
|
||||||
packet.set_tick(original_tick - start_tick);
|
packet.set_tick(original_tick - start_tick);
|
||||||
if ty != PacketType::ConsoleCmd {
|
// if ty != PacketType::ConsoleCmd {
|
||||||
packet
|
packet
|
||||||
.encode(&mut out_stream, &handler.state_handler)
|
.encode(&mut out_stream, &handler.state_handler)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
// }
|
||||||
handler.handle_packet(packet).unwrap();
|
handler.handle_packet(packet).unwrap();
|
||||||
|
|
||||||
if original_tick >= end_tick {
|
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();
|
PacketType::Stop.write(&mut out_stream).unwrap();
|
||||||
StopPacket { tick: end_tick }
|
StopPacket {
|
||||||
.encode(&mut out_stream, &handler.state_handler)
|
tick: end_tick - start_tick,
|
||||||
.unwrap();
|
}
|
||||||
|
.encode(&mut out_stream, &handler.state_handler)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
out_buffer
|
out_buffer
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,10 @@ fn test_reparse_with_analyser<A: BorrowMessageHandler + Default, F: Fn(&A::Outpu
|
||||||
while let (Some(original_tick), Some(cut_tick)) =
|
while let (Some(original_tick), Some(cut_tick)) =
|
||||||
(original_ticks.next().unwrap(), cut_ticks.next().unwrap())
|
(original_ticks.next().unwrap(), cut_ticks.next().unwrap())
|
||||||
{
|
{
|
||||||
|
if original_tick.tick >= 50000 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
assert_eq!(original_tick.tick, cut_tick.tick + 30000);
|
assert_eq!(original_tick.tick, cut_tick.tick + 30000);
|
||||||
// dbg!(original_tick.tick);
|
|
||||||
let original_state = &original_tick.state;
|
let original_state = &original_tick.state;
|
||||||
let cut_state = &cut_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)]
|
#[derive(Default)]
|
||||||
struct EntityDumper {
|
struct EntityDumper {
|
||||||
entities: Vec<(EntityId, Vec<SendProp>)>,
|
entities: Vec<(EntityId, (Vec<SendProp>, Vec<SendProp>))>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageHandler for EntityDumper {
|
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 {
|
fn does_handle(message_type: MessageType) -> bool {
|
||||||
match message_type {
|
match message_type {
|
||||||
|
|
@ -74,8 +76,10 @@ impl MessageHandler for EntityDumper {
|
||||||
match message {
|
match message {
|
||||||
Message::PacketEntities(entity_message) => {
|
Message::PacketEntities(entity_message) => {
|
||||||
for entity in &entity_message.entities {
|
for entity in &entity_message.entities {
|
||||||
self.entities
|
self.entities.push((
|
||||||
.push((entity.entity_index, entity.props().cloned().collect()));
|
entity.entity_index,
|
||||||
|
(entity.baseline_props.clone(), entity.props.clone()),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue