]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/wu.c
Fix pending anno count for annos squashed together
[empserver] / src / lib / subs / wu.c
index 5021cd0c0e20f09dfa078eb4632c3c3a4274aa18..84549a0df459b7e416b209fb6d4f6dc1f86481b5 100644 (file)
@@ -28,6 +28,7 @@
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2005-2011
  */
 
 #include <config.h>
@@ -51,7 +52,7 @@ void
 clear_telegram_is_new(natid to)
 {
     last_tel[to].tel_type = 0;
-    last_tel[to].tel_from = 0;
+    last_tel[to].tel_from = NATID_BAD;
     last_tel[to].tel_date = 0;
 }
 
@@ -67,7 +68,7 @@ telegram_is_new(natid to, struct telstr *tel)
 
     is_new |= tel->tel_type != last_tel[to].tel_type;
     is_new |= tel->tel_from != last_tel[to].tel_from;
-    is_new |= !update_running && /* updates can take a long time */
+    is_new |= tel->tel_type != TEL_UPDATE &&
        abs(tel->tel_date - last_tel[to].tel_date) > TEL_SECONDS;
 
     last_tel[to].tel_type = tel->tel_type;
@@ -120,7 +121,6 @@ typed_wu(natid from, natid to, char *message, int type)
     struct iovec iov[2];
     int fd;
     char box[1024];
-    int new_tele = 0;
     struct player *other;
 
     if (type == TEL_ANNOUNCE)
@@ -146,6 +146,7 @@ typed_wu(natid from, natid to, char *message, int type)
     len = strlen(message);
     tel.tel_length = len;
     tel.tel_type = type;
+    tel.tel_cont = !telegram_is_new(to, &tel);
     iov[0].iov_base = &tel;
     iov[0].iov_len = sizeof(tel);
     iov[1].iov_base = message;
@@ -166,20 +167,23 @@ typed_wu(natid from, natid to, char *message, int type)
                continue;
            if (!player->god && (getrejects(from, np) & REJ_ANNO))
                continue;
-           np->nat_ann++;
-           putnat(np);
+           if (!np->nat_ann || !tel.tel_cont) {
+               np->nat_ann++;
+               putnat(np);
+           }
        }
     } else {
-       new_tele = telegram_is_new(to, &tel);
-       np->nat_tgms += new_tele || np->nat_tgms == 0;
-       putnat(np);
-
-       if (new_tele && np->nat_flags & NF_INFORM) {
-           if (NULL != (other = getplayer(to))) {
-               if (np->nat_tgms == 1)
-                   pr_inform(other, "[new tele]\n");
-               else
-                   pr_inform(other, "[%d new teles]\n", np->nat_tgms);
+       if (!np->nat_tgms || !tel.tel_cont) {
+           np->nat_tgms++;
+           putnat(np);
+           if (np->nat_flags & NF_INFORM) {
+               other = getplayer(to);
+               if (other) {
+                   if (np->nat_tgms == 1)
+                       pr_inform(other, "[new tele]\n");
+                   else
+                       pr_inform(other, "[%d new teles]\n", np->nat_tgms);
+               }
            }
        }
     }