(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:
parent
1476e59dce
commit
976c885dfc
4 changed files with 10 additions and 15 deletions
|
@ -67,12 +67,11 @@ struct player {
|
||||||
char *condarg; /* conditional, ASCII, valid if command */
|
char *condarg; /* conditional, ASCII, valid if command */
|
||||||
char *comtail[128]; /* start of args in combuf[] */
|
char *comtail[128]; /* start of args in combuf[] */
|
||||||
time_t lasttime; /* when minleft was last debited */
|
time_t lasttime; /* when minleft was last debited */
|
||||||
int ncomstat;
|
|
||||||
int minleft;
|
int minleft;
|
||||||
int btused;
|
int btused;
|
||||||
int god;
|
int god;
|
||||||
int owner;
|
int owner;
|
||||||
int nstat;
|
int nstat; /* command capabilities */
|
||||||
int simulation; /* e.g. budget command */
|
int simulation; /* e.g. budget command */
|
||||||
double dolcost;
|
double dolcost;
|
||||||
time_t curup; /* when last input was received */
|
time_t curup; /* when last input was received */
|
||||||
|
|
|
@ -61,18 +61,14 @@ dispatch(char *buf, char *redir)
|
||||||
struct cmndstr *command;
|
struct cmndstr *command;
|
||||||
int cmd;
|
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 < 0) {
|
||||||
if (cmd == M_NOTUNIQUE)
|
if (cmd == M_NOTUNIQUE)
|
||||||
pr("Command \"%s\" is ambiguous -- ", player->argp[0]);
|
pr("Command \"%s\" is ambiguous -- ", player->argp[0]);
|
||||||
else if (cmd == M_IGNORE)
|
else if (cmd == M_IGNORE)
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else
|
||||||
pr("\"%s\" is not a legal command ", player->argp[0]);
|
pr("\"%s\" is not a legal command\n", player->argp[0]);
|
||||||
if (player->nstat != player->ncomstat)
|
|
||||||
pr("now ");
|
|
||||||
pr("\n");
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
command = &player_coms[cmd];
|
command = &player_coms[cmd];
|
||||||
|
|
|
@ -134,13 +134,14 @@ explain(void)
|
||||||
"Args in [brackets] are optional.\n"
|
"Args in [brackets] are optional.\n"
|
||||||
"All-caps args in <angle brackets>"
|
"All-caps args in <angle brackets>"
|
||||||
" have the following meanings:\n"
|
" have the following meanings:\n"
|
||||||
|
/* FIXME incomplete */
|
||||||
" <NUM> :: a number in unspecified units\n"
|
" <NUM> :: a number in unspecified units\n"
|
||||||
" <COMM> :: a commodity such as `food', `guns', etc\n"
|
" <COMM> :: a commodity such as `food', `guns', etc\n"
|
||||||
" <VAR> :: 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");
|
" <TYPE> :: an item type such as `ship', `plane', etc\n");
|
||||||
for (i = 0; (format = player_coms[i].c_form) != 0; i++) {
|
for (i = 0; (format = player_coms[i].c_form) != 0; i++) {
|
||||||
if ((player_coms[i].c_permit & player->ncomstat) ==
|
if ((player_coms[i].c_permit & player->nstat)
|
||||||
player_coms[i].c_permit) {
|
== player_coms[i].c_permit) {
|
||||||
pr("%2d ", player_coms[i].c_cost);
|
pr("%2d ", player_coms[i].c_cost);
|
||||||
if ((player_coms[i].c_permit & MONEY) == MONEY)
|
if ((player_coms[i].c_permit & MONEY) == MONEY)
|
||||||
pr("$");
|
pr("$");
|
||||||
|
|
|
@ -173,13 +173,12 @@ status(void)
|
||||||
|
|
||||||
old_nstat = player->nstat;
|
old_nstat = player->nstat;
|
||||||
player_set_nstat(player, natp);
|
player_set_nstat(player, natp);
|
||||||
|
if (player->god)
|
||||||
|
player->nstat |= CAP | MONEY;
|
||||||
if ((old_nstat & MONEY) && !(player->nstat & MONEY))
|
if ((old_nstat & MONEY) && !(player->nstat & MONEY))
|
||||||
pr("You are now broke; industries are on strike.\n");
|
pr("You are now broke; industries are on strike.\n");
|
||||||
if (!(old_nstat & MONEY) && (player->nstat & MONEY))
|
if (!(old_nstat & MONEY) && (player->nstat & MONEY))
|
||||||
pr("You are no longer broke!\n");
|
pr("You are no longer broke!\n");
|
||||||
player->ncomstat = player->nstat;
|
|
||||||
if (player->god)
|
|
||||||
player->ncomstat |= CAP | MONEY;
|
|
||||||
|
|
||||||
time(&player->curup);
|
time(&player->curup);
|
||||||
minute = (player->curup - player->lasttime) / 60;
|
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) {
|
if (natp->nat_stat == STAT_ACTIVE && natp->nat_minused > m_m_p_d) {
|
||||||
pr("Max minutes per day limit exceeded.\n");
|
pr("Max minutes per day limit exceeded.\n");
|
||||||
player->ncomstat = VIS;
|
player->nstat = (player->nstat & ~NORM) | VIS;
|
||||||
}
|
}
|
||||||
if (player->btused) {
|
if (player->btused) {
|
||||||
natp->nat_btu -= player->btused;
|
natp->nat_btu -= player->btused;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue