diff options
| author | johannes <johannes.herman@gmail.com> | 2024-02-09 13:04:51 +0100 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-02-09 13:04:51 +0100 |
| commit | efa0424f21827ebc67d63375dcfeb0b77bd4d28f (patch) | |
| tree | a4706c29504a24144b0b0425fb521fe41bc08bf2 | |
| parent | 95ab92f65e0435f71478c09d5756f96c7a4b9c09 (diff) | |
added printsnap func
| -rw-r--r-- | inc/demo.h | 13 | ||||
| -rw-r--r-- | src/demo.c | 37 | ||||
| -rw-r--r-- | src/main.c | 2 |
3 files changed, 38 insertions, 14 deletions
@@ -95,6 +95,14 @@ typedef struct demochunk *chunks; } demodata; +typedef struct +{ + demoheader *header; + demotimeline *timeline; + demomap *map; + demodata *data; +} demo; + /* Read demo header from demofile into given demoheader */ /* Returns a positive number on success, negative on fail */ int readdemoheader(FILE *demofile, demoheader *header); @@ -124,4 +132,9 @@ int writedemotick(FILE *outfile, demotick *tick, unsigned char version); int writedemosnap(FILE *outfile, demosnap *snap, unsigned char version); int writedemomessage(FILE *outfile, demomessage *message, unsigned char ver); int writedemodelta(FILE *outfile, demodelta *delta, unsigned char ver); + +void printdemoheader(demoheader *header); +void printdemotick(demotick *tick); +void printdemosnap(demosnap *snap); + #endif // DEMO_H @@ -234,20 +234,6 @@ int readdemochunk(FILE *fp, demochunk *chunk, unsigned char ver) { chunk->type = DEMOSNAP; chunk->data.snap = snap; - - printf("SNAPSHOT={datasize: %d, numitems: %d, offsets: [ ", snap->datasize, snap->numitems); - for (int i = 0; i < snap->numitems; i++) - printf("%d, ", snap->offsets[i]); - - printf("], items: [ "); - for (int i = 0; i < snap->numitems; i++) - { - printf("(type: %d, id: %d) { ", snap->items[i].type, snap->items[i].id); - for (int y = 0; y < snap->items[i].numdata; y++) - printf("%i, ", snap->items[i].data[y]); - printf("} "); - } - printf("], "); } else { @@ -480,3 +466,26 @@ void printdemoheader(demoheader *header) printf("length: %d\n", header->length); printf("timestamp: %s\n", header->timestamp); } + +void printdemotick(demotick *tick) +{ + printf("TICK={keyframe: %s, innline: %s, delta: %d}\n", tick->keyframe ? "true" : "false", + tick->innline ? "true" : "false", tick->delta); +} + +void printdemosnap(demosnap *snap) +{ + printf("SNAPSHOT={datasize: %d, numitems: %d,\n offsets: [ ", snap->datasize, snap->numitems); + for (int i = 0; i < snap->numitems; i++) + printf("%d, ", snap->offsets[i]); + + printf("],\n items: [\n"); + for (int i = 0; i < snap->numitems; i++) + { + printf(" (type: %d, id: %d) {", snap->items[i].type, snap->items[i].id); + for (int y = 0; y < snap->items[i].numdata; y++) + printf("%x%s", snap->items[i].data[y], (y != snap->items[i].numdata - 1) ? "," : ""); + printf("}\n"); + } + printf("]}\n"); +} @@ -136,10 +136,12 @@ int main() { if (dd.chunks[i].type == DEMOTICK) { + printdemotick(dd.chunks[i].data.tick); writedemotick(op, dd.chunks[i].data.tick, dh.version); } else if (dd.chunks[i].type == DEMOSNAP) { + printdemosnap(dd.chunks[i].data.snap); demosnap *snap = dd.chunks[i].data.snap; for (int y = 0; y < snap->numitems; y++) { |
