diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-27 17:02:01 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-27 17:02:01 +0000 |
commit | aee28916b06c3ce47d68f76ef8d1fe7dc55f151a (patch) | |
tree | 9050f0cfb85e202814786d094ef17af74f1ea5ca /sys | |
parent | 30da40c16a94d56875aa705dd2485fb2eacc9bb4 (diff) |
games/doom: dont pretend we are in a netgame, fix save/load
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/games/doom/i_net.c | 2 | ||||
-rw-r--r-- | sys/src/games/doom/m_misc.c | 68 |
2 files changed, 24 insertions, 46 deletions
diff --git a/sys/src/games/doom/i_net.c b/sys/src/games/doom/i_net.c index a40fec4ea..945287eaf 100644 --- a/sys/src/games/doom/i_net.c +++ b/sys/src/games/doom/i_net.c @@ -50,7 +50,7 @@ printf("PORTME i_net.c I_InitNetwork (use 9P)\n"); // netsend = PacketSend; // netget = PacketGet; - netgame = true; +// netgame = true; /* parse player number and host list */ // doomcom->consoleplayer = myargv[i+1][0]-'1'; diff --git a/sys/src/games/doom/m_misc.c b/sys/src/games/doom/m_misc.c index 56451128f..3b36dc566 100644 --- a/sys/src/games/doom/m_misc.c +++ b/sys/src/games/doom/m_misc.c @@ -107,26 +107,13 @@ M_WriteFile void* source, int length ) { - USED(name, source, length); - I_Error("PORTME: m_misc.c M_WriteFile"); - return false; -/* - int handle; - int count; - - handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - - if (handle == -1) - return false; + int fd, n; - count = write (handle, source, length); - close (handle); - - if (count < length) - return false; - - return true; -*/ + if((fd = create(name, OWRITE | OTRUNC, 0666)) < 0) + return false; + n = write(fd, source, length); + close(fd); + return n == length; } @@ -138,32 +125,23 @@ M_ReadFile ( char const* name, byte** buffer ) { - USED(name, buffer); - I_Error("PORTME m_misc.c M_ReadFile"); - return -1; -/* - int handle, count, length; - struct stat fileinfo; - byte *buf; - - length = 0; - - handle = I_Open (name); - if (handle == -1) - I_Error ("Couldn't read file %s", name); - if (fstat (handle,&fileinfo) == -1) - I_Error ("Couldn't read file %s", name); - length = fileinfo.st_size; - buf = Z_Malloc (length, PU_STATIC, NULL); - count = I_Read (handle, buf, length); - I_Close (handle); - - if (count < length) - I_Error ("Couldn't read file %s", name); - - *buffer = buf; - return length; -*/ + int fd, length; + Dir *d; + byte *buf; + + if((fd = open(name, OREAD)) < 0) + I_Error ("Couldn't open file %s", name); + if((d = dirfstat(fd)) == nil) + I_Error ("Couldn't stat file %s", name); + length = d->length; + free(d); + + buf = Z_Malloc(length, PU_STATIC, NULL); + if(readn(fd, buf, length) != length) + I_Error ("Couldn't read file %s", name); + close(fd); + *buffer = buf; + return length; } |