diff options
| author | johannes <johannes.herman@gmail.com> | 2024-02-09 16:01:33 +0100 |
|---|---|---|
| committer | johannes <johannes.herman@gmail.com> | 2024-02-09 16:01:33 +0100 |
| commit | c39ca31ffb42414b26ded21aa5b904253c7c7edc (patch) | |
| tree | 292d372c8a5ce631424c38f01bec66a99fe9803a /src/main.c | |
| parent | efa0424f21827ebc67d63375dcfeb0b77bd4d28f (diff) | |
added read demo and write demo functions
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 52 |
1 files changed, 6 insertions, 46 deletions
@@ -117,57 +117,17 @@ int main() FILE *fp = fopen("data/test.demo", "r"); FILE *op = fopen("data/out.demo", "w"); - demoheader dh; - demotimeline dt; - demomap dm; - demodata dd; + demo d; - readdemoheader(fp, &dh); - readdemotimeline(fp, &dt); - readdemomap(fp, &dm, dh.mapsize, dh.version); - - writedemoheader(op, &dh); - writedemotimeline(op, &dt); - writedemomap(op, &dm, dh.mapsize, dh.version); - - readdemochunks(fp, &dd, dh.version); - - for (int i = 0; i < dd.numchunks; i++) - { - 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++) - { - demosnapitem *item = &snap->items[y]; - if (item->type == 11 && item->id == 9) - { - char newname[16] = ">>Hextcjd!\0"; - - strtoint(newname, 16, item->data); - } - } - writedemosnap(op, dd.chunks[i].data.snap, dh.version); - } - else if (dd.chunks[i].type == DEMOMESSAGE) - { - writedemomessage(op, dd.chunks[i].data.message, dh.version); - } - else if (dd.chunks[i].type == DEMODELTA) - { - writedemodelta(op, dd.chunks[i].data.delta, dh.version); - } - } + readdemo(fp, &d); + printdemo(&d); + writedemo(op, &d); fclose(fp); fclose(op); + exit(EXIT_SUCCESS); + // Testing /* inithuff(NULL); |
