/** Check warnings on a specific object. * We check for ownership or hasprivs before allowing this. * \param player the enactor. * \param name name of object to check. */ void do_wcheck(dbref player, const char *name) { dbref thing; switch (thing = match_result(player, name, NOTYPE, MAT_EVERYTHING)) { case NOTHING: notify(player, T("I don't see that object.")); return; case AMBIGUOUS: notify(player, T("I don't know which one you mean.")); return; default: if (!(CanSee(player, thing) || (Owner(player) == Owner(thing)))) { notify(player, T("Permission denied.")); return; } if (IsGarbage(thing)) { notify(player, T("Why would you want to be warned about garbage?")); return; } break; } check_topology_on(player, thing); notify(player, T("@wcheck complete.")); return; }
/** Set/lock a lock (user interface). * \verbatim * This implements @lock. * \endverbatim * \param player the enactor. * \param name name of object to lock. * \param keyname key to lock the lock to, as a string. * \param type type of lock to lock. */ void do_lock(dbref player, const char *name, const char *keyname, lock_type type) { lock_type real_type; dbref thing; boolexp key; /* check for '@lock <object>/<atr>' */ if (strchr(name, '/')) { do_atrlock(player, name, "on"); return; } if (!keyname || !*keyname) { do_unlock(player, name, type); return; } switch (thing = match_result(player, name, NOTYPE, MAT_EVERYTHING)) { case NOTHING: notify(player, T("I don't see what you want to lock!")); return; case AMBIGUOUS: notify(player, T("I don't know which one you want to lock!")); return; default: if (!controls(player, thing)) { notify(player, T("You can't lock that!")); return; } if (IsGarbage(thing)) { notify(player, T("Why would you want to lock garbage?")); return; } break; } key = parse_boolexp(player, keyname, type); /* do the lock */ if (key == TRUE_BOOLEXP) { notify(player, T("I don't understand that key.")); } else { if ((real_type = check_lock_type(player, thing, type)) != NULL) { /* everything ok, do it */ if (add_lock(player, thing, real_type, key, LF_DEFAULT)) { if (!AreQuiet(player, thing)) notify_format(player, T("%s(%s) - %s locked."), AName(thing, AN_SYS, NULL), unparse_dbref(thing), real_type); if (!IsPlayer(thing)) ModTime(thing) = mudtime; } else { notify(player, T("Permission denied.")); /* Done by a failed add_lock() // free_boolexp(key); */ } } else free_boolexp(key); } }
/** Loop through all objects and check their topology. */ void run_topology(void) { int ndone; for (ndone = 0; ndone < db_top; ndone++) { if (!IsGarbage(ndone) && Connected(Owner(ndone)) && !NoWarn(Owner(ndone))) { check_topology_on(Owner(ndone), ndone); } } }
/** Check warnings on a specific player by themselves. * \param player player checking warnings on their objects. */ void do_wcheck_me(dbref player) { int ndone; if (!Connected(player)) return; for (ndone = 0; ndone < db_top; ndone++) { if ((Owner(ndone) == player) && !IsGarbage(ndone)) check_topology_on(player, ndone); } notify(player, T("@wcheck complete.")); return; }
static int chown_ok(dbref player, dbref thing, dbref newowner, NEW_PE_INFO *pe_info) { /* Can't touch garbage */ if (IsGarbage(thing)) return 0; /* Wizards can do it all */ if (Wizard(player)) return 1; /* In order for non-wiz player to @chown thing to newowner, * player must control newowner or newowner must be a Zone Master * and player must pass its zone lock. * * In addition, one of the following must apply: * 1. player owns thing, or * 2. player controls Owner(thing), newowner is a zone master, * and Owner(thing) passes newowner's zone-lock, or * 3. thing is CHOWN_OK, and player holds thing if it's an object. * * The third condition is syntactic sugar to handle the situation * where Joe owns Box, an ordinary object, and Tool, an inherit object, * and ZMP, a Zone Master Player, is zone-locked to =tool. * In this case, if Joe doesn't pass ZMP's lock, we don't want * Joe to be able to @fo Tool=@chown Box=ZMP */ /* Does player control newowner, or is newowner a Zone Master and player * passes the lock? */ if (!(controls(player, newowner) || (ZMaster(newowner) && eval_lock_with(player, newowner, Zone_Lock, pe_info)))) return 0; /* Target player is legitimate. Does player control the object? */ if (Owns(player, thing)) return 1; if (controls(player, Owner(thing)) && ZMaster(newowner) && eval_lock_with(Owner(thing), newowner, Zone_Lock, pe_info)) return 1; if ((!IsThing(thing) || (Location(thing) == player)) && ChownOk(thing) && eval_lock_with(player, thing, Chown_Lock, pe_info)) return 1; return 0; }
void Bullet::FlyThreadProc() { static const unsigned int flyDistance = 20; static const int delta = 1; static const unsigned int timeout = 30; for( unsigned int i = 0; i < flyDistance; ++i ) { Move( delta, direction_ ); Sleep(100); } IsGarbage(true); }
// Checks to see if the specified object exists, isn't garbage, // etc. HS_BOOL8 CHSInterface::ValidObject(HS_DBREF objnum) { #ifdef PENNMUSH // No change in code between versions if (GoodObject(objnum) && !IsGarbage(objnum)) return true; else return false; #endif #if defined(TM3) || defined(MUX) if (Good_obj(objnum) && !isGarbage(objnum)) return true; else return false; #endif }
/** Set warnings on an object. * \verbatim * This implements @warnings obj=warning list * \endverbatim * \param player the enactor. * \param name name of object to set warnings on. * \param warns list of warnings to set, space-separated. */ void do_warnings(dbref player, const char *name, const char *warns) { dbref thing; warn_type w, old; switch (thing = match_result(player, name, NOTYPE, MAT_EVERYTHING)) { case NOTHING: notify(player, T("I don't see that object.")); return; case AMBIGUOUS: notify(player, T("I don't know which one you mean.")); return; default: if (!controls(player, thing)) { notify(player, T("Permission denied.")); return; } if (IsGarbage(thing)) { notify(player, T("Why would you want to be warned about garbage?")); return; } break; } old = Warnings(thing); w = parse_warnings(player, warns); if (w != old) { Warnings(thing) = w; if (Warnings(thing)) notify_format(player, T("@warnings set to: %s"), unparse_warnings(Warnings(thing))); else notify(player, T("@warnings cleared.")); } else { notify(player, T("@warnings not changed.")); } }
/** Clone an object. * \verbatim * This is the top-level function for @clone, which creates a duplicate * of a (non-player) object. * \endverbatim * \param player the enactor. * \param name the name of the object to clone. * \param newname the name to give the duplicate. * \param preserve if 1, preserve ownership and privileges on duplicate. * \paran newdbref the (unparsed) dbref to give the object, or NULL to use the next free * \return dbref of the duplicate, or NOTHING. */ dbref do_clone(dbref player, char *name, char *newname, int preserve, char *newdbref) { dbref clone, thing; char dbnum[BUFFER_LEN]; thing = noisy_match_result(player, name, NOTYPE, MAT_EVERYTHING); if ((thing == NOTHING)) return NOTHING; if (newname && *newname && !ok_name(newname, IsExit(thing))) { notify(player, T("That is not a reasonable name.")); return NOTHING; } if (!controls(player, thing) || IsPlayer(thing) || (IsRoom(thing) && !command_check_byname(player, "@dig")) || (IsExit(thing) && !command_check_byname(player, "@open")) || (IsThing(thing) && !command_check_byname(player, "@create"))) { notify(player, T("Permission denied.")); return NOTHING; } /* don't allow cloning of destructed things */ if (IsGarbage(thing)) { notify(player, T("There's nothing left of it to clone!")); return NOTHING; } if (preserve && !Wizard(player)) { notify(player, T("You cannot @CLONE/PRESERVE. Use normal @CLONE instead.")); return NOTHING; } if (!make_first_free_wrapper(player, newdbref)) { return NOTHING; } /* make sure owner can afford it */ switch (Typeof(thing)) { case TYPE_THING: if (can_pay_fees(player, Pennies(thing))) { clone = clone_object(player, thing, newname, preserve); notify_format(player, T("Cloned: Object %s."), unparse_dbref(clone)); if (IsRoom(player)) moveto(clone, player, player, "cloned"); else moveto(clone, Location(player), player, "cloned"); current_state.things++; local_data_clone(clone, thing); real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; } return NOTHING; break; case TYPE_ROOM: if (can_pay_fees(player, ROOM_COST)) { clone = clone_object(player, thing, newname, preserve); Exits(clone) = NOTHING; notify_format(player, T("Cloned: Room #%d."), clone); current_state.rooms++; local_data_clone(clone, thing); real_did_it(player, clone, NULL, NULL, NULL, NULL, "ACLONE", NOTHING, global_eval_context.wenv, 0); return clone; } return NOTHING; break; case TYPE_EXIT: /* For exits, we don't want people to be able to link it to a location they can't with @open. So, all this stuff. */ switch (Location(thing)) { case NOTHING: strcpy(dbnum, "#-1"); break; case HOME: strcpy(dbnum, "home"); break; case AMBIGUOUS: strcpy(dbnum, "variable"); break; default: strcpy(dbnum, unparse_dbref(Location(thing))); } if (newname && *newname) clone = do_real_open(player, newname, dbnum, NOTHING); else clone = do_real_open(player, Name(thing), dbnum, NOTHING); if (!GoodObject(clone)) { return NOTHING; } else { atr_cpy(clone, thing); clone_locks(player, thing, clone); Zone(clone) = Zone(thing); Parent(clone) = Parent(thing); Flags(clone) = clone_flag_bitmask("FLAG", Flags(thing)); if (!preserve) { clear_flag_internal(clone, "WIZARD"); clear_flag_internal(clone, "ROYALTY"); Warnings(clone) = 0; /* zap warnings */ Powers(clone) = new_flag_bitmask("POWER"); /* zap powers */ } else { Warnings(clone) = Warnings(thing); Powers(clone) = clone_flag_bitmask("POWER", Powers(thing)); } if (Wizard(clone) || Royalty(clone) || Warnings(clone) || !null_flagmask("POWER", Powers(clone))) notify(player, T ("Warning: @CLONE/PRESERVE on an object with WIZ, ROY, @powers, or @warnings.")); notify_format(player, T("Cloned: Exit #%d."), clone); local_data_clone(clone, thing); return clone; } } return NOTHING; }
/** Set/lock a lock (user interface). * \verbatim * This implements @lock. * \endverbatim * \param player the enactor. * \param name name of object to lock. * \param keyname key to lock the lock to, as a string. * \param type type of lock to lock. */ void do_lock(dbref player, const char *name, const char *keyname, lock_type type) { lock_type real_type; dbref thing; boolexp key; char *sp; /* check for '@lock <object>/<atr>' */ sp = strchr(name, '/'); if (sp) { do_atrlock(player, name, keyname, 0); return; } if (!keyname || !*keyname) { do_unlock(player, name, type); return; } switch (thing = match_result(player, name, NOTYPE, MAT_EVERYTHING)) { case NOTHING: notify(player, T("I don't see what you want to lock!")); return; case AMBIGUOUS: notify(player, T("I don't know which one you want to lock!")); return; default: if (!controls(player, thing)) { notify(player, T("You can't lock that!")); return; } if (IsGarbage(thing)) { notify(player, T("Why would you want to lock garbage?")); return; } break; } key = parse_boolexp(player, keyname, type); /* do the lock */ if (key == TRUE_BOOLEXP) { notify(player, T("I don't understand that key.")); } else { if ((real_type = check_lock_type(player, thing, type)) != NULL) { /* everything ok, do it */ if (add_lock(player, thing, real_type, key, -1)) { if (!AreQuiet(player, thing)) notify_format(player, T("%s(%s) - %s locked."), Name(thing), unparse_dbref(thing), real_type); if (!IsPlayer(thing)) { char lmbuf[1024]; ModTime(thing) = mudtime; snprintf(lmbuf, 1023, "%s lock[#%d]", real_type, player); lmbuf[strlen(lmbuf)+1] = '\0'; set_lmod(thing, lmbuf); } } else { notify(player, T("Permission denied.")); free_boolexp(key); } } else free_boolexp(key); } }