]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/fortdef.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / subs / fortdef.c
index 6f33653de02a2af02757d269b5555459b3caf2fd..29579937167e91f154a509b51c717016d42cad9d 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.
  *
  *  ---
  *
  *  Known contributors to this file:
  *    
  */
+
 /*
  * The base routines can also be used for general purposes.
  * Noisy tells whther to send teles, print things, etc.
  * Defending tells whether they are being defensive, or offensive.
  */
 
+#include <config.h>
+
 #include "misc.h"
-#include "var.h"
 #include "xy.h"
 #include "nat.h"
 #include "sect.h"
@@ -46,7 +48,6 @@
 #include "news.h"
 #include "nsc.h"
 #include "file.h"
-#include "options.h"
 #include "optlist.h"
 #include "prototypes.h"
 
@@ -73,7 +74,7 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
     double eff;
     struct shpstr ship;
     struct nstr_item ni;
-    int vec[I_MAX + 1];
+    int shell;
     int dam, rel, rel2;
 
     if (own == 0)
@@ -82,7 +83,7 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
        return 0;
     eff = 1.0;
     snxtitem_dist(&ni, EF_SHIP, x, y, 8);
-    while (nxtitem(&ni, (caddr_t)&ship) && eff > 0.30) {
+    while (nxtitem(&ni, &ship) && eff > 0.30) {
        if (ship.shp_own == att)
            continue;
        if (ship.shp_own == 0)
@@ -94,7 +95,7 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
            continue;
        if (ship.shp_effic < 60)
            continue;
-       if ((mchr[(int)ship.shp_type].m_flags & M_SUB) && (!usesubs))
+       if ((mchr[(int)ship.shp_type].m_flags & M_SUB) && !usesubs)
            continue;
        range = techfact(ship.shp_tech,
                         ship.shp_frnge * ship.shp_effic / 200.0);
@@ -102,17 +103,15 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
        if (range < ni.curdist)
            continue;
        /* must have gun, shell, and milit to fire */
-       if (getvec(VT_ITEM, vec, (caddr_t)&ship, EF_SHIP) < 3)
-           continue;
-       if (vec[I_SHELL] < ship.shp_glim)
-           vec[I_SHELL] += supply_commod(ship.shp_own, ship.shp_x,
-                                         ship.shp_y, I_SHELL,
-                                         vec[I_SHELL] - ship.shp_glim);
-       nshot = min(min(vec[I_GUN], vec[I_SHELL]), vec[I_MILIT]);
-       nshot = min(nshot, ship.shp_glim);
+       shell = ship.shp_item[I_SHELL];
+       if (shell < ship.shp_glim)
+           shell += supply_commod(ship.shp_own, ship.shp_x, ship.shp_y,
+                                  I_SHELL, shell - ship.shp_glim);
+       nshot = MIN(MIN(ship.shp_item[I_GUN], shell), ship.shp_item[I_MILIT]);
+       nshot = MIN(nshot, ship.shp_glim);
        if (nshot <= 0)
            continue;
-       ship.shp_item[I_SHELL] = vec[I_SHELL] - nshot;
+       ship.shp_item[I_SHELL] = shell - nshot;
        putship(ship.shp_uid, &ship);
        if (defending)
            nreport(ship.shp_own, N_FIRE_BACK, att, 1);
@@ -145,30 +144,9 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
            }
        }
     }
-    return (int)100 - (eff * 100);
+    return (int)100 - eff * 100;
 }
 
-/*
- * Determine if any nearby gun-equipped sectors are within
- * range and able to fire at an attacker.  Firing sectors
- * need to have guns, shells, and military.  Sector being
- * attacked is x,y -- attacker is at ax,ay.
- */
-#if 0
-/* defdef isn't called anywhere, and uses wrong
- * number of arguments for dd */
-int
-defdef(att, def_own, defval, ax, ay)
-natid att;
-natid def_own;
-int defval;
-coord ax;
-coord ay;
-{
-    return dd(att, def_own, defval, ax, ay, NOISY, 1);
-}
-#endif
-
 int
 dd(natid att, natid def_own, coord ax, coord ay, int noisy, int defending)
 {
@@ -177,7 +155,6 @@ dd(natid att, natid def_own, coord ax, coord ay, int noisy, int defending)
     double range;
     struct sctstr firing;
     struct nstr_sect ns;
-    int vec[I_MAX + 1];
 
     if (opt_NO_FORT_FIRE)      /* Forts can't fire! */
        return 0;
@@ -193,15 +170,13 @@ dd(natid att, natid def_own, coord ax, coord ay, int noisy, int defending)
            continue;
        if (firing.sct_own == 0)
            continue;
-       if (firing.sct_effic < (u_char)FORTEFF)
+       if (firing.sct_effic < FORTEFF)
            continue;
        rel = getrel(getnatp(firing.sct_own), def_own);
        rel2 = getrel(getnatp(firing.sct_own), att);
        if ((firing.sct_own != def_own) &&
            ((rel != ALLIED) || (rel2 != AT_WAR)))
            continue;
-       if (getvec(VT_ITEM, vec, (caddr_t)&firing, EF_SECTOR) < 0)
-           continue;
 
        range = tfactfire(def_own, 7.0);
        if (firing.sct_effic > 59)
@@ -227,7 +202,7 @@ int
 sb(natid att, natid def, struct sctstr *sp, coord tx, coord ty, int noisy,
    int defending)
 {
-    register int damage;
+    int damage;
     natid own;
     int shell;
     double range;
@@ -238,7 +213,7 @@ sb(natid att, natid def, struct sctstr *sp, coord tx, coord ty, int noisy,
        return 0;
     }
 
-    if (sp->sct_effic < (u_char)FORTEFF)
+    if (sp->sct_effic < FORTEFF)
        return 0;
 
     own = sp->sct_own;