destruct.c

MudOSa4DGD/mudlib/dgd/lib/sys/kfun/destruct.c · 1.1 KB

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * 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);
    }
  }
}

Site Stats

Snippets: 1791
Codebases: 571