};
extern int trade_check_ok(struct trdstr *, union trdgenstr *);
+extern int trade_check_item_ok(union trdgenstr *);
extern s_char *trade_nameof(struct trdstr *, union trdgenstr *);
extern int trade_desc(struct trdstr *, union trdgenstr *);
extern int trade_getitem(struct trdstr *, union trdgenstr *);
struct nstr_item ni;
struct nstr_item ni_trade;
union trdgenstr item;
- union trdgenstr check;
struct sctstr sect;
int freeslot;
int foundslot;
trade.trd_type = type;
sprintf(prompt, "%s #%d; Price? ",
trade_nameof(&trade, &item), ni.cur);
- memcpy(&check, &item, sizeof(union trdgenstr));
if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
break;
- if (memcmp(&check, &item, sizeof(union trdgenstr))) {
- pr("That item has changed!\n");
+ if (!trade_check_item_ok(&item))
return RET_FAIL;
- }
if ((price = atoi(p)) < 0)
continue;
foundslot = -1;
int
trade_check_ok(struct trdstr *tp, union trdgenstr *tgp)
{
- union trdgenstr check;
-
- if (!check_trade_ok(tp))
- return 0;
+ return check_trade_ok(tp) && trade_check_item_ok(tgp);
+}
- trade_getitem(tp, &check);
- if (tp->trd_type == EF_LAND)
+int
+trade_check_item_ok(union trdgenstr *tgp)
+{
+ if (tgp->gen.ef_type == EF_LAND)
return check_land_ok(&tgp->lnd);
- if (tp->trd_type == EF_PLANE)
+ if (tgp->gen.ef_type == EF_PLANE)
return check_plane_ok(&tgp->pln);
- if (tp->trd_type == EF_SHIP)
+ if (tgp->gen.ef_type == EF_SHIP)
return check_ship_ok(&tgp->shp);
- if (tp->trd_type == EF_NUKE)
+ if (tgp->gen.ef_type == EF_NUKE)
return check_nuke_ok(&tgp->nuk);
- CANT_HAPPEN("Bad TRD_TYPE");
- pr("Trade lot #%d went bad!\n", tp->trd_uid);
+ CANT_HAPPEN("Bad EF_TYPE");
+ pr("Trade lot went bad!\n");
return 0;
}