Skip to content

Commit

Permalink
Fixes crasher and adds mlvel 1 resteictions to CONTENTS_ARRAY. (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyld-sw authored Jan 29, 2024
1 parent 4edc578 commit 169b68c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 3 additions & 4 deletions include/p_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,9 @@ void prim_newprogram(PRIM_PROTOTYPE);
/**
* Implementation of MUF CONTENTS_ARRAY
*
* Consumes a dbref, and returns an array of its contents. Requires
* remote-read permissions when applicable.
*
* Unlike prim_contents, this has no MUCKER level 1 restrictions.
* Consumes a dbref, and returns an array of its contents. Only returns
* controlled non-DARK objects for MUCKER level 1. Requires remote-read
* permissions when applicable.
*
* @param player the player running the MUF program
* @param program the program being run
Expand Down
17 changes: 12 additions & 5 deletions src/p_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ prim_contents(PRIM_PROTOTYPE)
abort_interp("Invalid argument type.");
}

CHECKREMOTE(oper1->data.objref);
ref = CONTENTS(oper1->data.objref);
CHECKREMOTE(ref);

while (mlev < 2 && ref != NOTHING && (FLAGS(ref) & DARK) && !controls(ProgUID, ref)) {
ref = NEXTOBJ(ref);
Expand Down Expand Up @@ -3345,10 +3345,9 @@ prim_getpidinfo(PRIM_PROTOTYPE)
/**
* Implementation of MUF CONTENTS_ARRAY
*
* Consumes a dbref, and returns an array of its contents. Requires
* remote-read permissions when applicable.
*
* Unlike prim_contents, this has no MUCKER level 1 restrictions.
* Consumes a dbref, and returns an array of its contents. Only returns
* controlled non-DARK objects for MUCKER level 1. Requires remote-read
* permissions when applicable.
*
* @param player the player running the MUF program
* @param program the program being run
Expand Down Expand Up @@ -3382,12 +3381,20 @@ prim_contents_array(PRIM_PROTOTYPE)
CHECKREMOTE(oper1->data.objref);

for (ref = CONTENTS(oper1->data.objref); ObjExists(ref); ref = NEXTOBJ(ref)) {
if (mlev < 2 && ref != NOTHING && (FLAGS(ref) & DARK) && !controls(ProgUID, ref)) {
continue;
}

count++;
}

nw = new_array_packed(count, fr->pinning);

for (ref = CONTENTS(oper1->data.objref), count = 0; ObjExists(ref); ref = NEXTOBJ(ref)) {
if (mlev < 2 && ref != NOTHING && (FLAGS(ref) & DARK) && !controls(ProgUID, ref)) {
continue;
}

array_set_intkey_refval(&nw, count++, ref);
}

Expand Down

0 comments on commit 169b68c

Please sign in to comment.