PennMUSH Community

Changeset 1226

Show
Ignore:
Timestamp:
03/07/08 02:14:27 (6 months ago)
Author:
shawnw
Message:

#7554: hasattr(foo/bar)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/CHANGES.183

    r1225 r1226  
    4747 * controls(<who>,<what>/<attribute>) tests if someone can change or 
    4848   create a specific attribute on an object. By Talvo. 
     49 * hasattr() and family also understand foo(<object>/<attribute>) in 
     50   addition to the traditional two-argument form. Suggested by Impster, 
     51   patch by Talvo. 
    4952 
    5053Fixes: 
  • 1.8.3/branches/devel/game/txt/hlp/pennfunc.hlp

    r1199 r1226  
    16381638  hasattrpval() is hasattrval() but checks parents. 
    16391639   
     1640  All four functions will also work with one argument in the form 
     1641  of <object>/<attribute>. 
     1642 
    16401643& HASFLAG() 
    16411644  hasflag(<object>[/<attrib>], <flag name>) 
  • 1.8.3/branches/devel/src/function.c

    r1183 r1226  
    438438  {"GT", fun_gt, 2, 2, FN_REG}, 
    439439  {"GTE", fun_gte, 2, 2, FN_REG}, 
    440   {"HASATTR", fun_hasattr, 2, 2, FN_REG}, 
    441   {"HASATTRP", fun_hasattr, 2, 2, FN_REG}, 
    442   {"HASATTRPVAL", fun_hasattr, 2, 2, FN_REG}, 
    443   {"HASATTRVAL", fun_hasattr, 2, 2, FN_REG}, 
     440  {"HASATTR", fun_hasattr, 1, 2, FN_REG}, 
     441  {"HASATTRP", fun_hasattr, 1, 2, FN_REG}, 
     442  {"HASATTRPVAL", fun_hasattr, 1, 2, FN_REG}, 
     443  {"HASATTRVAL", fun_hasattr, 1, 2, FN_REG}, 
    444444  {"HASFLAG", fun_hasflag, 2, 2, FN_REG}, 
    445445  {"HASPOWER", fun_haspower, 2, 2, FN_REG}, 
  • 1.8.3/branches/devel/src/fundb.c

    r1199 r1226  
    198198{ 
    199199  dbref thing; 
     200  char *attr; 
    200201  ATTR *a; 
     202   
     203  if (nargs == 1) { 
     204      attr = strchr(args[0], '/'); 
     205      if (!attr) { 
     206          safe_format(buff, bp, T("#-1 BAD ARGUMENT FORMAT TO %s"), called_as); 
     207          return; 
     208      } 
     209      *attr++ = '\0'; 
     210  } else { 
     211      attr = args[1]; 
     212  } 
    201213 
    202214  thing = match_thing(executor, args[0]); 
     
    206218  } 
    207219  if (strchr(called_as, 'P')) 
    208     a = atr_get(thing, upcasestr(args[1])); 
    209   else 
    210     a = atr_get_noparent(thing, upcasestr(args[1])); 
     220    a = atr_get(thing, upcasestr(attr)); 
     221  else 
     222    a = atr_get_noparent(thing, upcasestr(attr)); 
    211223  if (a && Can_Read_Attr(executor, thing, a)) { 
    212224    if (strchr(called_as, 'V'))