]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/age.c
Update copyright notice
[empserver] / src / lib / update / age.c
index a1322cc5f01893757368028a53a88ae35d971a9c..5e19418ac65d29a0af5992b294ee784b0bf3e750 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
- *  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.
  *
  *  ---
  *
  *  age.c: Age people
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  */
 
 #include <config.h>
 
-#include "misc.h"
-#include "nat.h"
-#include "file.h"
+#include "chance.h"
 #include "update.h"
-#include "gen.h"
-#include "optlist.h"
+
+int
+age_people(int n, int etu)
+{
+    /* age by 1% per 24 etus */
+    return roundavg(n * (1.0 - etu / 2400.0));
+}
 
 void
 age_levels(int etu)
 {
-    register float best_tech;
-    register float best_res;
-    register struct natstr *np;
+    float best_tech, best_res;
+    struct natstr *np;
     int i;
     double level;
     double delta;
-    int deltares;
 
     best_tech = 0.0;
     best_res = 0.0;
@@ -67,23 +67,12 @@ age_levels(int etu)
            delta = np->nat_level[NAT_TLEV] * etu / (100 * level_age_rate);
            np->nat_level[NAT_TLEV] -= delta;
        }
-       /*
-        * age reserves by 1% per every 24 etus
-        */
-       deltares = -roundavg(np->nat_reserve * etu / 2400.0);
-       if (deltares != 0)
-           np->nat_reserve += deltares;
-       /* Chad Zabel - above number is negative ( was a -= there
-          which was wrong. */
+       np->nat_reserve = age_people(np->nat_reserve, etu);
     }
     best_tech /= 5;
     best_res /= 5;
     for (i = 0; NULL != (np = getnatp(i)); i++) {
-       if (np->nat_stat == STAT_UNUSED)
-           continue;
-       if (np->nat_stat == STAT_GOD)
-           continue;
-       if (np->nat_stat == STAT_VIS)
+       if (np->nat_stat < STAT_SANCT || np->nat_stat == STAT_GOD)
            continue;
        level = np->nat_level[NAT_TLEV];
        if (level < best_tech && chance(0.2))