From the NannyMUD documentation
2001-01-06
NAME
clean_up - notify an object that it's time to clean upLOCATION
/std/basic_room.c, /std/stationary.cSYNTAX
int clean_up(int ref_count)DESCRIPTION
In an effort to save valuable memory space, here is your possibility to help reduce the load on the machine. clean_up() will be called when no function has been called in this object for a certain amount of time. (normally about half an hour) ref_count is a count of how many objects there is that has pointers to this object. If in doubt, never destruct an object with more than 1 refcount. (an object always has at least one refcount) It is up to the object itself to self destruct ("destruct(this_object());"). If clean_up() returns 1 it will be called again later.RETURN VALUES
A non-zero value means call it again later.A zero value means never call again clean_up in object again.NOTE
Remember that if you have a room that keeps track of important variables or something, remember that to redefine clean_up so that you won't loose any data when it is destructed.EXAMPLE
A minimal and reasonably safe clean_up() for rooms would be this one: int clean_up(int ref_count) { if (ref_count>1 || // Someone has a pointer to this object. environment() || // We are inside another object. first_inventory(this_object()) // There is someting inside us. ) return 1; // Don't destruct now, check again later. destruct(this_object()); // Self destruct. return 0; // Don't call me again, I am gone. } // clean_up This clean_up will destruct a room if it empty and noone has visite it for 30 minutes. This is the default for rooms that inherit std/basic_room on nannymud. A more general approach would be to take into consideration that any objects that was cloned in reset() will be cloned again if the room is destructed and loaded again, this is not normally the case.EXAMPLE
Here is an example of a clean_up that will destruct the master if there are no clones of it. (Note that it does not care if there are objects in the master or not) int clean_up(int arg) { if (environment()) return 0; while (first_inventory()) destruct(first_inventory()); if (_isclone(this_object()) || (arg<2 && this_object() == _next_clone(this_object()))) destruct(this_object()); return 1; }SEE ALSO
destruct in efun/object_related/destruct destruct in wizcommands/object/destructSEE ALSO
no_clean_up in std/basic/stationary no_clean_up in std/room/basic_room