4 # ./demosplit.pl demo.dem
5 # splits the demo into separate demos for each map played and writes them
6 # to demo-0000.dem, demo-0001.dem ...
12 my $svc_signon = "\001";
16 die "Usage: $0 infile"
20 my $demoname = [$in =~ /^(.*)\.dem$/]->[0];
22 if not defined $demoname;
24 open my $infh, "<", $in
25 or die "open $in: $!";
31 my $cdtrack = <$infh>;
41 unless 4 == read $infh, my $length, 4;
42 $length = unpack("V", $length);
43 die "Invalid demo packet"
44 unless 12 == read $infh, my $angles, 12;
45 die "Invalid demo packet"
46 unless $length == read $infh, my($data), $length;
48 use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $data;
58 my $outname = sprintf("%s-%04d.dem", $demoname, $outnum++);
59 open $outfh, ">", $outname
60 or die "open $outname: $!";
62 print $outfh $cdtrack;
63 print "Writing to $outname...\n";
66 #die "No signon received"
68 #print $outfh pack("V", length $data);
69 #print $outfh $angles;