(dispatch): Argument buf is user text and must be printed as such. In
error messages, print just the command name instead.
This commit is contained in:
parent
ddfd5c1699
commit
2f35354097
2 changed files with 14 additions and 5 deletions
|
@ -417,7 +417,7 @@ extern void player_wakeup_all(natid);
|
||||||
extern void player_wakeup(struct player *);
|
extern void player_wakeup(struct player *);
|
||||||
extern void player_accept(void *);
|
extern void player_accept(void *);
|
||||||
/* dispatch.c */
|
/* dispatch.c */
|
||||||
extern int dispatch(s_char *, s_char *);
|
extern int dispatch(char *, char *);
|
||||||
/* empdis.c */
|
/* empdis.c */
|
||||||
extern int getcommand(s_char *);
|
extern int getcommand(s_char *);
|
||||||
extern void init_player_commands(void);
|
extern void init_player_commands(void);
|
||||||
|
|
|
@ -46,8 +46,16 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute command named by player->argp[0].
|
||||||
|
* BUF is the raw command line (user text). It should have been
|
||||||
|
* passed to parse() to set up player->argp.
|
||||||
|
* If REDIR is not null, it's the command's redirection; it is user
|
||||||
|
* text.
|
||||||
|
* Return -1 if the command is not unique or doesn't exist, else 0.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
dispatch(s_char *buf, s_char *redir)
|
dispatch(char *buf, char *redir)
|
||||||
{
|
{
|
||||||
struct natstr *np;
|
struct natstr *np;
|
||||||
struct cmndstr *command;
|
struct cmndstr *command;
|
||||||
|
@ -57,11 +65,11 @@ dispatch(s_char *buf, s_char *redir)
|
||||||
player->ncomstat, player->god);
|
player->ncomstat, player->god);
|
||||||
if (cmd < 0) {
|
if (cmd < 0) {
|
||||||
if (cmd == M_NOTUNIQUE)
|
if (cmd == M_NOTUNIQUE)
|
||||||
pr("\"%s\" is ambiguous -- ", buf);
|
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 ", buf);
|
pr("\"%s\" is not a legal command ", player->argp[0]);
|
||||||
if (player->nstat != player->ncomstat)
|
if (player->nstat != player->ncomstat)
|
||||||
pr("now ");
|
pr("now ");
|
||||||
pr("\n");
|
pr("\n");
|
||||||
|
@ -88,7 +96,8 @@ dispatch(s_char *buf, s_char *redir)
|
||||||
}
|
}
|
||||||
if (redir) {
|
if (redir) {
|
||||||
prredir(redir);
|
prredir(redir);
|
||||||
pr("%s\n", buf);
|
uprnf(buf);
|
||||||
|
pr("\n");
|
||||||
}
|
}
|
||||||
player->command = command;
|
player->command = command;
|
||||||
switch (command->c_addr()) {
|
switch (command->c_addr()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue