blob: 8eb772028283aecef0a6bed11b8bd9aba0022a31 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 int restore_object(string name)
3 int restore_object(string str)
MG Mud User88f12472016-06-24 23:31:02 +02004
Zesstra715ec202025-07-09 22:18:31 +02005DESCRIPTION
6 Restore values of variables for current object from the file <name>,
7 or directly from the string <str>.
MG Mud User88f12472016-06-24 23:31:02 +02008
Zesstra715ec202025-07-09 22:18:31 +02009 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 User88f12472016-06-24 23:31:02 +020012
Zesstra715ec202025-07-09 22:18:31 +020013 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 User88f12472016-06-24 23:31:02 +020017
Zesstra715ec202025-07-09 22:18:31 +020018 Return 1 on success, 0 if there was nothing to restore.
MG Mud User88f12472016-06-24 23:31:02 +020019
Zesstra715ec202025-07-09 22:18:31 +020020 Variables that has the type modifer 'nosave' will not be restored.
21 Example: nosave int xxx;
MG Mud User88f12472016-06-24 23:31:02 +020022
Zesstra715ec202025-07-09 22:18:31 +020023 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 User88f12472016-06-24 23:31:02 +020026
Zesstra715ec202025-07-09 22:18:31 +020027 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 User88f12472016-06-24 23:31:02 +020035
Zesstra715ec202025-07-09 22:18:31 +020036HISTORY
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 User88f12472016-06-24 23:31:02 +020043
Zesstra715ec202025-07-09 22:18:31 +020044SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020045 save_object(E), restore_value(E), valid_read(M)