MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
| 2 | #include <sys/driver_hooks.h> |
| 3 | |
| 4 | set_driver_hook(H_CREATE_CLONE, value) |
| 5 | |
| 6 | <value> being: |
| 7 | |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 8 | void <name> (...) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 9 | int <closure> ( void ) |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 10 | int <closure> (object obj_to_init, ...) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 11 | |
| 12 | DESCRIPTION |
| 13 | Optional hooks to initialize a cloned object after creation. |
| 14 | Hook setting can be unbound lambda closures, or the name of |
| 15 | the function (static or public) to call in the object. |
| 16 | |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 17 | If the hook is a closure expecting arguments, it is bound to the |
| 18 | current object and called with the created object as the first |
| 19 | argument and any further arguments from the clone_object() call. |
| 20 | If the hook is a closure without arguments, it is bound to |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 21 | the object to be initalized and called. |
| 22 | |
| 23 | If the result of the closure call is a non-zero number, it is used |
| 24 | as the interval to wait before the first reset(), else the default |
| 25 | interval computed from TIME_TO_RESET is used. |
| 26 | |
| 27 | If the hook is defined as the name of an lfun in the object, |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 28 | it is called in the object with any further arguments from the |
| 29 | clone_object() call, and any result is ignored. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 30 | |
| 31 | HISTORY |
| 32 | LDMud 3.2.10 allowed static functions to be given by name. |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 33 | LDMud 3.6.5 removed the argument given for the lfun call. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 34 | |
| 35 | SEE ALSO |
Zesstra | 8513612 | 2021-05-08 20:32:01 +0200 | [diff] [blame] | 36 | hooks(C), create_ob(H), create_super(H), create_lwobject(H) |