summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tags.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-25 00:01:38 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-25 00:01:38 +0000
commit97f93f7d2dd30fee884ee4eeb8a16dcb51cf4a7c (patch)
treeef959b41c9373a02d6424717be5cbcbd1c72782f /crawl-ref/source/tags.cc
parentbe49ad27a08b4d5a5e347e6d8a2e6852f81c4a8b (diff)
downloadcrawl-ref-97f93f7d2dd30fee884ee4eeb8a16dcb51cf4a7c.tar.gz
crawl-ref-97f93f7d2dd30fee884ee4eeb8a16dcb51cf4a7c.zip
Allow ziggurats placed in Pandemonium to return to the same Pan level when the player leaves the ziggurat. Breaks saves.
Cleaned up up_stairs() and down_stairs() to remove spurious depth changes when changing you.level_type - depth (you.your_level) now changes only for stairs with both ends in LEVEL_DUNGEON. All levels are now saved on exit, including non LEVEL_DUNGEON levels. Re-entering non-dungeon levels from down_stairs will still delete the old level. Re-entering non-dungeon levels from up_stairs (i.e. returning to a non-dungeon level from some other place, like a ziggurat) will reload the old level. Fixed bogus marker trashing when player attempts to use a Zot entrance with insufficient runes. Delete .msg files when game ends. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7598 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tags.cc')
-rw-r--r--crawl-ref/source/tags.cc55
1 files changed, 31 insertions, 24 deletions
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 3e6c484140..409b35f06a 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -96,7 +96,8 @@ extern std::map<level_pos, char> portal_vault_colours;
extern std::map<level_id, std::string> level_annotations;
// temp file pairs used for file level cleanup
-FixedArray < bool, MAX_LEVELS, NUM_BRANCHES > tmp_file_pairs;
+
+level_id_set Generated_Levels;
// The minor version for the tag currently being read.
static int _tag_minor_version = -1;
@@ -292,6 +293,16 @@ void marshall_as_long(writer& th, const T& t)
marshallLong( th, static_cast<long>(t) );
}
+template <typename data>
+void marshallSet(writer &th, const std::set<data> &s,
+ void (*marshall)(writer &, const data &))
+{
+ marshallLong( th, s.size() );
+ typename std::set<data>::const_iterator i = s.begin();
+ for ( ; i != s.end(); ++i)
+ marshall(th, *i);
+}
+
template<typename key, typename value>
void marshallMap(writer &th, const std::map<key,value>& data,
void (*key_marshall)(writer&, const key&),
@@ -354,6 +365,16 @@ void marshall_level_pos( writer& th, const level_pos& lpos )
marshall_level_id(th, lpos.id);
}
+template <typename data, typename set>
+void unmarshallSet(reader &th, set &dset,
+ data (*data_unmarshall)(reader &))
+{
+ dset.clear();
+ long len = unmarshallLong(th);
+ for (long i = 0L; i < len; ++i)
+ dset.insert(data_unmarshall(th));
+}
+
template<typename key, typename value, typename map>
void unmarshallMap(reader& th, map& data,
key (*key_unmarshall) (reader&),
@@ -1096,25 +1117,20 @@ static void marshallPlaceInfo(writer &th, PlaceInfo place_info)
static void tag_construct_you_dungeon(writer &th)
{
- int i,j;
-
// how many unique creatures?
marshallShort(th, NUM_MONSTERS);
- for (j = 0; j < NUM_MONSTERS; ++j)
+ for (int j = 0; j < NUM_MONSTERS; ++j)
marshallByte(th,you.unique_creatures[j]); // unique beasties
// how many branches?
marshallByte(th, NUM_BRANCHES);
- for (j = 0; j < NUM_BRANCHES; ++j)
+ for (int j = 0; j < NUM_BRANCHES; ++j)
{
marshallLong(th, branches[j].startdepth);
marshallLong(th, branches[j].branch_flags);
}
- marshallShort(th, MAX_LEVELS);
- for (i = 0; i < MAX_LEVELS; ++i)
- for (j = 0; j < NUM_BRANCHES; ++j)
- marshallBoolean(th, tmp_file_pairs[i][j]);
+ marshallSet(th, Generated_Levels, marshall_level_id);
marshallMap(th, stair_level,
marshall_as_long<branch_type>, marshall_level_id);
@@ -1542,16 +1558,10 @@ static PlaceInfo unmarshallPlaceInfo(reader &th)
static void tag_read_you_dungeon(reader &th)
{
- int i,j;
- int count_c;
- short count_s;
-
- unsigned short count_p;
-
// how many unique creatures?
- count_c = unmarshallShort(th);
+ int count_c = unmarshallShort(th);
you.unique_creatures.init(false);
- for (j = 0; j < count_c; ++j)
+ for (int j = 0; j < count_c; ++j)
{
const bool created = static_cast<bool>(unmarshallByte(th));
@@ -1561,16 +1571,13 @@ static void tag_read_you_dungeon(reader &th)
// how many branches?
count_c = unmarshallByte(th);
- for (j = 0; j < count_c; ++j)
+ for (int j = 0; j < count_c; ++j)
{
branches[j].startdepth = unmarshallLong(th);
branches[j].branch_flags = (unsigned long) unmarshallLong(th);
}
- count_s = unmarshallShort(th);
- for (i = 0; i < count_s; ++i)
- for (j = 0; j < count_c; ++j)
- tmp_file_pairs[i][j] = unmarshallBoolean(th);
+ unmarshallSet(th, Generated_Levels, unmarshall_level_id);
unmarshallMap(th, stair_level,
unmarshall_long_as<branch_type>,
@@ -1593,12 +1600,12 @@ static void tag_read_you_dungeon(reader &th)
you.set_place_info(place_info);
std::vector<PlaceInfo> list = you.get_all_place_info();
- count_p = (unsigned short) unmarshallShort(th);
+ unsigned short count_p = (unsigned short) unmarshallShort(th);
// Use "<=" so that adding more branches or non-dungeon places
// won't break save-file compatibility.
ASSERT(count_p <= list.size());
- for (i = 0; i < count_p; i++)
+ for (int i = 0; i < count_p; i++)
{
place_info = unmarshallPlaceInfo(th);
ASSERT(!place_info.is_global());