# # Patch name: fun_children.patch # Patch version: 1 # Author's name: Kurt Fitzner # Author's email: kfitzner@nexus.v-wave.com # Version of PennMUSH: 1.7.2pALL # Date patch made: Fri Feb 12 10:34:27 1999 # Author is willing to support (yes/no): No # Patch format: diff -u5 # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # # fun_children.patch # Adds the children() function, which gives a list of all the # objects parented to a given object. This is a little faster # than doing lsearch() (actually, about half the cost). # # Looking back on this as I make this note, I have no idea why # I didn't have this patch into funlocal.c. It would be a very # good idea to put it there. I really wouldn't suggest using # this patch, unless you intend to move the function over into # funlocal.c. Since I'm too lazy, I'll let you do it. # diff -c5 ../BACKUP/src/function.c src/function.c *** ../BACKUP/src/function.c Fri Feb 12 11:35:43 1999 --- src/function.c Fri Feb 12 10:34:27 1999 *************** *** 127,136 **** --- 127,137 ---- #endif {"CENTER", fun_center, 2, 3, FN_REG}, #ifdef CHAT_SYSTEM {"CHANNELS", fun_channels, 0, 1, FN_REG}, #endif + {"CHILDREN", fun_children, 1, 3, FN_REG}, {"CLONE", fun_clone, 1, 1, FN_REG}, {"COMP", fun_comp, 2, 2, FN_REG}, {"CON", fun_con, 1, 1, FN_REG}, {"CONN", fun_conn, 1, 1, FN_REG}, {"CONTROLS", fun_controls, 2, 2, FN_REG}, diff -c5 ../BACKUP/src/fundb.c src/fundb.c *** ../BACKUP/src/fundb.c Wed Feb 3 09:52:51 1999 --- src/fundb.c Fri Feb 12 10:35:22 1999 *************** *** 1146,1155 **** --- 1146,1221 ---- par = Parent(par); } } /* ARGSUSED */ + FUNCTION(fun_children) + { + /* The first argument is the parent to check for chilren. + * The second and third args limit the range of dbrefs (default=0,db_top) + */ + dbref low = 0; + dbref high = db_top - 1; + dbref counter; + dbref it; + int first; + + if (options.daytime) { + notify(executor, "Function disabled."); + safe_str("#-1", buff, bp); + return; + } + it = match_thing(executor, args[0]); + if (!GoodObject(it) || !Can_Examine(executor, it)) { + safe_str("#-1", buff, bp); + return; + } + if (!payfor(executor, FIND_COST)) { + notify(executor, tprintf("You don't have %d %s to do that.", + FIND_COST, + ((FIND_COST == 1) ? MONEY : MONIES))); + safe_str("#-1", buff, bp); + return; + } + + if (nargs > 1) { + if (is_integer(args[1])) { + low = parse_integer(args[1]); + } else if (is_dbref(args[1])) { + low = parse_dbref(args[1]); + } else { + safe_str(e_ints, buff, bp); + return; + } + } + if (nargs > 2) { + if (is_integer(args[2])) { + high = parse_integer(args[2]); + } else if (is_dbref(args[2])) { + high = parse_dbref(args[2]); + } else { + safe_str(e_ints, buff, bp); + return; + } + } + if (!GoodObject(low)) + low = 0; + if (!GoodObject(high)) + high = db_top - 1; + first = 1; + for (counter = low; counter <= high; counter++) { + if (Parent(counter) == it) { + if (first) + first = 0; + else + safe_chr(' ', buff, bp); + safe_str(unparse_dbref(counter), buff, bp); + } + } + } + + /* ARGSUSED */ FUNCTION(fun_home) { dbref it = match_thing(executor, args[0]); if ((it == NOTHING) || !Can_Examine(executor, it) || (Typeof(it) == TYPE_ROOM)) {