]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/lndsub.c
Get rid of msl_launch_mindam()
[empserver] / src / lib / subs / lndsub.c
index 39b0b83f944c9ced35f9a6ec6c7075d9851d59bf..98fb636cdcf9d8b8a842ecc6898f39dd41e4ccfd 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
@@ -124,6 +124,17 @@ defense_val(struct lndstr *lp)
     return value;
 }
 
+int
+lnd_reaction_range(struct lndstr *lp)
+{
+    struct sctstr sect;
+
+    getsect(lp->lnd_x, lp->lnd_y, &sect);
+    if (sect.sct_type == SCT_HEADQ && sect.sct_effic >= 60)
+       return lchr[lp->lnd_type].l_rad + 1;
+    return lchr[lp->lnd_type].l_rad;
+}
+
 void
 lnd_print(struct ulist *llp, char *s)
 {
@@ -542,10 +553,10 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
                    prland(&llp->unit.land));
            continue;
        }
-       if (sect.sct_type == SCT_BSPAN) {
+       if (SCT_MINES_ARE_SEAMINES(&sect)) {
            if (verbose)
-               mpr(actor, "%s is on a bridge.  No mines there!\n",
-                   prland(&llp->unit.land));
+               mpr(actor, "%s is in a %s sector.  No landmines there!\n",
+                   prland(&llp->unit.land), dchr[sect.sct_type].d_name);
            continue;
        }
        if (takemob) {
@@ -609,9 +620,7 @@ lnd_check_mines(struct emp_qelem *land_list)
        getsect(llp->unit.land.lnd_x, llp->unit.land.lnd_y, &sect);
        if (sect.sct_oldown == llp->unit.land.lnd_own)
            continue;
-       if (sect.sct_type == SCT_BSPAN)
-           continue;
-       if (!sect.sct_mines)
+       if (SCT_LANDMINES(&sect) == 0)
            continue;
        if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
            lnd_hit_mine(&llp->unit.land, ((struct lchrstr *)llp->chrp));
@@ -709,26 +718,47 @@ static int
 lnd_missile_interdiction(struct emp_qelem *list, coord newx, coord newy,
                         natid victim)
 {
-    int dam;
+    int mindam = lnd_count(list) * 20;
+    int hardtarget = lnd_easiest_target(list);
+    int dam, newdam;
+    struct plist *plp;
     struct emp_qelem msl_list, *qp, *newqp;
 
     msl_sel(&msl_list, newx, newy, victim, P_T, P_MAR, MI_INTERDICT);
 
-    dam = msl_launch_mindam(&msl_list, newx, newy,
-                           lnd_easiest_target(list), EF_LAND,
-                           lnd_count(list) * 20, "troops", victim,
-                           MI_INTERDICT);
+    dam = 0;
+    for (qp = msl_list.q_back; qp != &msl_list; qp = newqp) {
+       newqp = qp->q_back;
+       plp = (struct plist *)qp;
+
+       if (dam < mindam && mission_pln_equip(plp, NULL, 'p') >= 0) {
+           if (msl_hit(&plp->plane, hardtarget, EF_LAND,
+                       N_LND_MISS, N_LND_SMISS,
+                       "troops", newx, newy, victim)) {
+               newdam = pln_damage(&plp->plane, 'p', 1);
+               dam += newdam;
+#if 0
+           /*
+            * FIXME want collateral damage on miss, 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, 'p', 0);
+               collateral_damage(newx, newy, newdam);
+#endif
+           }
+           plp->plane.pln_effic = 0;
+           putplane(plp->plane.pln_uid, &plp->plane);
+       }
+       emp_remque(qp);
+       free(qp);
+    }
+
     if (dam) {
        mpr(victim, "missile interdiction mission does %d damage!\n", dam);
        collateral_damage(newx, newy, dam);
     }
-    qp = msl_list.q_forw;
-    while (qp != msl_list.q_forw) {
-       newqp = qp->q_forw;
-       emp_remque(qp);
-       free(qp);
-       qp = newqp;
-    }
     return dam;
 }
 
@@ -978,7 +1008,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
                    pr("%s was shot and killed.\n", prland(&llp->unit.land));
                    llp->unit.land.lnd_effic = 0;
                    putland(llp->unit.land.lnd_uid, &llp->unit.land);
-                   lnd_delete(llp, 0);
+                   lnd_delete(llp, NULL);
                }
            }
        }