@@ -0,0 +1,2089 @@
+package com.timepath.hl2;%0A%0Aimport com.timepath.hl2.io.demo.DemoHeader;%0Aimport com.timepath.hl2.io.demo.HL2DEM;%0Aimport com.timepath.hl2.io.demo.Message;%0Aimport com.timepath.hl2.io.demo.MessageType;%0Aimport com.timepath.io.OrderedOutputStream;%0A%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.nio.ByteOrder;%0Aimport java.util.ListIterator;%0A%0A/**%0A * .block conversion:%0A * (for f in *.block; do bzcat $f; done) %3E join.dem%0A *%0A * @author TimePath%0A */%0Apublic class ReplayConverter %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        if(args.length %3C 2) %7B%0A            System.err.println(%22Usage: java ... input.dem output.dem%22);%0A            System.exit(1);%0A        %7D%0A        String input = args%5B0%5D;%0A        String output = args%5B1%5D;%0A        patch(input, output);%0A    %7D%0A%0A    public static void patch(String input, String output) throws Exception %7B%0A        HL2DEM demo = HL2DEM.load(new File(input), false);%0A        boolean flag = false; // Injected%0A        int ticks = 0; // Highest tick%0A        int frames = 0; // Number of MessageType.Packet messages%0A        for(ListIterator%3CMessage%3E iterator = demo.getFrames().listIterator(); iterator.hasNext(); ) %7B%0A            Message frame = iterator.next();%0A            ticks = frame.tick;%0A            if(frame.type == MessageType.Packet) %7B%0A                frames++;%0A            %7D else if(frame.type == MessageType.Synctick && !flag) %7B%0A                Message injection = new Message(demo, MessageType.ConsoleCmd, frame.tick);%0A                injection.setData(%22tv_transmitall 1%22.getBytes());%0A                iterator.add(injection);%0A                flag = true;%0A            %7D%0A        %7D%0A        DemoHeader header = demo.getHeader();%0A        header.ticks = ticks;%0A        header.frames = frames;%0A        header.playbackTime = ticks / ( 66f + ( 2f / 3f ) );%0A        OrderedOutputStream out = new OrderedOutputStream(new FileOutputStream(output));%0A        out.order(ByteOrder.LITTLE_ENDIAN);%0A        out.writeStruct(header);%0A        for(Message message : demo.getFrames()) %7B%0A            message.write(out);%0A        %7D%0A    %7D%0A%7D%0A

Create ReplayConverter