Forbid selling units with unsalable cargo, permit selling military
Deities can customize which commodities can be sold in table item. Default is to allow anything but civilians and military. However, this applies only to the commodity market, not to the unit market: cargo of ships and land units is not restricted. Make the two markets consistent: permit selling military by default, forbid selling units carrying unsalable commodities. This outlaws selling units carrying civilians by default.
This commit is contained in:
parent
6c086a8110
commit
324109ae45
4 changed files with 38 additions and 2 deletions
|
@ -60,6 +60,7 @@ struct trdstr {
|
|||
extern int trade_check_ok(struct trdstr *, struct empobj *);
|
||||
extern char *trade_nameof(struct trdstr *, struct empobj *);
|
||||
extern int trade_desc(struct empobj *);
|
||||
extern int trade_has_unsalable_cargo(struct empobj *, int);
|
||||
extern int trade_getitem(struct trdstr *, union empobj_storage *);
|
||||
|
||||
#define gettrade(n, p) ef_read(EF_TRADE, (n), (p))
|
||||
|
|
|
@ -116,6 +116,8 @@ set(void)
|
|||
puttrade(ni_trade.cur, &trade);
|
||||
}
|
||||
} else {
|
||||
if (trade_has_unsalable_cargo(&item.gen, 1))
|
||||
return RET_FAIL;
|
||||
if (foundslot >= 0)
|
||||
id = foundslot;
|
||||
else if (freeslot >= 0)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
# item.config: Item characteristics
|
||||
#
|
||||
# Known contributors to this file:
|
||||
# Markus Armbruster, 2006-2011
|
||||
# Markus Armbruster, 2006-2012
|
||||
#
|
||||
# Derived from item.c; no known contributors.
|
||||
#
|
||||
|
@ -45,7 +45,7 @@
|
|||
config item # ineff norm ware urban bank
|
||||
uid mnem val sell lbs pkg(0) pkg(1) pkg(2) pkg(3) pkg(4) melt name
|
||||
0 "c" 1 0 1 1 10 10 10 10 4 "civilians"
|
||||
1 "m" 0 0 1 1 1 1 1 1 20 "military"
|
||||
1 "m" 0 1 1 1 1 1 1 1 20 "military"
|
||||
2 "s" 5 1 1 1 1 10 1 1 80 "shells"
|
||||
3 "g" 60 1 10 1 1 10 1 1 100 "guns"
|
||||
4 "p" 4 1 1 1 1 10 1 1 50 "petrol"
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "sect.h"
|
||||
#include "ship.h"
|
||||
#include "trade.h"
|
||||
#include "unit.h"
|
||||
#include "xy.h"
|
||||
|
||||
int
|
||||
|
@ -171,6 +172,38 @@ trade_desc(struct empobj *tgp)
|
|||
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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue