diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-29 01:08:06 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-29 01:14:47 -0800 |
commit | 7f9e84d7674d4a370c1514f40832afaf654736cc (patch) | |
tree | f286f068de02f1470c7db26ec80e5e4e72d66dd1 /crawl-ref/source/externs.h | |
parent | 83b3d564bcad6422fca7545cb5bc56fd9aa92a1c (diff) | |
download | crawl-ref-7f9e84d7674d4a370c1514f40832afaf654736cc.tar.gz crawl-ref-7f9e84d7674d4a370c1514f40832afaf654736cc.zip |
Reduce dependency on travel.h
Removed inclusion of travel.h from most .h files to reduce the number
of .cc files dependant on it. This involved moving the level_pos
declaration to externs.h, moving the flood_find template to it's own
header file, and moving two typedefs from travel.h to travel_defs.h
because typedefs can't be forward declared (argh).
Diffstat (limited to 'crawl-ref/source/externs.h')
-rw-r--r-- | crawl-ref/source/externs.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 979e7f81a7..51e2eea241 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -400,6 +400,66 @@ public: void load(reader&); }; +// A position on a particular level. +struct level_pos +{ + level_id id; + coord_def pos; // The grid coordinates on this level. + + level_pos() : id(), pos() + { + pos.x = pos.y = -1; + } + + level_pos(const level_id &lid, const coord_def &coord) + : id(lid), pos(coord) + { + } + + level_pos(const level_id &lid) + : id(lid), pos() + { + pos.x = pos.y = -1; + } + + // Returns the level_pos of where the player is standing. + static level_pos current(); + + bool operator == ( const level_pos &lp ) const + { + return id == lp.id && pos == lp.pos; + } + + bool operator != ( const level_pos &lp ) const + { + return id != lp.id || pos != lp.pos; + } + + bool operator < ( const level_pos &lp ) const + { + return (id < lp.id) || (id == lp.id && pos < lp.pos); + } + + bool is_valid() const + { + return id.depth > -1 && pos.x != -1 && pos.y != -1; + } + + bool is_on( const level_id _id) + { + return id == _id; + } + + void clear() + { + id.clear(); + pos = coord_def(-1, -1); + } + + void save(writer&) const; + void load(reader&); +}; + class monsters; struct item_def |