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/show.cc | |
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/show.cc')
-rw-r--r-- | crawl-ref/source/show.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/crawl-ref/source/show.cc b/crawl-ref/source/show.cc index 2290725962..5a60fea988 100644 --- a/crawl-ref/source/show.cc +++ b/crawl-ref/source/show.cc @@ -31,6 +31,7 @@ #include "terrain.h" #ifdef USE_TILE #include "tileview.h" + #include "tiledef-main.h" #endif #include "traps.h" #include "travel.h" @@ -253,12 +254,39 @@ static void _update_item_at(const coord_def &gp) static void _update_cloud(int cloudno) { - const coord_def gp = env.cloud[cloudno].pos; - cloud_type cloud = env.cloud[cloudno].type; - env.map_knowledge(gp).set_cloud(cloud, get_cloud_colour(cloudno)); + cloud_struct& cloud = env.cloud[cloudno]; + const coord_def gp = cloud.pos; + + tileidx_t ch = 0; + +#ifdef USE_TILE + tileidx_t index = 0; + if (!cloud.tile.empty()) + { + if (!tile_main_index(cloud.tile.c_str(), &index)) + { + mprf(MSGCH_ERROR, "Invalid tile requested for cloud: '%s'.", cloud.tile.c_str()); + ch = TILE_ERROR; + } + else + { + int offset = tile_main_count(index); + ch = index + offset; + } + } +#endif + + int dur = cloud.decay/20; + if (dur < 0) + dur = 0; + else if (dur > 3) + dur = 3; + + cloud_info ci(cloud.type, get_cloud_colour(cloudno), dur, ch, gp); + env.map_knowledge(gp).set_cloud(ci); #ifdef USE_TILE - tile_place_cloud(gp, env.cloud[cloudno]); + tile_place_cloud(gp, *env.map_knowledge(gp).cloudinfo()); #endif } |