summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/ouch.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-12 22:17:01 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-12 22:19:32 +0100
commitc9bda0d87efaabba61def8217432a2d6b61836a8 (patch)
treea30fa6515bd77ec4a3a31a1602d005398de0d885 /crawl-ref/source/ouch.cc
parentcbb378630e7900bcd7109a6527e173e691fdf858 (diff)
downloadcrawl-ref-c9bda0d87efaabba61def8217432a2d6b61836a8.tar.gz
crawl-ref-c9bda0d87efaabba61def8217432a2d6b61836a8.zip
Extract and move file deletion on game end.
This should prevent problems with the morgue dump from making a game unlosable, fixing 2782923. Note that the other problem in that bug report (crash of mons_type_name on invalid monster type) has already been fixed.
Diffstat (limited to 'crawl-ref/source/ouch.cc')
-rw-r--r--crawl-ref/source/ouch.cc60
1 files changed, 33 insertions, 27 deletions
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 5b6cf0a010..b3912a3e1f 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -1218,34 +1218,9 @@ static std::string morgue_name(time_t when_crawl_got_even)
#endif // SHORT_FILE_NAMES
}
-void end_game( scorefile_entry &se )
+// Delete save files on game end.
+static void delete_files()
{
- bool dead = true;
-
- for (int i = 0; i < ENDOFPACK; i++)
- set_ident_flags( you.inv[i], ISFLAG_IDENT_MASK );
-
- for (int i = 0; i < ENDOFPACK; i++)
- {
- if (you.inv[i].base_type != 0)
- set_ident_type( you.inv[i], ID_KNOWN_TYPE );
- }
-
- if (!dump_char( morgue_name(se.death_time), !dead, true, &se ))
- {
- mpr("Char dump unsuccessful! Sorry about that.");
- if (!crawl_state.seen_hups)
- more();
- clrscr();
- }
-
- if (se.death_type == KILLED_BY_LEAVING
- || se.death_type == KILLED_BY_QUITTING
- || se.death_type == KILLED_BY_WINNING)
- {
- dead = false;
- }
-
// clean all levels that we think we have ever visited
for (level_id_set::const_iterator i = Generated_Levels.begin();
i != Generated_Levels.end(); ++i)
@@ -1289,6 +1264,37 @@ void end_game( scorefile_entry &se )
std::string tmpname = basename + suffixes[i];
unlink( tmpname.c_str() );
}
+}
+
+void end_game(scorefile_entry &se)
+{
+ bool dead = true;
+
+ for (int i = 0; i < ENDOFPACK; i++)
+ set_ident_flags( you.inv[i], ISFLAG_IDENT_MASK );
+
+ for (int i = 0; i < ENDOFPACK; i++)
+ {
+ if (you.inv[i].base_type != 0)
+ set_ident_type( you.inv[i], ID_KNOWN_TYPE );
+ }
+
+ delete_files();
+
+ if (!dump_char( morgue_name(se.death_time), !dead, true, &se ))
+ {
+ mpr("Char dump unsuccessful! Sorry about that.");
+ if (!crawl_state.seen_hups)
+ more();
+ clrscr();
+ }
+
+ if (se.death_type == KILLED_BY_LEAVING
+ || se.death_type == KILLED_BY_QUITTING
+ || se.death_type == KILLED_BY_WINNING)
+ {
+ dead = false;
+ }
// death message
if (dead)