MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | SYNOPSIS |
Zesstra | d59c389 | 2019-11-28 20:53:39 +0100 | [diff] [blame] | 2 | int restore_object(string name) |
| 3 | int restore_object(string str) |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 4 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 5 | DESCRIPTION |
| 6 | Restore values of variables for current object from the file <name>, |
| 7 | or directly from the string <str>. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 8 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 9 | To restore directly from a string <str>, the string must begin |
| 10 | with the typical line "#x:y" as it is created by the save_object() |
| 11 | efun. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 12 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 13 | When restoring from a file, the name may end in ".c" which is stripped |
| 14 | off by the parser. The master object will probably append a .o to the |
| 15 | <name>. The validity of the filename is checked with a call to |
| 16 | check_valid_path(). |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 17 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 18 | Return 1 on success, 0 if there was nothing to restore. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 19 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 20 | Variables that has the type modifer 'nosave' will not be restored. |
| 21 | Example: nosave int xxx; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 22 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 23 | Lfun, variable and simul_efun closures are restored only if they |
| 24 | can be found (this excludes closures of private lfuns as well) - if |
| 25 | not, they are restored as value '0'. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 26 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 27 | If inheritance is used, then it might be possible that a |
| 28 | variable will exist with the same name in more than one place, |
| 29 | and thus appear in the save file multiple times. When |
| 30 | restoring, the variables are restored in the order they are |
| 31 | found in the inheritance tree. A good practice is to have |
| 32 | verbose and unique name on non-static variables, which also |
| 33 | will make it more easy to read or patch the save file |
| 34 | manually. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 35 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 36 | HISTORY |
| 37 | Restoring directly from a string was added in LDMud 3.2.8 and |
| 38 | may be moved in future into a separate efun. |
| 39 | LDMud 3.2.9 added the restoring of non-lambda closures, symbols, |
| 40 | and quoted arrays, using a new savefile format version. |
| 41 | LDMud 3.5.0 added the possibility to restore version 2 with its higher |
| 42 | float precision and version 3 with lvalue references. |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 43 | |
Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 44 | SEE ALSO |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 45 | save_object(E), restore_value(E), valid_read(M) |