示例#1
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;
}
示例#2
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);
}
示例#3
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.
 * \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);
}