]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mslsub.c
Update copyright notice
[empserver] / src / lib / subs / mslsub.c
index f5d42a2210319052dfb41c4d63bce94b3d3d3c3a..f5decdd09a177b2087a184687b335d3272c2e458 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  mslsub.c: Missile subroutine stuff
- * 
+ *
  *  Known contributors to this file:
  *     Ken Stevens, 1995
  *     Steve McClure, 1996-2000
@@ -42,6 +42,7 @@
 #include "nat.h"
 #include "news.h"
 #include "nsc.h"
+#include "nuke.h"
 #include "optlist.h"
 #include "path.h"
 #include "plane.h"
@@ -124,10 +125,15 @@ msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
        return 0;
     }
 
+    CANT_HAPPEN(pp->pln_flags & PLN_LAUNCHED);
+    pp->pln_flags |= PLN_LAUNCHED;
+    putplane(pp->pln_uid, pp);
     mpr(pp->pln_own, "\tSHWOOOOOSH!  Missile launched!\n");
 
-    if (pp->pln_nuketype != -1)
+    if (nuk_on_plane(pp) >= 0) {
        mpr(pp->pln_own, "\tArming nuclear warheads...\n");
+       hitchance = 100;
+    }
 
     if (pcp->pl_flags & P_T)
        mpr(victim, "Incoming %s missile sighted at %s...\n",
@@ -147,9 +153,6 @@ msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
        }
     }
 
-    if (pp->pln_nuketype != -1)
-       hitchance = 100;
-
     mpr(pp->pln_own, "\t%d%% hitchance...", hitchance);
     hit = (roll(100) <= hitchance);
 
@@ -191,6 +194,9 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim,
            continue;
        if (mission && plane.pln_mission != mission)
            continue;
+       if (mission &&
+           plane.pln_radius < mapdist(x, y, plane.pln_opx, plane.pln_opy))
+           continue;
        if (getrel(getnatp(plane.pln_own), victim) >= NEUTRAL)
            continue;
        /* missiles go one way, so we can use all the range */
@@ -405,10 +411,17 @@ msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
                        dam += nukedam;
                } else
                    dam += newdam;
+#if 0
+           /*
+            * FIXME want collateral damage on miss (which can't
+            * happen for nuclear war heads), but we get here too when
+            * launch fails or missile is intercepted
+            */
            } else {
                /* Missiles that miss have to hit somewhere! */
                newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 0);
                collateral_damage(x, y, newdam);
+#endif
            }
            plp->plane.pln_effic = 0;
            putplane(plp->plane.pln_uid, &plp->plane);