]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/zdon.c
Update copyright notice
[empserver] / src / lib / commands / zdon.c
index b3136ecec9b59ff52349aa7741243c54da359123..284b6442b5577ec876bf5604110b5f3d54506a5c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
@@ -29,6 +29,7 @@
  * 
  *  Known contributors to this file:
  *     Doug Hay, 1990
+ *     Markus Armbruster, 2007
  */
 
 /*
  * if an update should occur.
  */
 
-#include <stdio.h>
-#include "misc.h"
-#include "player.h"
-#include "nat.h"
-#include "file.h"
-#include "empthread.h"
+#include <config.h>
+
 #include "commands.h"
 #include "optlist.h"
 #include "server.h"
@@ -64,17 +61,17 @@ zdon(void)
 {
     natid whichcnum;
     struct natstr *natp;
-    register s_char *p;
+    char *p;
 
-    int update;
     int checking;
     int wantupd;
     int totpop;
     int totwant;
     int dowant;
-    s_char buf[1024];
+    char buf[1024];
 
-    if (!opt_DEMANDUPDATE) {
+    if (update_demand != UPD_DEMAND_SCHED
+       && update_demand != UPD_DEMAND_ASYNC) {
        pr("Demand updates are not enabled.\n");
        return RET_FAIL;
     }
@@ -92,36 +89,34 @@ zdon(void)
     if (player->aborted)
        return RET_FAIL;
 
-    if (!p) {
-       /* Default response is checking only */
-       checking = 1;
-    } else {
-       checking = 0;
-       if (*p == 'n' || *p == 'N') {
-           wantupd = 0;
-       } else if (*p == 'y' || *p == 'Y') {
+    checking = 1;
+    wantupd = 0;
+    if (p) {
+       if (*p == 'y' || *p == 'Y') {
+           checking = 0;
            wantupd = 1;
-       } else {
-           /* Default response is checking only */
-           checking = 1;
+       } else if  (*p == 'n' || *p == 'N') {
+           checking = 0;
+           wantupd = 0;
        }
     }
 
+    if (!(natp = getnatp(whichcnum))) {
+       pr("Unable to find country. %d\n", whichcnum);
+       pr("Notify the Deity.\n");
+       return RET_FAIL;
+    }
     if (!checking) {
-       if (!(natp = getnatp(whichcnum))) {
-           pr("Unable to find country. %d\n", whichcnum);
-           pr("Notify the Deity.\n");
-           return RET_FAIL;
-       }
        if (wantupd) {
-           update = natp->nat_update | WUPD_WANT;
-           natp->nat_missed = 0;
+           if (influx(natp)) {
+               pr("Unable to request an update as the country is in flux\n");
+               return RET_FAIL;
+           }
            pr("You (%d) now want an update.\n", whichcnum);
        } else {
-           update = natp->nat_update & ~WUPD_WANT;
            pr("You (%d) now DON'T want an update.\n", whichcnum);
        }
-       natp->nat_update = update;
+       natp->nat_update = wantupd;
        putnat(natp);
     }
 
@@ -137,7 +132,7 @@ zdon(void)
 
     if (!checking && wantupd && demandupdatecheck()) {
        pr("Here goes...\n");
-       empth_sem_signal(update_sem);
+       update_trigger();
     }
     return RET_OK;
 }