From 4c1860113f640efeb503505542393f3dccdd5060 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 12 Dec 2006 19:53:45 +0000 Subject: Tweaked stash-tracker so that greedy explore works in Pandemonium. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@621 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/travel.h | 56 ++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'crawl-ref/source/travel.h') diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h index b84d2d0584..c92dcbfb1a 100644 --- a/crawl-ref/source/travel.h +++ b/crawl-ref/source/travel.h @@ -109,24 +109,34 @@ enum explore_stop_type //////////////////////////////////////////////////////////////////////////// // Structs for interlevel travel. -// Identifies a level. This has no meaning in the Abyss, labyrinths or -// Pandemonium. +// Identifies a level. struct level_id { - unsigned char branch; // The branch in which the level is. - int depth; // What depth (in this branch - starting from 1) - // this level is. - - level_id() : branch(0), depth(-1) { } +public: + int branch; // The branch in which the level is. + int depth; // What depth (in this branch - starting from 1) + int level_type; - level_id(unsigned char br, int dep) : branch(br), depth(dep) { } +public: + level_id() : branch(0), depth(-1), level_type(LEVEL_DUNGEON) { } + level_id(int br, int dep, int ltype = LEVEL_DUNGEON) + : branch(br), depth(dep), level_type(ltype) + { + if (level_type != LEVEL_DUNGEON) + branch = depth = -1; + } + level_id(int ltype) : branch(-1), depth(-1), level_type(ltype) { } unsigned short packed_place() const; + std::string describe(bool long_name = false, bool with_number = true) const; - std::string describe( bool long_name, bool with_number ) const; + bool is_valid() const + { + return (branch != -1 && depth != -1) || level_type != LEVEL_DUNGEON; + } // Returns the level_id of the current level. - static level_id get_current_level_id(); + static level_id current(); // Returns the level_id of the level that the stair/portal/whatever at // 'pos' on the current level leads to. @@ -134,28 +144,24 @@ struct level_id bool operator == ( const level_id &id ) const { - return branch == id.branch && depth == id.depth; + return branch == id.branch && depth == id.depth + && level_type == id.level_type; } bool operator != ( const level_id &id ) const { - return branch != id.branch || depth != id.depth; + return branch != id.branch || depth != id.depth + || level_type != id.level_type; } bool operator <( const level_id &id ) const { + if (level_type != id.level_type) + return (level_type < id.level_type); + return (branch < id.branch) || (branch==id.branch && depth < id.depth); } - struct less_than - { - bool operator () (const level_id &first, const level_id &second) const - { - return first.branch < second.branch || - (first.branch == second.branch && first.depth < second.depth); - } - }; - void save(FILE *) const; void load(FILE *); }; @@ -359,6 +365,12 @@ public: return li; } + LevelInfo *find_level_info(const level_id &lev) + { + std::map::iterator i = levels.find(lev); + return (i != levels.end()? &i->second : NULL); + } + bool know_level(const level_id &lev) const { return levels.find(lev) != levels.end(); @@ -391,7 +403,7 @@ private: void fixup_levels(); private: - std::map levels; + std::map levels; level_pos waypoints[TRAVEL_WAYPOINT_COUNT]; }; -- cgit v1.2.3-54-g00ecf