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; }
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_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 decompile_flags( dbref player, dbref thing, char *thingname ) { FLAG f1, f2, f3; FLAGENT *fp; /* * Report generic flags */ f1 = Flags( thing ); f2 = Flags2( thing ); f3 = Flags3( thing ); for( fp = gen_flags; fp->flagname; fp++ ) { /* * Skip if we shouldn't decompile this flag */ if( fp->listperm & CA_NO_DECOMP ) { continue; } /* * Skip if this flag is not set */ if( fp->flagflag & FLAG_WORD3 ) { if( !( f3 & fp->flagvalue ) ) { continue; } } else if( fp->flagflag & FLAG_WORD2 ) { if( !( f2 & fp->flagvalue ) ) { continue; } } else { if( !( f1 & fp->flagvalue ) ) { continue; } } /* * Skip if we can't see this flag */ if( !check_access( player, fp->listperm ) ) { continue; } /* * We made it this far, report this flag */ notify_check( player, player, MSG_PUP_ALWAYS|MSG_ME_ALL|MSG_F_DOWN, "@set %s=%s", strip_ansi( thingname ), fp->flagname ); } }
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 *unparse_object( dbref player, dbref target, int obey_myopic ) { char *buf, *fp, *bp; int exam; buf = alloc_lbuf( "unparse_object" ); if( target == NOTHING ) { strcpy( buf, "*NOTHING*" ); } else if( target == HOME ) { strcpy( buf, "*HOME*" ); } else if( target == AMBIGUOUS ) { strcpy( buf, "*VARIABLE*" ); } else if( isGarbage( target ) ) { fp = unparse_flags( player, target ); bp = buf; safe_sprintf( buf, &bp, "*GARBAGE*(#%d%s)", target, fp ); free_sbuf( fp ); } else if( !Good_obj( target ) ) { sprintf( buf, "*ILLEGAL*(#%d)", target ); } else { if( obey_myopic ) { exam = MyopicExam( player, target ); } else { exam = Examinable( player, target ); } if( exam || ( Flags( target ) & ( CHOWN_OK | JUMP_OK | LINK_OK | DESTROY_OK ) ) || ( Flags2( target ) & ABODE ) ) { /* * show everything */ fp = unparse_flags( player, target ); bp = buf; safe_sprintf( buf, &bp, "%s(#%d%s)", Name( target ), target, fp ); free_sbuf( fp ); } else { /* * show only the name. */ strcpy( buf, Name( target ) ); } } return buf; }
// Clones an object and returns the HS_DBREF of the new clone. HS_DBREF CHSInterface::CloneThing(HS_DBREF model) { HS_DBREF clone; #ifdef PENNMUSH // No change in code between versions clone = new_object(); // Copy the basic information from the model to the clone. memcpy(REFDB(clone), REFDB(model), sizeof(struct object)); Owner(clone) = Owner(model); Name(clone) = NULL; // NULL-out some memory pointers we didn't really want copied. db[clone].list = NULL; // Now copy the pointer information. atr_cpy(clone, model); Locks(clone) = NULL; clone_locks(model, model, clone); Zone(clone) = Zone(model); Parent(clone) = Parent(model); Flags(clone) = clone_flag_bitmask("FLAG", Flags(model)); set_name(clone, Name(model)); s_Pennies(clone, Pennies(model)); #ifdef CREATION_TIMES /* * We give the clone the same modification time that its * other clone has, but update the creation time */ db[clone].creation_time = time((time_t *) 0); #endif db[clone].contents = db[clone].location = db[clone].next = NOTHING; #endif #if defined(TM3) || defined(MUX) clone = create_obj(Owner(model), Typeof(model), Name(model), Pennies(model)); //atr_free(clone); s_Name(clone, Name(model)); s_Pennies(clone, Pennies(model)); s_Parent(clone, Parent(model)); #ifdef TM3 atr_cpy(Owner(clone), clone, model); s_Flags(clone, Flags(model)); s_Flags2(clone, Flags2(model)); s_Flags3(clone, Flags3(model)); #endif #ifdef MUX atr_cpy(clone, model); s_Flags(clone, FLAG_WORD1, Flags(model)); s_Flags(clone, FLAG_WORD2, Flags2(model)); s_Flags(clone, FLAG_WORD3, Flags3(model)); s_Home(clone, Home(model)); #endif #endif return clone; }
static int db_write_object(FILE * f, dbref i, int db_format, int flags) { ATTR *a; char *got, *as; dbref aowner; int ca, aflags, save, j; BOOLEXP *tempbool; if(!(flags & V_ATRNAME)) putstring(f, Name(i)); putref(f, Location(i)); if(flags & V_ZONE) putref(f, Zone(i)); putref(f, Contents(i)); putref(f, Exits(i)); if(flags & V_LINK) putref(f, Link(i)); putref(f, Next(i)); if(!(flags & V_ATRKEY)) { got = atr_get(i, A_LOCK, &aowner, &aflags); tempbool = parse_boolexp(GOD, got, 1); free_lbuf(got); putboolexp(f, tempbool); if(tempbool) free_bool(tempbool); } putref(f, Owner(i)); if(flags & V_PARENT) putref(f, Parent(i)); if(!(flags & V_ATRMONEY)) putref(f, Pennies(i)); putref(f, Flags(i)); if(flags & V_XFLAGS) putref(f, Flags2(i)); if(flags & V_3FLAGS) putref(f, Flags3(i)); if(flags & V_POWERS) { putref(f, Powers(i)); putref(f, Powers2(i)); } /* * write the attribute list */ if((!(flags & V_GDBM)) || (mudstate.panicking == 1)) { for(ca = atr_head(i, &as); ca; ca = atr_next(&as)) { save = 0; a = atr_num(ca); if(a) j = a->number; else j = -1; if(j > 0) { switch (j) { case A_NAME: if(flags & V_ATRNAME) save = 1; break; case A_LOCK: if(flags & V_ATRKEY) save = 1; break; case A_LIST: case A_MONEY: break; default: save = 1; } } if(save) { got = atr_get_raw(i, j); fprintf(f, ">%d\n", j); putstring(f, got); } } fprintf(f, "<\n"); } return 0; }
/* * --------------------------------------------------------------------------- * * Return an lbuf pointing to the object name and possibly the db# and flags */ UTF8 *unparse_object(dbref player, dbref target, bool obey_myopic, bool bAddColor) { UTF8 *buf = alloc_lbuf("unparse_object"); if (NOPERM <= target && target < 0) { mux_strncpy(buf, aszSpecialDBRefNames[-target], LBUF_SIZE-1); } else if (!Good_obj(target)) { mux_sprintf(buf, LBUF_SIZE, T("*ILLEGAL*(#%d)"), target); } else { bool exam; if (obey_myopic) { exam = MyopicExam(player, target); } else { exam = Examinable(player, target); } // Leave and extra 100 bytes for the dbref and flags at the end and // color at the beginning if necessary.. // mux_field fldName = StripTabsAndTruncate( Moniker(target), buf, LBUF_SIZE-100, LBUF_SIZE-100); UTF8 *bp = buf + fldName.m_byte; #if defined(FIRANMUX) if ( fldName.m_column == fldName.m_byte && bAddColor) { // There is no color in the name, so look for @color, or highlight. // UTF8 *buf2 = alloc_lbuf("unparse_object.color"); UTF8 *bp2 = buf2; UTF8 *pLetters = AcquireColorLetters(player, target); if (NULL != pLetters) { safe_str(LettersToBinary(pLetters), buf2, &bp2); free_lbuf(pLetters); pLetters = NULL; } else { safe_str((UTF8 *)COLOR_INTENSE, buf2, &bp2); } *bp = '\0'; safe_str(buf, buf2, &bp2); safe_str((UTF8 *)COLOR_RESET, buf2, &bp2); // Swap buffers. // free_lbuf(buf); buf = buf2; bp = bp2; } #else UNUSED_PARAMETER(bAddColor); #endif // FIRANMUX if ( exam || (Flags(target) & (CHOWN_OK | JUMP_OK | LINK_OK | DESTROY_OK)) || (Flags2(target) & ABODE)) { // Show everything. // UTF8 *fp = decode_flags(player, &(db[target].fs)); safe_str(T("(#"), buf, &bp); safe_ltoa(target, buf, &bp); safe_str(fp, buf, &bp); safe_chr(')', buf, &bp); free_sbuf(fp); } *bp = '\0'; } return buf; }
char *unparse_flags( dbref player, dbref thing ) { char *buf, *bp, *s; FLAGENT *fp; int flagtype; FLAG fv, flagword, flag2word, flag3word; buf = bp = s = alloc_sbuf( "unparse_flags" ); *bp = '\0'; if( !Good_obj( player ) || !Good_obj( thing ) ) { strcpy( buf, "#-2 ERROR" ); return buf; } flagword = Flags( thing ); flag2word = Flags2( thing ); flag3word = Flags3( thing ); flagtype = ( flagword & 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 = flag3word; } else if( fp->flagflag & FLAG_WORD2 ) { fv = flag2word; } else { fv = flagword; } 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( ( flagtype == TYPE_PLAYER ) && isConnFlag( fp ) && Can_Hide( thing ) && Hidden( thing ) && !See_Hidden( player ) ) { continue; } /* * Check if this is a marker flag and we're at the * beginning of a buffer. If so, we need to insert a * separator character first so we don't end up * running the dbref number into the flags. */ if( ( s == bp ) && isMarkerFlag( fp ) ) { safe_sb_chr( MARK_FLAG_SEP, buf, &bp ); } safe_sb_chr( fp->flaglett, buf, &bp ); } } *bp = '\0'; return buf; }