untermud/DOC/
untermud/DOC/U/
untermud/DOC/U/U-examples/
untermud/DOC/internals/
untermud/DOC/wizard/
untermud/MISC/
untermud/MISC/dbchk/
untermud/RWHO/
untermud/RWHO/rwhod/
/*
    Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/

/* configure all options BEFORE including system stuff. */
#include    "config.h"
#include    "mud.h"
#include    "match.h"
#include    "vars.h"


/* ARGSUSED */
int cmd_take (int ac, char *av[], char *who, char *aswho)
{
  int x;
  char *loc;
  char ob[MAXOID];

  loc = ut_loc (who);

  for (x = 1; x < ac; x++) {
    if (matchobjects (who, av[x], loc, MTCH_UNIQ | MTCH_QUIET, ob) &&
      matchobjects (who, av[x], loc, MTCH_FRST, ob))
      continue;

    /* check locks */
    if (bool_locked (who, ob, loc, var_lock, 0)) {
      if (!activate (ACTIV_PONLY, who, ob, loc, var_fail, ac, av))
        say (who, "you can't take ", ut_name (ob), ".\n", (char *) 0);

      (void) activate (ACTIV_ECAST, who, ob, loc, var_ofail, ac, av);
      continue;
    }

    if (ut_listadd (who, who, var_cont, ob))
      return (UERR_FATAL);
    if (ut_listdel (who, loc, var_cont, ob))
      return (UERR_FATAL);
    if (ut_set (who, ob, typ_obj, var_loc, who))
      return (UERR_FATAL);

    if (!activate (ACTIV_PONLY, who, ob, loc, var_succ, ac, av))
      say (who, "took ", ut_name (ob), ".\n", (char *) 0);
    eval_cmd_returnstr (ob);
    (void) activate (ACTIV_ECAST, who, ob, loc, var_osucc, ac, av);
  }
  return (UERR_NONE);
}