]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/rea.c
commands: Rename the command functions
[empserver] / src / lib / commands / rea.c
index 118e08696ea7e174dc43526d5193510ed43da53c..fea82ce5966dcfce91843ea79d6763d872a7afff 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
  *     Doug Hay, 1998
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2005-2007
- *     Markus Armbruster, 2009-2011
+ *     Markus Armbruster, 2009-2016
  */
 
 #include <config.h>
@@ -39,6 +39,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
+#include "chance.h"
 #include "commands.h"
 #include "match.h"
 #include "misc.h"
@@ -48,7 +49,7 @@
 static int print_sink(char *, size_t, void *);
 
 int
-rea(void)
+c_read(void)
 {
     static char *telnames[] = {
        /* must follow TEL_ defines in tel.h */
@@ -59,7 +60,7 @@ rea(void)
     char mbox_buf[256];                /* Maximum path length */
     struct telstr tgm;
     FILE *telfp;
-    int teles;
+    int teles, need_hdr;
     char buf[1024];
     char *kind;
     int n, res;
@@ -99,13 +100,14 @@ rea(void)
        return RET_FAIL;
     }
     teles = 0;
+    need_hdr = 1;
     for (;;) {
        res = tel_read_header(telfp, mbox, &tgm);
     more:
        if (res <= 0)
            break;
        if (*kind == 'a') {
-           if ((!player->god && (getrejects(tgm.tel_from, np) & REJ_ANNO))
+           if ((!nat_accepts(player->cnum, tgm.tel_from, REJ_ANNO))
                || tgm.tel_date < then) {
                res = tel_read_body(telfp, mbox, &tgm, NULL, NULL);
                if (res < 0)
@@ -115,7 +117,7 @@ rea(void)
        }
        if (!teles && *kind == 'a')
            pr("\nAnnouncements since %s", ctime(&then));
-       if (!teles || !tgm.tel_cont) {
+       if (need_hdr || !tgm.tel_cont) {
            pr("\n> ");
            pr("%s ", telnames[tgm.tel_type]);
            if ((tgm.tel_type == TEL_NORM) ||
@@ -125,6 +127,7 @@ rea(void)
            pr("  dated %s", ctime(&tgm.tel_date));
        }
        teles++;
+       need_hdr = 0;
        res = tel_read_body(telfp, mbox, &tgm, print_sink, NULL);
        if (res < 0)
            break;
@@ -169,6 +172,7 @@ rea(void)
                res = tel_read_header(telfp, mbox, &tgm);
                if (res != 0) {
                    pr("Wait a sec!  A new %s has arrived...\n", kind);
+                   need_hdr = 1;
                    goto more;
                }
                /* Here, we just re-open the file for "w" only,
@@ -189,7 +193,7 @@ rea(void)
 }
 
 /*
- * Print first telegram in file FNAME.
+ * Print first telegram in file @fname.
  */
 int
 show_first_tel(char *fname)