From f251994ff016cc935e026fe0366d4384890b638a Mon Sep 17 00:00:00 2001 From: Enne Walker Date: Tue, 3 Nov 2009 22:34:28 -0500 Subject: Support for X map multi-level viewing on tiles. Fixes seeing in-LOS squares on incorrect levels. Fixes the minimap not updating. Fixes the player dot appearing on the minimap on wrong levels. --- crawl-ref/source/files.cc | 2 ++ crawl-ref/source/player.cc | 2 ++ crawl-ref/source/player.h | 3 +++ crawl-ref/source/tilesdl.cc | 6 ++++-- crawl-ref/source/view.cc | 17 ++++++++++++++++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 3c8ee8e2ed..a4e2588b75 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1915,6 +1915,8 @@ void level_excursion::go_to(const level_id& next) _save_level(you.your_level, you.level_type, you.where_are_you); _restore_level(next); } + + you.on_current_level = (level_id::current() == original); } level_excursion::~level_excursion() diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index c81874056b..36eac16777 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6003,6 +6003,8 @@ void player::init() // Currently only set if Xom accidentally kills the player. reset_escaped_death(); + + on_current_level = true; } player_save_info player_save_info::operator=(const player& rhs) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 940d828120..f11168d436 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -280,6 +280,9 @@ public: CrawlHashTable props; + // When other levels are loaded (e.g. viewing), is the player on this level? + bool on_current_level; + protected: FixedVector branch_info; FixedVector non_branch_info; diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index fb56de2c8e..90d3ac4ef1 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -427,6 +427,8 @@ void TilesFramework::load_dungeon(const coord_def &cen) unsigned int *tb = (unsigned int*)alloca(sizeof(unsigned int) * wy * wx * 2); + bool draw_los = you.on_current_level; + int count = 0; for (int y = 0; y < wy; y++) for (int x = 0; x < wx; x++) @@ -444,7 +446,7 @@ void TilesFramework::load_dungeon(const coord_def &cen) fg = 0; bg = TILE_DNGN_UNSEEN; } - else if (!crawl_view.in_grid_los(gc) || !env.show(ep)) + else if (!crawl_view.in_grid_los(gc) || !env.show(ep) || !draw_los) { fg = env.tile_bk_fg(gc); bg = env.tile_bk_bg(gc); @@ -1325,7 +1327,7 @@ void TilesFramework::update_minimap(int gx, int gy, map_feature f) coord_def gc(gx, gy); - if (you.pos() == gc) + if (you.pos() == gc && you.on_current_level) { f = MF_PLAYER; } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b7378efc18..f136e492b9 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2405,13 +2405,28 @@ static void _reset_travel_colours(std::vector &features, arrange_features(features); } +class levelview_excursion : public level_excursion +{ +public: + void go_to(const level_id& next) + { +#ifdef USE_TILE + tiles.clear_minimap(); + level_excursion::go_to(next); + TileNewLevel(false); +#else + level_excursion::go_to(next); +#endif + } +}; + // show_map() now centers the known map along x or y. This prevents // the player from getting "artificial" location clues by using the // map to see how close to the end they are. They'll need to explore // to get that. This function is still a mess, though. -- bwr void show_map( level_pos &spec_place, bool travel_mode, bool allow_esc ) { - level_excursion le; + levelview_excursion le; level_id original(level_id::current()); cursor_control ccon(!Options.use_fake_cursor); -- cgit v1.2.3-54-g00ecf