… | |
… | |
28 | #include <define.h> |
28 | #include <define.h> |
29 | |
29 | |
30 | extern void sub_weight (object *, signed long); |
30 | extern void sub_weight (object *, signed long); |
31 | extern void add_weight (object *, signed long); |
31 | extern void add_weight (object *, signed long); |
32 | extern long pticks; |
32 | extern long pticks; |
33 | |
|
|
34 | /* If flag is non zero, it means that we want to try and save everyone, but |
|
|
35 | * keep the game running. Thus, we don't want to free any information. |
|
|
36 | */ |
|
|
37 | void |
|
|
38 | emergency_save (int flag) |
|
|
39 | { |
|
|
40 | player *pl; |
|
|
41 | |
|
|
42 | trying_emergency_save = 1; |
|
|
43 | |
|
|
44 | LOG (llevError, "Emergency save: "); |
|
|
45 | for (pl = first_player; pl; pl = pl->next) |
|
|
46 | { |
|
|
47 | if (!pl->ob) |
|
|
48 | { |
|
|
49 | LOG (llevError, "No name, ignoring this.\n"); |
|
|
50 | continue; |
|
|
51 | } |
|
|
52 | |
|
|
53 | LOG (llevError, "%s ", &pl->ob->name); |
|
|
54 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Emergency save..."); |
|
|
55 | |
|
|
56 | /* If we are not exiting the game (ie, this is sort of a backup save), then |
|
|
57 | * don't change the location back to the village. Note that there are other |
|
|
58 | * options to have backup saves be done at the starting village |
|
|
59 | */ |
|
|
60 | if (!flag) |
|
|
61 | { |
|
|
62 | strcpy (pl->maplevel, first_map_path); |
|
|
63 | |
|
|
64 | pl->ob->map = 0; |
|
|
65 | pl->ob->x = -1; |
|
|
66 | pl->ob->y = -1; |
|
|
67 | } |
|
|
68 | |
|
|
69 | pl->save (1); |
|
|
70 | } |
|
|
71 | |
|
|
72 | LOG (llevError, "\n"); |
|
|
73 | } |
|
|
74 | |
33 | |
75 | /* Delete character with name. if new is set, also delete the new |
34 | /* Delete character with name. if new is set, also delete the new |
76 | * style directory, otherwise, just delete the old style playfile |
35 | * style directory, otherwise, just delete the old style playfile |
77 | * (needed for transition) |
36 | * (needed for transition) |
78 | */ |
37 | */ |
… | |
… | |
164 | /* Match the enumerations but in string form */ |
123 | /* Match the enumerations but in string form */ |
165 | fprintf (freezer, "unapply %s\n", unapply == unapply_nochoice ? "unapply_nochoice" : |
124 | fprintf (freezer, "unapply %s\n", unapply == unapply_nochoice ? "unapply_nochoice" : |
166 | (unapply == unapply_never ? "unapply_never" : "unapply_always")); |
125 | (unapply == unapply_never ? "unapply_never" : "unapply_always")); |
167 | |
126 | |
168 | if (ob->map) |
127 | if (ob->map) |
169 | fprintf (freezer, "map %s\n", ob->map->path); |
128 | fprintf (freezer, "map %s\n", &ob->map->path); |
170 | else |
|
|
171 | fprintf (freezer, "map %s\n", settings.emergency_mapname); |
|
|
172 | |
129 | |
173 | fprintf (freezer, "savebed_map %s\n", savebed_map); |
130 | fprintf (freezer, "savebed_map %s\n", savebed_map); |
174 | fprintf (freezer, "bed_x %d\nbed_y %d\n", bed_x, bed_y); |
131 | fprintf (freezer, "bed_x %d\nbed_y %d\n", bed_x, bed_y); |
175 | fprintf (freezer, "weapon_sp %f\n", weapon_sp); |
132 | fprintf (freezer, "weapon_sp %f\n", weapon_sp); |
176 | fprintf (freezer, "Str %d\n", orig_stats.Str); |
133 | fprintf (freezer, "Str %d\n", orig_stats.Str); |
… | |
… | |
194 | |
151 | |
195 | fprintf (freezer, "endplst\n"); |
152 | fprintf (freezer, "endplst\n"); |
196 | |
153 | |
197 | SET_FLAG (ob, FLAG_NO_FIX_PLAYER); |
154 | SET_FLAG (ob, FLAG_NO_FIX_PLAYER); |
198 | CLEAR_FLAG (ob, FLAG_WIZ); |
155 | CLEAR_FLAG (ob, FLAG_WIZ); |
199 | save_object (freezer, ob, 3); /* don't check and don't remove */ |
156 | save_object (freezer, ob, 1); /* don't check and don't remove */ |
200 | |
157 | |
201 | char filename[MAX_BUF]; |
158 | char filename[MAX_BUF]; |
202 | |
159 | |
203 | sprintf (filename, "%s/%s/%s/%s.pl", settings.localdir, settings.playerdir, &ob->name, &ob->name); |
160 | sprintf (filename, "%s/%s/%s/%s.pl", settings.localdir, settings.playerdir, &ob->name, &ob->name); |
204 | make_path_to_file (filename); |
161 | make_path_to_file (filename); |
… | |
… | |
344 | } |
301 | } |
345 | |
302 | |
346 | /* this loads the standard objects values. */ |
303 | /* this loads the standard objects values. */ |
347 | load_object (thawer, pl->ob, 0); |
304 | load_object (thawer, pl->ob, 0); |
348 | |
305 | |
349 | /* If the map where the person was last saved does not exist, |
|
|
350 | * restart them on their home-savebed. This is good for when |
|
|
351 | * maps change between versions |
|
|
352 | * First, we check for partial path, then check to see if the full |
|
|
353 | * path (for unique player maps) |
|
|
354 | */ |
|
|
355 | if (!has_been_loaded (pl->maplevel) |
|
|
356 | && check_path (pl->maplevel, 1) == -1 |
|
|
357 | && check_path (pl->maplevel, 0) == -1) |
|
|
358 | { |
|
|
359 | strcpy (pl->maplevel, pl->savebed_map); |
|
|
360 | pl->ob->x = pl->bed_x, pl->ob->y = pl->bed_y; |
|
|
361 | } |
|
|
362 | |
|
|
363 | pl->last_save_tick = pticks; |
306 | pl->last_save_tick = pticks; |
364 | |
307 | |
365 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (path)); |
308 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (path)); |
366 | |
309 | |
367 | return pl; |
310 | return pl; |