A
/ \ _ Play Now Nemesis on
| | | | _______ _ _ _______ _______ _ _______
| |\ | | | ____| | \ / | | ____| / ____| | | / ____|
/-------/-------------------------------------------------------------------,
O= Home <=XX| About News Pics Adventurers Wizards Download Connect >
\-------\-------------------------------------------------------------------'
| | \ | | |____ | | | | | |____ ___ \ \ | | ___ \ \
| | \_| |_______| |_| |_| |_______| |_______/ |_| |_______/
\ /
V
Documentation Area
Document Path: /doc/object/clean_up
Lfun: clean_up - keeping the memory a bit cleaner
Synopsis:
int clean_up()
Description:
The lfun clean_up() is a function that is called now and then (as
specified in config.h of the GD). The idea is that this function
should destruct the object if the object doesn't feel it is needed:
empty rooms for example or clones of any object forgotten in the
nirvana - not moved to somewhere (and later any reference is lost).
This will make the game use less memory.
This is a kind of garbage collection!
Return value:
1 if clean_up should be called again now and then
0 if the function should not be called again in this object.
Examples:
// from obj/persistent that is inherited by (almost) all generic
// objects (obj/item etc. - active!):
clean_up() {
if (clonep() && !environment()) destruct(this_object());
}
// something similar in obj/monster (active!):
clean_up() {
if (clonep() && !environment()) {
while(first_inventory(this_object()))
destruct(first_inventory(this_object()));
destruct(this_object());
}
}
// possible code for the room code (not active):
clean_up() {
if (file_name(this_object())[0..3] != "obj/") {
if (first_inventory()) return 1;
destruct(this_object());
}
}
Note:
Currently (late 2016) the clean_up is (step by step) introduced
for (almost) all generic clonable objects based on obj/item (via
obj/persistent and obj/persistent_simple) and for obj/monster.
Later (or sooner) this will be activated also for the room code.
This does NOT mean that we should code like weirdos and leave
lots of objects in the nirvana ;-)
See also:
This page was generated in LPC
Imprint / Impressum