Mercurial > hg > early-roguelike
changeset 193:533f1882dcb6
Merge a bug fix from the stable branch.
author | John "Elwin" Edwards |
---|---|
date | Fri, 07 Aug 2015 09:07:14 -0400 |
parents | 3de8058dd549 (diff) 7bdac632ab9d (current diff) |
children | 68a63ddfbe14 |
files | |
diffstat | 14 files changed, 55 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/rogue3/chase.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue3/chase.c Fri Aug 07 09:07:14 2015 -0400 @@ -162,7 +162,7 @@ int x, y; int dist, thisdist; struct linked_list *item; - struct object *obj; + struct object *obj = NULL; coord *er = &tp->t_pos; int ch;
--- a/rogue3/move.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue3/move.c Fri Aug 07 09:07:14 2015 -0400 @@ -339,7 +339,7 @@ int ch; int ex, ey, nopen = 0; struct linked_list *item; - struct object *obj; + struct object *obj = NULL; static coord ret; /* what we will be returning */ static coord dest;
--- a/rogue3/pack.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue3/pack.c Fri Aug 07 09:07:14 2015 -0400 @@ -22,8 +22,8 @@ void add_pack(struct linked_list *item, int silent) { - struct linked_list *ip, *lp; - struct object *obj, *op; + struct linked_list *ip, *lp = NULL; + struct object *obj, *op = NULL; int exact, from_floor; if (item == NULL)
--- a/rogue3/passages.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue3/passages.c Fri Aug 07 09:07:14 2015 -0400 @@ -22,7 +22,7 @@ void do_passages() { - struct rdes *r1, *r2; + struct rdes *r1, *r2 = NULL; int i, j; int roomcount; static struct rdes @@ -131,7 +131,7 @@ void conn(int r1, int r2) { - struct room *rpf, *rpt; + struct room *rpf, *rpt = NULL; int rmt; int distance, turn_spot, turn_distance; int rm;
--- a/rogue4/mdport.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue4/mdport.c Fri Aug 07 09:07:14 2015 -0400 @@ -36,7 +36,6 @@ #if defined(_WIN32) #include <Windows.h> #include <Lmcons.h> -#include <process.h> #include <shlobj.h> #include <sys/types.h> #include <io.h> @@ -73,6 +72,10 @@ #include <term.h> #endif +#if defined(_WIN32) +#include <process.h> +#endif + #include <stdio.h> #include <fcntl.h> #include <limits.h>
--- a/rogue4/save.c Tue Aug 04 11:39:49 2015 -0400 +++ b/rogue4/save.c Fri Aug 07 09:07:14 2015 -0400 @@ -160,7 +160,10 @@ /* * close any open score file */ - close(fd); + if (fd >= 0) { + close(fd); + fd = -1; + } move(LINES-1, 0); refresh(); fstat(md_fileno(savef), &sbuf);
--- a/srogue/command.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/command.c Fri Aug 07 09:07:14 2015 -0400 @@ -23,6 +23,8 @@ #include "rogue.ext" #ifdef __DJGPP__ #include <process.h> +#elif defined(_WIN32) +#include <process.h> #else #include <unistd.h> #endif
--- a/srogue/main.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/main.c Fri Aug 07 09:07:14 2015 -0400 @@ -172,7 +172,7 @@ /* START NEW GAME */ dnum = (wizard && getenv("SEED") != NULL ? - atoi(getenv("SEED")) : lowtime + getpid()); + atoi(getenv("SEED")) : lowtime + md_getpid()); if(wizard) printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum); @@ -438,7 +438,7 @@ struct stat sb; if (stat(dirname, &sb) == 0) /* path exists */ - return (S_ISDIR (sb.st_mode)); + return ((sb.st_mode & S_IFMT) == S_IFDIR); return(0); }
--- a/srogue/mdport.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/mdport.c Fri Aug 07 09:07:14 2015 -0400 @@ -42,9 +42,9 @@ #pragma warning( default: 4201 ) #include <Shlwapi.h> #undef MOUSE_MOVED +#define HAVE_PROCESS_H #endif -#include <curses.h> #include "rogue.h" #if defined(HAVE_SYS_TYPES) @@ -81,8 +81,6 @@ #endif #endif -#include <curses.h> /* AIX requires curses.h be included before term.h */ - #if defined(HAVE_TERM_H) #include <term.h> #elif defined(HAVE_NCURSES_TERM_H) @@ -358,6 +356,16 @@ #endif } +FILE * +md_fdopen(int fd, char *mode) +{ +#ifdef _WIN32 + return( _fdopen(fd, mode) ); +#else + return( fdopen(fd, mode) ); +#endif +} + int md_chmod(const char *filename, int mode) {
--- a/srogue/pack.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/pack.c Fri Aug 07 09:07:14 2015 -0400 @@ -29,7 +29,7 @@ bool silent; { reg struct linked_list *ip, *lp; - reg struct object *obj, *op; + reg struct object *obj, *op = NULL; bool from_floor; char delchar; @@ -292,7 +292,7 @@ char *purpose; int type; { - reg struct linked_list *obj, *pit, *savepit; + reg struct linked_list *obj, *pit, *savepit = NULL; struct object *pob; int ch, och, anr, cnt;
--- a/srogue/passages.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/passages.c Fri Aug 07 09:07:14 2015 -0400 @@ -24,7 +24,7 @@ do_passages() { - reg struct rdes *r1, *r2; + reg struct rdes *r1, *r2 = NULL; reg int i, j; reg int roomcount; static struct rdes { @@ -126,7 +126,7 @@ conn(r1, r2) int r1, r2; { - reg struct room *rpf, *rpt; + reg struct room *rpf, *rpt = NULL; reg char rmt, direc; reg int distance, turn_spot, turn_distance, rm; struct coord curr, turn_delta, spos, epos;
--- a/srogue/rip.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/rip.c Fri Aug 07 09:07:14 2015 -0400 @@ -145,7 +145,7 @@ */ if ((fd = scorefd) < 0) return; - outf = (FILE *) fdopen(fd, "w"); + outf = (FILE *) md_fdopen(fd, "w"); for (scp = top_ten; scp <= &top_ten[9]; scp++) { scp->sc_score = 0; for (i = 0; i < 80; i++)
--- a/srogue/rogue.h Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/rogue.h Fri Aug 07 09:07:14 2015 -0400 @@ -29,6 +29,9 @@ #ifdef HAVE_CONFIG_H #include "config.h" +#elif defined(_WIN32) && defined(__PDCURSES__) +#define HAVE_ERASECHAR +#define HAVE_KILLCHAR #endif /* mdport functions */ @@ -36,10 +39,21 @@ #include <sys/types.h> #endif +#ifndef uid_t +typedef unsigned int uid_t; +#endif +#ifndef gid_t +typedef unsigned int gid_t; +#endif +#ifndef pid_t +typedef int pid_t; +#endif + int md_chmod(const char *filename, int mode); char *md_crypt(const char *key, const char *salt); int md_dsuspchar(void); int md_erasechar(void); +FILE * md_fdopen(int fd, char *mode); char *md_gethomedir(void); char *md_getusername(void); uid_t md_getuid(void);
--- a/srogue/save.c Tue Aug 04 11:39:49 2015 -0400 +++ b/srogue/save.c Fri Aug 07 09:07:14 2015 -0400 @@ -14,15 +14,18 @@ * See the file LICENSE.TXT for full copyright and licensing information. */ +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <ctype.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <signal.h> #include <errno.h> +#if !defined(_WIN32) +#include <unistd.h> +#endif #include "rogue.h" #include "rogue.ext" @@ -157,7 +160,6 @@ save_file(savef) FILE *savef; { - reg int fnum; int slines = LINES; int scols = COLS; @@ -165,20 +167,12 @@ _djstat_flags |= _STAT_INODE; /* so turn off computing it for now */ #endif - /* - * force allocation of the buffer now so that inodes, etc - * can be checked when restoring saved games. - */ - fnum = fileno(savef); - fstat(fnum, &sbuf); - write(fnum, "RDK", 4); - lseek(fnum, 0L, 0); encwrite(version,strlen(version)+1,savef); encwrite(&slines,sizeof(slines),savef); encwrite(&scols,sizeof(scols),savef); msg(""); rs_save_file(savef); - close(fnum); + fclose(savef); md_onsignal_exit(); wclear(cw); draw(cw); @@ -283,7 +277,7 @@ #endif if (!wizard) { - if (unlink(file) < 0) + if (md_unlink(file) < 0) { endwin(); printf("Cannot unlink file\n"); @@ -302,6 +296,6 @@ strcpy(file_name, file); setup(); restscr(cw); - md_srandom(getpid()); + md_srandom(md_getpid()); playit(); }