Changeset 1202
- Timestamp:
- 01/19/08 23:11:34 (9 months ago)
- Files:
-
- 1.8.3/branches/devel/CHANGES.183 (modified) (1 diff)
- 1.8.3/branches/devel/src/command.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/CHANGES.183
r1199 r1202 26 26 are changed and automatically reload them instead of waiting for a 27 27 @readcache. 28 * '@hook/override cmd=#1234' will look at all attributes on the object 29 for a matching $command. By Talvo. 28 30 29 31 Functions: 1.8.3/branches/devel/src/command.c
r1177 r1202 68 68 int run_hook(dbref player, dbref cause, struct hook_data *hook, 69 69 char *saveregs[], int save); 70 71 int run_hook_override(COMMAND_INFO *cmd, dbref player, const char *commandraw); 72 70 73 71 74 /** The list of standard commands. Additional commands can be added … … 1343 1346 if (run_hook(player, cause, &cmd->hooks.ignore, saveregs, 1)) { 1344 1347 /* If we have a hook/override, we use that instead */ 1345 if (!has_hook(&cmd->hooks.override) || 1346 !one_comm_match(cmd->hooks.override.obj, player, 1347 cmd->hooks.override.attrname, commandraw)) { 1348 if (!run_hook_override(cmd, player, commandraw)) { 1348 1349 /* Otherwise, we do hook/before, the command, and hook/after */ 1349 1350 /* But first, let's see if we had an invalid switch */ … … 1948 1949 has_hook(struct hook_data *hook) 1949 1950 { 1950 if (!hook || !GoodObject(hook->obj) || IsGarbage(hook->obj) 1951 || !hook->attrname) 1951 if (!hook || !GoodObject(hook->obj) || IsGarbage(hook->obj)) 1952 1952 return 0; 1953 1953 return 1; … … 2004 2004 mush_free(code, "hook.code"); 2005 2005 return parse_boolean(buff); 2006 } 2007 2008 int 2009 run_hook_override(COMMAND_INFO *cmd, dbref player, const char *commandraw) 2010 { 2011 2012 if (!has_hook(&cmd->hooks.override)) 2013 return 0; 2014 2015 if (cmd->hooks.override.attrname) { 2016 return one_comm_match(cmd->hooks.override.obj, player, 2017 cmd->hooks.override.attrname, commandraw); 2018 } else { 2019 return atr_comm_match(cmd->hooks.override.obj, player, '$', ':', commandraw, 2020 0, NULL, NULL, NULL); 2021 } 2006 2022 } 2007 2023 … … 2052 2068 mush_free(h->attrname, "hook.attr"); 2053 2069 h->attrname = NULL; 2054 } else if (!obj || !*obj || !attrname || !*attrname) { 2055 notify(player, T("You must give both an object and attribute.")); 2070 } else if (!obj || !*obj 2071 || (flag != HOOK_OVERRIDE && (!attrname || !*attrname))) { 2072 if (flag == HOOK_OVERRIDE) { 2073 notify(player, T("You must give an object.")); 2074 } else { 2075 notify(player, T("You must give both an object and attribute.")); 2076 } 2056 2077 } else { 2057 2078 dbref objdb = match_thing(player, obj); … … 2063 2084 if (h->attrname) 2064 2085 mush_free(h->attrname, "hook.attr"); 2065 h->attrname = mush_strdup(strupper(attrname), "hook.attr"); 2086 if (!attrname || !*attrname) { 2087 h->attrname = NULL; 2088 } else { 2089 h->attrname = mush_strdup(strupper(attrname), "hook.attr"); 2090 } 2066 2091 notify_format(player, T("Hook set for %s"), cmd->name); 2067 2092 }
