(trade_check_item_ok): New.
(trade_check_ok): Use it and simplify. (set): Use new trade_check_item_ok(). The code replaced by it didn't work (abusable bug).
This commit is contained in:
parent
79714720cc
commit
38f3f7ea49
3 changed files with 13 additions and 16 deletions
|
@ -65,6 +65,7 @@ union trdgenstr {
|
|||
};
|
||||
|
||||
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 *);
|
||||
|
|
|
@ -64,7 +64,6 @@ set(void)
|
|||
struct nstr_item ni;
|
||||
struct nstr_item ni_trade;
|
||||
union trdgenstr item;
|
||||
union trdgenstr check;
|
||||
struct sctstr sect;
|
||||
int freeslot;
|
||||
int foundslot;
|
||||
|
@ -98,13 +97,10 @@ set(void)
|
|||
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;
|
||||
|
|
|
@ -55,22 +55,22 @@
|
|||
int
|
||||
trade_check_ok(struct trdstr *tp, union trdgenstr *tgp)
|
||||
{
|
||||
union trdgenstr check;
|
||||
return check_trade_ok(tp) && trade_check_item_ok(tgp);
|
||||
}
|
||||
|
||||
if (!check_trade_ok(tp))
|
||||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue