void do_newpassword(dbref player, const char *name, const char *password) { dbref victim; char buf[BUFFER_LEN]; if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only a Wizard player can newpassword someone."); return; } else if ((victim = lookup_player(name)) == NOTHING) { notify(player, "No such player."); } else if (*password != '\0' && !ok_password(password)) { /* Wiz can set null passwords, but not bad passwords */ notify(player, "Bad password"); #ifdef GOD_PRIV } else if (God(victim)) { notify(player, "You can't change God's password!"); return; } else { if (TrueWizard(victim) && !God(player)) { notify(player, "Only God can change a wizard's password."); return; } #else /* GOD_PRIV */ } else {
static bool fh_going_bit(dbref target, dbref player, FLAG flag, int fflags, bool reset) { if ( Going(target) && reset && (Typeof(target) != TYPE_GARBAGE)) { notify(player, T("Your object has been spared from destruction.")); return (fh_any(target, player, flag, fflags, reset)); } if (!God(player)) { return false; } // Even God should not be allowed set protected dbrefs GOING. // if ( !reset && ( target == 0 || God(target) || target == mudconf.start_home || target == mudconf.start_room || target == mudconf.default_home || target == mudconf.master_room)) { return false; } return (fh_any(target, player, flag, fflags, reset)); }
/** Actually change the ownership of something, and fix bits. * \param player the enactor. * \param thing object to change ownership of. * \param newowner new owner for thing. * \param preserve if 1, preserve privileges and don't halt. */ void chown_object(dbref player, dbref thing, dbref newowner, int preserve) { (void) undestroy(player, thing); if (God(player)) { Owner(thing) = newowner; } else { Owner(thing) = Owner(newowner); } /* Don't allow circular zones */ Zone(thing) = NOTHING; if (GoodObject(Zone(newowner))) { dbref tmp; int ok_to_zone = 1; int zone_depth = MAX_ZONES; for (tmp = Zone(Zone(newowner)); GoodObject(tmp); tmp = Zone(tmp)) { if (tmp == thing) { notify(player, T("Circular zone broken.")); ok_to_zone = 0; break; } if (tmp == Zone(tmp)) /* Ran into an object zoned to itself */ break; zone_depth--; if (!zone_depth) { ok_to_zone = 0; notify(player, T("Overly deep zone chain broken.")); break; } } if (ok_to_zone) Zone(thing) = Zone(newowner); } clear_flag_internal(thing, "CHOWN_OK"); if (!preserve || !Wizard(player)) { clear_flag_internal(thing, "WIZARD"); clear_flag_internal(thing, "ROYALTY"); clear_flag_internal(thing, "TRUST"); set_flag_internal(thing, "HALT"); destroy_flag_bitmask("POWER", Powers(thing)); Powers(thing) = new_flag_bitmask("POWER"); do_halt(thing, "", thing); } else { if ((newowner != player) && Wizard(thing) && !God(player)) { notify_format(player, T ("Warning: WIZ flag reset on #%d because @CHOWN/PRESERVE is to a third party."), thing); clear_flag_internal(thing, "WIZARD"); } if (!null_flagmask("POWER", Powers(thing)) || Wizard(thing) || Royalty(thing) || Inherit(thing)) notify_format(player, T ("Warning: @CHOWN/PRESERVE on an object (#%d) with WIZ, ROY, INHERIT, or @power privileges."), thing); } }
int blessprops_wildcard(dbref player, dbref thing, const char *dir, const char *wild, int blessp) { char propname[BUFFER_LEN]; char wld[BUFFER_LEN]; char buf[BUFFER_LEN]; char buf2[BUFFER_LEN]; char *ptr, *wldcrd = wld; PropPtr propadr, pptr; int i, cnt = 0; int recurse = 0; #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(thing))) { notify(player,"Only God may touch what is God's."); return 0; } #endif strcpyn(wld, sizeof(wld), wild); i = strlen(wld); if (i && wld[i - 1] == PROPDIR_DELIMITER) strcatn(wld, sizeof(wld), "*"); for (wldcrd = wld; *wldcrd == PROPDIR_DELIMITER; wldcrd++) ; if (!strcmp(wldcrd, "**")) recurse = 1; for (ptr = wldcrd; *ptr && *ptr != PROPDIR_DELIMITER; ptr++) ; if (*ptr) *ptr++ = '\0'; propadr = first_prop(thing, (char *) dir, &pptr, propname, sizeof(propname)); while (propadr) { if (equalstr(wldcrd, propname)) { snprintf(buf, sizeof(buf), "%s%c%s", dir, PROPDIR_DELIMITER, propname); if (!Prop_System(buf) && ((!Prop_Hidden(buf) && !(PropFlags(propadr) & PROP_SYSPERMS)) || Wizard(OWNER(player)))) { if (!*ptr || recurse) { cnt++; if (blessp) { set_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Blessed %s", buf); } else { clear_property_flags(thing, buf, PROP_BLESSED); snprintf(buf2, sizeof(buf2), "Unblessed %s", buf); } notify(player, buf2); } if (recurse) ptr = "**"; cnt += blessprops_wildcard(player, thing, buf, ptr, blessp); } } propadr = next_prop(pptr, propadr, propname, sizeof(propname)); } return cnt; }
void prim_force(PRIM_PROTOTYPE) { struct inst *oper1 = NULL; /* prevents re-entrancy issues! */ struct inst *oper2 = NULL; /* prevents re-entrancy issues! */ int i; /* d s -- */ CHECKOP(2); oper1 = POP(); /* string to @force */ oper2 = POP(); /* player dbref */ if (mlev < 4) abort_interp("Wizbit only primitive."); if (fr->level > 8) abort_interp("Interp call loops not allowed."); if (oper1->type != PROG_STRING) abort_interp("Non-string argument (2)."); if (oper2->type != PROG_OBJECT) abort_interp("Non-object argument (1)."); ref = oper2->data.objref; if (ref < 0 || ref >= db_top) abort_interp("Invalid object to force. (1)"); if (Typeof(ref) != TYPE_PLAYER && Typeof(ref) != TYPE_THING) abort_interp("Object to force not a thing or player. (1)"); if (0 == strcmp(DoNullInd(oper1->data.string), "")) abort_interp("Empty command argument (2)."); if (index(oper1->data.string->data, '\r')) abort_interp("Carriage returns not allowed in command string. (2)."); #ifdef GOD_PRIV if (God(oper2->data.objref) && !God(OWNER(program))) abort_interp("Cannot force god (1)."); #endif force_prog = program; force_level++; process_command(dbref_first_descr(oper2->data.objref), oper2->data.objref, oper1->data.string->data); force_level--; force_prog = NOTHING; for (i = 1; i <= fr->caller.top; i++) { if (Typeof(fr->caller.st[i]) != TYPE_PROGRAM) { #ifdef DEBUG char str[BUFFER_LEN]; snprintf(str,BUFFER_LEN,"[debug] prim_force: fr->caller.st[%d] isn't a program.",i); notify_nolisten(player,str,1); #endif /* DEBUG */ do_abort_silent(); } } CLEAR(oper1); CLEAR(oper2); }
void do_dump(dbref player, const char *newfile) { char buf[BUFFER_LEN]; #ifndef DISKBASE if (global_dumper_pid != 0) { notify(player, "Sorry, there is already a dump currently in progress."); return; } #endif if (*newfile #ifdef GOD_PRIV && God(player) #endif /* GOD_PRIV */ ) { if (dumpfile) free((void *) dumpfile); dumpfile = alloc_string(newfile); snprintf(buf, sizeof(buf), "Dumping to file %s...", dumpfile); } else { snprintf(buf, sizeof(buf), "Dumping..."); } notify(player, buf); dump_db_now(); }
void interp_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix, char *true_text, char *false_text) { char *buf, *bp, *cp; NAMETAB *nt; buf = alloc_lbuf("interp_nametab"); bp = buf; for(cp = prefix; *cp; cp++) *bp++ = *cp; nt = ntab; while (nt->name) { if(God(player) || check_access(player, nt->perm)) { *bp++ = ' '; for(cp = nt->name; *cp; cp++) *bp++ = *cp; *bp++ = '.'; *bp++ = '.'; *bp++ = '.'; if((flagword & nt->flag) != 0) cp = true_text; else cp = false_text; while (*cp) *bp++ = *cp++; if((++nt)->name) *bp++ = ';'; } } *bp = '\0'; notify(player, buf); free_lbuf(buf); }
static bool fh_any(dbref target, dbref player, FLAG flag, int fflags, bool reset) { // Never let God drop his/her own wizbit. // if ( God(target) && reset && flag == WIZARD && fflags == FLAG_WORD1) { notify(player, T("You cannot make God mortal.")); return false; } // Otherwise we can go do it. // if (reset) { db[target].fs.word[fflags] &= ~flag; } else { db[target].fs.word[fflags] |= flag; } return true; }
void display_flagtab(dbref player) { UTF8 *buf, *bp; FLAGNAMEENT *fp; bp = buf = alloc_lbuf("display_flagtab"); safe_str(T("Flags:"), buf, &bp); for (fp = gen_flag_names; fp->flagname; fp++) { FLAGBITENT *fbe = fp->fbe; if ( ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player))) { continue; } safe_chr(' ', buf, &bp); safe_str(fp->flagname, buf, &bp); if (fbe->flaglett != ' ') { safe_chr('(', buf, &bp); if (!fp->bPositive) { safe_chr('!', buf, &bp); } safe_chr(fbe->flaglett, buf, &bp); safe_chr(')', buf, &bp); } } *bp = '\0'; notify(player, buf); free_lbuf(buf); }
void display_nametab(dbref player, NAMETAB * ntab, char *prefix, int list_if_none) { char *buf, *bp, *cp; NAMETAB *nt; int got_one; buf = alloc_lbuf("display_nametab"); bp = buf; got_one = 0; for(cp = prefix; *cp; cp++) *bp++ = *cp; for(nt = ntab; nt->name; nt++) { if(God(player) || check_access(player, nt->perm)) { *bp++ = ' '; for(cp = nt->name; *cp; cp++) *bp++ = *cp; got_one = 1; } } *bp = '\0'; if(got_one || list_if_none) notify(player, buf); free_lbuf(buf); }
int has_power(dbref player, dbref it, char *powername) { POWERENT *fp; POWER fv; fp = find_power(it, powername); if (fp == NULL) { return 0; } if (fp->powerpower & POWER_EXT) { fv = Powers2(it); } else { fv = Powers(it); } if (fv & fp->powervalue) { if ((fp->listperm & CA_WIZARD) && !Wizard(player)) { return 0; } if ((fp->listperm & CA_GOD) && !God(player)) { return 0; } return 1; } return 0; }
static int can_write_lock(dbref player, dbref thing, lock_list *lock) { if (God(player)) return 1; if (God(thing)) return 0; if ((L_FLAGS(lock) & LF_PRIVILEGE) && !Prived(player)) return 0; if (L_FLAGS(lock) & LF_OWNER) return player == Owner(thing); if (L_FLAGS(lock) & LF_LOCKED) return Owner(player) == lock->creator; return 1; }
void listset_nametab(dbref player, NAMETAB * ntab, int flagword, char *prefix, int list_if_none) { char *buf, *bp, *cp; NAMETAB *nt; int got_one; buf = bp = alloc_lbuf("listset_nametab"); for(cp = prefix; *cp; cp++) *bp++ = *cp; nt = ntab; got_one = 0; while (nt->name) { if(((flagword & nt->flag) != 0) && (God(player) || check_access(player, nt->perm))) { *bp++ = ' '; for(cp = nt->name; *cp; cp++) *bp++ = *cp; got_one = 1; } nt++; } *bp = '\0'; if(got_one || list_if_none) notify(player, buf); free_lbuf(buf); }
char *flag_description( dbref player, dbref target ) { char *buff, *bp; FLAGENT *fp; int otype; FLAG fv; /* * Allocate the return buffer */ otype = Typeof( target ); bp = buff = alloc_mbuf( "flag_description" ); /* * Store the header strings and object type */ safe_mb_str( ( char * ) "Type: ", buff, &bp ); safe_mb_str( ( char * ) object_types[otype].name, buff, &bp ); safe_mb_str( ( char * ) " Flags:", buff, &bp ); if( object_types[otype].perm != CA_PUBLIC ) { return buff; } /* * Store the type-invariant flags */ for( fp = gen_flags; fp->flagname; fp++ ) { if( fp->flagflag & FLAG_WORD3 ) { fv = Flags3( target ); } else if( fp->flagflag & FLAG_WORD2 ) { fv = Flags2( target ); } else { fv = Flags( target ); } if( fv & fp->flagvalue ) { if( ( fp->listperm & CA_WIZARD ) && !Wizard( player ) ) { continue; } if( ( fp->listperm & CA_GOD ) && !God( player ) ) { continue; } /* * don't show CONNECT on dark wizards to mortals */ if( isPlayer( target ) && isConnFlag( fp ) && Can_Hide( target ) && Hidden( target ) && !See_Hidden( player ) ) { continue; } safe_mb_chr( ' ', buff, &bp ); safe_mb_str( ( char * ) fp->flagname, buff, &bp ); } } return buff; }
int fh_any( dbref target, dbref player, FLAG flag, int fflags, int reset ) { /* * Never let God drop his own wizbit. */ if( God( target ) && reset && ( flag == WIZARD ) && !( fflags & FLAG_WORD2 ) && !( fflags & FLAG_WORD3 ) ) { notify( player, "You cannot make God mortal." ); return 0; } /* * Otherwise we can go do it. */ if( fflags & FLAG_WORD3 ) { if( reset ) { s_Flags3( target, Flags3( target ) & ~flag ); } else { s_Flags3( target, Flags3( target ) | flag ); } } else if( fflags & FLAG_WORD2 ) { if( reset ) { s_Flags2( target, Flags2( target ) & ~flag ); } else { s_Flags2( target, Flags2( target ) | flag ); } } else { if( reset ) { s_Flags( target, Flags( target ) & ~flag ); } else { s_Flags( target, Flags( target ) | flag ); } } return 1; }
int fh_privileged( dbref target, dbref player, FLAG flag, int fflags, int reset ) { int has_it; if( !God( player ) ) { if( !isPlayer( player ) || ( player != Owner( player ) ) ) { return 0; } if( isPlayer( target ) ) { return 0; } if( fflags & FLAG_WORD3 ) { has_it = ( Flags3( player ) & flag ) ? 1 : 0; } else if( fflags & FLAG_WORD2 ) { has_it = ( Flags2( player ) & flag ) ? 1 : 0; } else { has_it = ( Flags( player ) & flag ) ? 1 : 0; } if( !has_it ) { return 0; } } return ( fh_any( target, player, flag, fflags, reset ) ); }
void do_bless(int descr, dbref player, const char *what, const char *propname) { dbref victim; struct match_data md; char buf[BUFFER_LEN]; int cnt; if (force_level) { notify(player, "Can't @force an @bless."); return; } if (!Wizard(player) || Typeof(player) != TYPE_PLAYER) { notify(player, "Only Wizard players may use this command."); return; } if (!propname || !*propname) { notify(player, "Usage is @bless object=propname."); return; } /* get victim */ init_match(descr, player, what, NOTYPE, &md); match_everything(&md); if ((victim = noisy_match_result(&md)) == NOTHING) { return; } #ifdef GOD_PRIV if(tp_strict_god_priv && !God(player) && God(OWNER(victim))) { notify(player, "Only God may touch God's stuff."); return; } #endif if (!Wizard(OWNER(player))) { notify(player, "Permission denied. (you're not a wizard)"); return; } cnt = blessprops_wildcard(player, victim, "", propname, 1); snprintf(buf, sizeof(buf), "%d propert%s blessed.", cnt, (cnt == 1)? "y" : "ies"); notify(player, buf); }
static bool fh_god(dbref target, dbref player, FLAG flag, int fflags, bool reset) { if (!God(player)) { return false; } return (fh_any(target, player, flag, fflags, reset)); }
int ph_wizroy(dbref target, dbref player, POWER power, int fpowers, int reset) { if (!WizRoy(player) & !God(player)) { return 0; } return (ph_any(target, player, power, fpowers, reset)); }
int ph_restrict_player(dbref target, dbref player, POWER power, int fpowers, int reset) { if (isPlayer(target) && !Wizard(player) && !God(player)) { return 0; } return (ph_any(target, player, power, fpowers, reset)); }
const char * mfn_force(MFUNARGS) { char *nxt, *ptr; dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("FORCE","Failed match. (arg1)"); if (obj == PERMDENIED) ABORT_MPI("FORCE","Permission denied. (arg1)"); if (Typeof(obj) != TYPE_THING && Typeof(obj) != TYPE_PLAYER) ABORT_MPI("FORCE","Bad object reference. (arg1)"); if (!*argv[1]) ABORT_MPI("FORCE","Null command string. (arg2)"); if (!tp_zombies && !Wizperms(perms)) ABORT_MPI("FORCE","Permission Denied."); if (!Wizperms(perms)) { const char *ptr = RNAME(obj); char objname[BUFFER_LEN], *ptr2; dbref loc = getloc(obj); if (Typeof(obj) == TYPE_THING) { if (FLAGS(obj) & DARK) ABORT_MPI("FORCE","Cannot force a dark puppet."); if ((FLAGS(OWNER(obj)) & ZOMBIE)) ABORT_MPI("FORCE","Permission denied."); if (loc != NOTHING && (FLAGS(loc) & ZOMBIE) && Typeof(loc) == TYPE_ROOM) ABORT_MPI("FORCE","Cannot force a Puppet in a no-puppets room."); for (ptr2 = objname; *ptr && !isspace(*ptr);) *(ptr2++) = *(ptr++); *ptr2 = '\0'; if (lookup_player(objname) != NOTHING) ABORT_MPI("FORCE","Cannot force a thing named after a player."); } if (!(FLAGS(obj) & XFORCIBLE)) { ABORT_MPI("FORCE","Permission denied: forced object not @set Xforcible."); } if (!test_lock_false_default(perms, obj, "@/flk")) { ABORT_MPI("FORCE","Permission denied: Object not force-locked to trigger."); } } if (God(obj)) ABORT_MPI("FORCE","Permission denied: You can't force God."); if (force_level) ABORT_MPI("FORCE","Permission denied: You can't force recursively."); strcpy(buf, argv[1]); ptr = buf; do { nxt = index(ptr, '\r'); if (nxt) *nxt++ = '\0'; force_level++; if (*ptr) process_command(obj, ptr); force_level--; ptr = nxt; } while (ptr); *buf = '\0'; return ""; }
static int can_write_lock(dbref player, dbref thing, lock_list *lock) { if (God(player)) return 1; if (God(thing)) return 0; if (Wizard(player)) return 1; if (L_FLAGS(lock) & LF_WIZARD) return 0; if ((L_FLAGS(lock) & LF_OWNER) && player != Owner(thing)) return 0; if ((L_FLAGS(lock) & LF_LOCKED) && player != lock->creator && Owner(player) != lock->creator) return 0; return 1; }
int fh_going_bit( dbref target, dbref player, FLAG flag, int fflags, int reset ) { if( Going( target ) && reset && ( Typeof( target ) != TYPE_GARBAGE ) ) { notify( player, "Your object has been spared from destruction." ); return ( fh_any( target, player, flag, fflags, reset ) ); } if( !God( player ) || !destroyable( target ) ) { return 0; } return ( fh_any( target, player, flag, fflags, reset ) ); }
/** Decide if a host can access someway. * \param hname a host or user+host pattern. * \param flag the access type we're testing. * \param who the player attempting access. * \retval 1 access permitted. * \retval 0 access denied. * \verbatim * Given a hostname and a flag decide if the host can do it. * Here's how it works: * We run the linked list and take the first match. * (If the hostname is user@host, we try to match both user@host * and just host to each line in the file.) * If we make a match, and the line tells us whether the site can/can't * do the action, we're done. * Otherwise, we assume that the host can do any toggleable option * (can create, connect, guest), and don't have any special * flags (can't register, isn't suspect) * \endverbatim */ bool site_can_access(const char *hname, uint32_t flag, dbref who) { struct access *ap; acsflag *c; const char *p; if (!hname || !*hname) return 0; if ((p = strchr(hname, '@'))) p++; for (ap = access_top; ap; ap = ap->next) { if (ap->can & ACS_SITELOCK) continue; if ((ap->can & ACS_REGEXP) ? (qcomp_regexp_match(ap->re, hname) || (p && qcomp_regexp_match(ap->re, p))) : (quick_wild(ap->host, hname) || (p && quick_wild(ap->host, p))) && (ap->who == AMBIGUOUS || ap->who == who)) { /* Got one */ if (flag & ACS_CONNECT) { if ((ap->cant & ACS_GOD) && God(who)) /* God can't connect from here */ return 0; else if ((ap->cant & ACS_WIZARD) && Wizard(who)) /* Wiz can't connect from here */ return 0; else if ((ap->cant & ACS_ADMIN) && Hasprivs(who)) /* Wiz and roy can't connect from here */ return 0; } if (ap->cant && ((ap->cant & flag) == flag)) return 0; if (ap->can && (ap->can & flag)) return 1; /* Hmm. We don't know if we can or not, so continue */ break; } } /* Flag was neither set nor unset. If the flag was a toggle, * then the host can do it. If not, the host can't */ for (c = acslist; c->name; c++) { if (flag & c->flag) return c->toggle ? 1 : 0; } /* Should never reach here, but just in case */ return 1; }
/** Can a player control a thing? * The control rules are, in order: * Only God controls God. * Wizards control everything else. * Nothing else controls a wizard, and only royalty control royalty. * Mistrusted objects control only themselves. * Objects with the same owner control each other, unless the * target object is TRUST and the would-be controller isn't. * If ZMOs allow control, and you pass the ZMO, you control. * If the owner is a Zone Master, and you pass the ZM, you control. * If you pass the control lock, you control. * Otherwise, no dice. * \param who object attempting to control. * \param what object to be controlled. * \retval 1 who controls what. * \retval 0 who doesn't control what. */ int controls(dbref who, dbref what) { boolexp c; if (!GoodObject(what)) return 0; if (Guest(who)) return 0; if (what == who) return 1; if (God(what)) return 0; if (Wizard(who)) return 1; if (Wizard(what) || (Hasprivs(what) && !Hasprivs(who))) return 0; if (Mistrust(who)) return 0; if (Owns(who, what) && (!Inheritable(what) || Inheritable(who))) return 1; if (Inheritable(what) || IsPlayer(what)) return 0; if (!ZONE_CONTROL_ZMP && (Zone(what) != NOTHING) && eval_lock(who, Zone(what), Zone_Lock)) return 1; if (ZMaster(Owner(what)) && !IsPlayer(what) && eval_lock(who, Owner(what), Zone_Lock)) return 1; c = getlock_noparent(what, Control_Lock); if (c != TRUE_BOOLEXP) { if (eval_boolexp(who, c, what, NULL)) return 1; } return 0; }
int has_flag( dbref player, dbref it, char *flagname ) { FLAGENT *fp; FLAG fv; fp = find_flag( it, flagname ); if( fp == NULL ) { /* find_flag() uppercases the string */ if( !strcmp( flagname, "PLAYER" ) ) { return isPlayer( it ); } if( !strcmp( flagname, "THING" ) ) { return isThing( it ); } if( !strcmp( flagname, "ROOM" ) ) { return isRoom( it ); } if( !strcmp( flagname, "EXIT" ) ) { return isExit( it ); } return 0; } if( fp->flagflag & FLAG_WORD3 ) { fv = Flags3( it ); } else if( fp->flagflag & FLAG_WORD2 ) { fv = Flags2( it ); } else { fv = Flags( it ); } if( fv & fp->flagvalue ) { if( ( fp->listperm & CA_WIZARD ) && !Wizard( player ) ) { return 0; } if( ( fp->listperm & CA_GOD ) && !God( player ) ) { return 0; } /* * don't show CONNECT on dark wizards to mortals */ if( isPlayer( it ) && isConnFlag( fp ) && Can_Hide( it ) && Hidden( it ) && !See_Hidden( player ) ) { return 0; } return 1; } return 0; }
char *power_description(dbref player, dbref target) { char *buff, *bp; POWERENT *fp; int otype; POWER fv; /* * Allocate the return buffer */ otype = Typeof(target); bp = buff = alloc_mbuf("power_description"); /* * Store the header strings and object type */ safe_mb_str((char *) "Powers:", buff, &bp); for (fp = gen_powers; fp->powername; fp++) { if (fp->powerpower & POWER_EXT) { fv = Powers2(target); } else { fv = Powers(target); } if (fv & fp->powervalue) { if ((fp->listperm & CA_WIZARD) && !Wizard(player)) { continue; } if ((fp->listperm & CA_GOD) && !God(player)) { continue; } safe_mb_chr(' ', buff, &bp); safe_mb_str((char *) fp->powername, buff, &bp); } } /* * Terminate the string, and return the buffer to the caller */ *bp = '\0'; return buff; }
int ph_privileged(dbref target, dbref player, POWER power, int fpowers, int reset) { if (!God(player)) { if (!isPlayer(player) || (player != Owner(player))) { return 0; } if (isPlayer(target)) { return 0; } if (Powers(player) & power) { return (ph_any(target, player, power, fpowers, reset)); } else { return 0; } } return (ph_any(target, player, power, fpowers, reset)); }
char *decode_flags( dbref player, FLAGSET flagset ) { char *buf, *bp, *s; FLAGENT *fp; int flagtype; FLAG fv; buf = bp = s = alloc_sbuf( "decode_flags" ); *bp = '\0'; flagtype = ( flagset.word1 & TYPE_MASK ); if( object_types[flagtype].lett != ' ' ) { safe_sb_chr( object_types[flagtype].lett, buf, &bp ); } for( fp = gen_flags; fp->flagname; fp++ ) { if( fp->flagflag & FLAG_WORD3 ) { fv = flagset.word3; } else if( fp->flagflag & FLAG_WORD2 ) { fv = flagset.word2; } else { fv = flagset.word1; } if( fv & fp->flagvalue ) { if( ( fp->listperm & CA_WIZARD ) && !Wizard( player ) ) { continue; } if( ( fp->listperm & CA_GOD ) && !God( player ) ) { continue; } safe_sb_chr( fp->flaglett, buf, &bp ); } } *bp = '\0'; return buf; }
bool has_flag(dbref player, dbref it, const UTF8 *flagname) { FLAGNAMEENT *fp = find_flag(flagname); if (!fp) { return false; } FLAGBITENT *fbe = fp->fbe; if ( ( fp->bPositive && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue)) || ( !fp->bPositive && (db[it].fs.word[fbe->flagflag] & fbe->flagvalue) == 0)) { if ( ( (fbe->listperm & CA_STAFF) && !Staff(player)) || ( (fbe->listperm & CA_ADMIN) && !WizRoy(player)) || ( (fbe->listperm & CA_WIZARD) && !Wizard(player)) || ( (fbe->listperm & CA_GOD) && !God(player))) { return false; } // Don't show CONNECT on dark wizards to mortals // if ( isPlayer(it) && (fbe->flagvalue == CONNECTED) && (fbe->flagflag == FLAG_WORD2) && Hidden(it) && !See_Hidden(player)) { return false; } return true; } return false; }