| 1 | *** src/attrib.c.orig Sun Dec 16 23:18:28 2007 |
|---|
| 2 | --- src/attrib.c Sun Dec 16 23:41:03 2007 |
|---|
| 3 | *************** |
|---|
| 4 | *** 389,394 **** |
|---|
| 5 | --- 389,414 ---- |
|---|
| 6 | return 1; |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | + /** If the attribute exists on the object, see if the player can modify it. |
|---|
| 10 | + * Otherwise, see if they can create it. |
|---|
| 11 | + * \param player the player trying to set the attr |
|---|
| 12 | + * \param thing the object to check |
|---|
| 13 | + * \param attrname the name of the attribute to check |
|---|
| 14 | + * \retval 0 attribute cannot be changed by player |
|---|
| 15 | + * \retval 1 attribute can be changed by player |
|---|
| 16 | + */ |
|---|
| 17 | + int |
|---|
| 18 | + can_edit_attr(dbref player, dbref thing, const char *attrname) |
|---|
| 19 | + { |
|---|
| 20 | + ATTR *ptr = find_atr_in_list(List(thing), attrname); |
|---|
| 21 | + if (ptr) { |
|---|
| 22 | + if (AF_Safe(ptr) || !Can_Write_Attr(player, thing, ptr)) |
|---|
| 23 | + return 0; |
|---|
| 24 | + } else { |
|---|
| 25 | + return (can_create_attr(player, thing, attrname, 0) == AE_OKAY); |
|---|
| 26 | + } |
|---|
| 27 | + } |
|---|
| 28 | + |
|---|
| 29 | /** Utility define for atr_add and can_create_attr */ |
|---|
| 30 | #define set_default_flags(atr,flags) \ |
|---|
| 31 | do { \ |
|---|
| 32 | *** src/fundb.c.orig Mon Jul 9 04:50:12 2007 |
|---|
| 33 | --- src/fundb.c Sun Dec 16 23:41:06 2007 |
|---|
| 34 | *************** |
|---|
| 35 | *** 958,973 **** |
|---|
| 36 | FUNCTION(fun_controls) |
|---|
| 37 | { |
|---|
| 38 | dbref it = match_thing(executor, args[0]); |
|---|
| 39 | ! dbref thing = match_thing(executor, args[1]); |
|---|
| 40 | |
|---|
| 41 | ! if (!GoodObject(it)) |
|---|
| 42 | safe_str(T("#-1 ARG1 NOT FOUND"), buff, bp); |
|---|
| 43 | ! else if (!GoodObject(thing)) |
|---|
| 44 | safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp); |
|---|
| 45 | ! else if (!(controls(executor, it) || controls(executor, thing) |
|---|
| 46 | ! || See_All(executor))) |
|---|
| 47 | safe_str(T(e_perm), buff, bp); |
|---|
| 48 | ! else |
|---|
| 49 | safe_chr(controls(it, thing) ? '1' : '0', buff, bp); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | --- 958,988 ---- |
|---|
| 53 | FUNCTION(fun_controls) |
|---|
| 54 | { |
|---|
| 55 | dbref it = match_thing(executor, args[0]); |
|---|
| 56 | ! dbref thing; |
|---|
| 57 | ! char *attrname; |
|---|
| 58 | |
|---|
| 59 | ! if (!GoodObject(it)) { |
|---|
| 60 | safe_str(T("#-1 ARG1 NOT FOUND"), buff, bp); |
|---|
| 61 | ! return; |
|---|
| 62 | ! } |
|---|
| 63 | ! |
|---|
| 64 | ! if ((attrname = strchr(args[1], '/')) != NULL) |
|---|
| 65 | ! *attrname++ = '\0'; |
|---|
| 66 | ! thing = match_thing(executor, args[1]); |
|---|
| 67 | ! if (!GoodObject(thing)) { |
|---|
| 68 | safe_str(T("#-1 ARG2 NOT FOUND"), buff, bp); |
|---|
| 69 | ! return; |
|---|
| 70 | ! } |
|---|
| 71 | ! if (!(controls(executor, it) || controls(executor, thing) |
|---|
| 72 | ! || See_All(executor))) |
|---|
| 73 | safe_str(T(e_perm), buff, bp); |
|---|
| 74 | ! else if (attrname) { |
|---|
| 75 | ! if (!good_atr_name(upcasestr(attrname))) { |
|---|
| 76 | ! safe_str(T("#-1 BAD ATTR NAME"), buff, bp); |
|---|
| 77 | ! return; |
|---|
| 78 | ! } |
|---|
| 79 | ! safe_chr(can_edit_attr(it, thing, attrname) ? '1' : '0', buff, bp); |
|---|
| 80 | ! } else |
|---|
| 81 | safe_chr(controls(it, thing) ? '1' : '0', buff, bp); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | *** hdrs/attrib.h.orig Sun Dec 16 23:18:37 2007 |
|---|
| 85 | --- hdrs/attrib.h Sun Dec 16 23:41:16 2007 |
|---|
| 86 | *************** |
|---|
| 87 | *** 89,94 **** |
|---|
| 88 | --- 89,95 ---- |
|---|
| 89 | extern int can_read_attr_internal(dbref player, dbref obj, ATTR *attr); |
|---|
| 90 | extern int can_write_attr_internal(dbref player, dbref obj, ATTR *attr, |
|---|
| 91 | int safe); |
|---|
| 92 | + extern int can_edit_attr(dbref player, dbref thing, const char *attrname); |
|---|
| 93 | extern unsigned const char *atr_get_compressed_data(ATTR *atr); |
|---|
| 94 | extern char *atr_value(ATTR *atr); |
|---|
| 95 | extern char * |
|---|
| 96 | *** game/txt/hlp/pennfunc.hlp.orig Fri Oct 5 23:36:32 2007 |
|---|
| 97 | --- game/txt/hlp/pennfunc.hlp Sun Dec 16 23:43:30 2007 |
|---|
| 98 | *************** |
|---|
| 99 | *** 800,812 **** |
|---|
| 100 | |
|---|
| 101 | See also: CONNECTED |
|---|
| 102 | & CONTROLS() |
|---|
| 103 | ! controls(<object>, <victim>) |
|---|
| 104 | |
|---|
| 105 | ! This function returns 1 if <object> controls <victim>, or 0, if |
|---|
| 106 | ! it does not. If one of the objects does not exist, it will return |
|---|
| 107 | ! #-1 ARGN NOT FOUND (where N is the argument which is the invalid |
|---|
| 108 | ! object). You must control <object> or <victim>, or have the See_All |
|---|
| 109 | ! power, to use this function. |
|---|
| 110 | |
|---|
| 111 | See also: CONTROL |
|---|
| 112 | |
|---|
| 113 | --- 800,815 ---- |
|---|
| 114 | |
|---|
| 115 | See also: CONNECTED |
|---|
| 116 | & CONTROLS() |
|---|
| 117 | ! controls(<object>, <victim>[/<attribute>]) |
|---|
| 118 | |
|---|
| 119 | ! With no <attribute>, this function returns 1 if <object> controls |
|---|
| 120 | ! <victim>, or 0, if it does not. With an <attribute>, it will return 1 |
|---|
| 121 | ! if <object> could successfully set <attribute> on <victim> (or alter |
|---|
| 122 | ! <attribute>, if it already exists). If one of the objects does not exist, |
|---|
| 123 | ! it will return #-1 ARGN NOT FOUND (where N is the argument which is the |
|---|
| 124 | ! invalid object). If <attribute> is not a valid attribute name, it will |
|---|
| 125 | ! return #-1 BAD ATTR NAME. You must control <object> or <victim>, or have |
|---|
| 126 | ! the See_All power, to use this function. |
|---|
| 127 | |
|---|
| 128 | See also: CONTROL |
|---|
| 129 | |
|---|