that it will continue to do this for the time being. Don't rely on it.
Related functions: FULLNAME(), ACCNAME(), INAME()
+& NAMEGRAB()
+& NAMEGRABALL()
+ namegrab(<dbref list>,<name>)
+ namegraball(<dbref list>,<name>)
+
+ The namegrab() function, when given a list of dbrefs and a name, returns
+ the first dbref in the list that would match <name> as if you were
+ checking num() or locate(). An exact match has priority over non-exact matches.
+
+ namegraball() returns all dbrefs whose names would be matched by<name>.
+
+ eg: @@(#0: Room Zero. #1: One. #2: Master Room)
+ > th namegrab(#0 #1 #2,room)
+ #0
+ > th namegrab(#0 #1 #2,master room)
+ #2
+ > th namegraball(#0 #1 #2,room)
+ #0 #2
& NAND()
nand(<boolean>, <boolean>,...)
{"MUNGE", fun_munge, 3, 5, FN_REG},
{"MWHO", fun_lwho, 0, 0, FN_REG},
{"NAME", fun_name, 0, 2, FN_REG},
+ {"NAMEGRAB", fun_namegrab, 2, 3, FN_REG},
+ {"NAMEGRABALL", fun_namegraball, 2, 3, FN_REG},
{"NAND", fun_nand, 1, INT_MAX, FN_REG},
{"NATTR", fun_nattr, 1, 1, FN_REG},
{"NCON", fun_dbwalker, 1, 1, FN_REG},
} while (s);
}
+/* ARGSUSED */
+FUNCTION(fun_namegraball)
+{
+ /* Given a list of dbrefs and a string, it matches the
+ * name of the dbrefs against the string.
+ * grabnameall(#1 #2 #3,god) -> #1
+ */
+
+ char *r, *s, sep;
+ dbref victim;
+ dbref absolute;
+ int first = 1;
+
+ if (!delim_check(buff, bp, nargs, args, 3, &sep))
+ return;
+
+ absolute = parse_dbref(args[1]);
+ if (!RealGoodObject(absolute))
+ absolute = NOTHING;
+
+ if (*args[1]) {
+ s = trim_space_sep(args[0], sep);
+ do {
+ r = split_token(&s, sep);
+ victim = parse_dbref(r);
+ if (!RealGoodObject(victim))
+ continue; /* Don't bother with garbage */
+ if (!(string_match(Name(victim), args[1]) || (absolute == victim)))
+ continue;
+ if (!can_interact(victim, executor, INTERACT_MATCH))
+ continue;
+ /* It matches, and is interact-able */
+ if (!first)
+ safe_chr(sep, buff, bp);
+ safe_str(r, buff, bp);
+ first = 0;
+ } while (s);
+ } else {
+ /* Pull out all good objects (those that _have_ names) */
+ s = trim_space_sep(args[0], sep);
+ do {
+ r = split_token(&s, sep);
+ victim = parse_dbref(r);
+ if (!RealGoodObject(victim))
+ continue; /* Don't bother with garbage */
+ if (!can_interact(victim, executor, INTERACT_MATCH))
+ continue;
+ /* It's real, and is interact-able */
+ if (!first)
+ safe_chr(sep, buff, bp);
+ safe_str(r, buff, bp);
+ first = 0;
+ } while (s);
+ }
+}
+
+/* ARGSUSED */
+FUNCTION(fun_namegrab)
+{
+ /* Given a list of dbrefs and a string, it matches the
+ * name of the dbrefs against the string.
+ */
+
+ char *r, *s, sep;
+ dbref victim;
+ dbref absolute;
+ char *exact_res, *res;
+
+ exact_res = res = NULL;
+
+ if (!delim_check(buff, bp, nargs, args, 3, &sep))
+ return;
+
+ absolute = parse_dbref(args[1]);
+ if (!RealGoodObject(absolute))
+ absolute = NOTHING;
+
+ /* Walk the wordstring, until we find the word we want. */
+ s = trim_space_sep(args[0], sep);
+ do {
+ r = split_token(&s, sep);
+ victim = parse_dbref(r);
+ if (!RealGoodObject(victim))
+ continue; /* Don't bother with garbage */
+ /* Dbref match has top priority */
+ if ((absolute == victim) && can_interact(victim, executor, INTERACT_MATCH)) {
+ safe_str(r, buff, bp);
+ return;
+ }
+ /* Exact match has second priority */
+ if (!exact_res && !strcasecmp(Name(victim), args[1]) &&
+ can_interact(victim, executor, INTERACT_MATCH)) {
+ exact_res = r;
+ }
+ /* Non-exact match. */
+ if (!res && string_match(Name(victim), args[1]) &&
+ can_interact(victim, executor, INTERACT_MATCH)) {
+ res = r;
+ }
+ } while (s);
+ if (exact_res)
+ safe_str(exact_res, buff, bp);
+ else if (res)
+ safe_str(res, buff, bp);
+}
+
/* ARGSUSED */
FUNCTION(fun_match)
{