Method code for $sys.make_core()

[Turn on line numbering]
arg ver;
var obj, obj2, d, o, top, x, admin, tmp, name;

// core rooms should be +core, and cant be destroyed
// traverse the list inverseley, less unseen heirarchial shuffling
.add_var('__making_core);
dblog("** Starting Core Extraction " + ctime());
d = $root.descendants();
top = listlen(d);
core_version = ver;
dblog("** " + top + " objects total, tidying up core objects...");

// tidy up core objects first
for obj in (d) {
    refresh();
    if (obj.has_flag('core)) {
        tmp++;
        catch any {
            obj.change_manager(obj);
            for o in (obj.writers('literal)) {
                refresh();
                obj.del_writer(o);
            }
        } with {
            dblog("** TIDY " + obj + " traceback: ");
            for o in ($parse_lib.traceback(traceback()))
                dblog("**   " + o);
        }
    }
}

// nuke anything not core
dblog("** " + tmp + " core objects, destroying non-core objects...");
for x in [1 .. top] {
    pause();
    obj = d[top - x + 1];
    if (!valid(obj)) {
        // dblog(".. Skipping invalid object " + obj);
        continue;
    }
    if (!obj.has_flag('core)) {
        if (obj.children()) {
            for obj2 in (obj.children()) {
                if (obj2.has_flag('core)) {
                    dblog("** ABORTING: A NON CORE OBJECT HAS CORE CHILDREN: ");
                    dblog("** " + obj + " => " + obj.children());
                    shutdown();
                }
            }
        }
        catch any {
            // dblog(".. Destroying " + obj);
            obj.destroy();
        } with {
            dblog("** " + obj + ".destroy() traceback: ");
            for o in ($parse_lib.traceback(traceback()))
                dblog("**   " + o);
        }
    }
}

// shutdown this task so that references can have
// a chance to clear out, on destroyed objects.
dblog("** done, suspending for new task **");

// do this the hard way, to be secure--wait a little while for
// things to wrapup, five seconds should be fine.
pause();
set_heartbeat(5);
.add_var('TMP_HEARTBEAT_CODE, .list_method('heartbeat));
.add_method([".finish_core();"], 'heartbeat);

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark