@hook/list
authorAri Johnson <ari@cobramush.org>
Wed, 21 Feb 2007 01:00:35 +0000 (01:00 +0000)
committerAri Johnson <ari@cobramush.org>
Wed, 21 Feb 2007 01:00:35 +0000 (01:00 +0000)
game/txt/hlp/cobra_cmd.hlp
hdrs/game.h
src/cmds.c
src/command.c

index 884c36b02869567666d2afbc0120513fd8599c76..7c71fb658823d065f42db5eb9353223d9c99c808 100644 (file)
@@ -1656,6 +1656,7 @@ See also: HAVEN, page, @lock, @away
 See also: enter, @enter, ENTER_OK, @describe, look, @idescformat
 & @hook
   @hook/<switch> <command>[=<object>, <attribute>]
+  @hook/list <command>
 
   @hook tells the command parser to evaluate given attributes at certain points
   in command evaluation. The possible points, indicated by the proper switch:
@@ -1681,7 +1682,7 @@ See also: enter, @enter, ENTER_OK, @describe, look, @idescformat
   the hooks.
 
   Leaving out the object and attribute clears an existing hook. Directors can
-  see existing hooks with @command.
+  see existing hooks with @command or @hook/list.
 
   See HELP @HOOK2 for an example.
 & @hook2
index 1731c6d3a6f6da98b5cf21a3a2fa643426041724..6d7f4c48f0fc07f9bd45785d7a296365ebdc5f0b 100644 (file)
@@ -47,6 +47,7 @@ extern int do_signal_qid(dbref signalby, int qid, enum qid_flags qid_flags, int
 enum hook_type { HOOK_BEFORE, HOOK_AFTER, HOOK_IGNORE, HOOK_OVERRIDE };
 extern void do_hook(dbref player, char *command, char *obj, char *attrname,
                    enum hook_type flag);
+extern void do_hook_list(dbref player, char *command);
 
 
 /* From compress.c */
index f74131d55924b9580ad8f44b18e392a971e9b6d2..38024d8b387d2faa556b532d537425f562a8e38b 100644 (file)
@@ -472,7 +472,10 @@ COMMAND (cmd_hook) {
     flags = HOOK_IGNORE;
   else if (SW_ISSET(sw, SWITCH_OVERRIDE))
     flags = HOOK_OVERRIDE;
-  else {
+  else if (SW_ISSET(sw, SWITCH_LIST)) {
+    do_hook_list(player, arg_left);
+    return;
+  } else {
     notify(player, T("You must give a switch for @hook"));
     return;
   }
index 052534e4d16f5056f94aba0c7151fc198c11c224..780472a57326a8145017d43a5cac20b89ce65f98 100644 (file)
@@ -158,7 +158,8 @@ COMLIST commands[] = {
    CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_NOPARSE | CMD_T_NOGAGGED, NULL},
   {"@HALT", "ALL", cmd_halt, CMD_T_ANY | CMD_T_EQSPLIT, NULL},
   {"@HIDE", "NO OFF YES ON", cmd_hide, CMD_T_ANY, NULL},
-  {"@HOOK", "AFTER BEFORE IGNORE OVERRIDE", cmd_hook, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS,
+  {"@HOOK", "LIST AFTER BEFORE IGNORE OVERRIDE", cmd_hook,
+   CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS,
    "POWER^SITE"},
   {"@KICK", NULL, cmd_kick, CMD_T_ANY, "POWER^SITE"},
 
@@ -1647,23 +1648,7 @@ COMMAND (cmd_command) {
       *bp = '\0';
       notify_format(player, "Arguments    : %s", buff);
     }
-    if (Site(player)) {
-      if (GoodObject(command->hooks.before.obj))
-       notify_format(player, "@hook/before: #%d/%s",
-                     command->hooks.before.obj,
-                     command->hooks.before.attrname);
-      if (GoodObject(command->hooks.after.obj))
-       notify_format(player, "@hook/after: #%d/%s", command->hooks.after.obj,
-                     command->hooks.after.attrname);
-      if (GoodObject(command->hooks.ignore.obj))
-       notify_format(player, "@hook/ignore: #%d/%s",
-                     command->hooks.ignore.obj,
-                     command->hooks.ignore.attrname);
-      if (GoodObject(command->hooks.override.obj))
-       notify_format(player, "@hook/override: #%d/%s",
-                     command->hooks.override.obj,
-                     command->hooks.override.attrname);
-    }
+    do_hook_list(player, arg_left);
   }
 }
 
@@ -1926,3 +1911,38 @@ do_hook(dbref player, char *command, char *obj, char *attrname,
     notify_format(player, T("Hook set for %s"), cmd->name);
   }
 }
+
+
+/** List command hooks.
+ * \verbatim
+ * This is the top-level function for @hook/list, @list/hooks, and
+ * the hook-listing part of @command.
+ * \endverbatim
+ * \param player the enactor.
+ * \param command command to list hooks on.
+ */
+void
+do_hook_list(dbref player, char *command)
+{
+  COMMAND_INFO *cmd;
+
+  cmd = command_find(command);
+  if (!cmd) {
+    notify(player, T("No such command."));
+    return;
+  }
+  if (Site(player)) {
+    if (GoodObject(cmd->hooks.before.obj))
+      notify_format(player, "@hook/before: #%d/%s",
+                   cmd->hooks.before.obj, cmd->hooks.before.attrname);
+    if (GoodObject(cmd->hooks.after.obj))
+      notify_format(player, "@hook/after: #%d/%s", cmd->hooks.after.obj,
+                   cmd->hooks.after.attrname);
+    if (GoodObject(cmd->hooks.ignore.obj))
+      notify_format(player, "@hook/ignore: #%d/%s",
+                   cmd->hooks.ignore.obj, cmd->hooks.ignore.attrname);
+    if (GoodObject(cmd->hooks.override.obj))
+      notify_format(player, "@hook/override: #%d/%s",
+                   cmd->hooks.override.obj, cmd->hooks.override.attrname);
+  }
+}