From e2d1b5dfa2a106a40db5ab6a23e6eb19e3aae8ca Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sat, 9 Aug 2008 12:27:44 +0000 Subject: Rework xx and V to use monster_pane_info() to benefit from the difficulty comparison and sorting functions. Make V work as a shortcut for xx, but keep the original monster listing (now repaired) for the dump. Most of the monster_pane_function struct and functions are now also included in Tiles compiles, even though the monster list itself is still not available. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6800 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source/directn.cc') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 095f917f1d..8a7cdd856d 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -448,34 +448,27 @@ static void _direction_again(dist& moves, targeting_type restricts, static void _describe_monster(const monsters *mon); // Lists all the monsters and items currently in view by the player. -// Internals: -// Menu items have meaningful tags. 'i' means item and 'm' means monster. -// -void _full_describe_view() +// TODO: Allow sorting of items lists. +void full_describe_view() { const coord_def start = view2grid(coord_def(1,1)); const coord_def end(start.x + crawl_view.viewsz.x, start.y + crawl_view.viewsz.y); - std::vector list_mons; + std::vector list_mons; std::vector list_items; coord_def p; - // Iterate over viewport and get all the items and monsters in view. - // TODO: Allow sorting of monster and items lists. + // Iterate over viewport and get all the itemsin view. for (p.x = start.x; p.x < end.x; p.x++) for (p.y = start.y; p.y < end.y; p.y++) { if (!in_bounds(p.x,p.y) || !see_grid(p.x,p.y)) continue; - const int mid = mgrd(p); const int oid = igrd(p); - if (mid != NON_MONSTER && player_monster_visible(&menv[mid])) - list_mons.push_back(&menv[mid]); - if (oid != NON_ITEM) { std::vector items; @@ -484,6 +477,14 @@ void _full_describe_view() } } + // Get monsters via the monster_pane_info, sorted by difficulty. + std::vector mons; + get_monster_pane_info(mons); + std::sort(mons.begin(), mons.end(), monster_pane_info::less_than_wrapper); + + for (unsigned int i = 0; i < mons.size(); i++) + list_mons.push_back(mons[i].m_mon); + if (!list_mons.size() && !list_items.size()) { mprf("Neither monsters nor items are visible."); @@ -508,7 +509,7 @@ void _full_describe_view() for (unsigned int i = 0; i < list_mons.size(); ++i) { // List monsters in the form - // (g) A goblin (hostile) wielding an orcish dagger + // (A) An angel (neutral), wielding a glowing long sword ++menu_index; const char letter = index_to_letter(menu_index); @@ -1316,9 +1317,7 @@ void direction(dist& moves, targeting_type restricts, break; case CMD_TARGET_ALL_DESCRIBE: - _full_describe_view(); - //TODO: Check if this is neccesary - //force_redraw = true; + full_describe_view(); break; case CMD_TARGET_HELP: @@ -2796,8 +2795,6 @@ std::string get_monster_desc(const monsters *mon, bool full_desc, desc += " (friendly)"; else if (mons_neutral(mon)) desc += " (neutral)"; - else - desc += " (hostile)"; } } -- cgit v1.2.3-54-g00ecf