]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/rea.c
Don't lie "You have a new telegram" after read with inform off
[empserver] / src / lib / commands / rea.c
index 8592d2512ce0adb6e25a1a04fa77b7d824074e10..33fcde34ca4ac5128c465d77d5f1fce23a2c2cae 100644 (file)
@@ -31,7 +31,7 @@
  *     Doug Hay, 1998
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2005-2007
- *     Markus Armbruster, 2009
+ *     Markus Armbruster, 2009-2011
  */
 
 #include <config.h>
@@ -62,10 +62,6 @@ rea(void)
     int teles;
     int size;
     char buf[1024];
-    int lasttype;
-    int lastcnum;
-    time_t lastdate;
-    int header;
     int filelen;
     char *kind;
     int n, res;
@@ -74,7 +70,6 @@ rea(void)
     time_t now;
     time_t then;
     time_t delta;
-    int first = 1;
     int may_delete = 1; /* may messages be deleted? */
 
     now = time(NULL);
@@ -99,7 +94,6 @@ rea(void)
            may_delete = 0;
        }
        mbox = mailbox(mbox_buf, num);
-       clear_telegram_is_new(player->cnum);
     }
 
     if (!(telfp = fopen(mbox, "rb+"))) {
@@ -107,12 +101,8 @@ rea(void)
        return RET_FAIL;
     }
     teles = 0;
-    fseek(telfp, 0L, SEEK_SET);
     size = fsize(fileno(telfp));
   more:
-    lastdate = 0;
-    lastcnum = -1;
-    lasttype = -1;
     while ((res = tel_read_header(telfp, mbox, &tgm)) > 0) {
        if (*kind == 'a') {
            if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
@@ -123,26 +113,16 @@ rea(void)
                continue;
            }
        }
-       if (first && *kind == 'a') {
+       if (!teles && *kind == 'a')
            pr("\nAnnouncements since %s", ctime(&then));
-           first = 0;
-       }
-       header = 0;
-       if (tgm.tel_type != lasttype || tgm.tel_from != lastcnum)
-           header++;
-       if (abs((int)(tgm.tel_date - (long)lastdate)) > TEL_SECONDS)
-           header++;
-       if (header) {
+       if (!teles || !tgm.tel_cont) {
            pr("\n> ");
-           lastcnum = tgm.tel_from;
-           lasttype = tgm.tel_type;
            pr("%s ", telnames[tgm.tel_type]);
            if ((tgm.tel_type == TEL_NORM) ||
                (tgm.tel_type == TEL_ANNOUNCE) ||
                (tgm.tel_type == TEL_BULLETIN))
                pr("from %s, (#%d)", cname(tgm.tel_from), tgm.tel_from);
            pr("  dated %s", ctime(&tgm.tel_date));
-           lastdate = tgm.tel_date;
        }
        teles++;
        res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
@@ -152,6 +132,16 @@ rea(void)
     if (res < 0)
        pr("\n> Mailbox corrupt, tell the deity.\n");
 
+    if (*kind == 'a')
+       np->nat_ann = 0;
+    else {
+       np->nat_tgms = 0;
+       if (np->nat_flags & NF_INFORM) {
+           pr_inform(player, "\n");
+       }
+    }
+    putnat(np);
+
     if (teles > 0 && player->cnum == num && may_delete) {
        pr("\n");
        if (teles == 1) {
@@ -194,11 +184,6 @@ rea(void)
            pr("No %ss for %s at the moment...\n", kind, cname(num));
     }
     (void)fclose(telfp);
-    if (np->nat_flags & NF_INFORM) {
-       pr_inform(player, "\n");
-       np->nat_tgms = 0;
-       putnat(np);
-    }
     return RET_OK;
 }