diff options
-rw-r--r-- | crawl-ref/source/actor-los.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/arena.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/los_def.cc | 19 | ||||
-rw-r--r-- | crawl-ref/source/los_def.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 3 |
5 files changed, 28 insertions, 24 deletions
diff --git a/crawl-ref/source/actor-los.cc b/crawl-ref/source/actor-los.cc index b7d543f386..9471a871f6 100644 --- a/crawl-ref/source/actor-los.cc +++ b/crawl-ref/source/actor-los.cc @@ -64,12 +64,9 @@ void player::update_los() // Player LOS overrides for arena. -bool player::see_cell(const coord_def &c) const +void player::set_arena_los(const coord_def& c) { - if (crawl_state.arena || crawl_state.arena_suspended) - return (crawl_view.in_grid_los(c)); - else - return (actor::see_cell(c)); + los.init_arena(c); } bool player::can_see(const actor* a) const diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index 39f6db4e24..0f4b71c394 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -472,14 +472,12 @@ namespace arena you.char_class = JOB_FIGHTER; you.experience_level = 27; - you.mutation[MUT_ACUTE_VISION] = 3; - + you.position.y = -1; coord_def yplace(dgn_find_feature_marker(DNGN_ESCAPE_HATCH_UP)); - // Fix up the viewport. Temporarily unset arena mode to avoid - // assertion. - crawl_state.arena = false; - you.moveto(yplace); - crawl_state.arena = true; + you.set_arena_los(yplace); + crawl_view.set_player_at(yplace); + + you.mutation[MUT_ACUTE_VISION] = 3; you.your_name = "Arena"; @@ -733,11 +731,9 @@ namespace arena unwind_bool ar (crawl_state.arena, false); unwind_bool ar_susp(crawl_state.arena_suspended, true); - - unwind_var<coord_def> pos(you.position); coord_def yplace(dgn_find_feature_marker(DNGN_ESCAPE_HATCH_UP)); - you.moveto(yplace); - + unwind_var<coord_def> pos(you.position); + you.position = yplace; process_command(cmd); } @@ -837,9 +833,6 @@ namespace arena count_foes(); viewwindow(false); - unwind_var<coord_def> pos(you.position); - // Move hero offscreen. - you.position.y = -1; you.time_taken = 10; // Make sure we don't starve. you.hunger = 10999; diff --git a/crawl-ref/source/los_def.cc b/crawl-ref/source/los_def.cc index 3e2a3eae2e..a84399115d 100644 --- a/crawl-ref/source/los_def.cc +++ b/crawl-ref/source/los_def.cc @@ -10,19 +10,19 @@ #include "coord-circle.h" los_def::los_def() - : show(0), opc(opc_default.clone()), bds(BDS_DEFAULT) + : show(0), opc(opc_default.clone()), bds(BDS_DEFAULT), arena(false) { } los_def::los_def(const coord_def& c, const opacity_func &o, const circle_def &b) - : show(0), center(c), opc(o.clone()), bds(b) + : show(0), center(c), opc(o.clone()), bds(b), arena(false) { } los_def::los_def(const los_def& los) : show(los.show), center(los.center), - opc(los.opc->clone()), bds(los.bds) + opc(los.opc->clone()), bds(los.bds), arena(los.arena) { } @@ -30,6 +30,7 @@ los_def& los_def::operator=(const los_def& los) { init(los.center, *los.opc, los.bds); show = los.show; + arena = los.arena; return (*this); } @@ -40,6 +41,14 @@ void los_def::init(const coord_def &c, const opacity_func &o, set_center(c); set_opacity(o); set_bounds(b); + arena = false; +} + +void los_def::init_arena(const coord_def& c) +{ + center = c; + arena = true; + set_bounds(circle_def(LOS_MAX_RADIUS, C_SQUARE)); } los_def::~los_def() @@ -75,11 +84,13 @@ circle_def los_def::get_bounds() const bool los_def::in_bounds(const coord_def& p) const { - return (bds.contains(p)); + return (bds.contains(p - center)); } bool los_def::see_cell(const coord_def& p) const { + if (arena) + return (in_bounds(p)); const coord_def sp = p - center; return (sp.rdist() <= LOS_MAX_RANGE && show(sp)); } diff --git a/crawl-ref/source/los_def.h b/crawl-ref/source/los_def.h index 82a82f6447..d9841cea96 100644 --- a/crawl-ref/source/los_def.h +++ b/crawl-ref/source/los_def.h @@ -11,6 +11,7 @@ class los_def coord_def center; opacity_func const * opc; circle_def bds; + bool arena; public: los_def(); @@ -21,6 +22,7 @@ public: los_def& operator=(const los_def& l); void init(const coord_def& center, const opacity_func& o, const circle_def& b); + void init_arena(const coord_def& center); void set_center(const coord_def& center); void set_opacity(const opacity_func& o); void set_bounds(const circle_def& b); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 9694298fdf..239ac20765 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -327,11 +327,12 @@ public: bool can_see_invisible(bool unid) const; bool visible_to(const actor *looker) const; bool can_see(const actor* a) const; - bool see_cell(const coord_def& c) const; bool see_cell_no_trans(const coord_def &c) const; // Is c in view but behind a transparent wall? bool trans_wall_blocking(const coord_def &c) const; + // Override LOS for arena. + void set_arena_los(const coord_def &c); void update_los(); bool is_icy() const; |