]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/prod.c
Clean up redundant code in prod()
[empserver] / src / lib / commands / prod.c
index 80f281b207e6ddd0390b0bba430dc5139a696f74..882ff28cb79c84b96b7afe78241dc61761e16462 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2013, 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,
@@ -14,8 +14,7 @@
  *  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/>.
  *
  *  ---
  *
@@ -30,7 +29,7 @@
  *  Known contributors to this file:
  *     David Muir Sharnoff, 1987
  *     Steve McClure, 1997-2000
- *     Markus Armbruster, 2004-2008
+ *     Markus Armbruster, 2004-2010
  */
 
 #include <config.h>
@@ -136,7 +135,6 @@ prod(void)
                eff = 0;
            }
            if (!eff && IS_BIG_CITY(otype) && !IS_BIG_CITY(type)) {
-               natp = getnatp(sect.sct_own);
                maxpop = max_population(natp->nat_level[NAT_RLEV],
                                        type, eff);
                work = new_work(&sect,
@@ -185,12 +183,8 @@ prod(void)
 
            if (sect.sct_own != sect.sct_oldown)
                continue;
-           civs = (1.0 + obrate * etu_per_update) * sect.sct_item[I_CIVIL];
-           natp = getnatp(sect.sct_own);
-           maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
-           civs = MIN(civs, maxpop);
            enlisted = 0;
-           maxmil = (civs / 2) - sect.sct_item[I_MILIT];
+           maxmil = MIN(civs, maxpop) / 2 - sect.sct_item[I_MILIT];
            if (maxmil > 0) {
                enlisted = (etu_per_update
                            * (10 + sect.sct_item[I_MILIT])
@@ -211,14 +205,16 @@ prod(void)
        unit_work = 0;
        pp = &pchr[dchr[type].d_prd];
        vtype = pp->p_type;
-       natp = getnatp(sect.sct_own);
+       if (pp->p_nrndx)
+           resource = (unsigned char *)&sect + pp->p_nrndx;
+       else
+           resource = NULL;
        /*
         * sect p_e  (inc improvements)
         */
-       if (pp->p_nrndx != 0) {
+       if (resource) {
            unit_work++;
-           resource = (unsigned char *)&sect + pp->p_nrndx;
-           p_e = (*resource * p_e) / 100.0;
+           p_e *= *resource / 100.0;
        }
        /*
         * production effic.
@@ -244,7 +240,7 @@ prod(void)
         * workforce?
         */
        max = (int)(work * p_e / (double)unit_work + 0.5);
-       if (pp->p_nrdep != 0 && vtype != I_NONE) {
+       if (resource && pp->p_nrdep != 0) {
            if (*resource * 100 < pp->p_nrdep * max)
                max = *resource * 100 / pp->p_nrdep;
        }
@@ -324,7 +320,7 @@ prprod(coord x, coord y, int type, double p_e, double prodeff, int work,
        pr("   sect  des eff avail  make p.e. cost   use1 use2 use3  max1 max2 max3   max\n");
     }
 
-    prxy("%4d,%-4d", x, y, player->cnum);
+    prxy("%4d,%-4d", x, y);
     pr(" %c %3.0f%% %5d", dchr[type].d_mnem, p_e * 100.0, work);
     if (mnem == '.')
        pr(" %5.2f", make);