diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/acr.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/defines.h | 17 | ||||
-rw-r--r-- | crawl-ref/source/directn.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/it_use2.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/los.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/los.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/losparam.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mon-los.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/newgame.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/view.h | 1 |
14 files changed, 36 insertions, 29 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index e4ba83d5cd..0b782be733 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3620,7 +3620,7 @@ static bool _initialise(void) you.lava_in_sight = you.water_in_sight = -1; // Set vision radius to player's current vision. - setLOSRadius(you.current_vision); + set_los_radius(you.current_vision); init_exclusion_los(); if (newc) // start a new game diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h index a5ca761886..ef22c9d029 100644 --- a/crawl-ref/source/defines.h +++ b/crawl-ref/source/defines.h @@ -106,18 +106,23 @@ const int LABYRINTH_BORDER = 4; #define Y_ABYSS_WIDTH (Y_ABYSS_2 - Y_ABYSS_1 + 1) #define Y_ABYSS_CENTER (Y_ABYSS_1 + Y_ABYSS_WIDTH / 2) -#define LOS_RADIUS 8 +// default LOS radius +#define LOS_RADIUS 10 +// default LOS radius squared, for comparison with distance() #define LOS_RADIUS_SQ (LOS_RADIUS * LOS_RADIUS + 1) +// maximal LOS radius #define LOS_MAX_RADIUS LOS_RADIUS #define LOS_MAX_RADIUS_SQ (LOS_MAX_RADIUS * LOS_MAX_RADIUS + 1) -#define LOS_MAX_RADIUS LOS_RADIUS +// maximal horizontal or vertical LOS range: +// a quadrant needs to fit inside an 2D array with +// 0 <= x, y <= LOS_MAX_RANGE #define LOS_MAX_RANGE LOS_MAX_RADIUS -#define ENV_SHOW_OFFSET (LOS_MAX_RANGE + 1) +#define ENV_SHOW_OFFSET LOS_MAX_RANGE #define ENV_SHOW_DIAMETER (ENV_SHOW_OFFSET * 2 + 1) #define VIEW_BASE_WIDTH 33 // FIXME: never used -#define VIEW_MIN_WIDTH 17 -#define VIEW_MIN_HEIGHT 17 +#define VIEW_MIN_WIDTH ENV_SHOW_DIAMETER +#define VIEW_MIN_HEIGHT ENV_SHOW_DIAMETER #define MSG_MIN_HEIGHT 7 // max traps per level @@ -143,7 +148,7 @@ const int MAX_SKILL_LEVEL = 27; const int MIN_HIT_MISS_PERCENTAGE = 5; // grids that monsters can see -const int MONSTER_LOS_RANGE = 8; +const int MONSTER_LOS_RANGE = LOS_RADIUS; // Maximum charge level for rods const int MAX_ROD_CHARGE = 17; diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index 84aad0b116..d7bbd68656 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -238,12 +238,12 @@ inline coord_def grid2view(const coord_def &pos) inline coord_def view2show(const coord_def &pos) { - return (pos - crawl_view.vlos1 + coord_def(1, 1)); + return (pos - crawl_view.vlos1); } inline coord_def show2view(const coord_def &pos) { - return (pos + crawl_view.vlos1 - coord_def(1, 1)); + return (pos + crawl_view.vlos1); } inline coord_def grid2show(const coord_def &pos) diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 8370797f44..710f8e8321 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -684,8 +684,8 @@ void game_options::reset_options() mouse_input = false; - view_max_width = 33; - view_max_height = 21; + view_max_width = std::max(33, VIEW_MIN_WIDTH); + view_max_height = std::max(21, VIEW_MIN_HEIGHT); mlist_min_height = 5; msg_max_height = 10; mlist_allow_alternate_layout = false; diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index dd6aa27168..fd65cb0db2 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -21,6 +21,7 @@ REVISION("$Rev$"); #include "item_use.h" #include "itemname.h" #include "itemprop.h" +#include "los.h" #include "misc.h" #include "mutation.h" #include "player.h" @@ -472,7 +473,7 @@ bool unwield_item(bool showMsgs) && item.sub_type == MISC_LANTERN_OF_SHADOWS ) { you.current_vision += 2; - setLOSRadius(you.current_vision); + set_los_radius(you.current_vision); you.attribute[ATTR_SHADOWS] = 0; } else if (item.base_type == OBJ_WEAPONS) diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index ab63b492ae..94795dba5d 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -36,6 +36,7 @@ REVISION("$Rev$"); #include "items.h" #include "itemname.h" #include "itemprop.h" +#include "los.h" #include "macro.h" #include "message.h" #include "misc.h" @@ -459,7 +460,7 @@ void wield_effects(int item_wield_2, bool showMsgs) mpr("The area is filled with flickering shadows."); you.current_vision -= 2; - setLOSRadius(you.current_vision); + set_los_radius(you.current_vision); you.attribute[ATTR_SHADOWS] = 1; } else if (item.sub_type == MISC_HORN_OF_GERYON) diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc index 7c00a0b3e4..1a34f84f34 100644 --- a/crawl-ref/source/los.cc +++ b/crawl-ref/source/los.cc @@ -77,8 +77,8 @@ const bounds_func& bds_precalc = bds_maxlos; // means it will be exactly centered. // This is done to accomodate possible future changes in viewable screen // area - simply change sh_xo and sh_yo to the new view center. -const int sh_xo = 9; // X and Y origins for the sh array -const int sh_yo = 9; +const int sh_xo = ENV_SHOW_OFFSET; // X and Y origins for the sh array +const int sh_yo = ENV_SHOW_OFFSET; const coord_def sh_o = coord_def(sh_xo, sh_yo); // These store all unique (in terms of footprint) full rays. @@ -130,17 +130,18 @@ void clear_rays_on_exit() } // Pre-squared LOS radius. -int _los_radius_squared = LOS_RADIUS_SQ; +int _los_radius_sq = LOS_RADIUS_SQ; -void setLOSRadius(int newLR) +void set_los_radius(int r) { - _los_radius_squared = newLR * newLR + 1*1; + ASSERT(r <= LOS_MAX_RADIUS); + _los_radius_sq = r * r + 1; } // XXX: just for monster_los -int get_los_radius_squared() +int get_los_radius_sq() { - return _los_radius_squared; + return _los_radius_sq; } bool double_is_zero(const double x) diff --git a/crawl-ref/source/los.h b/crawl-ref/source/los.h index 3b84c3bb76..a9e74a23ff 100644 --- a/crawl-ref/source/los.h +++ b/crawl-ref/source/los.h @@ -13,8 +13,8 @@ bool double_is_zero(const double x); -void setLOSRadius(int newLR); -int get_los_radius_squared(); // XXX +void set_los_radius(int r); +int get_los_radius_sq(); // XXX struct ray_def; bool find_ray(const coord_def& source, const coord_def& target, diff --git a/crawl-ref/source/losparam.cc b/crawl-ref/source/losparam.cc index b281aa7df9..4f1f100244 100644 --- a/crawl-ref/source/losparam.cc +++ b/crawl-ref/source/losparam.cc @@ -65,5 +65,5 @@ bool bounds_radius_sq::operator()(const coord_def& p) const // LOS bounded by current global LOS radius. bool bounds_cur_los_radius::operator()(const coord_def& p) const { - return (p.abs() <= get_los_radius_squared()); + return (p.abs() <= get_los_radius_sq()); } diff --git a/crawl-ref/source/mon-los.cc b/crawl-ref/source/mon-los.cc index 0dd0f3ad19..c4161352cf 100644 --- a/crawl-ref/source/mon-los.cc +++ b/crawl-ref/source/mon-los.cc @@ -89,7 +89,7 @@ void monster_los::set_los_value(int x, int y, bool blocked, bool override) int monster_los::get_los_value(int x, int y) { // Too far away -> definitely out of sight! - if (distance(x, y, gridx, gridy) > get_los_radius_squared()) + if (distance(x, y, gridx, gridy) > get_los_radius_sq()) return (L_BLOCKED); coord_def c(x,y); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 42bc6a5606..dd4ca7822a 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3557,7 +3557,7 @@ static bool _target_is_unreachable(monsters *mon) bool can_go_straight(const coord_def& p1, const coord_def& p2, dungeon_feature_type allowed) { - if (distance(p1, p2) > get_los_radius_squared()) + if (distance(p1, p2) > get_los_radius_sq()) return (false); dungeon_feature_type max_disallowed = DNGN_MAXOPAQUE; diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index 258a013871..eb00c2d95a 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -1297,8 +1297,8 @@ game_start: // Before we get into the inventory init, set light radius based // on species vision. Currently, all species see out to 8 squares. - you.normal_vision = 8; - you.current_vision = 8; + you.normal_vision = LOS_RADIUS; + you.current_vision = LOS_RADIUS; _jobs_stat_init( you.char_class ); _give_last_paycheck( you.char_class ); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index eed2184778..516f021132 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -1799,7 +1799,7 @@ static const char* _player_vampire_smells_blood(int dist) if (dist < 16) // 4*4 return " near-by"; - if (you.hunger_state <= HS_NEAR_STARVING && dist > 65) // 8*8+1 (LOS) + if (you.hunger_state <= HS_NEAR_STARVING && dist > get_los_radius_sq()) return " in the distance"; return ""; diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h index 9c146226b6..b9a850e13c 100644 --- a/crawl-ref/source/view.h +++ b/crawl-ref/source/view.h @@ -78,7 +78,6 @@ void blood_smell( int strength, const coord_def& where); void handle_monster_shouts(monsters* monster, bool force = false); void show_map( coord_def &spec_place, bool travel_mode ); -void setLOSRadius(int newLR); bool check_awaken(monsters* monster); int count_detected_mons(void); void clear_map(bool clear_items = true, bool clear_mons = true); |