2004-01-04 01:21:39 +01:00
|
|
|
diff -urN orig/nethack-3.4.3/include/decl.h nethack-3.4.3/include/decl.h
|
|
|
|
--- orig/nethack-3.4.3/include/decl.h 2003-12-07 15:39:13.000000000 -0800
|
|
|
|
+++ nethack-3.4.3/include/decl.h 2004-01-03 15:57:34.000000000 -0800
|
2004-01-03 23:35:09 +01:00
|
|
|
@@ -385,6 +385,10 @@
|
|
|
|
};
|
|
|
|
#endif /* AUTOPICKUP_EXCEPTIONS */
|
|
|
|
|
|
|
|
+#ifdef SIMPLE_MAIL
|
|
|
|
+E int mailckfreq;
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#undef E
|
|
|
|
|
|
|
|
#endif /* DECL_H */
|
2004-01-04 01:21:39 +01:00
|
|
|
diff -urN orig/nethack-3.4.3/include/flag.h nethack-3.4.3/include/flag.h
|
|
|
|
--- orig/nethack-3.4.3/include/flag.h 2003-12-07 15:39:13.000000000 -0800
|
|
|
|
+++ nethack-3.4.3/include/flag.h 2004-01-03 15:57:34.000000000 -0800
|
|
|
|
@@ -175,6 +175,9 @@
|
|
|
|
uchar bouldersym; /* symbol for boulder display */
|
|
|
|
boolean travel1; /* first travel step */
|
|
|
|
coord travelcc; /* coordinates for travel_cache */
|
|
|
|
+#ifdef SIMPLE_MAIL
|
|
|
|
+ boolean simplemail; /* simple mail format $NAME:$MESSAGE */
|
|
|
|
+#endif
|
|
|
|
#ifdef WIZARD
|
|
|
|
boolean sanity_check; /* run sanity checks */
|
|
|
|
boolean mon_polycontrol; /* debug: control monster polymorphs */
|
|
|
|
diff -urN orig/nethack-3.4.3/include/unixconf.h nethack-3.4.3/include/unixconf.h
|
|
|
|
--- orig/nethack-3.4.3/include/unixconf.h 2003-12-07 15:39:13.000000000 -0800
|
|
|
|
+++ nethack-3.4.3/include/unixconf.h 2004-01-03 15:57:34.000000000 -0800
|
|
|
|
@@ -193,7 +193,6 @@
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#define MAILCKFREQ 50
|
|
|
|
#endif /* MAIL */
|
|
|
|
|
|
|
|
|
|
|
|
diff -urN orig/nethack-3.4.3/src/mail.c nethack-3.4.3/src/mail.c
|
|
|
|
--- orig/nethack-3.4.3/src/mail.c 2003-12-07 15:39:13.000000000 -0800
|
|
|
|
+++ nethack-3.4.3/src/mail.c 2004-01-03 16:07:21.000000000 -0800
|
|
|
|
@@ -5,6 +5,8 @@
|
|
|
|
#include "hack.h"
|
|
|
|
|
|
|
|
#ifdef MAIL
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
#include "mail.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
@@ -36,6 +38,8 @@
|
2004-01-03 23:35:09 +01:00
|
|
|
STATIC_DCL boolean FDECL(md_rush,(struct monst *,int,int));
|
|
|
|
STATIC_DCL void FDECL(newmail, (struct mail_info *));
|
|
|
|
|
|
|
|
+int mailckfreq = 0;
|
|
|
|
+
|
|
|
|
extern char *viz_rmin, *viz_rmax; /* line-of-sight limits (vision.c) */
|
|
|
|
|
|
|
|
#ifdef OVL0
|
2004-01-04 01:21:39 +01:00
|
|
|
@@ -464,11 +468,15 @@
|
2004-01-03 23:35:09 +01:00
|
|
|
void
|
|
|
|
ckmailstatus()
|
|
|
|
{
|
2004-01-04 01:21:39 +01:00
|
|
|
+#ifdef SIMPLE_MAIL
|
2004-01-03 23:35:09 +01:00
|
|
|
+ if (mailckfreq == 0)
|
2004-01-04 01:21:39 +01:00
|
|
|
+ mailckfreq = (iflags.simplemail ? 5 : 10);
|
|
|
|
+#else
|
|
|
|
+ mailckfreq = 10;
|
|
|
|
+#endif
|
2004-01-03 23:35:09 +01:00
|
|
|
+
|
|
|
|
if(!mailbox || u.uswallow || !flags.biff
|
|
|
|
-# ifdef MAILCKFREQ
|
|
|
|
- || moves < laststattime + MAILCKFREQ
|
|
|
|
-# endif
|
|
|
|
- )
|
|
|
|
+ || moves < laststattime + mailckfreq)
|
|
|
|
return;
|
|
|
|
|
|
|
|
laststattime = moves;
|
2004-01-06 20:04:07 +01:00
|
|
|
@@ -501,9 +509,68 @@
|
2004-01-03 21:19:38 +01:00
|
|
|
readmail(otmp)
|
|
|
|
struct obj *otmp;
|
|
|
|
{
|
2004-01-03 23:35:09 +01:00
|
|
|
-# ifdef DEF_MAILREADER /* This implies that UNIX is defined */
|
|
|
|
+#ifdef DEF_MAILREADER
|
|
|
|
register const char *mr = 0;
|
|
|
|
+#endif /* DEF_MAILREADER */
|
|
|
|
+#ifdef SIMPLE_MAIL
|
2004-01-04 01:21:39 +01:00
|
|
|
+ if (iflags.simplemail)
|
2004-01-03 23:35:09 +01:00
|
|
|
+ {
|
|
|
|
+ FILE* mb = fopen(mailbox, "r");
|
2004-01-06 20:04:07 +01:00
|
|
|
+ char curline[102], *msg;
|
2004-01-04 01:21:39 +01:00
|
|
|
+ boolean seen_one_already = FALSE;
|
|
|
|
+ struct flock fl = { 0 };
|
|
|
|
+
|
|
|
|
+ fl.l_type = F_RDLCK;
|
|
|
|
+ fl.l_whence = SEEK_SET;
|
|
|
|
+ fl.l_start = 0;
|
|
|
|
+ fl.l_len = 0;
|
2004-01-03 21:19:38 +01:00
|
|
|
+
|
2004-01-03 23:35:09 +01:00
|
|
|
+ if (!mb)
|
|
|
|
+ goto bail;
|
2004-01-03 21:19:38 +01:00
|
|
|
+
|
2004-01-04 01:21:39 +01:00
|
|
|
+ /* Allow this call to block. */
|
|
|
|
+ if (fcntl (fileno (mb), F_SETLKW, &fl) == -1)
|
|
|
|
+ goto bail;
|
|
|
|
+
|
|
|
|
+ errno = 0;
|
|
|
|
+
|
2004-01-06 20:04:07 +01:00
|
|
|
+ while (fgets(curline, 102, mb) != NULL)
|
2004-01-04 01:21:39 +01:00
|
|
|
+ {
|
|
|
|
+ fl.l_type = F_UNLCK;
|
|
|
|
+ fcntl (fileno(mb), F_UNLCK, &fl);
|
|
|
|
+
|
|
|
|
+ pline("There is a%s message on this scroll.",
|
|
|
|
+ seen_one_already ? "nother" : "");
|
|
|
|
+
|
|
|
|
+ msg = strchr(curline, ':');
|
|
|
|
+
|
|
|
|
+ if (!msg)
|
|
|
|
+ goto bail;
|
|
|
|
+
|
|
|
|
+ *msg = '\0';
|
|
|
|
+ msg++;
|
|
|
|
+
|
|
|
|
+ pline ("This message is from '%s'.", curline);
|
2004-01-03 21:19:38 +01:00
|
|
|
+
|
2004-01-04 01:21:39 +01:00
|
|
|
+ msg[strlen(msg) - 1] = '\0'; /* kill newline */
|
|
|
|
+ pline ("It reads: \"%s\".", msg);
|
|
|
|
+
|
|
|
|
+ seen_one_already = TRUE;
|
|
|
|
+ errno = 0;
|
|
|
|
+
|
|
|
|
+ fl.l_type = F_RDLCK;
|
|
|
|
+ fcntl(fileno(mb), F_SETLKW, &fl);
|
|
|
|
+ }
|
2004-01-03 21:19:38 +01:00
|
|
|
|
2004-01-04 01:21:39 +01:00
|
|
|
+ fl.l_type = F_UNLCK;
|
|
|
|
+ fcntl(fileno(mb), F_UNLCK, &fl);
|
|
|
|
+
|
2004-01-03 23:35:09 +01:00
|
|
|
+ fclose(mb);
|
2004-01-06 20:04:07 +01:00
|
|
|
+ unlink(mailbox);
|
2004-01-03 23:35:09 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
2004-01-03 21:19:38 +01:00
|
|
|
+# endif /* SIMPLE_MAIL */
|
2004-01-03 23:35:09 +01:00
|
|
|
+# ifdef DEF_MAILREADER /* This implies that UNIX is defined */
|
|
|
|
display_nhwindow(WIN_MESSAGE, FALSE);
|
|
|
|
if(!(mr = nh_getenv("MAILREADER")))
|
|
|
|
mr = DEF_MAILREADER;
|
2004-01-04 01:21:39 +01:00
|
|
|
@@ -512,15 +578,21 @@
|
2004-01-03 23:35:09 +01:00
|
|
|
(void) execl(mr, mr, (char *)0);
|
|
|
|
terminate(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
-# else
|
|
|
|
-# ifndef AMS /* AMS mailboxes are directories */
|
|
|
|
+# else
|
|
|
|
+# ifndef AMS /* AMS mailboxes are directories */
|
|
|
|
display_file(mailbox, TRUE);
|
|
|
|
-# endif /* AMS */
|
|
|
|
-# endif /* DEF_MAILREADER */
|
|
|
|
+# endif /* AMS */
|
|
|
|
+# endif /* DEF_MAILREADER */
|
2004-01-03 21:19:38 +01:00
|
|
|
|
|
|
|
/* get new stat; not entirely correct: there is a small time
|
|
|
|
window where we do not see new mail */
|
2004-01-03 23:35:09 +01:00
|
|
|
getmailstatus();
|
|
|
|
+ return;
|
|
|
|
+
|
2004-01-04 01:21:39 +01:00
|
|
|
+#ifdef SIMPLE_MAIL
|
2004-01-03 23:35:09 +01:00
|
|
|
+bail:
|
|
|
|
+ pline("It appears to be all gibberish."); /* bail out _professionally_ */
|
2004-01-04 01:21:39 +01:00
|
|
|
+#endif
|
2004-01-03 23:35:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# endif /* UNIX */
|
2004-01-04 01:21:39 +01:00
|
|
|
@@ -587,10 +659,7 @@
|
2004-01-03 23:35:09 +01:00
|
|
|
static int laststattime = 0;
|
|
|
|
|
|
|
|
if(u.uswallow || !flags.biff
|
|
|
|
-# ifdef MAILCKFREQ
|
|
|
|
- || moves < laststattime + MAILCKFREQ
|
|
|
|
-# endif
|
|
|
|
- )
|
|
|
|
+ || moves < laststattime + mailckfreq)
|
|
|
|
return;
|
|
|
|
|
|
|
|
laststattime = moves;
|
2004-01-04 01:21:39 +01:00
|
|
|
diff -urN orig/nethack-3.4.3/sys/unix/unixmain.c nethack-3.4.3/sys/unix/unixmain.c
|
|
|
|
--- orig/nethack-3.4.3/sys/unix/unixmain.c 2003-12-07 15:39:13.000000000 -0800
|
|
|
|
+++ nethack-3.4.3/sys/unix/unixmain.c 2004-01-03 15:57:34.000000000 -0800
|
2004-01-03 23:35:09 +01:00
|
|
|
@@ -54,7 +54,9 @@
|
|
|
|
register char *dir;
|
|
|
|
#endif
|
|
|
|
boolean exact_username;
|
|
|
|
-
|
|
|
|
+#ifdef SIMPLE_MAIL
|
|
|
|
+ char* e_simple = NULL;
|
|
|
|
+#endif
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
/* special hack to change working directory to a resource fork when
|
|
|
|
running from finder --sam */
|
|
|
|
@@ -84,6 +86,12 @@
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef SIMPLE_MAIL
|
|
|
|
+ /* figure this out early */
|
|
|
|
+ e_simple = nh_getenv("SIMPLEMAIL");
|
2004-01-04 01:21:39 +01:00
|
|
|
+ iflags.simplemail = (e_simple ? 1 : 0);
|
2004-01-03 23:35:09 +01:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
hname = argv[0];
|
|
|
|
hackpid = getpid();
|
|
|
|
(void) umask(0777 & ~FCMASK);
|