MCPcopy Index your code
hub / github.com/NetHack/NetHack / dosave0

Function dosave0

src/save.c:73–234  ·  view source on GitHub ↗

returns 1 if save successful */

Source from the content-addressed store, hash-verified

71
72/* returns 1 if save successful */
73int
74dosave0(void)
75{
76 const char *fq_save;
77 xint8 ltmp;
78 char whynot[BUFSZ];
79 NHFILE *nhfp, *onhfp;
80 int res = 0;
81
82 program_state.saving++; /* inhibit status and perm_invent updates */
83 notice_mon_off();
84 /* we may get here via hangup signal, in which case we want to fix up
85 a few of things before saving so that they won't be restored in
86 an improper state; these will be no-ops for normal save sequence */
87 u.uinvulnerable = 0;
88 if (iflags.save_uswallow)
89 u.uswallow = 1, iflags.save_uswallow = 0;
90 if (iflags.save_uinwater)
91 u.uinwater = 1, iflags.save_uinwater = 0; /* bypass set_uinwater() */
92 if (iflags.save_uburied)
93 u.uburied = 1, iflags.save_uburied = 0;
94 /* extra handling for hangup save or panic save; without this,
95 a thrown light source might trigger an "obj_is_local" panic;
96 if a thrown or kicked object is in transit, put it on the map;
97 when punished, make sure ball and chain are placed too */
98 done_object_cleanup(); /* maybe force some items onto map */
99
100 if (!program_state.something_worth_saving || !gs.SAVEF[0])
101 goto done;
102
103 fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); /* level files take 0 */
104#ifndef NO_SIGNAL
105#if defined(UNIX) || defined(VMS)
106 sethanguphandler((void (*)(int) ) SIG_IGN);
107#endif
108 (void) signal(SIGINT, SIG_IGN);
109#endif
110
111 HUP if (iflags.window_inited) {
112 nh_uncompress(fq_save);
113 nhfp = open_savefile();
114 if (nhfp) {
115 close_nhfile(nhfp);
116 clear_nhwindow(WIN_MESSAGE);
117 There("seems to be an old save file.");
118 if (y_n("Overwrite the old file?") == 'n') {
119 nh_sfconvert(fq_save);
120 nh_compress(fq_save);
121 goto done;
122 }
123 }
124 }
125
126 HUP mark_synch(); /* flush any buffered screen output */
127
128 nhfp = create_savefile();
129 if (!nhfp) {
130 HUP pline("Cannot open save file.");

Callers 7

qt_main.cppFile · 0.85
VA_DECLFunction · 0.85
dosaveFunction · 0.85
end_of_inputFunction · 0.85
ghack_save_gameFunction · 0.85
closeEventMethod · 0.85
MainWndProcFunction · 0.85

Calls 15

done_object_cleanupFunction · 0.85
fqnameFunction · 0.85
vision_recalcFunction · 0.85
change_luckFunction · 0.85
store_versionFunction · 0.85
store_plname_in_fileFunction · 0.85
savelevFunction · 0.85
ledger_noFunction · 0.85
savegamestateFunction · 0.85
set_ustuckFunction · 0.85
maxledgernoFunction · 0.85
close_nhfileFunction · 0.85

Tested by

no test coverage detected