extern ATTR *aname_hash_lookup(const char *name);
extern int alias_attribute(const char *atr, const char *alias);
extern void do_attribute_access
- (dbref player, char *name, char *perms, int retroactive);
+ (dbref player, char *name, char *perms, switch_mask sw);
extern void do_attribute_delete(dbref player, char *name, char def);
extern void do_attribute_rename(dbref player, char *old, char *newname);
extern void do_attribute_info(dbref player, char *name);
/* If a lock is already set on whatever we're doing.. clear it */
free_boolexp(SW_ISSET(swi, SWITCH_WRITE) ? AL_WLock(ap) : AL_RLock(ap));
- } else {
+ } else {
/* Create fresh if the name is ok */
- if (!good_atr_name(name)) {
+ if (!SW_ISSET(swi, SWITCH_DEFAULTS) && !good_atr_name(name)) {
notify(player, T("Invalid attribute name."));
return;
}
/* Only insert when it's not already in the table */
if (insert) {
- if(!SW_ISSET(swi, SWITCH_DEFAULTS)) {
- ptab_start_inserts(&ptab_attrib);
- ptab_insert(&ptab_attrib, name, ap);
- ptab_end_inserts(&ptab_attrib);
- }
+ if(!SW_ISSET(swi, SWITCH_DEFAULTS))
+ ptab_insert_one(&ptab_attrib, name, ap);
+
/* And If its the catchall.. just point the catchall to ap */
else catchall = ap;
}
* \param retroactive if true, apply the permissions retroactively.
*/
void
-do_attribute_access(dbref player, char *name, char *perms, int retroactive)
+do_attribute_access(dbref player, char *name, char *arg2, switch_mask sw)
{
ATTR *ap, *ap2;
privbits flags = 0;
+ char *perms;
int i;
int insert = 0;
/* Parse name and perms */
- if (!name || !*name) {
+ if ((!name || !*name) && !SW_ISSET(sw, SWITCH_DEFAULTS)) {
notify(player, T("Which attribute do you mean?"));
return;
}
+ perms = SW_ISSET(sw, SWITCH_DEFAULTS) ? name : arg2;
if(strcasecmp(perms, "none")) {
flags = list_to_privs(attr_privs_set, perms, 0);
if (!flags) {
return;
}
}
- upcasestr(name);
- /* Is this attribute already in the table? */
- if(*name == '@')
- name++;
- ap = (ATTR *) ptab_find_exact(&ptab_attrib, name);
+ if(!SW_ISSET(sw, SWITCH_DEFAULTS)) {
+ upcasestr(name);
+ /* Is this attribute already in the table? */
+ if(*name == '@')
+ name++;
+ ap = (ATTR *) ptab_find_exact(&ptab_attrib, name);
+ } ap = catchall;
+
if (ap) {
if (AF_Internal(ap)) {
/* Don't muck with internal attributes */
}
AL_WLock(ap) = TRUE_BOOLEXP;
AL_RLock(ap) = TRUE_BOOLEXP;
- AL_NAME(ap) = mush_strdup(name, "GLOBAL.ATR.NAME");
+ if(SW_ISSET(sw, SWITCH_DEFAULTS))
+ AL_NAME(ap) = NULL;
+ else
+ AL_NAME(ap) = mush_strdup(name, "GLOBAL.ATR.NAME");
ap->data = NULL_CHUNK_REFERENCE;
}
/* Only insert when it's not already in the table */
if (insert) {
- ptab_insert_one(&ptab_attrib, name, ap);
+ if(!SW_ISSET(sw, SWITCH_DEFAULTS))
+ ptab_insert_one(&ptab_attrib, name, ap);
+ /* And If its the catchall.. just point the catchall to ap */
+ else catchall = ap;
}
/* Ok, now we need to see if there are any attributes of this name
* set on objects in the db. If so, and if we're retroactive, set
* perms/creator
*/
- if (retroactive) {
+ if (SW_ISSET(sw, SWITCH_RETROACTIVE)) {
for (i = 0; i < db_top; i++) {
if ((ap2 = atr_get_noparent(i, name))) {
AL_FLAGS(ap2) = flags;
}
}
- notify_format(player, T("%s -- Attribute permissions now: %s"), name,
+ notify_format(player, T("%s -- Attribute permissions now: %s"), SW_ISSET(sw, SWITCH_DEFAULTS) ? "Default" : name,
privs_to_string(attr_privs_view, flags));
}
}
COMMAND (cmd_attribute) {
+
if(SW_ISSET(sw, SWITCH_INFO) || !has_power(player, "GFUNCS")) {
- do_attribute_info(player, arg_left);
- } else if (SW_ISSET(sw, SWITCH_ACCESS))
- do_attribute_access(player, arg_left, arg_right,
- SW_ISSET(sw, SWITCH_RETROACTIVE));
- else if(SW_ISSET(sw, SWITCH_LOCK)) {
+ attribute_info:
+ do_attribute_info(player, (SW_ISSET(sw, SWITCH_DEFAULTS) ? NULL : arg_left));
+ } else if(SW_ISSET(sw, SWITCH_LOCK)) {
if(SW_ISSET(sw, SWITCH_DEFAULTS))
do_attribute_lock(player, NULL, arg_left, sw);
else
do_attribute_lock(player, arg_left, arg_right, sw);
- }
+ } else if (SW_ISSET(sw, SWITCH_ACCESS) || (*arg_right != '\0' && has_power(player, "GFUNCS")))
+ do_attribute_access(player, arg_left, arg_right, sw);
else if (SW_ISSET(sw, SWITCH_DELETE))
do_attribute_delete(player, arg_left, SW_ISSET(sw, SWITCH_DEFAULTS));
else if (SW_ISSET(sw, SWITCH_RENAME)) {
do_attribute_rename(player, arg_left, arg_right);
- } else notify(player, "You lost me...");
+ } else goto attribute_info; /* go back to info if everything else fails.. Its always a safe bet */
}
COMMAND(cmd_atrchown)
{"@ASSERT", NULL, cmd_assert, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_NOPARSE, NULL},
{"@ATRLOCK", "READ WRITE", cmd_atrlock, CMD_T_ANY | CMD_T_EQSPLIT, NULL},
{"@ATRCHOWN", NULL, cmd_atrchown, CMD_T_EQSPLIT, NULL},
- {"@ATTRIBUTE", "ACCESS DEFAULTS LOCK WRITE READ DELETE RENAME RETROACTIVE", cmd_attribute,
+ {"@ATTRIBUTE", "ACCESS DEFAULTS LOCK WRITE INFO READ DELETE RENAME RETROACTIVE", cmd_attribute,
CMD_T_ANY | CMD_T_EQSPLIT, NULL},
{"@BOOT", "PORT ME", cmd_boot, CMD_T_ANY, NULL},
{"@BREAK", NULL, cmd_break, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_NOPARSE, NULL},