1 /**
2  * @file
3  * @brief Functions dealing with env.map_knowledge.
4 **/
5 
6 #include "AppHdr.h"
7 
8 #include "fprop.h"
9 
10 #include "coord.h"
11 #include "env.h"
12 #include "libutil.h"
13 #include "terrain.h"
14 
is_sanctuary(const coord_def & p)15 bool is_sanctuary(const coord_def& p)
16 {
17     if (!map_bounds(p))
18         return false;
19     const bool sanct = (testbits(env.pgrid(p), FPROP_SANCTUARY_1)
20                         || testbits(env.pgrid(p), FPROP_SANCTUARY_2));
21     if (sanct)
22         ASSERT_IN_BOUNDS(env.sanctuary_pos);
23     return sanct;
24 }
25 
is_bloodcovered(const coord_def & p)26 bool is_bloodcovered(const coord_def& p)
27 {
28     return testbits(env.pgrid(p), FPROP_BLOODY);
29 }
30 
is_icecovered(const coord_def & p)31 bool is_icecovered(const coord_def& p)
32 {
33     return feat_is_wall(env.grid(p)) && testbits(env.pgrid(p), FPROP_ICY);
34 }
35 
is_tide_immune(const coord_def & p)36 bool is_tide_immune(const coord_def &p)
37 {
38     return bool(env.pgrid(p) & FPROP_NO_TIDE);
39 }
40 
str_to_fprop(const string & str)41 feature_property_type str_to_fprop(const string &str)
42 {
43     if (str == "bloody")
44         return FPROP_BLOODY;
45     if (str == "highlight")
46         return FPROP_HIGHLIGHT;
47     if (str == "no_cloud_gen")
48         return FPROP_NO_CLOUD_GEN;
49     if (str == "no_tele_into")
50         return FPROP_NO_TELE_INTO;
51     if (str == "no_tide")
52         return FPROP_NO_TIDE;
53     if (str == "no_jiyva")
54         return FPROP_NO_JIYVA;
55 
56     return FPROP_NONE;
57 }
58 
blood_rotation(const coord_def & p)59 char blood_rotation(const coord_def & p)
60 {
61     return (env.pgrid(p) & FPROP_BLOOD_EAST).flags >> 16;
62 }
63