/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2018, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
#include <config.h>
#include "empobj.h"
-#include "file.h"
#include "item.h"
#include "land.h"
#include "loan.h"
#include "sect.h"
#include "ship.h"
#include "trade.h"
+#include "unit.h"
#include "xy.h"
int
* Return 1 on success, 0 on error
*/
int
-trade_desc(struct trdstr *tp, struct empobj *tgp)
+trade_desc(struct empobj *tgp)
{
i_type it;
struct sctstr sect;
struct lndstr land;
struct nukstr nuke;
- switch (tp->trd_type) {
+ switch (tgp->ef_type) {
case EF_NUKE:
np = (struct nukstr *)tgp;
pr("(%3d) tech %d %d%% %s #%d",
np->nuk_own, np->nuk_tech, np->nuk_effic,
- nchr[(int)np->nuk_type].n_name, tp->trd_unitid);
+ nchr[(int)np->nuk_type].n_name, np->nuk_uid);
break;
case EF_SHIP:
sp = (struct shpstr *)tgp;
if (sp->shp_item[it])
pr("%c:%d ", ichr[it].i_mnem, sp->shp_item[it]);
}
- pr("] #%d", tp->trd_unitid);
+ pr("] #%d", sp->shp_uid);
snxtitem_cargo(&ni, EF_PLANE, EF_SHIP, sp->shp_uid);
while (nxtitem(&ni, &plane)) {
pr("\n\t\t\t\t tech %3d %3d%% %s #%d",
if (lp->lnd_item[it])
pr("%c:%d ", ichr[it].i_mnem, lp->lnd_item[it]);
}
- pr("] #%d", tp->trd_unitid);
+ pr("] #%d", lp->lnd_uid);
break;
case EF_PLANE:
pp = (struct plnstr *)tgp;
pp->pln_own,
pp->pln_tech,
pp->pln_effic,
- plchr[(int)pp->pln_type].pl_name, tp->trd_unitid);
+ plchr[(int)pp->pln_type].pl_name, pp->pln_uid);
if (getnuke(nuk_on_plane(pp), &nuke))
pr("(%s)", nchr[nuke.nuk_type].n_name);
break;
default:
- pr("flaky unit type %d", tp->trd_type);
+ pr("flaky unit type %d", tgp->uid);
break;
}
return 1;
}
+int
+trade_has_unsalable_cargo(struct empobj *tgp, int noisy)
+{
+ int ret, i, type;
+ short *item;
+ struct nstr_item ni;
+ union empobj_storage cargo;
+
+ ret = 0;
+ if (tgp->ef_type == EF_SHIP || tgp->ef_type == EF_LAND) {
+ item = tgp->ef_type == EF_SHIP
+ ? ((struct shpstr *)tgp)->shp_item
+ : ((struct lndstr *)tgp)->lnd_item;
+ for (i = I_NONE + 1; i <= I_MAX; i++) {
+ if (item[i] && !ichr[i].i_sell) {
+ if (noisy)
+ pr("%s carries %s, which you can't sell.\n",
+ unit_nameof(tgp), ichr[i].i_name);
+ ret = 1;
+ }
+ }
+ }
+
+ for (type = EF_PLANE; type <= EF_NUKE; type++) {
+ snxtitem_cargo(&ni, type, tgp->ef_type, tgp->uid);
+ while (nxtitem(&ni, &cargo))
+ ret |= trade_has_unsalable_cargo(&cargo.gen, noisy);
+ }
+
+ return ret;
+}
+
int
trade_getitem(struct trdstr *tp, union empobj_storage *tgp)
{
}
/*
- * Return amount due for LOAN at time PAYTIME.
+ * Return amount due for @loan at time @paytime.
*/
double
loan_owed(struct lonstr *loan, time_t paytime)