diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-11-16 17:48:53 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-11-16 20:32:25 +0100 |
commit | 2c9b3ce286f5c274cb0348253259bcca24d967a3 (patch) | |
tree | e1ac204d887238915b3fd8a2755b66973fd8bc9f /crawl-ref/source | |
parent | 5059f548248efbc905c16a7cfbaa41d98c30dcb0 (diff) | |
download | crawl-ref-2c9b3ce286f5c274cb0348253259bcca24d967a3.tar.gz crawl-ref-2c9b3ce286f5c274cb0348253259bcca24d967a3.zip |
Simplify out-of-range darkening.
Also fixes the range_view_annotator destructor
clobbering option "darken_beyond_range".
Options.target_range is now really an option, and called
Options.darken_beyond_range. Current darkening range is
now stored in crawl_state.darken_range.
I can't reproduce SIGHUP retaining darkened range
(BR 2151183) (why would it be saved?), so
range_view_annotator is not a crawl_exit_hook anymore.
crawl_exit_hook is not used anymore, but still present.
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/directn.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/directn.h | 5 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/options.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/state.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/state.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 5 |
8 files changed, 26 insertions, 28 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index ba02499131..8230db5e3e 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -875,24 +875,20 @@ crawl_exit_hook::~crawl_exit_hook() range_view_annotator::range_view_annotator(int range) { - if (range >= 0) + if (Options.darken_beyond_range && range >= 0) { -#ifndef USE_TILE - if (Options.target_range != -1) -#endif - Options.target_range = range; + crawl_state.darken_range = range; + viewwindow(false, false); } } range_view_annotator::~range_view_annotator() { - restore_state(); - viewwindow(false); -} - -void range_view_annotator::restore_state() -{ - Options.target_range = 0; + if (Options.darken_beyond_range && crawl_state.darken_range >= 0) + { + crawl_state.darken_range = -1; + viewwindow(false, false); + } } bool _dist_ok(const dist& moves, int range, targ_mode_type mode, @@ -1668,6 +1664,7 @@ void direction(dist& moves, targetting_type restricts, if (need_beam_redraw) { #ifndef USE_TILE + // Clear the old ray. viewwindow(false, false); #endif if (show_beam && have_beam) diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index 08d5fd60ca..65322b34e7 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -15,14 +15,11 @@ #include "ray.h" #include "state.h" -class range_view_annotator : public crawl_exit_hook +class range_view_annotator { public: range_view_annotator(int range); virtual ~range_view_annotator(); - virtual void restore_state(); -private: - bool do_anything; }; // An object that modifies the behaviour of the direction prompt. diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 41a3d66371..ee72fc3cbd 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -766,7 +766,7 @@ void game_options::reset_options() target_oos = true; target_los_first = true; target_unshifted_dirs = false; - target_range = 0; // -1 -> grey out targets out of range + darken_beyond_range = true; dump_kill_places = KDO_ONE_PLACE; dump_message_count = 7; @@ -3034,8 +3034,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) } else if (key == "darken_beyond_range") { - if (!_read_bool(field, target_range != -1)) - target_range = -1; + darken_beyond_range = _read_bool(field, darken_beyond_range); } else if (key == "drop_mode") { diff --git a/crawl-ref/source/options.h b/crawl-ref/source/options.h index b344176e99..f24d7f49c7 100644 --- a/crawl-ref/source/options.h +++ b/crawl-ref/source/options.h @@ -129,7 +129,7 @@ public: int colour[16]; // macro fg colours to other colours int background; // select default background colour int channels[NUM_MESSAGE_CHANNELS]; // msg channel colouring - int target_range; // for whether targetting is out of range + bool darken_beyond_range; // for whether targetting is out of range bool use_old_selection_order; // use old order of species/classes in // selection screen diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 06f4f1771b..812cfdbfe9 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -754,13 +754,13 @@ bool cast_a_spell(bool check_range, spell_type spell) mpr("There are no visible monsters within range! (Use <w>Z</w> to " "cast anyway.)"); - if (Options.target_range != -1) + if (Options.darken_beyond_range) { - Options.target_range = _calc_spell_range(spell); - viewwindow(false); + crawl_state.darken_range = _calc_spell_range(spell); + viewwindow(false, false); delay(500); - Options.target_range = 0; - viewwindow(false); + crawl_state.darken_range = -1; + viewwindow(false, false); } return (false); } diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index 299390c526..6918a7061d 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -33,7 +33,8 @@ game_state::game_state() doing_prev_cmd_again(false), prev_cmd(CMD_NO_CMD), repeat_cmd(CMD_NO_CMD), cmd_repeat_count(0), cmd_repeat_goal(0), prev_repetition_turn(0), cmd_repeat_started_unsafe(false), - input_line_curr(0), level_annotation_shown(false) + input_line_curr(0), level_annotation_shown(false), + darken_range(-1) { reset_cmd_repeat(); reset_cmd_again(); diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h index 74376b3b24..a1bf485298 100644 --- a/crawl-ref/source/state.h +++ b/crawl-ref/source/state.h @@ -91,6 +91,9 @@ struct game_state bool level_annotation_shown; + // Range beyond which view should be darkend, -1 == disabled. + int darken_range; + protected: void reset_cmd_repeat(); void reset_cmd_again(); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index afa1718677..42877990dc 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -895,9 +895,10 @@ void viewwindow(bool monster_updates, bool show_updates) : DARKGREY; #endif } - else if (Options.target_range > 0) + else if (crawl_state.darken_range >= 0) { - bool out_of_range = grid_distance(you.pos(), gc) > Options.target_range + bool out_of_range = grid_distance(you.pos(), gc) > + crawl_state.darken_range || !you.see_cell(gc); #ifndef USE_TILE if (out_of_range) |