]> git.pond.sub.org Git - empserver/commitdiff
Change wire not to read more after confirming deletion
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 23 Nov 2011 06:34:19 +0000 (07:34 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 29 Dec 2011 10:47:07 +0000 (11:47 +0100)
Telegram deletion deletes the mailbox.  If more telegrams arrive while
we wait for the player to confirm deletion, the mailbox again contains
unread telegrams, so we can't just delete it.  Instead, rea() loops to
read the new telegrams.

Announcements worked the same until Empire 3 put them in a single file
shared by all.  Since then, deleting announcements merely updates
nat_annotim, and there's no need to read new announcements after
getting the player's confirmation.  So don't.

src/lib/commands/rea.c

index 33fcde34ca4ac5128c465d77d5f1fce23a2c2cae..28f7872744060c6b7337c95d8d3785268fa1a4a1 100644 (file)
@@ -157,19 +157,19 @@ rea(void)
        }
        p = getstarg(player->argp[1], p, buf);
        if (p && *p == 'y') {
        }
        p = getstarg(player->argp[1], p, buf);
        if (p && *p == 'y') {
-           if ((filelen = fsize(fileno(telfp))) > size) {
-               pr("Wait a sec!  A new %s has arrived...\n", kind);
-               /* force stdio to re-read tel file */
-               (void)fflush(telfp);
-               (void)fseek(telfp, (long)size, SEEK_SET);
-               size = filelen;
-               now = time(NULL);
-               goto more;
-           }
            if (*kind == 'a') {
                np->nat_annotim = now;
                putnat(np);
            } else {
            if (*kind == 'a') {
                np->nat_annotim = now;
                putnat(np);
            } else {
+               if ((filelen = fsize(fileno(telfp))) > size) {
+                   pr("Wait a sec!  A new %s has arrived...\n", kind);
+                   /* force stdio to re-read tel file */
+                   (void)fflush(telfp);
+                   (void)fseek(telfp, (long)size, SEEK_SET);
+                   size = filelen;
+                   now = time(NULL);
+                   goto more;
+               }
                /* Here, we just re-open the file for "w" only,
                   and that will wipe the file clean automatically */
                (void)fclose(telfp);
                /* Here, we just re-open the file for "w" only,
                   and that will wipe the file clean automatically */
                (void)fclose(telfp);