예제 #1
0
파일: mfuns2.c 프로젝트: GlowMUCK/GlowMUCK
const char *
mfn_testlock(MFUNARGS)
{
    struct boolexp *lok;
    dbref who = player;
    dbref obj = mesg_dbref_local(player, what, perms, argv[0]);

    if (argc > 2)
	who = mesg_dbref_local(player, what, perms, argv[2]);
    if (who == AMBIGUOUS || who == UNKNOWN || who == NOTHING || who == HOME)
	ABORT_MPI("TESTLOCK","Match failed. (1)");
    if (who == PERMDENIED)
	ABORT_MPI("TESTLOCK","Permission denied. (1)");
    if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME)
	ABORT_MPI("TESTLOCK","Match failed. (2)");
    if (obj == PERMDENIED)
	ABORT_MPI("TESTLOCK","Permission denied. (2)");
    lok = get_property_lock(obj, argv[1]);
    if (argc > 3 && lok == TRUE_BOOLEXP)
	return (argv[3]);
    if (eval_boolexp(who, lok, obj)) {
	return "1";
    } else {
	return "0";
    }
}
예제 #2
0
파일: p_misc.c 프로젝트: foxbird/fuzzball
void
prim_testlock(PRIM_PROTOTYPE)
{
    struct inst *oper1 = NULL;	/* prevents re-entrancy issues! */
    struct inst *oper2 = NULL;	/* prevents re-entrancy issues! */


    /* d d - i */
    CHECKOP(2);
    oper1 = POP();		/* boolexp lock */
    oper2 = POP();		/* player dbref */
    if (fr->level > 8)
	abort_interp("Interp call loops not allowed.");
    if (!valid_object(oper2))
	abort_interp("Invalid argument (1).");
    if (Typeof(oper2->data.objref) != TYPE_PLAYER && Typeof(oper2->data.objref) != TYPE_THING) {
	abort_interp("Invalid object type (1).");
    }
    CHECKREMOTE(oper2->data.objref);
    if (oper1->type != PROG_LOCK)
	abort_interp("Invalid argument (2).");
    result = eval_boolexp(fr->descr, oper2->data.objref, oper1->data.lock,
			  tp_consistent_lock_source ? fr->trig : player);
    CLEAR(oper1);
    CLEAR(oper2);
    PushInt(result);
}
예제 #3
0
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player, passing dbrefs for %0/%1.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock_with(dbref player, dbref thing, lock_type ltype, dbref env0,
	       dbref env1)
{
  char *myenv[10] = { NULL };
  char e0[SBUF_LEN], e1[SBUF_LEN], *ep;
  char *preserves[10];
  int result;

  if (env0 != NOTHING) {
    ep = e0;
    safe_dbref(env0, e0, &ep);
    *ep = '\0';
    myenv[0] = e0;
  }

  if (env1 != NOTHING) {
    ep = e1;
    safe_dbref(env1, e1, &ep);
    *ep = '\0';
    myenv[1] = e1;
  }

  save_global_env("eval_lock_save", preserves);
  restore_global_env("eval_lock", myenv);

  boolexp b = getlock(thing, ltype);
  log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  result = eval_boolexp(player, b, thing, NULL);
  restore_global_env("eval_lock_save", preserves);
  return result;
}
예제 #4
0
/*
 * could_doit: Checks to see if player could actually do what is proposing
 * to be done: if thing is an exit, this checks to see if the exit will
 * perform a move that is allowed. Then, it checks the @lock on the thing,
 * whether it's an exit or not.
 */
int
could_doit(int descr, dbref player, dbref thing)
{
	dbref source, dest, owner;

	if (Typeof(thing) == TYPE_EXIT) {
			/* If exit is unlinked, can't do it. */
		if (DBFETCH(thing)->sp.exit.ndest == 0) {
			return 0;
		}

		owner = OWNER(thing);
		source = DBFETCH(player)->location;
		dest = *(DBFETCH(thing)->sp.exit.dest);

		if (Typeof(dest) == TYPE_PLAYER) {
			/* Check for additional restrictions related to player dests */
			dbref destplayer = dest;

			dest = DBFETCH(dest)->location;
			/* If the dest player isn't JUMP_OK, or if the dest player's loc
			 * is set BOUND, can't do it. */
			if (!(FLAGS(destplayer) & JUMP_OK) || (FLAGS(dest) & BUILDER)) {
				return 0;
			}
		}

		/* for actions */
		if ((DBFETCH(thing)->location != NOTHING) &&
			(Typeof(DBFETCH(thing)->location) != TYPE_ROOM)) {

			/* If this is an exit on a Thing or a Player... */

			/* If the destination is a room or player, and the current
			 * location is set BOUND (note: if the player is in a vehicle
			 * set BUILDER this will also return failure) */
			if ((Typeof(dest) == TYPE_ROOM || Typeof(dest) == TYPE_PLAYER) &&
				(FLAGS(source) & BUILDER)) return 0;

			/* If secure_teleport is true, and if the destination is a room */
			if (tp_secure_teleport && Typeof(dest) == TYPE_ROOM) {
				/* if player doesn't control the source and the source isn't
				 * set Jump_OK, then if the destination isn't HOME,
				 * can't do it.  (Should this include getlink(owner)?  Not
				 * everyone knows that 'home' or '#-3' can be linked to and
				 * be treated specially. -winged) */
				if ((dest != HOME) && (!controls(owner, source))
					&& ((FLAGS(source) & JUMP_OK) == 0)) {
					return 0;
				}
			/* FIXME: Add support for in-server banishment from rooms
			 * and environments here. */
			}
		}
	}

		/* Check the @lock on the thing, as a final test. */
	return (eval_boolexp(descr, player, GETLOCK(thing), thing));
}
예제 #5
0
int
test_lock(int descr, dbref player, dbref thing, const char *lockprop)
{
	struct boolexp *lokptr;

	lokptr = get_property_lock(thing, lockprop);
	return (eval_boolexp(descr, player, lokptr, thing));
}
예제 #6
0
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock(dbref player, dbref thing, lock_type ltype)
{
  boolexp b = getlock(thing, ltype);
  log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  if(Pass_Lock(player, thing) && IS_passlock_type(ltype))
    return 1;
  return eval_boolexp(player, getlock(thing, ltype), thing, NULL);
}
예제 #7
0
파일: lock.c 프로젝트: MrWigggles/pennmush
/** Evaluate a lock.
 * Evaluate lock ltype on thing for player.
 * \param player dbref attempting to pass the lock.
 * \param thing object containing the lock.
 * \param ltype type of lock to check.
 * \param pe_info the pe_info to use when evaluating softcode in the lock
 * \retval 1 player passes the lock.
 * \retval 0 player does not pass the lock.
 */
int
eval_lock_with(dbref player, dbref thing, lock_type ltype, NEW_PE_INFO *pe_info)
{
  boolexp b = getlock(thing, ltype);
  /* Prevent overwriting a static buffer in unparse_boolexp() */
  if (!unparsing_boolexp)
    log_activity(LA_LOCK, thing, unparse_boolexp(player, b, UB_DBREF));
  return eval_boolexp(player, b, thing, pe_info);
}
예제 #8
0
bool
test_lock_false_default(int descr, dbref player,
                        dbref thing, const char *lockprop)
{
    struct boolexp *lok = get_property_lock(thing, lockprop);

    if (lok == TRUE_BOOLEXP)
        return 0;

    return (eval_boolexp(descr, player, lok, thing));
}
예제 #9
0
/** 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;
}
예제 #10
0
파일: p_misc.c 프로젝트: CyberLeo/protomuck
void 
prim_testlock(PRIM_PROTOTYPE)
{
    /* d d - i */
    CHECKOP(2);
    oper1 = POP();		/* boolexp lock */
    oper2 = POP();		/* player dbref */
    if (fr->level > 8)
	abort_interp("Interp call loops not allowed");
    if (!valid_object(oper2))
	abort_interp("Invalid argument (1).");
    if (Typeof(oper2->data.objref) != TYPE_PLAYER &&
        Typeof(oper2->data.objref) != TYPE_THING )
    {
	abort_interp("Invalid object type (1).");
    }
    CHECKREMOTE(oper2->data.objref);
    if (oper1->type != PROG_LOCK)
	abort_interp("Invalid argument (2)");
    result = eval_boolexp(fr->descr, oper2->data.objref, oper1->data.lock, player);
    CLEAR(oper1);
    CLEAR(oper2);
    PushInt(result);
}
예제 #11
0
bool
could_doit(int descr, dbref player, dbref thing)
{
    dbref source, dest, owner;

    if (Typeof(thing) == TYPE_EXIT) {
        if (DBFETCH(thing)->sp.exit.ndest == 0) {
            return 0;
        }

        owner = OWNER(thing);
        source = DBFETCH(player)->location;
        dest = *(DBFETCH(thing)->sp.exit.dest);

        if (dest == NIL)        /* unless its locked, anyone can use #-4 */
            return (eval_boolexp(descr, player, GETLOCK(thing), thing));

        if (Typeof(dest) == TYPE_PLAYER) {
            dbref destplayer = dest;

            dest = DBFETCH(dest)->location;
            if (!(FLAGS(destplayer) & JUMP_OK) || (FLAGS(dest) & BUILDER)) {
                return 0;
            }
        }
/*
    if (OkObj(thing)) if
       ( ((FLAG2(player) & F2IMMOBILE) && !(FLAG2(thing) & F2IMMOBILE)) && 
         (!(Typeof(dest) == TYPE_PROGRAM) && !(dest == NIL))
       ) {
          envpropqueue(descr, player, OkObj(player) ? getloc(player) : -1,
	              thing, thing, NOTHING, "@immobile", "Immobile", 1, 1);
    	  return 0;
         }

*/
/*        if( (dest != HOME) &&
            (Typeof(dest)==TYPE_ROOM) &&
            (FLAGS(player) & ZOMBIE) && (Typeof(player) == TYPE_THING) &&
            (FLAGS(dest) & ZOMBIE) ) 
            return 0;
 Saving this part for a revision of trigger() and this function. */
        if ((dest != HOME) && (Typeof(dest) == TYPE_ROOM) && Guest(player)
            && (tp_guest_needflag ? !(FLAG2(dest) & F2GUEST)
                : (FLAG2(dest) & F2GUEST))) {
/*	    anotify_nolisten(player, CFAIL "Guests aren't allowed there.", 1); */
            return 0;
        }

        /* for actions */
        if ((DBFETCH(thing)->location != NOTHING) &&
            (Typeof(DBFETCH(thing)->location) != TYPE_ROOM)) {

            if ((Typeof(dest) == TYPE_ROOM || Typeof(dest) == TYPE_PLAYER) &&
                (FLAGS(source) & BUILDER))
                return 0;

            if (tp_secure_teleport && Typeof(dest) == TYPE_ROOM) {
                if ((dest != HOME) && (!controls(owner, dest))
                    && ((FLAGS(dest) & JUMP_OK) == 0)) {
                    return 0;
                }
            }
        }
    }


    return (eval_boolexp(descr, player, GETLOCK(thing), thing));
}