@@ -40,6 +40,8 @@ class Program
4040 private static string _recording ;
4141 private static string _tibiaDirectory = string . Empty ;
4242
43+ private static ulong _timestamp = ulong . MaxValue ;
44+
4345 private static bool _convertToNewFormat = false ;
4446 private static bool _extractItemData = false ;
4547 private static bool _extractMapData = false ;
@@ -94,6 +96,9 @@ static bool ParseArgs(string[] args)
9496 "If this parameter is not specified, and an OXR file is being used, " +
9597 "the Extract app will first try to find the equivalent client version in the ClientData folder. " +
9698 "Otherwise, it will use the default path CipSoft uses upon installation.\n " ) ;
99+ Console . WriteLine ( "[optional] --time=<seconds> or --timestamp=<seconds>: " +
100+ "<seconds> is the number of seconds from the start of the recording to stop extraction." +
101+ "If this is not specified, extraction will run until the end of the recording." ) ;
97102
98103 Console . WriteLine ( "[optional] --loglevel=[debug,info,warning,error,disabled]: " +
99104 "Sets the log level within the API. Default: error" ) ;
@@ -137,6 +142,16 @@ static bool ParseArgs(string[] args)
137142 _tibiaDirectory = splitArg [ 1 ] . Replace ( "\" " , "" ) ;
138143 }
139144 break ;
145+ case "--time" :
146+ case "--timestamp" :
147+ {
148+ if ( ! ulong . TryParse ( splitArg [ 1 ] , out _timestamp ) )
149+ {
150+ Console . WriteLine ( $ "{ splitArg [ 1 ] } is not a valid timestamp!") ;
151+ return false ;
152+ }
153+ }
154+ break ;
140155 case "--loglevel" :
141156 {
142157 _logLevel = Logger . ConvertToLogLevel ( splitArg [ 1 ] ) ;
@@ -429,13 +444,30 @@ static void Main(string[] args)
429444 return true ;
430445 } ;
431446
447+ var packetCount = 0 ;
448+ var startTimestamp = ulong . MinValue ;
432449 while ( reader . BaseStream . Position < reader . BaseStream . Length )
433450 {
434451 var packetType = PacketType . Server ;
435452 if ( isOxRecording )
436453 {
437454 packetType = ( PacketType ) reader . ReadByte ( ) ;
438455 var timestamp = reader . ReadInt64 ( ) ;
456+ // Converted recordings lack a timestamp, so we need to make an artificial one.
457+ if ( timestamp == 0 )
458+ {
459+ packetCount ++ ;
460+ timestamp = packetCount * 100 ;
461+ }
462+ else if ( startTimestamp == ulong . MinValue )
463+ {
464+ startTimestamp = ( ulong ) timestamp ;
465+ }
466+ var elapsed = ( ( ulong ) timestamp - startTimestamp ) / 1000 ;
467+ if ( elapsed >= _timestamp )
468+ {
469+ break ;
470+ }
439471 }
440472
441473 var size = reader . ReadUInt32 ( ) ;
0 commit comments