From 06025762f6871926b6746c0fc80a4ddb6c39396e Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Fri, 6 May 2011 17:03:25 -0400 Subject: [PATCH] PennMUSH 1.8.3p11 Author: talvo@talvo.com Date: Sun Nov 29 20:40:15 2009 +0000 Issue 41, namelist() now takes an optional obj/attr for error reporting Fixes #145 --- src/function.c | 2 +- src/fundb.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/function.c b/src/function.c index 6823ed1..66f4ff2 100644 --- a/src/function.c +++ b/src/function.c @@ -562,7 +562,7 @@ FUNTAB flist[] = { {"NAME", fun_name, 0, 2, FN_REG}, {"NAMEGRAB", fun_namegrab, 2, 3, FN_REG}, {"NAMEGRABALL", fun_namegraball, 2, 3, FN_REG}, - {"NAMELIST", fun_namelist, 1, 1, FN_REG}, + {"NAMELIST", fun_namelist, 1, 2, FN_REG}, {"NAND", fun_nand, 1, INT_MAX, FN_REG}, {"NATTR", fun_nattr, 1, 1, FN_REG}, {"NCHILDREN", fun_lsearch, 1, 1, FN_REG}, diff --git a/src/fundb.c b/src/fundb.c index f488e7a..b3e4604 100644 --- a/src/fundb.c +++ b/src/fundb.c @@ -1831,6 +1831,18 @@ FUNCTION(fun_namelist) char *current; dbref target; const char *start; + int report = 0; + ufun_attrib ufun; + char *wenv[2]; + + if (nargs > 1 && args[1] && *args[1]) { + if (fetch_ufun_attrib(args[1], executor, &ufun, 1)) { + report = 1; + } else { + safe_str(ufun.errmess, buff, bp); + return; + } + } start = args[0]; while (start && *start) { @@ -1843,12 +1855,14 @@ FUNCTION(fun_namelist) target = lookup_player(current); if (!GoodObject(target)) target = visible_short_page(executor, current); - if (target == NOTHING) { - safe_str("#-1", buff, bp); - } else if (target == AMBIGUOUS) { - safe_str("#-2", buff, bp); - } else { - safe_dbref(target, buff, bp); + safe_dbref(target, buff, bp); + if (target == NOTHING || target == AMBIGUOUS) { + if (report) { + wenv[0] = current; + wenv[1] = unparse_dbref(target); + if (call_ufun(&ufun, wenv, 2, NULL, executor, enactor, pe_info)) + report = 0; + } } } } -- 2.30.2