From c372df2fd239531ffdb5d5e2d99ba0e54f38ace9 Mon Sep 17 00:00:00 2001 From: johannes Date: Tue, 6 Feb 2024 13:00:51 +0100 Subject: changed chunk type to enum --- src/demo.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demo.c b/src/demo.c index fd1f310..21b5eea 100644 --- a/src/demo.c +++ b/src/demo.c @@ -109,7 +109,11 @@ int readdemosnap(FILE *fp, demosnap *snap, int size) fread(data, sizeof(unsigned char), size, fp); - int r = decompresshuff((char *)data, size, (char *)unpacked, 1034 * 8); + if (decompresshuff((char *)data, size, (char *)unpacked, 1034 * 8) < 0) + { + printf("[ ERROR ] error while decompressing snap cunk!\n"); + return 0; + } unsigned char *cp = unpacked; @@ -156,7 +160,7 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver) demotick *tick = (demotick *)malloc(sizeof(demotick)); if (readdemotick(fp, chunkhead, tick, ver)) { - chunk->type = 0; + chunk->type = DEMOTICK; chunk->data.tick = tick; printf("TICK={keyframe: %d, innline: %d, delta: %d}\n", tick->keyframe, tick->innline, tick->delta); } @@ -181,7 +185,7 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver) demosnap *snap = (demosnap *)malloc(sizeof(demosnap)); if (readdemosnap(fp, snap, size)) { - chunk->type = 1; // TODO make a chunk-type enum + chunk->type = DEMOSNAP; chunk->data.snap = snap; printf("SNAPSHOT={datasize: %d, numitems: %d, offsets: [ ", snap->datasize, snap->numitems); @@ -214,6 +218,10 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver) printf("SNAPSHOT_DELTA={"); fseek(fp, size, SEEK_CUR); } + else + { + printf("[ ERROR ] unknown chunk type!\n"); + } printf("size: %d}\n", size); } -- cgit v1.2.3