]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/bomb.c
COPYING duplicates information from README. Remove. Move GPL from
[empserver] / src / lib / commands / bomb.c
index 81b0e010f2200cc87f419d89b9e1d5f38f5e84c3..ba456860793b79bc660b997cc86e8038cb6ff42c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, 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.
  *
  *  ---
  *
@@ -33,6 +33,8 @@
  *     Steve McClure, 1998-2000
  */
 
+#include <config.h>
+
 #include <ctype.h>
 #include <string.h>
 #include "misc.h"
@@ -109,8 +111,8 @@ bomb(void)
     if (!snxtitem(&ni_esc, EF_PLANE,
                  getstarg(player->argp[2], "escort(s)? ", buf)))
        pr("No escorts...\n");
-    if ((p =
-        getstarg(player->argp[3], "pinpoint, or strategic? ", buf)) == 0)
+    p = getstarg(player->argp[3], "pinpoint, or strategic? ", buf);
+    if (!p)
        return RET_SYN;
     mission = *p;
     if (strchr("ps", mission) == 0)
@@ -202,8 +204,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
     int bad;
     s_char *p;
     struct plist *plp;
-    struct emp_qelem *qp;
-    int bestacc;
     int nsubs;
     int nunits;
     struct natstr *natp;
@@ -219,11 +219,6 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
     nsubs = 0;
     plp = (struct plist *)list->q_forw;
     if (plp->pcp->pl_flags & P_A) {
-       bestacc = 0;
-       for (qp = list->q_forw; qp != list; qp = qp->q_forw)
-           plp = (struct plist *)qp;
-       if (plp->plane.pln_acc < bestacc)
-           bestacc = plp->plane.pln_acc;
        nships = num_shipsatxy(target->sct_x, target->sct_y, 0, 0);
        nsubs = nships - shipsatxy(target->sct_x, target->sct_y, 0, M_SUB);
        if (nsubs > 0)
@@ -361,9 +356,8 @@ eff_bomb(struct emp_qelem *list, struct sctstr *target)
        if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
            continue;
        if (plp->bombs || plp->plane.pln_nuketype != -1)
-           dam +=
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
-                          &nukedam, 1);
+           dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                             'p', &nukedam, 1);
     }
     if (dam <= 0)              /* dam == 0 if only nukes were delivered */
        return;
@@ -448,9 +442,8 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
        if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
            continue;
        if (plp->bombs || plp->plane.pln_nuketype != -1)
-           dam +=
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
-                          &nukedam, 1);
+           dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                             'p', &nukedam, 1);
     }
     if (dam <= 0)              /* dam == 0 if only nukes were delivered */
        return;
@@ -549,7 +542,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
            continue;
 
        shell = gun = 0;
-       gun = min(ship.shp_item[I_GUN], ship.shp_glim);
+       gun = MIN(ship.shp_item[I_GUN], ship.shp_glim);
        if (gun > 0) {
            shell = ship.shp_item[I_SHELL];
            if (shell <= 0)
@@ -572,21 +565,19 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
        if (plp->plane.pln_nuketype != -1)
            hitchance = 100;
        else {
-           hitchance =
-               pln_hitchance(&plp->plane, shp_hardtarget(&ship), EF_SHIP);
+           hitchance = pln_hitchance(&plp->plane,
+                                     shp_hardtarget(&ship), EF_SHIP);
            pr("%d%% hitchance...", hitchance);
        }
        if (roll(100) <= hitchance) {
            /* pinbombing is more accurate than normal bombing */
-           dam =
-               2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
-                              'p', &nukedam, 1);
+           dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                                'p', &nukedam, 1);
        } else {
            pr("splash\n");
            /* Bombs that miss have to land somewhere! */
-           dam =
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
-                          &nukedam, 0);
+           dam = pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
+                            &nukedam, 0);
            collateral_damage(target->sct_x, target->sct_y, dam, list);
            dam = 0;
        }
@@ -688,15 +679,13 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
        }
        if (roll(100) <= hitchance) {
            /* pinbombing is more accurate than normal bombing */
-           dam =
-               2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
-                              'p', &nukedam, 1);
+           dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                                'p', &nukedam, 1);
        } else {
            pr("thud\n");
            /* Bombs that miss have to land somewhere! */
-           dam =
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
-                          &nukedam, 0);
+           dam = pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                            'p', &nukedam, 0);
            collateral_damage(target->sct_x, target->sct_y, dam, list);
            dam = 0;
        }
@@ -727,7 +716,7 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
               cname(player->cnum), dam, prplane(&plane),
               xyas(target->sct_x, target->sct_y, own));
        putplane(plane.pln_uid, &plane);
-       collateral_damage(plane.pln_x, plane.pln_y, dam, list);
+       collateral_damage(target->sct_x, target->sct_y, dam, list);
       next:
        ;
     }
@@ -803,20 +792,18 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
        if (plp->plane.pln_nuketype != -1)
            hitchance = 100;
        else {
-           hitchance =
-               pln_hitchance(&plp->plane, lnd_hardtarget(&land), EF_LAND);
+           hitchance = pln_hitchance(&plp->plane,
+                                     lnd_hardtarget(&land), EF_LAND);
            pr("%d%% hitchance...", hitchance);
        }
        if (roll(100) <= hitchance) {
-           dam =
-               2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
-                              'p', &nukedam, 1);
+           dam = 2 * pln_damage(&plp->plane, target->sct_x, target->sct_y,
+                                'p', &nukedam, 1);
        } else {
            pr("thud\n");
            /* Bombs that miss have to land somewhere! */
-           dam =
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
-                          &nukedam, 0);
+           dam = pln_damage(&plp->plane, target->sct_x, target->sct_y, 'p',
+                            &nukedam, 0);
            collateral_damage(target->sct_x, target->sct_y, dam, list);
            dam = 0;
        }
@@ -836,7 +823,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
                retreat_land(&land, 'b');
        nreport(player->cnum, N_UNIT_BOMB, own, 1);
        putland(land.lnd_uid, &land);
-       collateral_damage(land.lnd_x, land.lnd_y, dam, list);
+       collateral_damage(target->sct_x, target->sct_y, dam, list);
       next:
        ;
     }
@@ -856,9 +843,8 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
        if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
            continue;
        if (plp->bombs || plp->plane.pln_nuketype != -1)
-           dam +=
-               pln_damage(&plp->plane, target->sct_x, target->sct_y, 's',
-                          &nukedam, 1);
+           dam += pln_damage(&plp->plane, target->sct_x, target->sct_y, 's',
+                             &nukedam, 1);
     }
     if (dam <= 0)              /* dam == 0 if only nukes were delivered */
        return;