diff options
author | Florian Diebold <flodiebold@gmail.com> | 2011-12-01 22:12:51 +0100 |
---|---|---|
committer | Florian Diebold <flodiebold@gmail.com> | 2011-12-01 23:11:48 +0100 |
commit | a974ddbca26c65f6d293be9c968991e2696ea244 (patch) | |
tree | 4aa7f7e3ad7f3d0786763d843213fe774410ccdd /crawl-ref/source/map_knowledge.h | |
parent | 30efafb7cff94fb53cd9117f4cdea8ea4829428e (diff) | |
download | crawl-ref-a974ddbca26c65f6d293be9c968991e2696ea244.tar.gz crawl-ref-a974ddbca26c65f6d293be9c968991e2696ea244.zip |
Add more cloud data to map_knowledge; make tilepick.cc use it instead of the actual cloud_struct.
This adds the cloud tile and the value of cloud.decay/20, clipped to
the range 0-3, to the map_knowledge, and organizes all cloud-related
data into a new cloud_info struct. Both of these are required for the
tile picking code.
(Doesn't introduce a new minor tag, so saves from the previous commit
will crash.)
Diffstat (limited to 'crawl-ref/source/map_knowledge.h')
-rw-r--r-- | crawl-ref/source/map_knowledge.h | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/crawl-ref/source/map_knowledge.h b/crawl-ref/source/map_knowledge.h index aaeddca511..2b1a523403 100644 --- a/crawl-ref/source/map_knowledge.h +++ b/crawl-ref/source/map_knowledge.h @@ -4,6 +4,23 @@ #include "show.h" #include "mon-info.h" +struct cloud_info +{ + cloud_info() : type(CLOUD_NONE), colour(0), duration(3), tile(0), pos(0, 0) + { } + + cloud_info(cloud_type t, uint8_t c, + uint8_t dur, tileidx_t til, coord_def gc) + : type(t), colour(c), duration(dur), tile(til), pos(gc) + { } + + cloud_type type:8; + uint8_t colour; + uint8_t duration; // decay/20, clamped to 0-3 + tileidx_t tile; + coord_def pos; +}; + #define MAP_MAGIC_MAPPED_FLAG 0x01 #define MAP_SEEN_FLAG 0x02 #define MAP_CHANGED_FLAG 0x04 // FIXME: this doesn't belong here @@ -38,7 +55,7 @@ struct map_cell { map_cell() : flags(0), _feat(DNGN_UNSEEN), _feat_colour(0), - _cloud(CLOUD_NONE), _cloud_colour(0), _item(0), _mons(0), + _cloud(0), _item(0), _mons(0), _trap(TRAP_UNASSIGNED) { } @@ -46,6 +63,8 @@ struct map_cell map_cell(const map_cell& c) { memcpy(this, &c, sizeof(map_cell)); + if (_cloud) + _cloud = new cloud_info(*_cloud); if (_mons) _mons = new monster_info(*_mons); if (_item) @@ -54,6 +73,8 @@ struct map_cell ~map_cell() { + if (_cloud) + delete _cloud; if (!(flags & MAP_DETECTED_MONSTER) && _mons) delete _mons; if (_item) @@ -64,11 +85,15 @@ struct map_cell { if (&c == this) return (*this); + if (_cloud) + delete _cloud; if (_mons) delete _mons; if (_item) delete _item; memcpy(this, &c, sizeof(map_cell)); + if (_cloud) + _cloud = new cloud_info(*_cloud); if (_mons) _mons = new monster_info(*_mons); if (_item) @@ -190,18 +215,28 @@ struct map_cell cloud_type cloud() const { - return _cloud; + if (_cloud) + return _cloud->type; + else + return CLOUD_NONE; } unsigned cloud_colour() const { - return _cloud_colour; + if (_cloud) + return _cloud->colour; + else + return 0; + } + + cloud_info* cloudinfo() const + { + return _cloud; } - void set_cloud(cloud_type ncloud, unsigned colour = 0) + void set_cloud(const cloud_info& ci) { - _cloud = ncloud; - _cloud_colour = colour; + _cloud = new cloud_info(ci); } bool known() const @@ -244,8 +279,7 @@ private: dungeon_feature_type _feat:8; #endif uint8_t _feat_colour; - cloud_type _cloud:8; - uint8_t _cloud_colour; + cloud_info* _cloud; item_info* _item; monster_info* _mons; trap_type _trap:8; |