]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mslsub.c
Get rid of msl_launch_mindam()
[empserver] / src / lib / subs / mslsub.c
index a8ec1b4f08887acf3fe3dedf3c663ede0b967826..8e48692ec2aa035c41efb90b74c2dd3c7028616a 100644 (file)
 #include "ship.h"
 #include "xy.h"
 
-int
-msl_equip(struct plnstr *pp, char mission)
-{
-    struct plist pl;
-
-    memset(&pl, 0, sizeof(struct plist));
-    pl.pcp = plchr + pp->pln_type;
-    pl.plane = *pp;
-    return mission_pln_equip(&pl, NULL, 0, mission);
-}
-
 int
 msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
        int snews_item, char *what, coord x, coord y, int victim)
@@ -75,7 +64,7 @@ msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
     struct plchrstr *pcp = plchr + pp->pln_type;
     int hitchance;
     char *from;
-    int dam, dummyi;
+    int dam;
 
     mpr(pp->pln_own, "Preparing to launch %s at %s %s %s%s\n",
        prplane(pp),
@@ -107,19 +96,16 @@ msl_hit(struct plnstr *pp, int hardtarget, int type, int news_item,
               * (1 - techfact(pp->pln_tech, 1.0)))) {
        mpr(pp->pln_own, "KABOOOOM!  Missile explodes %s!\n", from);
        if (chance(0.33)) {
-           dam = pln_damage(pp, pp->pln_x, pp->pln_y,
-                            'p', &dummyi, 1) / 2;
-           if (dam) {
-               if (pp->pln_ship >= 0) {
-                   shipdamage(&ship, dam);
-                   putship(ship.shp_uid, &ship);
-               } else {
-                   pr("Explosion damages %s %d%%",
-                      xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
-                   getsect(pp->pln_x, pp->pln_y, &sect);
-                   sectdamage(&sect, dam);
-                   putsect(&sect);
-               }
+           dam = pln_damage(pp, 'p', 1) / 2;
+           if (pp->pln_ship >= 0) {
+               shipdamage(&ship, dam);
+               putship(ship.shp_uid, &ship);
+           } else {
+               pr("Explosion damages %s %d%%",
+                  xyas(pp->pln_x, pp->pln_y, pp->pln_own), dam);
+               getsect(pp->pln_x, pp->pln_y, &sect);
+               sectdamage(&sect, dam);
+               putsect(&sect);
            }
        }
        return 0;
@@ -210,8 +196,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim,
            continue;
        /* got a valid interceptor */
        irv = malloc(sizeof(*irv));
-       irv->bombs = 0;
-       irv->misc = 0;
+       irv->load = 0;
        irv->pcp = &plchr[(int)plane.pln_type];
        irv->plane = plane;
        emp_insque(&irv->queue, list);
@@ -233,7 +218,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
     struct emp_qelem *next;
     struct plist *ip;
     int icount = 0;
-    short destroyed = 0;
+    short destroyed;
     char *att_name;
     char *def_name;
     int news_item;
@@ -244,9 +229,9 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        att_name = "satellite";
        def_name = "a-sat missile";
        news_item = N_SAT_KILL;
+       CANT_HAPPEN(sublaunch);
        mpr(sect.sct_own, "%s has positioned a satellite over %s\n",
-           sublaunch ? "someone" : cname(bombown),
-           xyas(x, y, sect.sct_own));
+           cname(bombown), xyas(x, y, sect.sct_own));
     } else if (wantflags == P_N && nowantflags == P_O) {
        att_name = "warhead";
        def_name = "abm";
@@ -271,7 +256,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        if (pp->pln_own != sect.sct_own)
            continue;
        pcp = ip->pcp;
-       if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
+       if (mission_pln_equip(ip, NULL, 'i') < 0) {
            emp_remque(qp);
            free(qp);
            continue;
@@ -290,7 +275,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        ip = (struct plist *)qp;
        pp = &ip->plane;
        pcp = ip->pcp;
-       if (mission_pln_equip(ip, NULL, 0, 'i') < 0) {
+       if (mission_pln_equip(ip, NULL, 'i') < 0) {
            emp_remque(qp);
            free(qp);
            continue;
@@ -311,12 +296,13 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
     }
     if (icount == 0) {
        mpr(sect.sct_own, "No %ss launched to intercept.\n", def_name);
-       return destroyed;
+       return 0;
     }
 
     /* attempt to destroy incoming missile */
 
-    while (!QEMPTY(intlist)) {
+    destroyed = 0;
+    while (!destroyed && !QEMPTY(intlist)) {
        qp = intlist->q_forw;
        ip = (struct plist *)qp;
        pp = &ip->plane;
@@ -336,8 +322,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
                def_name, who, att_name, cname(sect.sct_own));
        }
 
-       if (!destroyed &&
-           msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
+       if (msl_hit(pp, hardtarget, EF_PLANE, news_item, news_item,
                    att_name, x, y, bombown)) {
            mpr(bombown, "%s destroyed by %s %s!\n",
                att_name, cname(pp->pln_own), def_name);
@@ -351,8 +336,6 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        putplane(pp->pln_uid, pp);
        emp_remque(qp);
        free(qp);
-       if (destroyed)
-           break;
     }
     /* Clean out what is left in the list */
     while (!QEMPTY(intlist)) {
@@ -361,73 +344,12 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget,
        free(qp);
     }
     if (destroyed)
-       return destroyed;
+       return 1;
     if (icount) {
        mpr(bombown, "%s made it through %s defenses!\n",
            att_name, def_name);
        mpr(sect.sct_own, "%s made it through %s defenses!\n",
            att_name, def_name);
     }
-    return destroyed;
-}
-
-/* Keep launching missiles on list until mindam damage has been done */
-int
-msl_launch_mindam(struct emp_qelem *list, coord x, coord y, int hardtarget,
-                 int type, int mindam, char *whatp, int victim,
-                 int mission)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *next;
-    struct plist *plp;
-    int newdam, dam = 0;
-    int nukedam = 0;
-    int news_item;
-    int snews_item;
-
-    if (type == EF_SHIP) {
-       news_item = N_SHP_MISS;
-       snews_item = N_SHP_SMISS;
-    } else if (type == EF_LAND) {
-       news_item = N_LND_MISS;
-       snews_item = N_LND_SMISS;
-    } else {
-       news_item = N_SCT_MISS;
-       snews_item = N_SCT_SMISS;
-    }
-
-    for (qp = list->q_back; qp != list && dam < mindam && !nukedam;
-        qp = next) {
-       next = qp->q_back;
-       plp = (struct plist *)qp;
-
-       if (mission_pln_equip(plp, NULL, 0, 'p') >= 0) {
-           if (msl_hit(&plp->plane,
-                       hardtarget, type, news_item, snews_item,
-                       whatp, x, y, victim)) {
-               newdam = pln_damage(&plp->plane, x, y, 'p', &nukedam, 1);
-               if (nukedam) {
-                   if (mission == MI_INTERDICT && type == EF_SECTOR)
-                       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);
-           emp_remque(qp);
-           free(qp);
-       }
-    }
-    return dam;
+    return 0;
 }