#include <stdio.h> #include <ctype.h> #include "externs.h" #include "attrib.h" void sc_do_set(char *arg1, char *arg2) { OBJ *thing; ATTR *attr; char *p, *b; unsigned long flag; int denied; char buf[4096]; int reset, flags2; /* See if we're setting an attribute */ if(parse_attrib(code_ptr->object, arg1, &thing, &attr)) { if(!is_root(code_ptr->object) && is_root(thing)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(attr->flags & AF_WIZARD && !controls(code_ptr->object, thing, POW_WATTR)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(!can_set_atr(code_ptr->object, thing, attr)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(!string_compare(attr->name, "ALIAS")) { notify(code_ptr->executor, tprintf("Trying to set alias attribute in |+Y|%d|n|.", code_ptr->pline->line)); show_line_and_end(); return; } else if(!string_compare(attr->name, "SEX")) { if(toupper(*arg2) != 'M' && toupper(*arg2) != 'F' && toupper(*arg2) != 'N') { notify(code_ptr->executor, tprintf("Trying to set invalid sex in |+Y|%d|n|.", code_ptr->pline->line)); show_line_and_end(); return; } } thing->mod_time = now; if(attr->flags & AF_LOCK) { if((p = process_lock(code_ptr->object, arg2))) atr_add_a(thing, attr, p); } else atr_add_a(thing, attr, arg2); return; } /* Set a flag */ if(!(thing = match_object(code_ptr->object, arg1, NOTYPE))) { notify(code_ptr->executor, tprintf("No such player '%s' in |+Y|%d|n|.", arg1, code_ptr->pline->line)); show_line_and_end(); return; } if(!is_root(code_ptr->object) && is_root(thing)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(!controls(code_ptr->object, thing, POW_MODIFY)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } p = arg2; if(!*p) { notify(code_ptr->executor, tprintf("No flag specified in |+Y|%d|n|.", code_ptr->pline->line)); show_line_and_end(); return; } while(*p) { flag = 0; denied = 0; reset = 0; flags2 = 0; b = buf; if(*p == NOT_TOKEN) { reset = 1; p++; } while(*p && *p != ',') *b++ = *p++; *b = '\0'; flag = match_flag(code_ptr->object, thing, buf, &denied); if(denied) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(!flag) { flag = match_flag2(code_ptr->object, thing, buf, &denied); if(denied) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(!flag) { notify(code_ptr->executor, tprintf("Unknown flag '%s' in |+Y|%d|n|.", buf, code_ptr->pline->line)); show_line_and_end(); return; } flags2 = 1; } if(!flags2 && flag == INHERIT_POWERS && !controls(code_ptr->object, thing, POW_SECURITY)) { notify(code_ptr->executor, tprintf("|+R|Permission denied in |+Y|%d|+R|.", code_ptr->pline->line)); show_line_and_end(); return; } if(reset) { if(flags2) thing->flags2 &= ~flag; else thing->flags &= ~flag; } else { if(flags2) thing->flags2 |= flag; else thing->flags |= flag; } if(*p) p++; } }