summaryrefslogtreecommitdiff
path: root/sys/src/games
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-29 14:51:00 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-29 14:51:00 +0200
commitfdb1698791dc51dbf690fec4a1d1c7b6a4b52345 (patch)
tree4423ee6c6439850feab625c67e3647280ab378d1 /sys/src/games
parentc4ae1a74357c419b8106a2c0e51d941e2b415a61 (diff)
games/doom: implement filelength() (thanks quux)
this function is used when playing demos from external lumps. the game just exits without this patch. to test this, download a demo lump from somewhere, and play it with -playdemo %s where %s is the file's name, without the .lmp extension: (note that this one is a doom 2 demo, so it requires doom2.wad) % hget http://doomedsda.us/lmps/945/3/30nm2939.zip | unzip -sv extracting 30nm2939.LMP extracting 30nm2939.txt % mv 30nm2939.LMP 30nm2939.lmp # checking for a lump filename is case sensitive % games/doom -playdemo 30nm2939 the game exits when the demo ends. also, note that this demo will desync on map06 (the crusher), because of an unrelated bug (that's another patch :>) note: filelength() returns vlong, but file lengths for doom lumps are ints. however, this might be used elsewhere (networking), so i'd leave it this way.
Diffstat (limited to 'sys/src/games')
-rw-r--r--sys/src/games/doom/w_wad.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/sys/src/games/doom/w_wad.c b/sys/src/games/doom/w_wad.c
index 8f4c3c35c..17f31fa0c 100644
--- a/sys/src/games/doom/w_wad.c
+++ b/sys/src/games/doom/w_wad.c
@@ -64,19 +64,18 @@ void strupr (char* s)
while (*s) { *s = toupper(*s); s++; }
}
-int filelength (int handle)
+vlong
+filelength(int fd)
{
- USED(handle);
- I_Error ("PORTME w_wad.c filelength");
- return -1;
-/*
- struct stat fileinfo;
-
- if (fstat (handle,&fileinfo) == -1)
- I_Error ("Error fstating");
-
- return fileinfo.st_size;
-*/
+ vlong l;
+ Dir *d;
+
+ d = dirfstat(fd);
+ if(d == nil)
+ sysfatal("dirfstat: %r");
+ l = d->length;
+ free(d);
+ return l; /* lump file lenghts in doom are ints */
}