summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-26 13:47:37 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-05-26 13:47:37 +0000
commita33ad3c3e6b0bf53a63554e96eb52db78b4a48f0 (patch)
tree8ff69133c16dfb19852f0e52b75283864eb60cdd /crawl-ref/source/files.cc
parentd73035c53987d171d07b7a39fdd23caf4f5967f5 (diff)
downloadcrawl-ref-a33ad3c3e6b0bf53a63554e96eb52db78b4a48f0.tar.gz
crawl-ref-a33ad3c3e6b0bf53a63554e96eb52db78b4a48f0.zip
Run some sanity checks when loading ghosts. If anything seems fishy
* don't load the ghost(s) * print an error message mentioning the bones file * don't delete the bones file, so players can attach it to a bug report The last point means that the player (or admin, in the case of the servers) has to delete a buggy bones file themselves, but the benefits of making tracking down bugs easier should outweigh that inconvenience. Add a new wizmode command that calls debug_stethoscope even if the game is not compiled in debugging mode. Also, Stone Soup 0.5 bones files are now officially incompatible with 0.4. (The changes to the spell ids cause ghosts casting spells to crash the game.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9832 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index e0fe414bde..4ea0bd5fee 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1600,7 +1600,7 @@ void _load_ghost(void)
if (!_determine_ghost_version(gfile, majorVersion, minorVersion))
{
fclose(gfile);
-#if DEBUG_DIAGNOSTICS
+#if DEBUG_BONES | DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS,
"Ghost file \"%s\" seems to be invalid.", cha_fil.c_str());
more();
@@ -1610,7 +1610,6 @@ void _load_ghost(void)
if (majorVersion != TAG_MAJOR_VERSION || minorVersion > TAG_MINOR_VERSION)
{
-
fclose(gfile);
unlink(cha_fil.c_str());
return;
@@ -1623,7 +1622,7 @@ void _load_ghost(void)
if (!feof(gfile))
{
fclose(gfile);
-#if DEBUG_DIAGNOSTICS
+#if DEBUG_BONES | DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Incomplete read of \"%s\".",
cha_fil.c_str() );
more();
@@ -1633,7 +1632,15 @@ void _load_ghost(void)
fclose(gfile);
-#if DEBUG_DIAGNOSTICS
+ if (!debug_check_ghosts())
+ {
+ mprf(MSGCH_DIAGNOSTICS, "Refusing to load buggy ghost from file \"%s\"! "
+ "Please submit a bug report.",
+ cha_fil.c_str());
+ return;
+ }
+
+#if DEBUG_BONES | DEBUG_DIAGNOSTICS
mpr("Loaded ghost.", MSGCH_DIAGNOSTICS);
#endif