]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/wantupd.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / common / wantupd.c
index b1861dc86b05959a28a495da9ec7d7350b3cba54..2557c643aa31c18e5c2eecbc8d50763ee27994c7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2006, 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.
  *
  *  ---
  *
@@ -31,6 +31,8 @@
  *     Doug Hay, 1990
  */
 
+#include <config.h>
+
 #include <stdio.h>
 #if !defined(_WIN32)
 #include <unistd.h>
@@ -127,8 +129,7 @@ demand_update_want(int *want, int *pop, int which)
     for (cn = 1; 0 != (natp = getnatp(cn)); cn++) {
        /* Only countries which are normal. */
        /* Should probably include sanctuaries ..... */
-       if (((natp->nat_stat & NORM) == NORM) &&
-           ((natp->nat_stat & GOD) != GOD)) {
+       if (natp->nat_stat == STAT_ACTIVE) {
            totpop++;
            if ((natp->nat_update & WUPD_WANT) == WUPD_WANT) {
                totwant++;
@@ -139,7 +140,7 @@ demand_update_want(int *want, int *pop, int which)
     }
     *want = totwant;
     *pop = totpop;
-    return (whichwants);
+    return whichwants;
 }
 
 static int
@@ -154,39 +155,38 @@ demand_check(void)
 
     if (0 == update_wantmin) {
        logerror("no demand update allowed, wantmin = 0");
-       return (0);
+       return 0;
     }
 
     demand_update_want(&want, &pop, 0);
     if (want < update_wantmin) {
        logerror("no demand update, want = %d, min = %d",
                 want, update_wantmin);
-       return (0);
+       return 0;
     }
 
     time(&now);
     if (!demand_update_time(&now)) {
        logerror("no demand update, not within hours allowed.");
-       return (0);
+       return 0;
     }
 
 
     veto = 0;
     for (cn = 1; 0 != (natp = getnatp(cn)); cn++) {
-       if (((natp->nat_stat & NORM) == NORM) &&
-           ((natp->nat_stat & GOD) != GOD)) {
+       if (natp->nat_stat == STAT_ACTIVE) {
            if (natp->nat_missed >= update_missed)
-               veto = cn + 1;
+               veto = cn;
        }
     }
 
     if (veto) {
        logerror("no demand update, %d has missed more than %d updates",
-                veto - 1, update_missed);
-       return (0);
+                veto, update_missed);
+       return 0;
     }
 
-    return (1);
+    return 1;
 }
 
 /* Check if enough countries want an update,
@@ -197,10 +197,10 @@ demandupdatecheck(void)
 {
     if (UDDEM_COMSET != update_demandpolicy) {
        logerror("no demand update, not policy.");
-       return (0);
+       return 0;
     }
 
-    return (demand_check());
+    return demand_check();
 }
 
 /* Is it time for a regular or scheduled update?
@@ -212,27 +212,27 @@ updatetime(time_t *now)
 {
     if (opt_BLITZ && update_policy == UDP_BLITZ) {
        logerror("BLITZ Update.");
-       return (1);
+       return 1;
     }
 
     if (UDP_NORMAL == update_policy) {
        logerror("Regular update, etu type.");
-       return (1);
+       return 1;
     }
 
     if (UDP_TIMES == update_policy) {
        if (scheduled_update_time(now)) {
            logerror("Scheduled update.");
-           return (1);
+           return 1;
        }
     }
     if (opt_DEMANDUPDATE) {
        if (demand_check()) {
            logerror("Demand update, at check time.");
-           return (1);
+           return 1;
        }
     }
-    return (0);
+    return 0;
 }
 
 /* Return the time, and delta seconds, of the next update.