summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-09 14:24:11 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-09 14:24:11 +0000
commitf2a95ba0d453ba6685ed29201beda8a2f703ab79 (patch)
treee7201beb995472236921334a363644e5782d648b /crawl-ref/source/files.cc
parent447bc8ac9d8557be01da02c40349e4301f42c089 (diff)
downloadcrawl-ref-f2a95ba0d453ba6685ed29201beda8a2f703ab79.tar.gz
crawl-ref-f2a95ba0d453ba6685ed29201beda8a2f703ab79.zip
Monsters get multilevel resists (incomplete). Monster data needs to be
adjusted per monster to hand out the right resists. The current MR_RES_FIRE gives one level of resistance only. Added a real ghost structure, discarded the old ghost values array. Adjusted bones file format so bones will work out-of-the-box with Hearse. Breaks bones format, older bones will be rejected. Fixed some maps with bad DEPTHs. Added more safe answers in Y/N prompts, added a check to make it less likely that Crawl will spin in a tight loop reading input from a closed tty. (Experimental) !a will override existing foe of friendlies in LOS. Blademasters no longer pick up stuff to throw (Erik). Zombies of swimming things are also swimming things. Currently applies only to zombies explicitly placed in .des files, since fish zombies cannot be generated otherwise (can of worms). Morgue is now saved before showing the inventory and other boring end-of-game stuff. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3231 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc73
1 files changed, 53 insertions, 20 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 78d8edb5ef..932c0a6a2c 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -63,6 +63,7 @@
#include "direct.h"
#include "dungeon.h"
#include "effects.h"
+#include "ghost.h"
#include "initfile.h"
#include "itemname.h"
#include "itemprop.h"
@@ -107,6 +108,8 @@ void save_level(int level_saved, level_area_type lt,
#define LEVEL_MINOR_VERSION 1
#define YOU_MINOR_VERSION 1
+const short GHOST_SIGNATURE = static_cast<short>( 0xDC55 );
+
static void redraw_all(void)
{
you.redraw_hit_points = 1;
@@ -601,8 +604,41 @@ std::string make_filename( const char *prefix, int level, branch_type where,
isGhost );
}
+static void write_version( FILE *dataFile, int majorVersion, int minorVersion,
+ bool extended_version )
+{
+ // write version
+ tagHeader versionTag;
+ versionTag.offset = 0;
+ versionTag.tagID = TAG_VERSION;
+
+ marshallByte(versionTag, majorVersion);
+ marshallByte(versionTag, minorVersion);
+
+ // extended_version just pads the version out to four 32-bit words.
+ // This makes the bones file compatible with Hearse with no extra
+ // munging needed.
+ if (extended_version)
+ {
+ // Use a single signature 16-bit word to indicate that this is
+ // Stone Soup and to disambiguate this (unmunged) bones file
+ // from the munged bones files offered by the old Crawl-aware
+ // hearse.pl. Crawl-aware hearse.pl will prefix the bones file
+ // with the first 16-bits of the Crawl version, and the following
+ // 7 16-bit words set to 0.
+ marshallShort(versionTag, GHOST_SIGNATURE);
+
+ // Write the three remaining 32-bit words of padding.
+ for (int i = 0; i < 3; ++i)
+ marshallLong(versionTag, 0);
+ }
+
+ tag_write(versionTag, dataFile);
+}
+
static void write_tagged_file( FILE *dataFile, char majorVersion,
- char minorVersion, int fileType )
+ char minorVersion, int fileType,
+ bool extended_version = false )
{
struct tagHeader th;
@@ -610,13 +646,7 @@ static void write_tagged_file( FILE *dataFile, char majorVersion,
char tags[NUM_TAGS];
tag_set_expected(tags, fileType);
- // write version
- struct tagHeader versionTag;
- versionTag.offset = 0;
- versionTag.tagID = TAG_VERSION;
- marshallByte(versionTag, majorVersion);
- marshallByte(versionTag, minorVersion);
- tag_write(versionTag, dataFile);
+ write_version( dataFile, majorVersion, minorVersion, extended_version );
// all other tags
for(int i=1; i<NUM_TAGS; i++)
@@ -1606,21 +1636,23 @@ static bool determine_ghost_version( FILE *ghostFile,
if (read2(ghostFile, buf, 2) != 2)
return false; // empty file?
- // check for pre-v4 -- simply started right in with ghost name.
- if (isprint(buf[0]) && buf[0] > 4)
- {
- majorVersion = 0;
- minorVersion = 0;
- rewind(ghostFile);
- return true;
- }
-
// otherwise, read version and validate.
majorVersion = buf[0];
minorVersion = buf[1];
- if (majorVersion == SAVE_MAJOR_VERSION)
- return true;
+ // check for the DCSS ghost signature.
+ if (readShort(ghostFile) != GHOST_SIGNATURE)
+ return (false);
+
+ if (majorVersion == SAVE_MAJOR_VERSION
+ && minorVersion <= GHOST_MINOR_VERSION)
+ {
+ // Discard three more 32-bit words of padding.
+ for (int i = 0; i < 3; ++i)
+ readLong(ghostFile);
+
+ return !feof(ghostFile);
+ }
return false; // if its not SAVE_MAJOR_VERSION, no idea!
}
@@ -1669,7 +1701,8 @@ void save_ghost( bool force )
}
write_tagged_file( gfile, SAVE_MAJOR_VERSION,
- GHOST_MINOR_VERSION, TAGTYPE_GHOST );
+ GHOST_MINOR_VERSION, TAGTYPE_GHOST,
+ true );
lk_close(gfile, "wb", cha_fil);