… | |
… | |
35 | * keep the game running. Thus, we don't want to free any information. |
35 | * keep the game running. Thus, we don't want to free any information. |
36 | */ |
36 | */ |
37 | void |
37 | void |
38 | emergency_save (int flag) |
38 | emergency_save (int flag) |
39 | { |
39 | { |
40 | player *pl; |
|
|
41 | |
|
|
42 | trying_emergency_save = 1; |
40 | trying_emergency_save = 1; |
43 | |
41 | |
44 | LOG (llevError, "Emergency save: "); |
42 | LOG (llevError, "Emergency save: "); |
45 | for (pl = first_player; pl; pl = pl->next) |
43 | for_all_players (pl) |
46 | { |
44 | { |
47 | if (!pl->ob) |
45 | if (!pl->ob) |
48 | { |
46 | { |
49 | LOG (llevError, "No name, ignoring this.\n"); |
47 | LOG (llevError, "No name, ignoring this.\n"); |
50 | continue; |
48 | continue; |
… | |
… | |
133 | |
131 | |
134 | INVOKE_PLAYER (SAVE, ob->contr); |
132 | INVOKE_PLAYER (SAVE, ob->contr); |
135 | |
133 | |
136 | object_freezer freezer; |
134 | object_freezer freezer; |
137 | |
135 | |
138 | int wiz = ob->flags [FLAG_WIZ]; |
136 | int wiz = ob->flag [FLAG_WIZ]; |
139 | |
137 | |
140 | /* Eneq(@csd.uu.se): If we have an open container hide it. */ |
138 | /* Eneq(@csd.uu.se): If we have an open container hide it. */ |
141 | container = ob->container; |
139 | container = ob->container; |
142 | ob->container = 0; |
140 | ob->container = 0; |
143 | |
141 | |
… | |
… | |
194 | |
192 | |
195 | fprintf (freezer, "endplst\n"); |
193 | fprintf (freezer, "endplst\n"); |
196 | |
194 | |
197 | SET_FLAG (ob, FLAG_NO_FIX_PLAYER); |
195 | SET_FLAG (ob, FLAG_NO_FIX_PLAYER); |
198 | CLEAR_FLAG (ob, FLAG_WIZ); |
196 | CLEAR_FLAG (ob, FLAG_WIZ); |
199 | save_object (freezer, ob, 3); /* don't check and don't remove */ |
197 | save_object (freezer, ob, 1); /* don't check and don't remove */ |
200 | |
198 | |
201 | char filename[MAX_BUF]; |
199 | char filename[MAX_BUF]; |
202 | |
200 | |
203 | sprintf (filename, "%s/%s/%s/%s.pl", settings.localdir, settings.playerdir, &ob->name, &ob->name); |
201 | sprintf (filename, "%s/%s/%s/%s.pl", settings.localdir, settings.playerdir, &ob->name, &ob->name); |
204 | make_path_to_file (filename); |
202 | make_path_to_file (filename); |
… | |
… | |
207 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
205 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
208 | |
206 | |
209 | /* Eneq(@csd.uu.se): Reveal the container if we have one. */ |
207 | /* Eneq(@csd.uu.se): Reveal the container if we have one. */ |
210 | ob->container = container; |
208 | ob->container = container; |
211 | |
209 | |
212 | ob->flags [FLAG_WIZ] = wiz; |
210 | ob->flag [FLAG_WIZ] = wiz; |
213 | |
211 | |
214 | enable_save = !final; |
212 | enable_save = !final; |
215 | } |
213 | } |
216 | |
214 | |
217 | player * |
215 | player * |
… | |
… | |
230 | |
228 | |
231 | char buf[MAX_BUF], bufall[MAX_BUF]; |
229 | char buf[MAX_BUF], bufall[MAX_BUF]; |
232 | |
230 | |
233 | pl->set_object (object::create ()); |
231 | pl->set_object (object::create ()); |
234 | pl->last_save_time = time (0); |
232 | pl->last_save_time = time (0); |
235 | pl->name_changed = 1; |
|
|
236 | |
233 | |
237 | assign (pl->savebed_map, first_map_path); |
234 | assign (pl->savebed_map, first_map_path); |
238 | |
235 | |
239 | /* Loop through the file, loading the rest of the values */ |
236 | /* Loop through the file, loading the rest of the values */ |
240 | while (fgets (bufall, MAX_BUF, thawer)) |
237 | while (fgets (bufall, MAX_BUF, thawer)) |
… | |
… | |
359 | { |
356 | { |
360 | strcpy (pl->maplevel, pl->savebed_map); |
357 | strcpy (pl->maplevel, pl->savebed_map); |
361 | pl->ob->x = pl->bed_x, pl->ob->y = pl->bed_y; |
358 | pl->ob->x = pl->bed_x, pl->ob->y = pl->bed_y; |
362 | } |
359 | } |
363 | |
360 | |
364 | /* make sure he's a player -- needed because of class change. */ |
|
|
365 | pl->name_changed = 1; |
|
|
366 | pl->last_save_tick = pticks; |
361 | pl->last_save_tick = pticks; |
367 | |
362 | |
368 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (path)); |
363 | INVOKE_PLAYER (LOAD, pl, ARG_STRING (path)); |
369 | |
364 | |
370 | return pl; |
365 | return pl; |