(trad, set): Treat trade file slots with zero owner as unused, so that

freshly extended trade file makes sense.  When set() removes a lot,
simply zero the slot.

(set): Initialize trd_uid.

(trade_check_ok): Use check_land_ok() & friends instead of doing it by
hand, but wrong.  This fixes bying planes and land units loaded on
ships that moved after loading.

(check_trade_ok): New.
(trade_check_ok): Use it.  Remove unused argument lot.  Callers
changed.
This commit is contained in:
Markus Armbruster 2004-08-28 15:22:50 +00:00
parent 133c1754f9
commit e16e38dfab
6 changed files with 52 additions and 47 deletions

View file

@ -98,7 +98,7 @@ trad(void)
snxtitem_all(&ni, EF_TRADE);
while (nxtitem(&ni, (char *)&trade)) {
if (trade.trd_unitid < 0)
if (trade.trd_owner == 0)
continue;
if (!trade_getitem(&trade, &tg)) {
continue;
@ -205,7 +205,7 @@ trad(void)
plflags = plchr[(int)tg.pln.pln_type].pl_flags;
while (1) {
p = getstring("Destination sector: ", buf);
if (!trade_check_ok(lotno, &trade, &tg))
if (!trade_check_ok(&trade, &tg))
return RET_FAIL;
if (p == 0) {
return RET_FAIL;
@ -234,7 +234,7 @@ trad(void)
if (trade.trd_type == EF_LAND) {
while (1) {
p = getstring("Destination sector: ", buf);
if (!trade_check_ok(lotno, &trade, &tg))
if (!trade_check_ok(&trade, &tg))
return RET_FAIL;
if (p == 0) {
return RET_FAIL;
@ -266,7 +266,7 @@ trad(void)
if ((p = getstring("How much do you bid: ", buf)) == 0 || *p == 0)
return RET_OK;
if (!trade_check_ok(lotno, &trade, &tg))
if (!trade_check_ok(&trade, &tg))
return RET_FAIL;
bid = atoi(p);
if (bid < price)