@@ -37,7 +37,7 @@ use tf_demo_parser::{
3737use weapons:: Weapon ;
3838
3939const SECTION_SIZE : usize = 1024 ;
40- const SHOW_UNKNOWN_ENTITIES : bool = false ;
40+ const SHOW_UNKNOWN_ENTITIES : bool = true ;
4141
4242#[ derive( Debug , Serialize ) ]
4343enum Command {
@@ -48,6 +48,7 @@ enum Command {
4848 FrameToTick ,
4949 Analysis ,
5050 Prefetch ( bool ) ,
51+ DumpUnknown ( usize ) ,
5152}
5253
5354impl Command {
@@ -80,6 +81,11 @@ impl Command {
8081 return Some ( Self :: Prefetch ( prefetch) ) ;
8182 }
8283 }
84+ if command. starts_with ( "dump" ) {
85+ if let Ok ( frame) = arg. parse ( ) {
86+ return Some ( Self :: DumpUnknown ( frame) ) ;
87+ }
88+ }
8389 }
8490 None
8591 }
@@ -406,6 +412,27 @@ pub(crate) fn run() -> Result<(), Box<dyn Error>> {
406412 output_writer. write_result ( "Prefetching disabled" ) ?;
407413 }
408414 }
415+ Command :: DumpUnknown ( frame) => {
416+ if let Some ( DemoPlayerState { player, frame_to_tick, .. } ) = demo_player_state. as_mut ( ) {
417+ if frame < frame_to_tick. len ( ) {
418+ let section_idx = frame / SECTION_SIZE ;
419+ let frame_idx = frame % SECTION_SIZE ;
420+ let section = & mut player. sections [ section_idx] ;
421+ let mut ticker = section. ticker . clone ( ) ;
422+ for _ in 0 ..frame_idx {
423+ ticker. tick ( ) . unwrap_or_default ( ) ;
424+ }
425+ dbg ! ( & ticker. state( ) . other_entities. iter( ) . filter( |elm| elm. 1 . position. x != 0.0 && elm. 1 . position. y != 0.0 && elm. 1 . position. z != 0.0
426+ && elm. 1 . entity_content != EntityContent :: Other { class_name: String :: from( "CTFWearable" ) }
427+ && elm. 1 . entity_content != EntityContent :: Other { class_name: String :: from( "CTFRagdoll" ) }
428+ ) . collect:: <Vec <_>>( ) ) ;
429+ } else {
430+ output_writer. write_error ( "Seeking to a frame out of bound" . into ( ) ) ?;
431+ }
432+ } else {
433+ output_writer. write_error ( "No demo loaded" . into ( ) ) ?;
434+ }
435+ }
409436 }
410437 } else {
411438 output_writer. write_error ( format ! ( "Can't parse command: \" {}\" " , & line) . into ( ) ) ?;
@@ -569,8 +596,14 @@ impl MessageHandler for DemoAnalyzer {
569596 }
570597 }
571598
572- fn handle_data_tables ( & mut self , _tables : & [ ParseSendTable ] , server_classes : & [ ServerClass ] ) {
599+ fn handle_data_tables ( & mut self , tables : & [ ParseSendTable ] , server_classes : & [ ServerClass ] ) {
573600 self . class_names = server_classes. iter ( ) . map ( |class| & class. name ) . cloned ( ) . collect ( ) ;
601+
602+ for table in tables {
603+ for prop_def in & table. props {
604+ self . prop_names . insert ( prop_def. identifier ( ) , ( table. name . clone ( ) , prop_def. name . clone ( ) ) ) ;
605+ }
606+ }
574607 }
575608}
576609
@@ -746,6 +779,15 @@ impl DemoAnalyzer {
746779 "m_angRotation" => entry. rotation = Vector :: try_from ( & prop. value ) . unwrap_or_default ( ) ,
747780 _ => { }
748781 }
782+ // if prop_name.as_str() == "m_vecOrigin" || prop_name.as_str() == "m_angRotation" {
783+ // if let Ok(value) = Vector::try_from(&prop.value) {
784+ // if value.x == 0.0 && value.y == 0.0 && value.z == 0.0 {continue;}
785+ // dbg!(value);
786+ // dbg!(&self.state);
787+ // panic!("");
788+
789+ // }
790+ // }
749791 }
750792 }
751793 }
0 commit comments