blob: 47dfa7379ffcd6e22e272e80afb9822e13cc6909 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
2 int <lfun> (int refcount)
3 int <closure>(int ref, object ob)
4
5DESCRIPTION
6 The hook H_CLEAN_UP defines a lfun or a closure used to clean
7 up an object. In older drivers this was hardwired to the lfun
8 clean_up().
9
10 The function is applied by the driver when an object hasn't been
11 used for a long time, to give it a possibility to
12 self-destruct. The refcount <ref> passed as argument will be 0 for
13 clone objects, 1 for a simple loaded object, and greater when
14 the object is cloned or inherited by some existing object. It
15 is recommended not to self_destruct the object when the
16 reference count is greater than one.
17
18 By convention, a refcount < 0 is used if some other object
19 asks the called object to clean_up.
20
21 If the function is a closure, the second argument <ob> is the
22 object to clean up.
23
24 If the hook specifies a non-existing lfun, or if the call
25 returns 0, no further attempt to clean up this object will be done.
26
27 Returning a non-zero value is only recommended when the reason
28 why the object can't self-destruct is likely to vanish without
29 the object being touched, that is, when no local function is
30 called in it, (and in compat mode also when the object is not
31 being moved around).
32
33 A typical mud configuration defines the time to wait for
34 clean_up() so long that you can assert reset() has been
35 called since the object has been touched last time.
36
37EXAMPLES
38 A clone of /std/drink defines clean_up() to self-destruct if
39 it is empty, not carried a living being and not touched for
40 a long time.
41
42 A room that inherits /std/room defines clean_up() to
43 self-destruct if it is neither inherited nor used as a
44 blueprint, is empty and was not entered for a long time.
45
46HISTORY
47 Before 3.2.1, the function was hardwired to the lfun clean_up().
48
49SEE ALSO
50 reset(A), heart_beat(A), call_out(E), destruct(E), remove(A),
51 hooks(C)