Method code for $root.uninitialize()

[Turn on line numbering]
arg @destroyed;
var a, v, d, definer, method, descendants, str, tb;

(> .perms(caller(), $root, $sys) <);
destroyed = destroyed ? 1 : 0;
descendants = .descendants() + [this()];

// call [ancestors...].uninit_ancestor() on the object being destroyed
for a in (ancestors()) {
    method = tosym("uninit_" + a.objname());
    if ((definer = (| find_method(method) |))) {
        if (definer != a) {
            // scream madly and run around--everybody should know this
            str = "UNINIT ERROR: uninit method for " + a;
            str += " in wrong place (" + definer + ")";
            (| definer.manager().tell(str) |);
            (| a.manager().tell(str) |);
            (| sender().tell(str) |);
            continue;
        }
        catch any {
            .(method)();
        } with {
            // try and let somebody know they made a boo-boo somewhere
            tb = traceback().fmt_tb();
            str = "UNINIT ERROR " + this() + "<" + definer + ">:";
            if (definer) {
                (| definer.manager().tell(str) |);
                (| definer.manager().tell(tb) |);
            }
            (| sender().tell(str) |);
            (| sender().tell(tb) |);
            (| sender().tell("Continuing uninit..") |);
            (| $sys.log_traceback(tb, "** " + str) |);
        }
    }
    refresh();
}

// if we have descendants, clean anything from the object being dested
method = tosym("uninit_" + .objname());
if ((definer = (| find_method(method) |))) {
    if (definer != this()) {
        // scream madly and run around--everybody should know this
        str = "UNINIT ERROR: uninit method for " + a;
        str += " in wrong place (" + definer + ")";
        (| definer.manager().tell(str) |);
        (| .manager().tell(str) |);
        (| sender().tell(str) |);
    } else {
        for d in (descendants) {
            catch any {
                d.(method)();
            } with {
                // try and let somebody know they made a boo-boo somewhere
                str = "UNINIT ERROR " + d + "<" + this() + ">:";
                tb = traceback().fmt_tb();
                (| .manager().tell(str) |);
                (| .manager().tell(tb) |);
                if (.manager() != sender()) {
                    (| sender().tell(str) |);
                    (| sender().tell(tb) |);
                }
                (| sender().tell("Continuing uninit..") |);
                (| $sys.log_traceback(tb, "** " + str) |);
            }
            refresh();
        }
    }
}

// clear vars
if (!destroyed && descendants)
    $sys.clear_definer_vars(this(), descendants);

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

the Cold Dark