From 169b68cdf9fa1675e2986aab6cd018fab9f9a7f7 Mon Sep 17 00:00:00 2001 From: wyld-sw Date: Mon, 29 Jan 2024 18:09:41 -0500 Subject: [PATCH] Fixes crasher and adds mlvel 1 resteictions to CONTENTS_ARRAY. (#723) --- include/p_db.h | 7 +++---- src/p_db.c | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/p_db.h b/include/p_db.h index e3e043b8..d16d880f 100644 --- a/include/p_db.h +++ b/include/p_db.h @@ -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 diff --git a/src/p_db.c b/src/p_db.c index 72037d2a..f230d535 100644 --- a/src/p_db.c +++ b/src/p_db.c @@ -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); @@ -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 @@ -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); }