]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/plnsub.c
launch interception: Drop support for ABM, a-sat consuming shells
[empserver] / src / lib / subs / plnsub.c
index 37daf508f36cd72d9e4f660cb873c34b4b3c8a95..afec51f38288a6385c7cc5d7fbf7d0bb48a58f02 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2015
+ *     Markus Armbruster, 2004-2021
  */
 
 #include <config.h>
 
 #include "chance.h"
 #include "empobj.h"
-#include "file.h"
 #include "item.h"
 #include "land.h"
 #include "map.h"
@@ -82,7 +81,8 @@ get_planes(struct nstr_item *ni_bomb, struct nstr_item *ni_esc,
 
 /*
  * Get assembly point argument.
- * If @input is not empty, use it, else prompt for more input using @prompt.
+ * If @input is not empty, use it.
+ * Else prompt for more input using @prompt.
  * If this yields a valid assembly point, read it into *@ap_sect and
  * return @ap_sect.
  * Else complain and return NULL.
@@ -109,7 +109,7 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf)
     /* over own or allied ship is fine */
     snxtitem_xy(&ni, EF_SHIP, x, y);
     while (nxtitem(&ni, &ship)) {
-       if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
+       if (!ship.shp_own)
            continue;
        if (relations_with(ship.shp_own, player->cnum) == ALLIED)
            return ap_sect;
@@ -130,6 +130,7 @@ int
 pln_where_to_land(coord x, coord y,
                  union empobj_storage *target, int *flagsp)
 {
+    /* Keep conditions for landing consistent with pln_airbase_ok() */
     int nships;
     int cno;
     int fl;
@@ -175,11 +176,10 @@ pln_where_to_land(coord x, coord y,
        pr("Nowhere to land at sector %s!\n", xyas(x, y, player->cnum));
        return -1;
     }
+    /* clear to land at sector */
     if (target->sect.sct_type == SCT_MOUNT) {
-       pr("Nowhere to land at sector %s!\n", xyas(x, y, player->cnum));
-       return -1;
+       *flagsp |= P_K;
     }
-    /* clear to land at sector */
     if (target->sect.sct_type != SCT_AIRPT || target->sect.sct_effic < 60)
        *flagsp |= P_V;
     return 0;
@@ -238,7 +238,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                       cname(player->cnum), prplane(&plp->plane),
                       prship(&ship));
                }
-               if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+               if (plp->pstage == PLG_INFECT
                    && ship.shp_pstage == PLG_HEALTHY)
                    ship.shp_pstage = PLG_EXPOSED;
            }
@@ -252,7 +252,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
                   cname(player->cnum),
                   prplane(&plp->plane), xyas(tx, ty, sect.sct_own));
            }
-           if (plp->pcp->pl_crew && plp->pstage == PLG_INFECT
+           if (plp->pstage == PLG_INFECT
                && sect.sct_pstage == PLG_HEALTHY)
                sect.sct_pstage = PLG_EXPOSED;
            plp->plane.pln_ship = cno;
@@ -357,7 +357,7 @@ pln_mine(struct emp_qelem *list, coord tx, coord ty)
     if (amt > 0) {
        getsect(tx, ty, &sect);
        if (sect.sct_type != SCT_WATER) {
-           pr("Your seamines have no effect here.\n");
+           pr("Your sea mines have no effect here.\n");
            return;
        }
        sect.sct_mines = MIN(sect.sct_mines + amt, MINES_MAX);
@@ -456,9 +456,15 @@ carrier_planes(struct shpstr *sp, int msl)
     return res;
 }
 
+/*
+ * Can @pp operate out its sector?
+ * If @oneway, consider only takeoff, else takeoff and landing.
+ * If @noisy, report to current player when it can't.
+ */
 int
 pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
 {
+    /* Keep conditions for landing consistent with pln_where_to_land() */
     struct shpstr ship;
     struct lndstr land;
     struct sctstr sect;
@@ -500,11 +506,18 @@ pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
            return 0;
 
     } else {
-       /* sector: needs to be own or allied, efficient airfield */
+       /* sector: needs to be own or allied, efficient, suitable type */
        if (!getsect(pp->pln_x, pp->pln_y, &sect)) {
            CANT_REACH();
            return 0;
        }
+       /* mountain requires helo or missile */
+       if (sect.sct_type == SCT_MOUNT && !(pcp->pl_flags & (P_K | P_M))) {
+           if (noisy)
+               pr("(note) %s is in a mountain and can't take off\n",
+                  prplane(pp));
+           return 0;
+       }
 
        if (relations_with(sect.sct_own, pp->pln_own) != ALLIED) {
            if (noisy)
@@ -568,7 +581,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
            continue;
        if (opt_MARKET) {
            if (ontradingblock(EF_PLANE, &plane)) {
-               pr("plane #%d inelligible - it's for sale.\n",
+               pr("plane #%d ineligible - it's for sale.\n",
                   plane.pln_uid);
                continue;
            }
@@ -701,13 +714,6 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
     case 'e':          /* escort */
        load = 0;
        break;
-    case 'i':          /* missile interception */
-       if (CANT_HAPPEN(!(pcp->pl_flags & P_M)
-                       || !(pcp->pl_flags & (P_N | P_O))))
-           break;
-       if (load)
-           itype = I_SHELL;
-       break;
     default:
        CANT_REACH();
        load = 0;
@@ -724,7 +730,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, char mission)
                needed = 0;
            else {
                pr("%s can't fly this mission"
-                  " while it is carrying a nuclear weapon",
+                  " while it is carrying a nuclear weapon\n",
                   prplane(pp));
                return -1;
            }
@@ -813,7 +819,7 @@ pln_put1(struct plist *plp)
        /* We should do more, like make sure it's really
           a carrier, etc. but for now just make sure it's
           not sunk. */
-       if (ship.shp_effic < SHIP_MINEFF) {
+       if (!ship.shp_own) {
            mpr(pp->pln_own,
                "Ship #%d has been sunk, plane #%d has nowhere to land, and\n"
                "splashes into the sea.\n",
@@ -1039,7 +1045,7 @@ pln_damage(struct plnstr *pp, char type, char *noisy)
        aim = 100 - aim;
     }
 
-    len = snprintf(buf, sizeof(buf), "%s", noisy);
+    len = noisy ? snprintf(buf, sizeof(buf), "%s", noisy) : 0;
     while (i--) {
        if (noisy) {
            if (len > 75) {