summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-10-23 01:35:58 -0700
committerMatthew Cline <zelgadis@sourceforge.net>2009-10-23 01:35:58 -0700
commit31429d39b7b11228e4731085f5f58958ef467eff (patch)
tree8a6f6ae5ac6b4b7b3fa4d3e1956a64bdec83adf5 /crawl-ref/source
parent4b41d9b5d515c32cd872e73fa91aaa702cc016c9 (diff)
downloadcrawl-ref-31429d39b7b11228e4731085f5f58958ef467eff.tar.gz
crawl-ref-31429d39b7b11228e4731085f5f58958ef467eff.zip
Removed 0.5 savefile minor versions, renumbered
Removed the savefile minor versions which were introducded in 0.5, since bumping the major version from 5 to 6 breaks compatibility with 0.5 savefiles. Renumbered the 0.6 minor versions to start with 0. This contains a hack to maintain compatibility with 0.6 savefiles before the renumbering, a hack which should be removed before 0.6 is released.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/files.cc32
-rw-r--r--crawl-ref/source/mapmark.cc14
-rw-r--r--crawl-ref/source/tags.cc101
-rw-r--r--crawl-ref/source/tags.h36
4 files changed, 73 insertions, 110 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 6e25f41248..1444025a33 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1958,8 +1958,11 @@ bool apply_to_all_dungeons(bool (*applicator)())
return (success);
}
-static bool _get_and_validate_version(FILE *restoreFile, char &major, char &minor,
- std::string* reason)
+// XXX: Minor version renumbering hack.
+bool _minor_renumbering_correction = false;
+
+static bool _get_and_validate_version(FILE *restoreFile, char &major,
+ char &minor, std::string* reason)
{
std::string dummy;
if (reason == 0)
@@ -1985,17 +1988,28 @@ static bool _get_and_validate_version(FILE *restoreFile, char &major, char &mino
return (false);
}
- // NOTE: This is a hacky replacement for what should have been caught
- // by MAJOR_VERSION above. Once the next major version update happens
- // (preferably when saves break with 0.5 -> 0.6) this check will need
- // to be removed.
- if (minor < TAG_MINOR_RELIGION)
+ if (minor < 0)
{
- *reason = "Sorry, but 0.4.x save and bones files are incompatible "
- "with 0.5!";
+ *reason = make_stringf("Minor version %d is negative!",
+ minor);
return (false);
}
+ // XXX: Temporary hack to avoid breaking savefile compatibility because
+ // of simply renumbering the minor-versions. Should be removed before
+ // 0.6 is released. 16 is the minor version which was introduced when
+ // the major version was bumped from 5 to 6.
+ COMPILE_CHECK(TAG_MINOR_VERSION < 16, c1);
+ if (minor >= 16)
+ {
+ mprf(MSGCH_WARN,
+ "Savefile minor version being changed from %d to %d "
+ "because of renumbering of minor versions after removing "
+ "0.5 minor versions.", minor, minor - 16);
+ minor -= 16;
+ _minor_renumbering_correction = true;
+ }
+
if (minor > TAG_MINOR_VERSION)
{
*reason = make_stringf("Minor version mismatch: %d (want <= %d).",
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 2a12913e28..794cfb74d5 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -804,21 +804,19 @@ void map_markers::write(writer &outf) const
void map_markers::read(reader &inf, int minorVersion)
{
+ UNUSED(minorVersion);
+
clear();
- if (minorVersion >= TAG_MINOR_MAPMARK)
- {
- const long cooky = unmarshallLong(inf);
- ASSERT(cooky == MARKERS_COOKY);
- UNUSED(cooky);
- }
+ const long cooky = unmarshallLong(inf);
+ ASSERT(cooky == MARKERS_COOKY);
+ UNUSED(cooky);
const int nmarkers = unmarshallShort(inf);
for (int i = 0; i < nmarkers; ++i)
{
// used by tools
- if (minorVersion >= TAG_MINOR_MAPMARK)
- unmarshallLong(inf);
+ unmarshallLong(inf);
if (map_marker *mark = map_marker::read_marker(inf))
{
add(mark);
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index d39b498be5..1f1e6a8b06 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -931,9 +931,6 @@ static void tag_construct_you(writer &th)
for (j = 0; j < NUM_ATTRIBUTES; ++j)
marshallLong(th, you.attribute[j]);
- // Was: remembered quiver items.
- marshallByte(th, 0);
-
// Sacrifice values.
marshallByte(th, NUM_OBJECT_CLASSES);
for (j = 0; j < NUM_OBJECT_CLASSES; ++j)
@@ -1003,20 +1000,15 @@ static void tag_construct_you(writer &th)
for (unsigned int k = 0; k < you.mesmerised_by.size(); k++)
marshallByte(th, you.mesmerised_by[k]);
- // minorVersion TAG_MINOR_PIETY starts here
marshallByte(th, you.piety_hysteresis);
- // minorVersion TAG_MINOR_QUIVER starts here
you.m_quiver->save(th);
- // minorVersion TAG_MINOR_FPICKUP starts here
marshallByte(th, you.friendly_pickup);
- // minorVersion TAG_MINOR_LUADGN starts here
if (!dlua.callfn("dgn_save_data", "u", &th))
mprf(MSGCH_ERROR, "Failed to save Lua data: %s", dlua.error.c_str());
- // minorVersion TAG_MINOR_GITREV starts here
// Write a human-readable string out on the off chance that
// we fail to be able to read this file back in using some later version.
std::string revision = "Git:";
@@ -1228,6 +1220,9 @@ static void tag_construct_lost_items(writer &th)
marshall_item_list );
}
+// XXX: Minor version renumbering hack.
+extern bool _minor_renumbering_correction;
+
static void tag_read_you(reader &th, char minorVersion)
{
char buff[20]; // For birth date.
@@ -1270,15 +1265,10 @@ static void tag_read_you(reader &th, char minorVersion)
you.level_type = static_cast<level_area_type>( unmarshallByte(th) );
you.level_type_name = unmarshallString(th);
- if (minorVersion >= TAG_MINOR_LUADGN)
- {
- you.level_type_name_abbrev = unmarshallString(th);
- you.level_type_origin = unmarshallString(th);
- you.level_type_tag = unmarshallString(th);
-
- if (minorVersion >= TAG_MINOR_PORTEXT)
- you.level_type_ext = unmarshallString(th);
- }
+ you.level_type_name_abbrev = unmarshallString(th);
+ you.level_type_origin = unmarshallString(th);
+ you.level_type_tag = unmarshallString(th);
+ you.level_type_ext = unmarshallString(th);
you.entry_cause = static_cast<entry_cause_type>( unmarshallByte(th) );
you.entry_cause_god = static_cast<god_type>( unmarshallByte(th) );
@@ -1376,13 +1366,14 @@ static void tag_read_you(reader &th, char minorVersion)
for (j = 0; j < count_c; ++j)
you.attribute[j] = unmarshallLong(th);
- // old: quiver info. Discard it.
- count_c = unmarshallByte(th);
- if (minorVersion >= TAG_MINOR_QUIVER)
+ // XXX: Hack to preserve compatibility despite renumbering the
+ // minor versions.
+ if (_minor_renumbering_correction)
+ {
+ // old: quiver info. Discard it.
+ count_c = unmarshallByte(th);
ASSERT(count_c == 0);
-
- for (j = 0; j < count_c; ++j)
- unmarshallByte(th);
+ }
count_c = unmarshallByte(th);
for (j = 0; j < count_c; ++j)
@@ -1440,24 +1431,17 @@ static void tag_read_you(reader &th, char minorVersion)
for (i = 0; i < count_c; i++)
you.mesmerised_by.push_back(unmarshallByte(th));
- if (minorVersion >= TAG_MINOR_PIETY)
- you.piety_hysteresis = unmarshallByte(th);
+ you.piety_hysteresis = unmarshallByte(th);
- if (minorVersion >= TAG_MINOR_QUIVER)
- you.m_quiver->load(th);
+ you.m_quiver->load(th);
- if (minorVersion >= TAG_MINOR_FPICKUP)
- you.friendly_pickup = unmarshallByte(th);
+ you.friendly_pickup = unmarshallByte(th);
- if (minorVersion >= TAG_MINOR_LUADGN)
- {
- if (!dlua.callfn("dgn_load_data", "u", &th))
- mprf(MSGCH_ERROR, "Failed to load Lua persist table: %s",
- dlua.error.c_str());
- }
+ if (!dlua.callfn("dgn_load_data", "u", &th))
+ mprf(MSGCH_ERROR, "Failed to load Lua persist table: %s",
+ dlua.error.c_str());
- if (minorVersion >= TAG_MINOR_SVNREV &&
- minorVersion < TAG_MINOR_GITREV)
+ if (minorVersion < TAG_MINOR_GITREV)
{
std::string rev_str = unmarshallString(th);
int rev_int = unmarshallLong(th);
@@ -2131,9 +2115,7 @@ static void unmarshall_monster(reader &th, monsters &m)
{
m.reset();
- if (_tag_minor_version >= TAG_MINOR_MONNAM)
- m.mname = unmarshallString(th, 100);
-
+ m.mname = unmarshallString(th, 100);
m.ac = unmarshallByte(th);
m.ev = unmarshallByte(th);
m.hit_dice = unmarshallByte(th);
@@ -2146,28 +2128,21 @@ static void unmarshall_monster(reader &th, monsters &m)
m.target.x = unmarshallByte(th);
m.target.y = unmarshallByte(th);
- if (_tag_minor_version >= TAG_MINOR_MPATROL)
- unmarshallCoord(th, m.patrol_point);
+ unmarshallCoord(th, m.patrol_point);
- if (_tag_minor_version >= TAG_MINOR_TRTARGET)
- {
- int help = unmarshallByte(th);
- m.travel_target = static_cast<montravel_target_type>(help);
- }
+ int help = unmarshallByte(th);
+ m.travel_target = static_cast<montravel_target_type>(help);
- if (_tag_minor_version >= TAG_MINOR_PATHFIND)
+ const int len = unmarshallShort(th);
+ for (int i = 0; i < len; ++i)
{
- const int len = unmarshallShort(th);
- for (int i = 0; i < len; ++i)
- {
- coord_def c;
- unmarshallCoord(th, c);
- m.travel_path.push_back(c);
- }
+ coord_def c;
+ unmarshallCoord(th, c);
+ m.travel_path.push_back(c);
}
- m.flags = unmarshallLong(th);
- m.experience = static_cast<unsigned long>(unmarshallLong(th));
+ m.flags = unmarshallLong(th);
+ m.experience = static_cast<unsigned long>(unmarshallLong(th));
m.enchantments.clear();
const int nenchs = unmarshallShort(th);
@@ -2182,11 +2157,7 @@ static void unmarshall_monster(reader &th, monsters &m)
m.hit_points = unmarshallShort(th);
m.max_hit_points = unmarshallShort(th);
m.number = unmarshallShort(th);
- if (_tag_minor_version >= TAG_MINOR_MONBASE)
- m.base_monster = static_cast<monster_type>(unmarshallShort(th));
- else
- m.base_monster = static_cast<monster_type>(m.number);
-
+ m.base_monster = static_cast<monster_type>(unmarshallShort(th));
m.colour = unmarshallShort(th);
for (int j = 0; j < NUM_MONSTER_SLOTS; j++)
@@ -2482,13 +2453,9 @@ static ghost_demon unmarshallGhost(reader &th, char minorVersion)
ghost_demon ghost;
ghost.name = unmarshallString(th, 20);
-
ghost.species = static_cast<species_type>( unmarshallShort(th) );
ghost.job = static_cast<job_type>( unmarshallShort(th) );
-
- if (minorVersion >= TAG_MINOR_RELIGION)
- ghost.religion = static_cast<god_type>( unmarshallByte(th) );
-
+ ghost.religion = static_cast<god_type>( unmarshallByte(th) );
ghost.best_skill = static_cast<skill_type>( unmarshallShort(th) );
ghost.best_skill_level = unmarshallShort(th);
ghost.xl = unmarshallShort(th);
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index 8d4f5e2e09..5b23eda941 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -47,32 +47,16 @@ enum tag_major_version
// the dungeon Lua changes.
enum tag_minor_version
{
- TAG_MINOR_PIETY = 2, // Added piety_hysteresis
- TAG_MINOR_QUIVER = 3, // Added quiver
- TAG_MINOR_MAPMARK = 4, // Added sizes to map markers
- TAG_MINOR_MONNAM = 5, // Monsters get individual names
- TAG_MINOR_MONBASE = 6, // Zombie base monster gets its own field.
- TAG_MINOR_FPICKUP = 7, // Added pickup option for allied monsters.
- TAG_MINOR_MPATROL = 8, // Added monster patrol points.
- TAG_MINOR_PATHFIND = 9, // Added monster pathfinding.
- TAG_MINOR_TRTARGET = 10, // Added travel target.
- TAG_MINOR_LUADGN = 11, // Allow dungeon Lua to persist data.
- // Bump version past 12.
- TAG_MINOR_SVNREV = 13, // Added SVN revision
- TAG_MINOR_PORTEXT = 14, // Keep track of portal vault extensions.
- TAG_MINOR_RELIGION = 15, // Keep track of ghosts' religions.
- // XXX: Release 0.5 -> switch to major version 6
- // Does that mean we can remove all the above minor version checks?
- TAG_MINOR_ARTEFACT = 16, // Turned fixed arts into unrandarts.
- TAG_MINOR_JIYVA = 17, // Added some player bits for Jiyva.
- TAG_MINOR_ZOT_OPEN = 18, // Remember whether Zot was opened.
- TAG_MINOR_JELLY = 19, // Remember whether the royal jelly is dead.
- TAG_ANNOTATE_EXCL = 20, // Store exclusion information for annotations.
- TAG_MINOR_UGLY = 21, // More ghost bits for (very) ugly things.
- TAG_MINOR_ROTTING = 22, // Added monster-specific rotting resistance.
- TAG_MINOR_TRANS = 23, // Keep track of cancellable transformations.
- TAG_MINOR_GITREV = 24, // Removed SVN revision and added Git revision.
- TAG_MINOR_VERSION = 24 // Current version. (Keep equal to max.)
+ TAG_MINOR_ARTEFACT = 0, // Turned fixed arts into unrandarts.
+ TAG_MINOR_JIYVA = 1, // Added some player bits for Jiyva.
+ TAG_MINOR_ZOT_OPEN = 2, // Remember whether Zot was opened.
+ TAG_MINOR_JELLY = 3, // Remember whether the royal jelly is dead.
+ TAG_ANNOTATE_EXCL = 4, // Store exclusion information for annotations.
+ TAG_MINOR_UGLY = 5, // More ghost bits for (very) ugly things.
+ TAG_MINOR_ROTTING = 6, // Added monster-specific rotting resistance.
+ TAG_MINOR_TRANS = 7, // Keep track of cancellable transformations.
+ TAG_MINOR_GITREV = 8, // Removed SVN revision and added Git revision.
+ TAG_MINOR_VERSION = 8 // Current version. (Keep equal to max.)
};