]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/sect.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / update / sect.c
index 7f3de4c80901702a1697dcd1459171001fda13df..e4e8b43b92aa3640cfcbeb46ccfd0579857c87ef 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2004, 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.
  *
  *  ---
  *
@@ -32,6 +32,8 @@
  *     Steve McClure, 1996
  */
 
+#include <config.h>
+
 #include "misc.h"
 #include "sect.h"
 #include "nat.h"
@@ -84,20 +86,18 @@ upd_buildeff(struct natstr *np, struct sctstr *sp, int *workp,
        }
        neweff = n;
        *cost += work_cost;
-       if (opt_BIG_CITY) {
-           if (!n && dchr[old_type].d_pkg == UPKG &&
-               dchr[*desig].d_pkg != UPKG) {
-               int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n);
-               if (vec[I_CIVIL] > maxpop)
-                   vec[I_CIVIL] = maxpop;
-               if (vec[I_UW] > maxpop)
-                   vec[I_UW] = maxpop;
-               *workp = (vec[I_CIVIL] * sctwork) / 100.0
-                   + (vec[I_MILIT] * 2 / 5.0) + vec[I_UW];
-               *workp = roundavg((etu * (*workp)) / 100.0);
-
-               buildeff_work = min((int)(*workp / 2), buildeff_work);
-           }
+       if (!n && IS_BIG_CITY(old_type) &&
+           !IS_BIG_CITY(*desig)) {
+           int maxpop = max_population(np->nat_level[NAT_RLEV], *desig, n);
+           if (vec[I_CIVIL] > maxpop)
+               vec[I_CIVIL] = maxpop;
+           if (vec[I_UW] > maxpop)
+               vec[I_UW] = maxpop;
+           *workp = (vec[I_CIVIL] * sctwork) / 100.0
+               + (vec[I_MILIT] * 2 / 5.0) + vec[I_UW];
+           *workp = roundavg((etu * (*workp)) / 100.0);
+
+           buildeff_work = MIN((int)(*workp / 2), buildeff_work);
        }
     }
     if (np->nat_priorities[*desig]) {
@@ -171,21 +171,21 @@ meltitems(int etus, int fallout, int own, short *vec, int type, int x, int y,
 
     for (n = I_NONE + 1; n <= I_MAX; n++) {
        melt = roundavg(vec[n] * etus * (long)fallout
-                       / (1000.0 * melt_item_denom[n]));
+                       / (1000.0 * ichr[n].i_melt_denom));
        if (melt > vec[n])
            melt = vec[n];
        if (melt > 5 && own) {
            if (type == EF_SECTOR)
                wu(0, own, "Lost %d %s to radiation in %s.\n",
-                  melt < vec[n] ? melt : vec[n], ichr[n].i_name,
+                  melt, ichr[n].i_name,
                   xyas(x, y, own));
            else if (type == EF_LAND)
                wu(0, own, "Unit #%d lost %d %s to radiation in %s.\n",
-                  uid, melt < vec[n] ? melt : vec[n], ichr[n].i_name,
+                  uid, melt, ichr[n].i_name,
                   xyas(x, y, own));
            else if (type == EF_SHIP)
                wu(0, own, "Ship #%d lost %d %s to radiation in %s.\n",
-                  uid, melt < vec[n] ? melt : vec[n], ichr[n].i_name,
+                  uid, melt, ichr[n].i_name,
                   xyas(x, y, own));
        }
        vec[n] -= melt;
@@ -193,12 +193,10 @@ meltitems(int etus, int fallout, int own, short *vec, int type, int x, int y,
 }
 
 /*
- * do_fallout - calculate fallout for sectors.
- *
- * This is etu based.  But, do limit HUGE kill offs in large ETU
- * games, the melting etus rate is limited to 24 etus.
+ * Do fallout meltdown for sector SP.
+ * ETUS above 24 are treated as 24 to avoid *huge* kill offs in
+ * large ETU games.
  */
-
 void
 do_fallout(struct sctstr *sp, int etus)
 {
@@ -231,10 +229,6 @@ do_fallout(struct sctstr *sp, int etus)
        meltitems(etus, sp->sct_fallout, spp->shp_own, spp->shp_item, EF_SHIP,
                  spp->shp_x, spp->shp_y, spp->shp_uid);
     }
-#ifdef GODZILLA
-    if ((sp->sct_fallout > 20) && chance(100))
-       do_godzilla(sp);
-#endif /* GODZILLA */
 }
 
 void
@@ -251,17 +245,9 @@ spread_fallout(struct sctstr *sp, int etus)
        if (ap->sct_type == SCT_SANCT)
            continue;
        inc = roundavg(etus * fallout_spread * (sp->sct_fallout)) - 1;
-#if 0
-       if (sp->sct_fallout) {
-           wu(0, 0, "Fallout from sector %d,%d to %d,%d is %d=%d*%e*%d\n",
-              sp->sct_x, sp->sct_y, sp->sct_x + diroff[n][0],
-              sp->sct_y + diroff[n][1], inc, etus,
-              fallout_spread, sp->sct_fallout);
-       }
-#endif
        if (inc < 0)
            inc = 0;
-       ap->sct_fallout = min(ap->sct_fallout + inc, FALLOUT_MAX);
+       ap->sct_fallout = MIN(ap->sct_fallout + inc, FALLOUT_MAX);
     }
 }
 
@@ -275,12 +261,6 @@ decay_fallout(struct sctstr *sp, int etus)
     decay = roundavg(((decay_per_etu + 6.0) * fallout_spread) *
                     (double)etus * (double)sp->sct_fallout);
 
-#if 0
-    if (decay || sp->sct_fallout)
-       wu(0, 0, "Fallout decay in %d,%d is %d from %d\n", sp->sct_x,
-          sp->sct_y, decay, sp->sct_fallout);
-#endif
-
     sp->sct_fallout = decay < sp->sct_fallout ? sp->sct_fallout - decay : 0;
 }