diff options
author | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-21 03:58:34 +0000 |
---|---|---|
committer | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-21 03:58:34 +0000 |
commit | 3bc5803595bf91439ca4805cec5f7f2bed0de72a (patch) | |
tree | 020c49afbd7e3e4798242fdc8354d899a0e61e54 /crawl-ref/source | |
parent | 20435a6543a7245c0f4bc64f85959064cc98abcf (diff) | |
download | crawl-ref-3bc5803595bf91439ca4805cec5f7f2bed0de72a.tar.gz crawl-ref-3bc5803595bf91439ca4805cec5f7f2bed0de72a.zip |
[2496621] Fixing view recentering on abyss shifts. Shifts now preserve any scrolling that had occured.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8641 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/abyss.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/directn.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 13 |
5 files changed, 33 insertions, 3 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index b3081d5379..76ce4be6b9 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -507,7 +507,7 @@ void area_shift(void) delete_cloud( i ); } - you.moveto(abyss_center); + you.shiftto(abyss_center); _generate_area(coord_def(MAPGEN_BORDER, MAPGEN_BORDER), coord_def(GXM - MAPGEN_BORDER, GYM - MAPGEN_BORDER), true); diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index 6d71cfa0b5..c20a3c792d 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -68,6 +68,8 @@ public: void init_view(); void set_player_at(const coord_def &c, bool force_centre = false); + // Set new location, but preserve scrolling as if the player didn't move. + void shift_player_to(const coord_def &c); coord_def view_centre() const { diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index d5e3f7e8a6..42d6024864 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -978,6 +978,8 @@ public: // Low-level move the player. Use this instead of changing pos directly. void moveto(const coord_def &c); + // Move the player during an abyss shift. + void shiftto(const coord_def &c); void reset_prev_move(); @@ -1153,6 +1155,8 @@ public: bool did_escape_death() const; void reset_escaped_death(); +protected: + void base_moveto(const coord_def &c); }; extern player you; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 086782330c..c0dbe2af63 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -7214,13 +7214,12 @@ bool player::is_icy() const return (attribute[ATTR_TRANSFORMATION] == TRAN_ICE_BEAST); } -void player::moveto(const coord_def &c) +void player::base_moveto(const coord_def &c) { ASSERT(!crawl_state.arena); const bool real_move = (c != pos()); position = c; - crawl_view.set_player_at(c); if (real_move) { @@ -7233,6 +7232,18 @@ void player::moveto(const coord_def &c) } } +void player::moveto(const coord_def &c) +{ + crawl_view.set_player_at(c); + base_moveto(c); +} + +void player::shiftto(const coord_def &c) +{ + crawl_view.shift_player_to(c); + base_moveto(c); +} + void player::reset_prev_move() { prev_move = coord_def(0,0); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b691992e32..d155f10004 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -5693,6 +5693,19 @@ void crawl_view_geometry::init_view() set_player_at(you.pos(), true); } +void crawl_view_geometry::shift_player_to(const coord_def &c) +{ + // Preserve vgrdc offset after moving. + const coord_def offset = crawl_view.vgrdc - you.pos(); + crawl_view.vgrdc = offset + c; + last_player_pos = c; + + set_player_at(c); + + ASSERT(crawl_view.vgrdc == offset + c); + ASSERT(last_player_pos == c); +} + void crawl_view_geometry::set_player_at(const coord_def &c, bool centre) { if (centre) |