member com_type from mnemo character to item type.
(whichitem): Unused, remove.
(check_market): Use full item name instead of mnemo in telegrams.
(display_mark): Separate arguments for item type and cheapest only.
Cheapest only of specific item type is not implemented.
(rese): Guard against bad com_type. Delete some code that had no
effect.
short ef_type;
natid com_owner;
short com_uid;
- char com_type;
+ int com_type;
int com_amount;
float com_price;
int com_maxbidder;
extern void set_coastal(struct sctstr *);
extern int sendmessage(struct natstr *, struct natstr *, char *, int);
extern void gift(int, int, s_char *, int, s_char *);
-extern int display_mark(int what);
+extern int display_mark(int, int);
extern int want_to_abandon(struct sctstr *, int, int, struct lndstr *);
extern int would_abandon(struct sctstr *, int, int, struct lndstr *);
extern int nav_map(int, int, int);
extern int trade_getitem(struct trdstr *, union trdgenstr *);
extern long get_couval(int);
extern long get_outstand(int);
-extern struct ichrstr *whichitem(char);
#define gettrade(n, p) \
ef_read(EF_TRADE, n, (caddr_t)p)
ip = whatitem(player->argp[1], "Commodity you want to buy: ");
if (!ip)
return RET_SYN;
- display_mark(ip->i_mnem);
+ display_mark(ip->i_vtype, 0);
pr("\n");
p = getstarg(player->argp[2], "Which lot are you bidding on: ", buf);
if (p == 0)
pr("Invalid lot number.\n");
return RET_OK;
}
- if (comm.com_type != ip->i_mnem) {
+ if (comm.com_type != ip->i_vtype) {
pr("That lot is not of the type you specified.\n");
return RET_OK;
}
pr("That sector is under construction.\n");
return RET_FAIL;
}
- ip = whichitem(comm.com_type);
n = sect.sct_item[ip->i_vtype];
qty = comm.com_amount;
if (qty + n > ITEM_MAX) {
{
struct comstr comm;
struct sctstr *sect;
- struct ichrstr *ip;
struct natstr *natp;
int m;
int n;
tleft = 0;
if (tleft > 0.0)
continue;
- ip = whichitem(comm.com_type);
+ if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX))
+ continue;
sect = getsectp(comm.com_x, comm.com_y);
- m = sect->sct_item[ip->i_vtype];
+ m = sect->sct_item[comm.com_type];
monleft = 0;
"Sale #%d fell through. Goods remain on the market.\n", n);
comm.com_maxbidder = comm.com_owner;
} else {
- sect->sct_item[ip->i_vtype] = m + comm.com_amount;
+ sect->sct_item[comm.com_type] = m + comm.com_amount;
putsect(sect);
nreport(comm.com_owner, N_MAKE_SALE, comm.com_maxbidder, 1);
- wu(0, comm.com_owner, "%s bought %d %c's from you for $%.2f\n",
+ wu(0, comm.com_owner, "%s bought %d %s from you for $%.2f\n",
cname(comm.com_maxbidder), comm.com_amount,
- comm.com_type, gain);
+ ichr[comm.com_type].i_name, gain);
wu(0, comm.com_maxbidder,
- "You just bought %d %c's from %s for $%.2f\n",
- comm.com_amount, comm.com_type, cname(comm.com_owner),
- gain * buytax);
+ "You just bought %d %s from %s for $%.2f\n",
+ comm.com_amount, ichr[comm.com_type].i_name,
+ cname(comm.com_owner), gain * buytax);
natp = getnatp(comm.com_owner);
/* Make sure we subtract the amount that came out in a loan */
natp->nat_money += (gain - subleft);
if (!p)
return RET_SYN;
if (!strcmp(p, "all"))
- return display_mark(0);
+ return display_mark(I_NONE, 0);
else {
ip = item_by_name(p);
if (!ip)
return RET_SYN;
- return display_mark(ip->i_mnem);
+ return display_mark(ip->i_vtype, 0);
}
}
- return display_mark(-1);
+ return display_mark(I_NONE, 1);
}
static void
comm->com_uid,
comm->com_price,
comm->com_maxbidder,
- tleft, comm->com_owner, comm->com_type, comm->com_amount);
+ tleft, comm->com_owner, ichr[comm->com_type].i_mnem, comm->com_amount);
if (comm->com_owner == player->cnum || player->god)
pr("%s", xyas(comm->sell_x, comm->sell_y, player->cnum));
pr("\n");
}
int
-display_mark(int what)
+display_mark(int only_itype, int only_cheapest)
{
struct comstr comm;
struct comstr comm2;
int sellers = 0;
int cnt = 0;
- struct ichrstr *ip;
int cheapest_items[I_MAX + 1];
int i;
pr(" lot high bid/unit by time left owner item amount sector\n");
pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
- if (what == -1) {
- /* Ok, just printing the lowest of all of them */
+ if (only_cheapest) {
for (i = 0; i < I_MAX + 1; i++)
cheapest_items[i] = -1;
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
if (comm.com_owner == 0)
continue;
- for (i = 0, ip = &ichr[0]; ip && ip->i_mnem; ip++, i++)
- if (ip->i_mnem == comm.com_type)
- break;
- if (!ip->i_mnem)
+ if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX))
continue;
- if (cheapest_items[i] != -1) {
- getcomm(cheapest_items[i], &comm2);
+ if (cheapest_items[comm.com_type] != -1) {
+ getcomm(cheapest_items[comm.com_type], &comm2);
if (comm.com_price < comm2.com_price) {
- cheapest_items[i] = sellers;
+ cheapest_items[comm.com_type] = sellers;
}
} else {
- cheapest_items[i] = sellers;
+ cheapest_items[comm.com_type] = sellers;
}
}
+ CANT_HAPPEN(only_itype != I_NONE); /* not implemented */
for (i = 0; i < I_MAX + 1; i++) {
if (cheapest_items[i] == -1)
continue;
pr_mark(&comm);
}
} else {
- /* Ok, print them all, or all of this type */
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
if (comm.com_owner == 0)
continue;
- if (what && comm.com_type != what)
+ if (only_itype != I_NONE && comm.com_type != only_itype)
continue;
cnt = 1;
pr_mark(&comm);
{
struct comstr comm;
struct sctstr sect;
- struct ichrstr *ix;
int number_set;
int m;
char *p;
pr("The destination sector must be at least 60%% efficient.\n");
return RET_OK;
}
- ix = whichitem(comm.com_type);
- sect.sct_x = comm.sell_x;
- sect.sct_y = comm.sell_y;
- m = sect.sct_item[ix->i_vtype];
+ if (CANT_HAPPEN((unsigned)comm.com_type > I_MAX)) {
+ pr("The goods have been eaten by a grue.");
+ return RET_OK;
+ }
+ m = sect.sct_item[comm.com_type];
m = m + comm.com_amount;
if (m > ITEM_MAX)
m = ITEM_MAX;
- sect.sct_item[ix->i_vtype] = m;
+ sect.sct_item[comm.com_type] = m;
putsect(§);
comm.com_owner = 0;
putcomm(number_set, &comm);
- pr("The goods have been returned to your trading post\n");
+ pr("The goods have been returned to your trading post.\n");
return RET_OK;
}
if (price >= comm.com_price) {
int com;
char *p;
float price;
- char cc;
time_t now;
int ii = 0;
coord x, y;
}
check_market();
check_trade();
- if ((ip =
- whatitem(player->argp[1], "Commodity you want to sell: ")) == 0)
+ if (!(ip = whatitem(player->argp[1], "Commodity you want to sell: ")))
return RET_SYN;
if (ip->i_sell == 0) {
pr("You can't sell %s\n", ip->i_name);
pr("Sold %d %s at %s (%d left)\n", com, ip->i_name,
xyas(sect.sct_x, sect.sct_y, player->cnum), amt);
sect.sct_item[ip->i_vtype] = amt;
- cc = ip->i_mnem;
putsect(§);
if (totalcom > 0) {
for (ii = 0; getcomm(ii, &comm); ii++) {
if (getcomm(ii, &comm) == 0)
ef_extend(EF_COMM, 1);
(void)time(&now);
- comm.com_type = ip->i_mnem;
+ comm.com_type = ip->i_vtype;
comm.com_owner = player->cnum;
comm.com_price = price;
comm.com_maxbidder = player->cnum;
}
return loantot;
}
-
-struct ichrstr *
-whichitem(char p)
-{
- register int i;
-
- if (p == 0)
- return 0;
- for (i = 1; ichr[i].i_mnem != 0; i++)
- if (p == ichr[i].i_mnem)
- return (struct ichrstr *)(&ichr[i]);
- pr("Unrecognized item \"%c\"\n", p);
- return 0;
-}