Dump of #4489 (LRPG Recycler)

@create $thing named LRPG Recycler:LRPG Recycler,LRPGR,recycler
"#4489.("key") => E_PERM (Permission denied)
;;#4489.("aliases") = {"LRPG Recycler", "LRPGR", "recycler"}
;;#4489.("description") = "A chugging mass of wires and pistons, throwing sparks and belching mechanical grunts of displeasure with the LambdaMOO Quota System."
;;#4489.("object_size") = {6201, 1141286558}

@verb #4489:"ok_to_recycle" this none this rx
@program #4489:ok_to_recycle
":ok_to_recycle(object)";
"Return false if the object has verbs or properties defined, or kids.";
"This recycler is intended for public use, and the public has no cause to recycle developed G_M-owned objects.";
o = args[1];
return !((children(o) || verbs(o)) || properties(o));
.

@verb #4489:"_recycle" this none this
@program #4489:_recycle
":_recycle(object) - Pass to $recycler if perms are secure.";
{o} = args;
if (!this:trust_to_recycle(caller_perms(), o))
  return E_PERM;
elseif (!this:ok_to_recycle(o))
  return E_NACC;
endif
(rpg = $local.rpg):s_i_n();
recycled = (o.owner == this.owner) ? $recycler:_recycle(o) | $nothing;
if (o in this.owner.owned_objects)
  this.rotten = {@this.rotten, {o, callers()}};
endif
return recycled;
"DR 08-MAY-95 -- Changed to pass obj to trust_to_recycle.";
"GMs are allowed to recycle killable things using this verb now.";
"Slither 6/7/95 -- Added suspend_if_needed call";
"THX1138 4-June-1997  -- Added a check after the suspend to make sure G_M still owns before attempting a recycle.";
.

@verb #4489:"_create" this none this rx
@program #4489:_create
":_create(parent-object[, announce-to])";
"Pass to $recycler if perms are secure.  If E_QUOTA is returned, find the bad object in our .owned_objects and re-recycle it.";
"If announce-to is given, tell that player when we suspend.";
if (!this:trust_to_create(caller_perms()))
  return E_PERM;
endif
{o, @extra} = args;
rpg = $local.rpg;
rpg:s_i_n();
if ((o.owner != this.owner) && (!o.f))
  o:make_fertile();
elseif ((((o.owner == this.owner) && (!(o in {rpg.doll, @rpg.object_db.generic_corpses, @this.exceptions, @rpg.dispenser.dispenses}))) && (parent(o) != rpg.doll)) && (!(parent(o) in {@rpg.object_db.generic_corpses})))
  "Extra bit about doll for zombies and conjurables.";
  this.owner:report_error(tostr("~recycler: making child of non-dispensed object.", $string_utils:nn(o), " Callers: ", $string_utils:print(callers(1))));
endif
created = $recycler:_create(o);
if (created != E_QUOTA)
  return created;
endif
if (!$code_utils:task_valid(this.summarize_task))
  this.summarize_task = task_id();
  for o in (this.owner.owned_objects)
    if ($command_utils:suspend_if_needed(0, "~recycler:_create() suspending..."))
      player:tell("~recycler:_create() resuming...");
    endif
    if ((typeof(o.object_size) == ERR) && $recycler:valid(o))
      this.owner:report_error(((("~recycler ->  " + tostr(this)) + ":_recycle(") + tostr(o)) + ");");
      this:_recycle(o);
    endif
  endfor
  "Last attempt at trying to fixie the problem.";
  $quota_utils:summarize_one_user(this.owner, -1);
  if ((o.owner != this.owner) && (!o.f))
    o:make_fertile();
  endif
  return $recycler:_create(o);
else
  player:tell("Grand_Master is in the process of attempting to compensate for a $recycler bug.  Please be patient and hold off playing for a bit.");
  return E_QUOTA;
endif
"Quinn 11-May-94: Added summarize_task so as not to over-burden the MOO with multiple surveys.";
"Quinn 11-May-94: If we can't create using the preferred $recycler method, do a raw create and return that.";
"08-NOV-94 DR: Reinstated above hacks, just return errors when summarize_task is running, no raw create (will not work).";
"Profane 16-MAR-95 12:47EST - Added :make_fertile() calls, mostly so #259:check_mine() calls don't bomb out on non-G_M owned equipment.";
"Slither 6/10/95 -- Changed test for no-object-size objects from being";
"  (!o.object_size) && (!$recycler:valid(o)), which doesn't work.";
"Slither 6/11/95 -- Added suspend_if_needed before creation starts";
"Slither 6/22/95 -- made it print error message if was making non-grabber GM owned object";
.

@verb #4489:"trust_to_recycle trust_to_create" this none this
@program #4489:trust_to_recycle
":trust_to_recycle(OBJ who [, OBJ what)";
"Is WHO allowed to recycle WHAT.  If there is no WHAT, is WHO allowed";
"to recycle anthing that this.owner owns?";
{who, ?what = $nothing} = args;
ok = 0;
rpg = $local.rpg;
if (rpg:is_grandmaster(who))
  ok = 1;
elseif ((verb[10] == "r") && rpg:trusted(who))
  if (rpg.vacuum:killable(what))
    ok = 1;
  elseif ((parent(what) == rpg.doll) && (what.character.owner == who))
    ok = 1;
  endif
endif
return ok;
"DR 08-MAY-95 -- Trust GMs to manually recycle what the vacuum cleaner would consider food anyway.";
"Profane 6-JAN-97 2003PST -- rewrote, added bit allowing GM's to reyclce dolls of their own monsters.";
"Profane 14-APR-96 1550PST -- Put in bit to check killable only if we're checking recycle rights.";
.

"***finished***