Skip to content

Commit

Permalink
Make lattrp() behave like 1.8.6 again. Fixes #1233
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnw committed Sep 21, 2018
1 parent 5b97142 commit 7fd9a01
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/attrib.c
Expand Up @@ -1496,9 +1496,7 @@ atr_iter_get_parent(dbref player, dbref thing, const char *name, unsigned flags,
if (AF_Private(ptr))
continue;
}
if (strchr(AL_NAME(ptr), '`')) {
continue;
}

if (((flags & AIG_MORTAL) ? Is_Visible_Attr(parent, ptr)
: Can_Read_Attr(player, parent, ptr)) &&
((flags & AIG_REGEX)
Expand All @@ -1514,6 +1512,7 @@ atr_iter_get_parent(dbref player, dbref thing, const char *name, unsigned flags,
if (AF_Private(ptr) && thing != parent) {
continue;
}

if (strchr(AL_NAME(ptr), '`')) {
/* We need to check all the branches of the tree for no_inherit
*/
Expand All @@ -1536,11 +1535,13 @@ atr_iter_get_parent(dbref player, dbref thing, const char *name, unsigned flags,
continue;
}

if (((flags & AIG_MORTAL) ? Is_Visible_Attr(thing, ptr)
if (!st_find(AL_NAME(ptr), &seen) &&
((flags & AIG_MORTAL) ? Is_Visible_Attr(thing, ptr)
: Can_Read_Attr(player, thing, ptr)) &&
((flags & AIG_REGEX)
? quick_regexp_match(name, AL_NAME(ptr), 0, NULL)
: atr_wild(name, AL_NAME(ptr)))) {
st_insert(AL_NAME(ptr), &seen);
result += func(player, thing, parent, name, ptr, args);
}
}
Expand Down
18 changes: 18 additions & 0 deletions test/testatree.t
Expand Up @@ -145,6 +145,24 @@ test('atree.parent.24', $god, 'think get(child/foo`bar)', '^$');
test('atree.parent.25', $god, 'think get(child/foo)', 'wibble');
test('atree.parent.26', $god, 'think get(child/foo`bar)', '^$');

# lattr() and lattrp() tests
$mortal->command("&tree`leaf parent=X");
$mortal->command("&tree child=Y");

test('atree.lattr.1', $mortal, 'think lattr(child/tree**)', '^TREE$');
test('atree.lattr.2', $mortal, 'think lattr(child/tree`)', '^$');
test('atree.lattr.3', $mortal, 'think lattr(parent/tree`)', '^TREE`LEAF$');
test('atree.lattr.4', $mortal, 'think lattr(parent/tree`**)', '^TREE`LEAF$');
test('atree.lattr.5', $mortal, 'think lattr(parent/tree**)', '^TREE TREE`LEAF$');

test('atree.lattrp.1', $mortal, 'think lattrp(child/tree`)', '^TREE`LEAF$');
test('atree.lattrp.2', $mortal, 'think lattrp(child/tree`**)', '^TREE`LEAF$');
test('atree.lattrp.3', $mortal, 'think lattrp(child/tree**)', '^TREE TREE`LEAF$');
$mortal->command("&tree`leaf child=Z");
test('atree.lattrp.4', $mortal, 'think lattrp(child/tree`)', '^TREE`LEAF$');
test('atree.lattrp.5', $mortal, 'think lattrp(child/tree`**)', '^TREE`LEAF$');
test('atree.lattrp.6', $mortal, 'think lattrp(child/tree**)', '^TREE TREE`LEAF$');

# Mix permissions and parents
# If parent is inheritable again, and mortal_dark,
# then we can't see the ancestor through it
Expand Down

0 comments on commit 7fd9a01

Please sign in to comment.