(buy, mark, display_mark): Move argument evaluation from
display_mark() to callers. buy() no longer accepts "all". It used to display all lots, but didn't let you buy any. Similar nonsense happened for "" if buy() prompted for it. (display_mark): Fix size of cheapest_items[]. (player_coms): Document mark accepting "all".
This commit is contained in:
parent
b0627a97cb
commit
60bbb6b0c0
5 changed files with 34 additions and 34 deletions
|
@ -65,7 +65,7 @@ extern int check_market(void);
|
||||||
extern void set_coastal(struct sctstr *);
|
extern void set_coastal(struct sctstr *);
|
||||||
extern int sendmessage(struct natstr *, struct natstr *, char *, int);
|
extern int sendmessage(struct natstr *, struct natstr *, char *, int);
|
||||||
extern void gift(int, int, s_char *, int, s_char *);
|
extern void gift(int, int, s_char *, int, s_char *);
|
||||||
extern int display_mark(s_char *);
|
extern int display_mark(int what);
|
||||||
extern int want_to_abandon(struct sctstr *, int, int, struct lndstr *);
|
extern int want_to_abandon(struct sctstr *, int, int, struct lndstr *);
|
||||||
extern int would_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 nav_map(int, int, int);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.TH Command MARKET
|
.TH Command MARKET
|
||||||
.NA market "Report current selling prices in the world market"
|
.NA market "Report current selling prices in the world market"
|
||||||
.LV Expert
|
.LV Expert
|
||||||
.SY "market <ITEM>"
|
.SY "market <ITEM|all>"
|
||||||
The market report displays the lowest price commodity of each type
|
The market report displays the lowest price commodity of each type
|
||||||
currently on the market.
|
currently on the market.
|
||||||
.s1
|
.s1
|
||||||
|
|
|
@ -82,7 +82,10 @@ buy(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
natp = getnatp(player->cnum);
|
natp = getnatp(player->cnum);
|
||||||
display_mark(player->argp[1]);
|
ip = whatitem(player->argp[1], "Commodity you want to buy: ");
|
||||||
|
if (!ip)
|
||||||
|
return RET_SYN;
|
||||||
|
display_mark(ip->i_mnem);
|
||||||
pr("\n");
|
pr("\n");
|
||||||
p = getstarg(player->argp[2], "Which lot are you bidding on: ", buf);
|
p = getstarg(player->argp[2], "Which lot are you bidding on: ", buf);
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
|
@ -96,8 +99,7 @@ buy(void)
|
||||||
pr("Invalid lot number.\n");
|
pr("Invalid lot number.\n");
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
if (player->argp[1] && *(player->argp[1]) &&
|
if (comm.com_type != ip->i_mnem) {
|
||||||
comm.com_type != player->argp[1][0]) {
|
|
||||||
pr("That lot is not of the type you specified.\n");
|
pr("That lot is not of the type you specified.\n");
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,29 @@
|
||||||
int
|
int
|
||||||
mark(void)
|
mark(void)
|
||||||
{
|
{
|
||||||
|
char buf[1024];
|
||||||
|
char *p;
|
||||||
|
struct ichrstr *ip;
|
||||||
|
|
||||||
if (!opt_MARKET) {
|
if (!opt_MARKET) {
|
||||||
pr("The market is disabled.\n");
|
pr("The market is disabled.\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if (player->argp[1] && *(player->argp[1]))
|
|
||||||
return display_mark(player->argp[1]);
|
if (player->argp[1] && player->argp[1]) {
|
||||||
else
|
p = getstarg(player->argp[1], "What commodity (or 'all')? ", buf);
|
||||||
return display_mark(" ");
|
if (!p)
|
||||||
|
return RET_SYN;
|
||||||
|
if (!strcmp(p, "all"))
|
||||||
|
return display_mark(0);
|
||||||
|
else {
|
||||||
|
ip = item_by_name(p);
|
||||||
|
if (!ip)
|
||||||
|
return RET_SYN;
|
||||||
|
return display_mark(ip->i_mnem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return display_mark(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -77,45 +92,28 @@ pr_mark(struct comstr *comm)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
display_mark(s_char *arg)
|
display_mark(int what)
|
||||||
{
|
{
|
||||||
struct comstr comm;
|
struct comstr comm;
|
||||||
struct comstr comm2;
|
struct comstr comm2;
|
||||||
int sellers = 0;
|
int sellers = 0;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
char c;
|
|
||||||
s_char *p;
|
|
||||||
struct ichrstr *ip;
|
struct ichrstr *ip;
|
||||||
s_char buf[1024];
|
int cheapest_items[I_MAX + 1];
|
||||||
int cheapest_items[I_MAX + 2];
|
|
||||||
int i;
|
int i;
|
||||||
int all = 0;
|
|
||||||
|
|
||||||
/* First, we execute all trades, so that we can only buy what is available. */
|
/* Execute trades so report lists only lots that are still available. */
|
||||||
check_market();
|
check_market();
|
||||||
check_trade();
|
check_trade();
|
||||||
|
|
||||||
p = getstarg(arg, "What commodity (or 'all')? ", buf);
|
|
||||||
c = (char)0;
|
|
||||||
if (p && *p)
|
|
||||||
c = *p;
|
|
||||||
for (ip = &ichr[0]; ip && ip->i_mnem; ip++)
|
|
||||||
if (ip->i_mnem == c)
|
|
||||||
break;
|
|
||||||
c = ip->i_mnem;
|
|
||||||
|
|
||||||
pr("\n Empire Market Report\n ");
|
pr("\n Empire Market Report\n ");
|
||||||
prdate();
|
prdate();
|
||||||
pr(" lot high bid/unit by time left owner item amount sector\n");
|
pr(" lot high bid/unit by time left owner item amount sector\n");
|
||||||
pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
|
pr(" --- ------------- -- --------- ----- ---- ------ ------\n");
|
||||||
|
|
||||||
if (arg) {
|
if (what == -1) {
|
||||||
if (strcmp(arg, "all"))
|
|
||||||
all = 1;
|
|
||||||
}
|
|
||||||
if (all && !c) {
|
|
||||||
/* Ok, just printing the lowest of all of them */
|
/* Ok, just printing the lowest of all of them */
|
||||||
for (i = 0; i < I_MAX + 2; i++)
|
for (i = 0; i < I_MAX + 1; i++)
|
||||||
cheapest_items[i] = -1;
|
cheapest_items[i] = -1;
|
||||||
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
|
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
|
||||||
if (comm.com_owner == 0)
|
if (comm.com_owner == 0)
|
||||||
|
@ -134,7 +132,7 @@ display_mark(s_char *arg)
|
||||||
cheapest_items[i] = sellers;
|
cheapest_items[i] = sellers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < I_MAX + 2; i++) {
|
for (i = 0; i < I_MAX + 1; i++) {
|
||||||
if (cheapest_items[i] == -1)
|
if (cheapest_items[i] == -1)
|
||||||
continue;
|
continue;
|
||||||
getcomm(cheapest_items[i], &comm);
|
getcomm(cheapest_items[i], &comm);
|
||||||
|
@ -146,7 +144,7 @@ display_mark(s_char *arg)
|
||||||
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
|
for (sellers = 0; getcomm(sellers, &comm); sellers++) {
|
||||||
if (comm.com_owner == 0)
|
if (comm.com_owner == 0)
|
||||||
continue;
|
continue;
|
||||||
if (c && comm.com_type != c)
|
if (what && comm.com_type != what)
|
||||||
continue;
|
continue;
|
||||||
cnt = 1;
|
cnt = 1;
|
||||||
pr_mark(&comm);
|
pr_mark(&comm);
|
||||||
|
|
|
@ -150,7 +150,7 @@ struct cmndstr player_coms[] = {
|
||||||
NORM + CAP},
|
NORM + CAP},
|
||||||
{"lunload <COMM|\"land\"|\"plane\"> <UNITS> <NUM|UNITS|PLANES>", 1,
|
{"lunload <COMM|\"land\"|\"plane\"> <UNITS> <NUM|UNITS|PLANES>", 1,
|
||||||
lload, C_MOD, NORM + CAP},
|
lload, C_MOD, NORM + CAP},
|
||||||
{"market [COMM]", 0, mark, 0, VIS},
|
{"market <COMM|\"all\">", 0, mark, 0, VIS},
|
||||||
{"map <SECTS|SHIP> [s|l|p|*|h]", 0, map, C_MOD, VIS},
|
{"map <SECTS|SHIP> [s|l|p|*|h]", 0, map, C_MOD, VIS},
|
||||||
{"march <UNITS> <PATH|DESTINATION>", 1, march, C_MOD, NORM + CAP},
|
{"march <UNITS> <PATH|DESTINATION>", 1, march, C_MOD, NORM + CAP},
|
||||||
{"mine <SHIPS>", 2, mine, C_MOD, NORM + MONEY + CAP},
|
{"mine <SHIPS>", 2, mine, C_MOD, NORM + MONEY + CAP},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue