/* /lib/clean.c * from the Foundation II LPC Library * the central object of the entire mudlib * created by Descartes of Borg 940210 * modified for new lfun structure 950207 */ #include <clean_up.h> #include "clean.h" private static int NoClean; static void create() { NoClean = 0; } int clean_up() { object ob, env; object *inv; int i; if( NoClean ) return NEVER_AGAIN; if( !(ob = this_object()) || ob->query_auto_load() ) return NEVER_AGAIN; if( env = environment(ob) ) { if( (int)env->is_bag() ) return TRY_AGAIN_LATER; if( (int)env->GetProperty("storage room") ) return TRY_AGAIN_LATER; } inv = deep_inventory(ob); if( sizeof(filter(inv, (: userp :))) ) return TRY_AGAIN_LATER; if( !env ) { catch(inv->eventDestruct()); if( ob ) ob->eventDestruct(); if( ob ) destruct(ob); return NEVER_AGAIN; } if( userp(env) ) return TRY_AGAIN_LATER; return (int)env->clean_up(); } int eventDestruct() { return Destruct(); } static int Destruct() { object env; object *inv; int i; if( env = environment(this_object()) ) { i = sizeof(inv = all_inventory(this_object())); while(i--) if(inv[i]) inv[i]->eventMove(env); } destruct(this_object()); return !(this_object()); } static int SetNoClean(int x) { return (NoClean = x); } int GetNoClean() { return NoClean; }