summaryrefslogtreecommitdiff
path: root/src/demo.c
diff options
context:
space:
mode:
authorjohannes <johannes.herman@gmail.com>2024-02-06 14:14:57 +0100
committerjohannes <johannes.herman@gmail.com>2024-02-06 14:14:57 +0100
commitec6a5c1ff3bb7731e17b798f9bbfdb0aedf94baa (patch)
treee766d76d0dcb2468ac34b6f096054d87513727ff /src/demo.c
parent26a7b9bbf466dd01b5449ed5819c3e90ac398a1d (diff)
made readdemomap follow version
Diffstat (limited to 'src/demo.c')
-rw-r--r--src/demo.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/demo.c b/src/demo.c
index 155d67c..23995ff 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -22,11 +22,11 @@ int readdemoheader(FILE *fp, demoheader *dh)
{
char magicbuff[sizeof(headermagic)];
unsigned char intbuff[4];
-
+
fread(magicbuff, 1, sizeof(headermagic), fp);
if (strcmp(magicbuff, headermagic) != 0)
return -1;
-
+
if (fread(&dh->version, 1, 1, fp) != 1)
return -2;
@@ -67,22 +67,22 @@ int readdemoheader(FILE *fp, demoheader *dh)
int readdemotimeline(FILE *fp, demotimeline *dt)
{
- if (fscanf(fp, "%260c", dt->data) != 1)
+ if (fread(dt->data, 1, 260, fp) != 260)
return -1;
return 1;
}
-// TODO make version sensitive
-int readdemomap(FILE *fp, demomap *dm, int mapsize)
+int readdemomap(FILE *fp, demomap *dm, int mapsize, unsigned char ver)
{
char magicbuf[sizeof(mapmagic)];
- fread(magicbuf, 1, sizeof(mapmagic), fp);
+ fread(magicbuf, 1, sizeof(mapmagic), fp);
if (memcmp(magicbuf, mapmagic, sizeof(mapmagic)) != 0)
return -1;
- if (fread(dm->sha256, 1, 32, fp) != 32)
- return -2;
+ if (ver >= 4)
+ if (fread(dm->sha256, 1, 32, fp) != 32)
+ return -2;
if (fread(dm->data, 1, mapsize, fp) != mapsize)
return -3;