version 1.18 | | version 1.19 |
---|
| | |
| | |
/* | | /* |
* static char *rcsid_loop_c = | | * static char *rcsid_loop_c = |
* "$Id: loop.c,v 1.18 2002/03/26 07:18:57 mwedel Exp $"; | | * "$Id: loop.c,v 1.19 2002/07/25 06:57:14 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
struct PlCmdMapping { | | struct PlCmdMapping { |
char *cmdname; | | char *cmdname; |
func_uint8_int_pl cmdproc; | | func_uint8_int_pl cmdproc; |
| | uint8 flag; |
}; | | }; |
| | |
/* | | /* |
| | |
* unsigned (pretty much needs to be for binary data), however, most | | * unsigned (pretty much needs to be for binary data), however, most |
* of these treat it only as strings, so it makes things easier | | * of these treat it only as strings, so it makes things easier |
* to cast it here instead of a bunch of times in the function itself. | | * to cast it here instead of a bunch of times in the function itself. |
| | * flag is 1 if the player must be in the playing state to issue the |
| | * command, 0 if they can issue it at any time. |
*/ | | */ |
static struct PlCmdMapping plcommands[] = { | | static struct PlCmdMapping plcommands[] = { |
{ "examine", ExamineCmd }, | | { "examine", ExamineCmd, 1}, |
{ "apply", ApplyCmd }, | | { "apply", ApplyCmd, 1}, |
{ "move", MoveCmd }, | | { "move", MoveCmd, 1}, |
{ "reply", ReplyCmd}, | | { "reply", ReplyCmd, 0}, |
{ "command", PlayerCmd}, | | { "command", PlayerCmd, 1}, |
{ "ncom", (func_uint8_int_pl)NewPlayerCmd}, | | { "ncom", (func_uint8_int_pl)NewPlayerCmd, 1}, |
{ "lookat", LookAt}, | | { "lookat", LookAt, 1}, |
{ "mapredraw", MapRedrawCmd}, /* Added: phil */ | | { "lock", (func_uint8_int_pl)LockItem, 1}, |
{ "lock", (func_uint8_int_pl)LockItem}, | | { "mark", (func_uint8_int_pl)MarkItem, 1}, |
{ "mark", (func_uint8_int_pl)MarkItem}, | | { "mapredraw", MapRedrawCmd, 0}, /* Added: phil */ |
{ NULL, NULL} /* terminator */ | | { NULL, NULL} /* terminator */ |
}; | | }; |
| | |
| | |
return; | | return; |
} | | } |
} | | } |
/* Only valid players can use these commands */ | | /* Player must be in the playing state or the flag on the |
| | * the command must be zero for the user to use the command - |
| | * otherwise, a player cam save, be in the play_again state, and |
| | * the map they were on getsswapped out, yet things that try to look |
| | * at the map causes a crash. If the command is valid, but |
| | * one they can't use, we still swallow it up. |
| | */ |
if (pl) for (i=0; plcommands[i].cmdname !=NULL; i++) { | | if (pl) for (i=0; plcommands[i].cmdname !=NULL; i++) { |
if (strcmp((char*)ns->inbuf.buf+2,plcommands[i].cmdname)==0) { | | if (strcmp((char*)ns->inbuf.buf+2,plcommands[i].cmdname)==0) { |
| | if (pl->state == ST_PLAYING || plcommands[i].flag == 0) |
plcommands[i].cmdproc((char*)data,len,pl); | | plcommands[i].cmdproc((char*)data,len,pl); |
ns->inbuf.len=0; | | ns->inbuf.len=0; |
return; | | return; |