# Patch name: getset.172p20 # Patch version: 1 # Author's name: Sam Sargeant # Author's email: sam@whackass.com # version of PennMUSH: 1.7.2p20 # Date patch made: 20/02/1999 # Author is willing to support (yes/no): Yes # Patch Format: diff -c # # # This is a contributed PennMUSH patch. Its subject to the same # restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necassarily 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. # This function was written to provide an atomic get() and set() pair so we could softcode an elevator that had proper locking. See the help file addition [help getset()] for the function's usage. *** src/function.c Mon Feb 15 21:50:58 1999 --- src/function.c.getset Mon Feb 15 21:50:51 1999 *************** *** 181,186 **** --- 181,187 ---- {"FULLNAME", fun_fullname, 1, 1, FN_REG}, {"GET", fun_get, 1, 1, FN_REG}, {"GET_EVAL", fun_get_eval, 1, 1, FN_REG}, + {"GETSET", fun_getset, 4, 4, FN_REG}, {"GRAB", fun_grab, 2, 3, FN_REG}, {"GRABALL", fun_graball, 2, 3, FN_REG}, {"GREP", fun_grep, 3, 3, FN_REG}, *** src/fundb.c Mon Feb 15 21:50:40 1999 --- src/fundb.c.getset Mon Feb 15 21:50:27 1999 *************** *** 261,266 **** --- 261,313 ---- return; } + FUNCTION(fun_getset) + { + /* + * Written by Bardak@Whackass (bardak@whackass.com) for atomic locking. + */ + dbref target; + ATTR *attrib; + char *tbuf; + + target = match_thing(executor,args[0]); + if (target == NOTHING) { + safe_str("#-1 NO SUCH OBJECT VISIBLE", buff, bp); + return; + } + attrib = atr_get(target, upcasestr(args[1])); + if (attrib && Can_Read_Attr(executor, target, attrib)) { + if (SAFER_UFUN) + if ((!Wizard(executor) && Wizard(target)) || + (!God(executor) && God(target)) || + (!Hasprivs(executor) && Hasprivs(target))) { + safe_str("#-1 PERMISSION DENIED", buff, bp); + return; + } + tbuf = safe_uncompress(attrib->value); + #ifdef MEM_CHECK + add_check("fun_getset.attr_value"); + #endif + if (!strcmp(tbuf,args[2])) { + if (!do_set_atr(target, args[1], args[3], executor, 0)) { + safe_str("#-1 DO_SET_ATR() FAILED", buff, bp); + } else { + /* safe_str(args[2], buff, bp); */ + safe_str("1", buff, bp); + } + } else { + safe_str("0", buff, bp); + } + mush_free((Malloc_t) tbuf, "fun_getset.attr_value"); + return; + } else if (attrib || !Can_Examine(executor, target)) { + safe_str("#-1 NO PERMISSION TO GET ATTRIBUTE", buff, bp); + return; + } + return; + + } + /* ARGSUSED */ FUNCTION(fun_get_eval) { *** game/txt/hlp/pennfunc.hlp Mon Feb 15 21:51:20 1999 --- game/txt/hlp/pennfunc.hlp.getset Mon Feb 15 21:51:13 1999 *************** *** 2701,2703 **** --- 2701,2712 ---- function tries to change the zone on the object. See also: ZONES + + & GETSET() + getset(, , , ) + + This function was written to provide an atomic get() and set() pair. + + If the on is equal to , the attribute is + set to and 1 is returned. If not, 0 is returned. +