MCPcopy Create free account
hub / github.com/NetHack/NetHack / savegamestate

Function savegamestate

src/save.c:264–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264staticfn void
265savegamestate(NHFILE *nhfp)
266{
267 int i;
268 unsigned long uid;
269
270 program_state.saving++; /* caller should/did already set this... */
271 uid = (unsigned long) getuid();
272 Sfo_ulong(nhfp, &uid, "gamestate-uid");
273 Sfo_char(nhfp, &svn.nhuuid[0], "nhuuid", sizeof svn.nhuuid);
274 Sfo_long(nhfp, &svm.moves, "gamestate-moves");
275 moves_to_relative_time(&svc.context.seer_turn);
276 moves_to_relative_time(&svc.context.digging.lastdigtime);
277 Sfo_context_info(nhfp, &svc.context, "gamestate-context");
278 relative_time_to_moves(&svc.context.seer_turn);
279 relative_time_to_moves(&svc.context.digging.lastdigtime);
280
281 Sfo_flag(nhfp, &flags, "gamestate-flags");
282 urealtime.finish_time = getnow();
283 urealtime.realtime += timet_delta(urealtime.finish_time,
284 urealtime.start_timing);
285 Sfo_long(nhfp, &svw.wreserve, "wreserve");
286 Sfo_int32(nhfp, &svw.wtreserved, "wtreserved");
287 Sfo_you(nhfp, &u, "gamestate-you");
288 Sfo_char(nhfp, yyyymmddhhmmss(ubirthday), "gamestate-ubirthday", 14);
289 Sfo_long(nhfp, &urealtime.realtime, "gamestate-realtime");
290 Sfo_char(nhfp, yyyymmddhhmmss(urealtime.start_timing), "gamestate-start_timing", 14);
291 /* this is the value to use for the next update of urealtime.realtime */
292 urealtime.start_timing = urealtime.finish_time;
293 save_killers(nhfp);
294
295 /* must come before gm.migrating_objs and gm.migrating_mons are freed */
296 save_timers(nhfp, RANGE_GLOBAL);
297 save_light_sources(nhfp, RANGE_GLOBAL);
298
299 /* when FREEING, deletes objects in invent and sets invent to Null;
300 pointers into invent (uwep, uarmg, uamul, &c) are set to Null too */
301 saveobjchn(nhfp, &gi.invent);
302
303 /* save ball and chain if they happen to be in an unusual state */
304 save_bc(nhfp);
305
306 saveobjchn(nhfp, &gm.migrating_objs); /* frees objs and sets to Null */
307 savemonchn(nhfp, gm.migrating_mons);
308 if (release_data(nhfp))
309 gm.migrating_mons = (struct monst *) 0;
310 for (i = 0; i < NUMMONS; ++i) {
311 Sfo_mvitals(nhfp, &svm.mvitals[i], "gamestate-mvitals");
312 }
313 save_dungeon(nhfp, (boolean) !!update_file(nhfp),
314 (boolean) !!release_data(nhfp));
315 savelevchn(nhfp);
316 Sfo_q_score(nhfp, &svq.quest_status, "gamestate-quest_status");
317 for (i = 0; i < (MAXSPELL + 1); ++i) {
318 Sfo_spell(nhfp, &svs.spl_book[i], "gamestate-spl_book");
319 }
320 save_artifacts(nhfp);
321 save_oracles(nhfp);

Callers 2

dosave0Function · 0.85
savestateinlockFunction · 0.85

Calls 15

getuidFunction · 0.85
moves_to_relative_timeFunction · 0.85
relative_time_to_movesFunction · 0.85
getnowFunction · 0.85
timet_deltaFunction · 0.85
yyyymmddhhmmssFunction · 0.85
save_killersFunction · 0.85
save_timersFunction · 0.85
save_light_sourcesFunction · 0.85
saveobjchnFunction · 0.85
save_bcFunction · 0.85
savemonchnFunction · 0.85

Tested by

no test coverage detected