]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/plane.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / update / plane.c
index dd0fcac489ea45f4231942693bd601b47ca225a8..ed59081d851933cf6a01527de97c24403f189296 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.
  *
  *  ---
  *
@@ -32,8 +32,9 @@
  *     Steve McClure, 1998
  */
 
+#include <config.h>
+
 #include "misc.h"
-#include "var.h"
 #include "sect.h"
 #include "plane.h"
 #include "ship.h"
 #include "common.h"
 #include "gen.h"
 
-#ifndef MIN
-#define MIN(x,y)        ((x) > (y) ? (y) : (x))
-#endif
-
 int
 prod_plane(int etus, int natnum, int *bp, int buildem)
 
@@ -59,18 +56,13 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
 
                 /* Build = 1, maintain =0 */
 {
-    extern double money_mil;
-    extern double money_plane;
-    extern int plane_grow_scale;
-    extern long air_money[MAXNOC];
-    register struct plnstr *pp;
-    register struct plchrstr *plp;
+    struct plnstr *pp;
+    struct plchrstr *plp;
     struct natstr *np;
     float leftp, buildp;
     int left, build;
     int lcm_needed, hcm_needed;
     int mil_needed;
-    int svec[I_MAX + 1];
     int mvec[I_MAX + 1];
     int n, k = 0;
     struct shpstr *shp;
@@ -83,7 +75,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
     int avail;
     int w_p_eff;
     int used;
-    int start_money, onship = 0;
+    int start_money, onship;
 
     for (n = 0; NULL != (pp = getplanep(n)); n++) {
        if (pp->pln_own == 0)
@@ -99,7 +91,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
 
        plp = &plchr[(int)pp->pln_type];
        if (pp->pln_flags & PLN_LAUNCHED) {
-           if (opt_ORBIT && (buildem == 0)) {
+           if (buildem == 0) {
                if ((!player->simulation) &&
                    (plp->pl_flags & P_O) &&
                    (pp->pln_flags & PLN_LAUNCHED) &&
@@ -130,7 +122,6 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
        np = getnatp(pp->pln_own);
        desc = &plchr[(int)pp->pln_type];
        sp = getsectp(pp->pln_x, pp->pln_y);
-       getvec(VT_ITEM, svec, (s_char *)sp, EF_SECTOR);
        mult = 1;
        if (np->nat_level[NAT_TLEV] < pp->pln_tech * 0.85)
            mult = 2;
@@ -138,7 +129,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
        if (buildem == 0) {
            /* flight pay is 5x the pay received by other military */
            start_money = np->nat_money;
-           cost = -(mult * etus * dmin(0.0, desc->pl_cost * money_plane));
+           cost = -(mult * etus * MIN(0.0, desc->pl_cost * money_plane));
            if ((np->nat_priorities[PRI_PMAINT] == 0 ||
                 np->nat_money < cost) && !player->simulation) {
                if ((eff = pp->pln_effic - etus / 5) < PLANE_MINEFF) {
@@ -182,17 +173,15 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
                avail = gt_bg_nmbr(bp, sp, I_MAX + 1) * 100;
 
            if (pp->pln_ship >= 0) {
-               int vec[I_MAX + 1];
                shp = getshipp(pp->pln_ship);
-               getvec(VT_ITEM, vec, (s_char *)shp, EF_SHIP);
-               avail += (etus * vec[I_MILIT] / 2);
+               avail += (etus * shp->shp_item[I_MILIT] / 2);
            }
-           w_p_eff = 20 + (desc->pl_lcm + 2 * desc->pl_hcm);
+           w_p_eff = PLN_BLD_WORK(desc->pl_lcm, desc->pl_hcm);
            delta = roundavg((double)avail / w_p_eff);
            if (delta <= 0)
                continue;
-           if (delta > etus * plane_grow_scale)
-               delta = etus * plane_grow_scale;
+           if (delta > (int)((float)etus * plane_grow_scale))
+               delta = (int)((float)etus * plane_grow_scale);
            if (delta > left)
                delta = left;
 
@@ -203,7 +192,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
                left = delta;
 
            leftp = ((float)left / 100.0);
-           bzero((s_char *)mvec, sizeof(mvec));
+           memset(mvec, 0, sizeof(mvec));
            mvec[I_MILIT] = mil_needed =
                ldround((double)(plp->pl_crew * leftp), 1);
            mvec[I_LCM] = lcm_needed =
@@ -227,7 +216,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem)
                                      (float)plp->pl_hcm));
 
            build = ldround((double)(buildp * 100.0), 1);
-           bzero((s_char *)mvec, sizeof(mvec));
+           memset(mvec, 0, sizeof(mvec));
            mvec[I_MILIT] = mil_needed =
                roundavg((double)(plp->pl_crew * buildp));
            mvec[I_LCM] = lcm_needed =