(dispatch, explain, status): Use player->nstat instead of

player->ncomstat for command permissions.  Side effect: status() no
longer notifies deities when they go broke or become solvent.
(dispatch): Don't distinguish between transiently and permanently
unavailable commands.  Didn't really work anyway.
(player): Remove unused member ncomstat.
This commit is contained in:
Markus Armbruster 2007-12-08 20:47:13 +00:00
parent 1476e59dce
commit 976c885dfc
4 changed files with 10 additions and 15 deletions

View file

@ -67,12 +67,11 @@ struct player {
char *condarg; /* conditional, ASCII, valid if command */
char *comtail[128]; /* start of args in combuf[] */
time_t lasttime; /* when minleft was last debited */
int ncomstat;
int minleft;
int btused;
int god;
int owner;
int nstat;
int nstat; /* command capabilities */
int simulation; /* e.g. budget command */
double dolcost;
time_t curup; /* when last input was received */

View file

@ -61,18 +61,14 @@ dispatch(char *buf, char *redir)
struct cmndstr *command;
int cmd;
cmd = comtch(player->argp[0], player_coms, player->ncomstat);
cmd = comtch(player->argp[0], player_coms, player->nstat);
if (cmd < 0) {
if (cmd == M_NOTUNIQUE)
pr("Command \"%s\" is ambiguous -- ", player->argp[0]);
else if (cmd == M_IGNORE)
return 0;
else {
pr("\"%s\" is not a legal command ", player->argp[0]);
if (player->nstat != player->ncomstat)
pr("now ");
pr("\n");
}
else
pr("\"%s\" is not a legal command\n", player->argp[0]);
return -1;
}
command = &player_coms[cmd];

View file

@ -134,13 +134,14 @@ explain(void)
"Args in [brackets] are optional.\n"
"All-caps args in <angle brackets>"
" have the following meanings:\n"
/* FIXME incomplete */
" <NUM> :: a number in unspecified units\n"
" <COMM> :: a commodity such as `food', `guns', etc\n"
" <VAR> :: a commodity such as `food', `guns', etc\n"
" <TYPE> :: an item type such as `ship', `plane', etc\n");
for (i = 0; (format = player_coms[i].c_form) != 0; i++) {
if ((player_coms[i].c_permit & player->ncomstat) ==
player_coms[i].c_permit) {
if ((player_coms[i].c_permit & player->nstat)
== player_coms[i].c_permit) {
pr("%2d ", player_coms[i].c_cost);
if ((player_coms[i].c_permit & MONEY) == MONEY)
pr("$");

View file

@ -173,13 +173,12 @@ status(void)
old_nstat = player->nstat;
player_set_nstat(player, natp);
if (player->god)
player->nstat |= CAP | MONEY;
if ((old_nstat & MONEY) && !(player->nstat & MONEY))
pr("You are now broke; industries are on strike.\n");
if (!(old_nstat & MONEY) && (player->nstat & MONEY))
pr("You are no longer broke!\n");
player->ncomstat = player->nstat;
if (player->god)
player->ncomstat |= CAP | MONEY;
time(&player->curup);
minute = (player->curup - player->lasttime) / 60;
@ -205,7 +204,7 @@ status(void)
}
if (natp->nat_stat == STAT_ACTIVE && natp->nat_minused > m_m_p_d) {
pr("Max minutes per day limit exceeded.\n");
player->ncomstat = VIS;
player->nstat = (player->nstat & ~NORM) | VIS;
}
if (player->btused) {
natp->nat_btu -= player->btused;