From: Rick L Bird Date: Sun, 15 May 2011 20:42:02 +0000 (-0400) Subject: PennMUSH 1.8.3p12 X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=4f594a7d12ebd3b4affb81169a4e6e7641dff6ab;p=cobramush.git PennMUSH 1.8.3p12 Author: talvo@talvo.com Date: Mon Jan 25 04:33:21 2010 +0000 Issue 162, new pfun() function to evaluate attrs from parents Fixes #208 --- diff --git a/src/function.c b/src/function.c index e45b1a4..ef61c5d 100644 --- a/src/function.c +++ b/src/function.c @@ -732,6 +732,7 @@ FUNTAB flist[] = { {"UCSTR", fun_ucstr, 1, -1, FN_REG}, {"UDEFAULT", fun_udefault, 2, 12, FN_NOPARSE}, {"UFUN", fun_ufun, 1, 11, FN_REG}, + {"PFUN", fun_pfun, 1, 11, FN_REG}, {"ULAMBDA", fun_ufun, 1, 11, FN_REG}, {"ULDEFAULT", fun_udefault, 1, 12, FN_NOPARSE | FN_LOCALIZE}, {"ULOCAL", fun_ufun, 1, 11, FN_REG | FN_LOCALIZE}, diff --git a/src/funufun.c b/src/funufun.c index 8c905c0..f622d33 100644 --- a/src/funufun.c +++ b/src/funufun.c @@ -205,6 +205,47 @@ FUNCTION(fun_ufun) return; } +/* ARGSUSED */ +FUNCTION(fun_pfun) +{ + + char rbuff[BUFFER_LEN]; + ATTR *a; + int pe_flags = PE_UDEFAULT; + dbref parent; + ufun_attrib ufun; + + parent = Parent(executor); + + if (!GoodObject(parent)) + return; + + /* This is a stripped down version of fetch_ufun_attrib that gets + the atr value directly from the parent */ + + a = atr_get(parent, upcasestr(args[0])); + if (!a) + return; /* no attr */ + + if(AF_Internal(a) || AF_Private(a)) + return; /* attr isn't inheritable */ + + /* DEBUG attributes */ + if (AF_Debug(a)) + pe_flags |= PE_DEBUG; + + ufun.thing = executor; + mush_strncpy(ufun.contents, atr_value(a), BUFFER_LEN); + ufun.pe_flags = pe_flags; + ufun.errmess = (char *) ""; + + call_ufun(&ufun, args + 1, nargs - 1, rbuff, executor, enactor, pe_info); + + safe_str(rbuff, buff, bp); + + return; +} + /* Like fun_ufun, but takes as second argument a default message * to use if the attribute isn't there. If called as uldefault, * then preserve registers, too.