summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/externs.h
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/externs.h
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/externs.h')
-rw-r--r--crawl-ref/source/externs.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 6c75be735d..ef22c4eb6d 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -434,6 +434,107 @@ struct delay_queue_item
};
+// Identifies a level. Should never include virtual methods or
+// dynamically allocated memory (see code to push level_id onto Lua
+// stack in luadgn.cc)
+class level_id
+{
+public:
+ branch_type branch; // The branch in which the level is.
+ int depth; // What depth (in this branch - starting from 1)
+ level_area_type level_type;
+
+public:
+ // Returns the level_id of the current level.
+ static level_id current();
+
+ // Returns the level_id of the level that the stair/portal/whatever at
+ // 'pos' on the current level leads to.
+ static level_id get_next_level_id(const coord_def &pos);
+
+ level_id()
+ : branch(BRANCH_MAIN_DUNGEON), depth(-1),
+ level_type(LEVEL_DUNGEON)
+ {
+ }
+ level_id(branch_type br, int dep, level_area_type ltype = LEVEL_DUNGEON)
+ : branch(br), depth(dep), level_type(ltype)
+ {
+ }
+ level_id(const level_id &ot)
+ : branch(ot.branch), depth(ot.depth), level_type(ot.level_type)
+ {
+ }
+ level_id(level_area_type ltype)
+ : branch(BRANCH_MAIN_DUNGEON), depth(-1), level_type(ltype)
+ {
+ }
+
+ static level_id parse_level_id(const std::string &s) throw (std::string);
+
+ unsigned short packed_place() const;
+ std::string describe(bool long_name = false, bool with_number = true) const;
+
+ void clear()
+ {
+ branch = BRANCH_MAIN_DUNGEON;
+ depth = -1;
+ level_type = LEVEL_DUNGEON;
+ }
+
+ int absdepth() const;
+
+ bool is_valid() const
+ {
+ return (branch != NUM_BRANCHES && depth != -1)
+ || level_type != LEVEL_DUNGEON;
+ }
+
+ const level_id &operator = (const level_id &id)
+ {
+ branch = id.branch;
+ depth = id.depth;
+ level_type = id.level_type;
+ return (*this);
+ }
+
+ bool operator == ( const level_id &id ) const
+ {
+ return (level_type == id.level_type
+ && (level_type != LEVEL_DUNGEON
+ || (branch == id.branch && depth == id.depth)));
+ }
+
+ bool operator != ( const level_id &id ) const
+ {
+ return !operator == (id);
+ }
+
+ bool operator <( const level_id &id ) const
+ {
+ if (level_type != id.level_type)
+ return (level_type < id.level_type);
+
+ if (level_type != LEVEL_DUNGEON)
+ return (false);
+
+ return (branch < id.branch) || (branch==id.branch && depth < id.depth);
+ }
+
+ bool operator == ( const branch_type _branch ) const
+ {
+ return (branch == _branch && level_type == LEVEL_DUNGEON);
+ }
+
+ bool operator != ( const branch_type _branch ) const
+ {
+ return !operator == (_branch);
+ }
+
+ void save(writer&) const;
+ void load(reader&);
+};
+
struct item_def
{
object_class_type base_type; // basic class (ie OBJ_WEAPON)