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; }
void CHSInterface::UnsetToggle(int objnum, int flag) #endif { #ifdef PENNMUSH clear_flag_internal(objnum, flag); #endif #ifdef TM3 s_Flags3(objnum, Flags3(objnum) & ~flag); #endif #ifdef MUX s_Flags(objnum, FLAG_WORD3, Flags3(objnum) & ~flag); #endif }
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 ); } }
void CHSInterface::SetFlag(HS_DBREF dbObject, HS_INT32 iFlag, HS_BOOL8 bAbsolute) { if (bAbsolute) { s_Flags(dbObject, FLAG_WORD3, iFlag); } else { s_Flags(dbObject, FLAG_WORD3, Flags3(dbObject) |= iFlag); } }
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; }
HS_BOOL8 CHSInterface::HasFlag(HS_DBREF objnum, int type, int flag) #endif { #ifdef PENNMUSH return (has_flag_by_name(objnum, flag, type) == 0 ? false : true); #endif #if defined(TM3) || defined(MUX) // Using only Flags3 is sufficient as HSpace does not look at // other flags for TM3. Thus the first two can be skipped. if (Typeof(objnum) != type) return false; //if (Flags(objnum) & flag) // return true; //if (Flags2(objnum) & flag) // return true; if (Flags3(objnum) & flag) return true; return false; #endif }
// 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; }
static void give_thing (dbref giver, dbref recipient, int key, char *what) { dbref thing, loc; char *str, *sp; init_match(giver, what, TYPE_THING); match_possession(); match_me(); thing = match_result(); switch (thing) { case NOTHING: notify(giver, "You don't have that!"); return; case AMBIGUOUS: notify(giver, "I don't know which you mean!"); return; } if (thing == giver) { notify(giver, "You can't give yourself away!"); return; } if (((Typeof(thing) != TYPE_THING) && (Typeof(thing) != TYPE_PLAYER)) || !(Enter_ok(recipient) || controls(giver, recipient))) { notify(giver, "Permission denied."); return; } if ((Flags3(thing) & NOMOVE) && !Wizard(giver)) { notify(giver, "Permission denied."); return; } if (!could_doit(giver, thing, A_LGIVE,1)) { sp = str = alloc_lbuf("do_give.gfail"); safe_str((char *)"You can't give ", str, &sp); safe_str(Name(thing), str, &sp); safe_str((char *)" away.", str, &sp); *sp = '\0'; did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL, A_AGFAIL, (char **)NULL, 0); free_lbuf(str); return; } if (!could_doit(thing, recipient, A_LRECEIVE,1)) { sp = str = alloc_lbuf("do_give.rfail"); safe_str(Name(recipient), str, &sp); safe_str((char *)" doesn't want ", str, &sp); safe_str(Name(thing), str, &sp); safe_chr('.', str, &sp); *sp = '\0'; did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL, A_ARFAIL, (char **)NULL, 0); free_lbuf(str); return; } loc = Location(giver); if ( !Good_obj(loc) || loc == NOTHING || loc == AMBIGUOUS || Recover(loc) || Going(loc) ) loc = giver; if (!could_doit(giver, loc, A_LGIVETO, 1)) { sp = str = alloc_lbuf("do_giveto.rfail"); safe_str((char *)"You can not give ", str, &sp); safe_str(Name(thing), str, &sp); safe_str((char *)" away at this location.", str, &sp); *sp = '\0'; notify(giver, str); free_lbuf(str); return; } move_via_generic(thing, recipient, giver, 0); divest_object(thing); if (!(key & GIVE_QUIET)) { str = alloc_lbuf("do_give.thing.ok"); strcpy(str, Name(giver)); notify_with_cause(recipient, giver, unsafe_tprintf("%s gave you %s.", str, Name(thing))); notify(giver, "Given."); notify_with_cause(thing, giver, unsafe_tprintf("%s gave you to %s.", str, Name(recipient))); free_lbuf(str); } else { notify(giver, "Given. (quiet)"); } did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP, (char **)NULL, 0); did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC, (char **)NULL, 0); }
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; }