/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
return NULL;
/* over own or allied sector is fine */
- if (ap_sect->sct_own == player->cnum
- || getrel(getnatp(ap_sect->sct_own), player->cnum) == ALLIED)
+ if (relations_with(ap_sect->sct_own, player->cnum) == ALLIED)
return ap_sect;
/* over own or allied ship is fine */
while (nxtitem(&ni, &ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
continue;
- if (ship.shp_own == player->cnum
- || getrel(getnatp(ship.shp_own), player->cnum) == ALLIED)
+ if (relations_with(ship.shp_own, player->cnum) == ALLIED)
return ap_sect;
}
}
/* try to land at sector */
- if (target->sct_own != player->cnum
- && getrel(getnatp(target->sct_own), player->cnum) != ALLIED) {
+ if (relations_with(target->sct_own, player->cnum) != ALLIED) {
pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
pr("Your %s vanish without a trace.\n", ip->i_name);
return;
}
- if (sect.sct_own != player->cnum
- && getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
+ if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
pr("You don't own %s! Cargo jettisoned...\n",
xyas(tx, ty, player->cnum));
return;
}
there += amt;
if (there > max) {
- pr("%d excess %s discarded\n", max - there, ip->i_name);
- amt = max - there;
+ pr("%d excess %s discarded\n", there - max, ip->i_name);
+ amt -= there - max;
there = max;
}
pr("%d %s landed safely", amt, ip->i_name);
CANT_REACH();
return 0;
}
- if (ship.shp_own != pp->pln_own
- && getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) {
+ if (relations_with(ship.shp_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the ship %s is on\n",
prplane(pp));
CANT_REACH();
return 0;
}
- if (land.lnd_own != pp->pln_own
- && getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) {
+ if (relations_with(land.lnd_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the unit %s is on\n",
prplane(pp));
return 0;
}
- if (sect.sct_own != pp->pln_own
- && getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED) {
+ if (relations_with(sect.sct_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the sector %s is in\n",
prplane(pp));
if (sect.sct_effic < 40) {
if (noisy)
pr("%s is not 40%% efficient, %s can't take off from there.\n",
- xyas(sect.sct_x, sect.sct_y, pp->pln_own),
+ xyas(sect.sct_x, sect.sct_y, player->cnum),
prplane(pp));
return 0;
}
if (!oneway && sect.sct_effic < 60) {
if (noisy)
pr("%s is not 60%% efficient, %s can't land there.\n",
- xyas(sect.sct_x, sect.sct_y, pp->pln_own),
+ xyas(sect.sct_x, sect.sct_y, player->cnum),
prplane(pp));
return 0;
}
emp_initque(list);
while (nxtitem(ni, &plane)) {
- if (!player->owner)
+ /*
+ * It would be nice to let deities fly foreign planes, but
+ * much of the code assumes that only the plane's owner can
+ * fly it.
+ */
+ if (plane.pln_own != player->cnum)
continue;
if (plane.pln_mobil <= 0)
continue;
break;
case 'r': /* reconnaissance */
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))))
{
struct plchrstr *pcp = &plchr[pp->pln_type];
struct mchrstr *mcp = &mchr[sp->shp_type];
+ int nfw;
if (pcp->pl_flags & P_K)
nch++;
else if (pcp->pl_flags & P_M)
nmsl++;
n++;
+ nfw = n - nch - nxl - nmsl;
- n -= MIN(nch, mcp->m_nchoppers);
- n -= MIN(nxl, mcp->m_nxlight);
+ if (nch > mcp->m_nchoppers) /* overflow into fixed-wing slots */
+ nfw += nch - mcp->m_nchoppers;
+ if (nxl > mcp->m_nxlight) /* overflow into missile slots */
+ nmsl += nxl - mcp->m_nxlight;
if (nmsl && !(mcp->m_flags & (M_MSL | M_FLY)))
return 0; /* missile slots wanted */
- if (nmsl < n && !(mcp->m_flags & M_FLY))
+ if (nfw && !(mcp->m_flags & M_FLY))
return 0; /* fixed-wing slots wanted */
- return n <= mcp->m_nplanes;
+ return nfw + nmsl <= mcp->m_nplanes;
}
/*
if (chance((100.0 - pln_acc(pp)) / 100.0)) {
pr("Sweep! in %s\n",
- xyas(sect.sct_x, sect.sct_y, pp->pln_own));
+ xyas(sect.sct_x, sect.sct_y, player->cnum));
mines_there--;
found = 1;
}
pln_damage(struct plnstr *pp, char type, int noisy)
{
struct plchrstr *pcp = plchr + pp->pln_type;
- int load, i;
- int hitroll;
+ int load, i, hitroll, aim, len;
int dam = 0;
- int aim;
int effective = 1;
int pinbomber = 0;
+ char buf[80];
- if (CANT_HAPPEN(nuk_on_plane(pp) >= 0)) /* FIXME check uses! */
+ if (CANT_HAPPEN(nuk_on_plane(pp) >= 0))
return 0;
load = pln_load(pp);
aim = 100 - aim;
}
+ len = 0;
while (i--) {
dam += roll(6);
hitroll = roll(100);
if (hitroll >= 90) {
dam += 8;
if (noisy)
- mpr(pp->pln_own, "BLAM");
+ len += sprintf(buf + len, "BLAM");
} else if (hitroll < aim) {
dam += 5;
if (noisy)
- mpr(pp->pln_own, "Blam");
+ len += sprintf(buf + len, "Blam");
} else {
dam += 1;
if (noisy)
- mpr(pp->pln_own, "blam");
+ len += sprintf(buf + len, "blam");
+ }
+ if (noisy) {
+ if (len > 75) {
+ mpr(pp->pln_own, "%s\n", buf);
+ len = 0;
+ }
+ if (i)
+ len += sprintf(buf + len, "-");
}
- if (i && noisy)
- mpr(pp->pln_own, "-");
}
- if (noisy)
- mpr(pp->pln_own, "\n");
+ if (noisy && len)
+ mpr(pp->pln_own, "%s\n", buf);
if (effective)
dam *= 2;
return dam;