Changes to be committed:
	modified:   include/extern.h
	modified:   src/bones.c
	modified:   src/do.c
	modified:   src/files.c
	modified:   src/music.c
	modified:   src/restore.c
	modified:   src/save.c
	modified:   sys/share/pcmain.c
	modified:   sys/share/pcsys.c
	modified:   sys/share/pcunix.c

In order to get level file locking correctly again post 3.4.3
with the newer compilers for windows, I had to funnel close()
calls to an intercepting routine.

I had two choices:

1. Surround every close() in at least 9 source files with messy:
	#ifdef WIN32
		nhclose(fd);
	#else
		close(fd);
	#endif

OR

2. Replace every close() with nhclose() and
   deal with the special code in the nhclose()
   version for windows, while just calling
   close() for other platforms (in files.c).

   It is also possible, although not done in this commit,
   to
	#define nhclose(fd) close(fd)
   in a header file for non-windows, rather than funnel
   though a real nhclose() function in files.c.
This commit is contained in:
nhmall
2015-04-06 10:12:10 -04:00
parent b7ad4a8a2a
commit 3d6fabf730
10 changed files with 68 additions and 60 deletions
+4 -4
View File
@@ -718,7 +718,7 @@ xchar ltmp;
/* Remove levels and bones that may have been created.
*/
(void) close(nfd);
(void) nhclose(nfd);
# ifdef AMIGA
clearlocks();
# else
@@ -767,7 +767,7 @@ register int fd;
if (!restgamestate(fd, &stuckid, &steedid)) {
display_nhwindow(WIN_MESSAGE, TRUE);
savelev(-1, 0, FREE_SAVE); /* discard current level */
(void) close(fd);
(void) nhclose(fd);
(void) delete_savefile();
restoring = FALSE;
return(0);
@@ -841,7 +841,7 @@ register int fd;
get_plname_from_file(fd, plname);
getlev(fd, 0, (xchar)0, FALSE);
(void) close(fd);
(void) nhclose(fd);
/* Now set the restore settings to match the
* settings used by the save file output routines
@@ -1558,7 +1558,7 @@ register unsigned int len;
} else {
pline("Read %d instead of %u bytes.", rlen, len);
if(restoring) {
(void) close(fd);
(void) nhclose(fd);
(void) delete_savefile();
error("Error restoring old game.");
}