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