static void cleanUp(O c) { if (c instanceof L) { cleanUp((L) c); ret; } if (!(c instanceof Class)) ret; pcall { // revoke license callOpt(c, "licensed_off"); // unpause setOpt(c, "ping_pauseAll", false); // call custom cleanMeUp() and cleanMeUp_*() functions if (!isFalse(pcallOpt(c, "cleanMeUp"))) for (S name : methodsStartingWith(c, "cleanMeUp_")) pcallOpt(c, name); // remove all virtual bots (does this work?) L androids = (L) getOpt(c, "record_list"); L ports = getMultiPorts(); if (androids != null) for (O port : ports) for (O android : androids) callOpt(android, "dispose"); // heck we'll dispose anything // sub-cleanup L classes = cast getOpt(c, "hotwire_classes"); if (classes != null) for (WeakReference cc : classes) pcall { cleanUp(cc.get()); } } } static void cleanUp(L l) { for (O c : l) cleanUp(c); l.clear(); }