MudOSa4DGD/
MudOSa4DGD/bin/
MudOSa4DGD/data/
MudOSa4DGD/doc/
MudOSa4DGD/doc/driver/
MudOSa4DGD/doc/efun/bitstrings/
MudOSa4DGD/doc/efun/command/
MudOSa4DGD/doc/efun/communication/
MudOSa4DGD/doc/efun/heart_beat/
MudOSa4DGD/doc/efun/interactive/
MudOSa4DGD/doc/efun/inventory/
MudOSa4DGD/doc/efun/living/
MudOSa4DGD/doc/efun/mappings/
MudOSa4DGD/doc/efun/strings/
MudOSa4DGD/doc/efun/uid/
MudOSa4DGD/doc/funs/
MudOSa4DGD/doc/language/
MudOSa4DGD/mudlib/dgd/doc/
MudOSa4DGD/mudlib/dgd/lib/include/dgd/
MudOSa4DGD/mudlib/dgd/lib/std/
MudOSa4DGD/mudlib/dgd/lib/sys/
MudOSa4DGD/mudlib/dgd/log/
MudOSa4DGD/mudlib/log/
MudOSa4DGD/mudlib/std/include/
MudOSa4DGD/mudlib/std/obj/
/*
 * destruct.c
 *
 * Destroy objects
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


/* DGD destruct_object() kfun override */
static void destruct_object(object ob) {
  /* do we have an object? */
  if (ob) {
    /* driver-PRIVILEGE gets past this trivial shit */
    if (!DRIVER_PRIV()) {
      /* prevent recursion error */
      if (calling_object() != ob || previous_function() != __DESTROY_FUNC) {
	/* call destroy() in ob since caller isn't it */
	catch(call_other(ob, __DESTROY_FUNC));
	/* destroy() will do its jobb if it wants to */
	return;
      }
    }

    /* disconnect any users connected to the object */
    if (ob->__query_user()) {
      ob->__query_user()->force_close();
    }

    if (ob) {
#ifdef MUDOS_INVENTORY
      object *obs, o;
      int i;
      
      /* destruct any remaining objects */
      if (i=::sizeof(obs=all_inventory(ob))) {
	while (--i >= 0) {
	  /* relocate inventory objects through master() */
	  catch(call_other(master(), __DESTRUCT_ENV_OF_FUNC, o=obs[i]));
	  if (o)
	    catch(destruct_object(o));
	}
      }

      /* ensure destruction of <ob> */
      if (ob)
#endif
	::destruct_object(ob);
    }
  }
}