/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
#include "sect.h"
#include "ship.h"
#include "trade.h"
+#include "unit.h"
#include "xy.h"
int
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)
{