diff options
| author | johannes <johannes.herman@gmail.com> | 2024-02-06 12:29:41 +0100 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-02-06 12:29:41 +0100 |
| commit | 0ab2c0afc6fd192f4008962ef400b92434e2dc2d (patch) | |
| tree | 31ff61e1945850048ac6b82f23cb428d62e0cb70 /src/main.c | |
| parent | 1bdee2153953e23bf71f7a5e83145bb4d67db567 (diff) | |
added read snap and read tick
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 40 |
1 files changed, 38 insertions, 2 deletions
@@ -1,9 +1,12 @@ #include "../inc/huffman.h" #include "../inc/demo.h" +#include "../inc/pack.h" #include <stdio.h> #include <stdlib.h> +#include <unistd.h> + int testcompress(char *line) { char inputbuff[4096]; @@ -109,16 +112,49 @@ int testdecompress(char *line) int main() { + inithuff(NULL); + FILE *fp = fopen("data/test.demo", "r"); + FILE *op = fopen("data/out.demo", "w"); + demoheader dh; demotimeline dt; + demomap dm; + int ret = readdemoheader(fp, &dh); - printf("\nheader: %i\n", ret); + dm.data = (unsigned char*) malloc(reverseint(dh.mapsize)); - ret = readdemotimeline(fp, &dt); + printf("\nheader: %i\n", ret); + + if (dh.version >= 4) + ret = readdemotimeline(fp, &dt); printf("\ntimeline: %i\n", ret); + + // TODO should be able to read 5 aswell, change readdemomap to fit + if (dh.version >= 6) + ret = readdemomap(fp, &dm, reverseint(dh.mapsize)); + printf("readdemomap ret: %d\n\n", ret); + + demochunk dc; + int i = 0; + while (readdemochunk(fp, &dc, dh.version) > 0) + { + i++; + } + printf("i: %d\n", i); + char c; + do + { + c = getc(fp); + // printf("%x\n", c & 0xff); + if (c != EOF) + { + putc(c, op); + } + } + while(c != EOF); return EXIT_SUCCESS; |
