/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2004, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* ---
*
- * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- * related information and legal notices. It is expected that any future
- * projects/authors will amend these files as needed.
+ * See files README, COPYING and CREDITS in the root of the source
+ * tree for related information and legal notices. It is expected
+ * that future projects/authors will amend these files as needed.
*
* ---
*
* Steve McClure, 2000
*/
+#include <config.h>
+
#include <string.h>
#include "misc.h"
#include "player.h"
#include "nat.h"
#include "land.h"
#include "plane.h"
-#include "nuke.h"
#include "genitem.h"
#include "commands.h"
getstarg(player->argp[2], "Tender(s)? ", buf)))
return RET_SYN;
- while (nxtitem(&tenders, (s_char *)&tender)) {
+ while (nxtitem(&tenders, &tender)) {
if (!player->owner)
continue;
if (type == EF_LAND) {
if (!check_ship_ok(&tender))
return RET_SYN;
total = 0;
- while (tend_nxtitem(&targets, (s_char *)&target)) {
+ while (nxtitem(&targets, &target)) {
if (!player->owner &&
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
continue;
amt = 0;
/* take from target and give to tender */
- transfer = min(ontarget, -amt);
- transfer = min(maxtender - ontender, transfer);
+ transfer = MIN(ontarget, -amt);
+ transfer = MIN(maxtender - ontender, transfer);
if (transfer == 0)
continue;
target.shp_item[ip->i_vtype] = ontarget - transfer;
total += transfer;
} else {
/* give to target from tender */
- transfer = min(ontender, amt);
- transfer = min(transfer, maxtarget - ontarget);
+ transfer = MIN(ontender, amt);
+ transfer = MIN(transfer, maxtarget - ontarget);
if (transfer == 0)
continue;
target.shp_item[ip->i_vtype] = ontarget + transfer;
pr("%d total %s transferred %s %s\n",
total, ip->i_name, (amt > 0) ? "off of" : "to",
prship(&tender));
+ if (target.shp_own != player->cnum) {
+ wu(0, target.shp_own, "%s tended %d %s to %s\n",
+ cname(player->cnum), total, ip->i_name, prship(&target));
+ }
tender.shp_item[ip->i_vtype] = ontender;
tender.shp_mission = 0;
putship(tender.shp_uid, &tender);
s1->shp_pstage = PLG_EXPOSED;
}
-/*
- * tend_nxtitem.c
- *
- * get next item from list. Stolen from nxtitem to make 1 itsy-bitsy change
- *
- * Dave Pare, 1989
- */
-
-int
-tend_nxtitem(struct nstr_item *np, void *ptr)
-{
- struct genitem *gp;
- int selected;
-
- if (np->sel == NS_UNDEF)
- return 0;
- gp = (struct genitem *)ptr;
- do {
- if (np->sel == NS_LIST) {
- np->index++;
- if (np->index >= np->size)
- return 0;
- np->cur = np->list[np->index];
- } else {
- np->cur++;
- }
- if (!np->read(np->type, np->cur, ptr)) {
- /* if read fails, fatal */
- return 0;
- }
- selected = 1;
- switch (np->sel) {
- case NS_LIST:
- /* The change is to take the player->owner check out here */
- break;
- case NS_ALL:
- /* XXX maybe combine NS_LIST and NS_ALL later */
- break;
- case NS_DIST:
- if (!xyinrange(gp->x, gp->y, &np->range)) {
- selected = 0;
- break;
- }
- np->curdist = mapdist((int)gp->x, (int)gp->y,
- (int)np->cx, (int)np->cy);
- if (np->curdist > np->dist)
- selected = 0;
- break;
- case NS_AREA:
- if (!xyinrange(gp->x, gp->y, &np->range))
- selected = 0;
- if (gp->x == np->range.hx || gp->y == np->range.hy)
- selected = 0;
- break;
- case NS_XY:
- if (gp->x != np->cx || gp->y != np->cy)
- selected = 0;
- break;
- case NS_GROUP:
- if (np->group != gp->group)
- selected = 0;
- break;
- default:
- CANT_HAPPEN("bad np->sel");
- return 0;
- }
- if (selected && np->ncond) {
- /* nstr_exec is expensive, so we do it last */
- if (!nstr_exec(np->cond, np->ncond, ptr))
- selected = 0;
- }
- } while (!selected);
- return 1;
-}
-
static int
tend_land(struct shpstr *tenderp, s_char *units)
{
if (!snxtitem(&lni, EF_LAND, units))
return RET_SYN;
- while (nxtitem(&lni, (s_char *)&land)) {
+ while (nxtitem(&lni, &land)) {
if (!player->owner)
continue;
if (land.lnd_ship != tenderp->shp_uid) {
break;
if (!check_land_ok(&land))
return RET_SYN;
- while (tend_nxtitem(&targets, (s_char *)&target)) {
+ while (nxtitem(&targets, &target)) {
if (!player->owner &&
(getrel(getnatp(target.shp_own), player->cnum) < FRIENDLY))
continue;
count_units(&target);
getship(target.shp_uid, &target);
- if (target.shp_nland >= mchr[(int)target.shp_type].m_nland) {
+ if ((mchr[(int)target.shp_type].m_flags & M_SUB) &&
+ (lchr[(int)land.lnd_type].l_flags & L_SPY) &&
+ !mchr[(int)target.shp_type].m_nland) {
+ if (target.shp_nland > 1) {
+ pr("%s doesn't have room for more than two spy units!\n",
+ prship(&target));
+ continue;
+ }
+ } else if (target.shp_nland >= mchr[(int)target.shp_type].m_nland) {
if (mchr[(int)target.shp_type].m_nland)
pr("%s doesn't have room for any more land units!\n",
prship(&target));
count_units(tenderp);
putship(tenderp->shp_uid, tenderp);
snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
- while (nxtitem(&pni, (s_char *)&plane)) {
+ while (nxtitem(&pni, &plane)) {
if (plane.pln_flags & PLN_LAUNCHED)
continue;
if (plane.pln_land != land.lnd_uid)