/*
* 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"
/* 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;
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;
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;
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;
}
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;
if (amt > 0) {
getsect(tx, ty, §);
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);
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;
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, §)) {
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)
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;
}
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;
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;
}
/* 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",
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) {