From a6bd85bb3e5f23f71b22835690825edee63fe110 Mon Sep 17 00:00:00 2001 From: Ari Johnson Date: Tue, 20 Feb 2007 22:36:41 +0000 Subject: [PATCH] "home" is now a regular command --- game/txt/hlp/cobratop.hlp | 1 - src/cmds.c | 9 +++++++++ src/command.c | 3 ++- src/game.c | 14 +------------- src/move.c | 18 +++++++++++------- win32/cmds.h | 1 + 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/game/txt/hlp/cobratop.hlp b/game/txt/hlp/cobratop.hlp index 1719792..4f095c1 100644 --- a/game/txt/hlp/cobratop.hlp +++ b/game/txt/hlp/cobratop.hlp @@ -557,7 +557,6 @@ Standard Attributes: (see @list/attribs for the complete list) order of possible commands: Special game commands: WHO, QUIT, etc. - "home" command Single-token commands: ", :, ;, + Exits in the room @-commands diff --git a/src/cmds.c b/src/cmds.c index 9235ed6..f74131d 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -483,6 +483,15 @@ COMMAND (cmd_huh_command) { notify(player, MSG_HUH); } +COMMAND (cmd_home) { + if (!Mobile(player)) + return; + if (Fixed(player)) + notify(player, T("You can't do that IC!")); + else + do_move(player, "home", MOVE_NORMAL); +} + COMMAND (cmd_kick) { do_kick(player, arg_left); } diff --git a/src/command.c b/src/command.c index e1fece1..052534e 100644 --- a/src/command.c +++ b/src/command.c @@ -317,6 +317,7 @@ COMLIST commands[] = { {"GET", NULL, cmd_get, CMD_T_PLAYER | CMD_T_THING | CMD_T_NOGAGGED, NULL}, {"GIVE", "SILENT", cmd_give, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_NOGAGGED, NULL}, {"GOTO", NULL, cmd_goto, CMD_T_PLAYER | CMD_T_THING, NULL}, + {"HOME", NULL, cmd_home, CMD_T_PLAYER | CMD_T_THING, NULL}, {"INVENTORY", NULL, cmd_inventory, CMD_T_ANY, NULL}, {"LOOK", "OUTSIDE", cmd_look, CMD_T_ANY, NULL}, @@ -957,7 +958,7 @@ command_parse(dbref player, dbref cause, dbref realcause, char *string, int from * usual processing. Exits have next priority. We still pass them * through the parser so @hook on GOTO can work on them. */ - if (can_move(player, p)) { + if (strcasecmp(p, "home") && can_move(player, p)) { ec = exit_command; safe_str("GOTO ", exit_command, &ec); safe_str(p, exit_command, &ec); diff --git a/src/game.c b/src/game.c index e3adc1d..316dc02 100644 --- a/src/game.c +++ b/src/game.c @@ -1102,7 +1102,7 @@ passwd_filter(const char *cmd) /** Attempt to match and execute a command. * This function performs some sanity checks and then attempts to - * run a command. It checks, in order: home, built-in commands, + * run a command. It checks, in order: built-in commands, * enter aliases, leave aliases, $commands on neighboring objects or * the player, $commands on the container, $commands on inventory, * exits in the zone master room, $commands on objects in the ZMR, @@ -1200,18 +1200,6 @@ process_command(dbref player, char *command, dbref cause, dbref realcause, int raw_notify(Owner(player), tprintf("#%d] %s", player, msg)); } - /* important home checking comes first! */ - if (strcmp(command, "home") == 0) { - if (!Mobile(player)) - return; - if (Fixed(player)) - notify(player, T("You can't do that IC!")); - else - do_move(player, command, 0); - return; - } - - strcpy(unp, command); cptr = command_parse(player, cause, realcause, command, from_port); diff --git a/src/move.c b/src/move.c index a51d450..a7d557c 100644 --- a/src/move.c +++ b/src/move.c @@ -301,12 +301,16 @@ safe_tel(dbref player, dbref dest, int nomovemsgs) int can_move(dbref player, const char *direction) { - if (!strcasecmp(direction, "home") && !Fixed(player) && !RPMODE(player)) - return 1; - - /* otherwise match on exits - don't use GoodObject here! */ - return (match_result(player, direction, TYPE_EXIT, MAT_ENGLISH | MAT_EXIT) != + int ok; + if (!strcasecmp(direction, "home")) { + ok = !Fixed(player); + ok = ok && command_check_byname(player, "HOME"); + } else { + /* otherwise match on exits - don't use GoodObject here! */ + ok = (match_result(player, direction, TYPE_EXIT, MAT_ENGLISH | MAT_EXIT) != NOTHING); + } + return ok; } static dbref @@ -355,7 +359,7 @@ void do_move(dbref player, const char *direction, enum move_type type) { dbref exit_m, loc, var_dest; - if(!strcasecmp(direction, "home") && (RPMODE(player) || Fixed(player))) { + if(!strcasecmp(direction, "home") && can_move(player, "home")) { notify(player, "Not right now pal."); return; } @@ -365,7 +369,7 @@ do_move(dbref player, const char *direction, enum move_type type) return; } #endif - if (!strcasecmp(direction, "home")) { + if (!strcasecmp(direction, "home") && can_move(player, "home")) { /* send him home */ /* but steal all his possessions */ if (!Mobile(player) || !GoodObject(Home(player)) || diff --git a/win32/cmds.h b/win32/cmds.h index 217b3b7..ab0a856 100644 --- a/win32/cmds.h +++ b/win32/cmds.h @@ -59,6 +59,7 @@ COMMAND_PROTO(cmd_grep); COMMAND_PROTO(cmd_halt); COMMAND_PROTO(cmd_helpcmd); COMMAND_PROTO(cmd_hide); +COMMAND_PROTO(cmd_home); COMMAND_PROTO(cmd_hook); COMMAND_PROTO(cmd_huh_command); COMMAND_PROTO(cmd_inventory); -- 2.30.2