summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-04 23:54:14 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-04 23:54:14 +0000
commit38cb4b1f9f75c3695a14723f129aa795a5d72b4f (patch)
tree5db52a76b76948268ca9f21216f6afc951ec96b9 /crawl-ref
parentf6ee7314cca8474b59cba7fceb8b3866957b3cb7 (diff)
downloadcrawl-ref-38cb4b1f9f75c3695a14723f129aa795a5d72b4f.tar.gz
crawl-ref-38cb4b1f9f75c3695a14723f129aa795a5d72b4f.zip
[1603670] Altars and portals can now be found by the stash search.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@569 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/direct.cc2
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/it_use3.cc3
-rw-r--r--crawl-ref/source/items.cc2
-rw-r--r--crawl-ref/source/misc.cc12
-rw-r--r--crawl-ref/source/misc.h1
-rw-r--r--crawl-ref/source/overmap.cc133
-rw-r--r--crawl-ref/source/overmap.h6
-rw-r--r--crawl-ref/source/stash.cc46
-rw-r--r--crawl-ref/source/stash.h10
10 files changed, 169 insertions, 47 deletions
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 1c6266e80a..247632b56a 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1153,7 +1153,7 @@ std::string feature_description(int grid)
case DNGN_STONE_STAIRS_UP_III:
return ("A stone staircase leading up.");
case DNGN_ENTER_HELL:
- return ("A gateway to hell.");
+ return ("A gateway to Hell.");
case DNGN_TRAP_MECHANICAL:
return ("A mechanical trap.");
case DNGN_TRAP_MAGICAL:
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index c9cc1f821a..c647910f30 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1365,6 +1365,7 @@ enum ghost_value_type
GVAL_DEMONLORD_CYCLE_COLOUR // 13
};
+// The order of this enum must match the order of DNGN_ALTAR_FOO.
enum god_type
{
GOD_NO_GOD, // 0 -- must be zero
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 3de5614691..4e0011e262 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -33,6 +33,7 @@
#include "misc.h"
#include "monplace.h"
#include "monstuff.h"
+#include "overmap.h"
#include "player.h"
#include "randart.h"
#include "religion.h"
@@ -693,6 +694,8 @@ bool evoke_wielded( void )
mpr("You unfold the altar and place it on the floor.");
grd[you.x_pos][you.y_pos] = DNGN_ALTAR_NEMELEX_XOBEH;
dec_inv_item_quantity( you.equip[EQ_WEAPON], 1 );
+ seen_notable_thing(
+ DNGN_ALTAR_NEMELEX_XOBEH, you.x_pos, you.y_pos);
}
break;
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 69e7490292..e8863eefd1 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -49,6 +49,7 @@
#include "mstuff2.h"
#include "mon-util.h"
#include "mutation.h"
+#include "overmap.h"
#include "player.h"
#include "randart.h"
#include "religion.h"
@@ -1202,6 +1203,7 @@ void pickup()
}
grd[you.x_pos][you.y_pos] = DNGN_FLOOR;
+ unnotice_altar();
}
}
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 183e643184..a30de8f852 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -177,7 +177,7 @@ bool grid_destroys_items( int grid )
return (grid == DNGN_LAVA || grid == DNGN_DEEP_WATER);
}
-// returns 0 is grid is not an altar, else it returns the GOD_* type
+// returns 0 if grid is not an altar, else it returns the GOD_* type
god_type grid_altar_god( unsigned char grid )
{
if (grid >= DNGN_ALTAR_ZIN && grid <= DNGN_ALTAR_ELYVILON)
@@ -186,6 +186,16 @@ god_type grid_altar_god( unsigned char grid )
return (GOD_NO_GOD);
}
+// returns DNGN_FLOOR for non-gods, otherwise returns the altar for
+// the god.
+int altar_for_god( god_type god )
+{
+ if (god == GOD_NO_GOD || god >= NUM_GODS)
+ return (DNGN_FLOOR); // Yeah, lame. Tell me about it.
+
+ return (DNGN_ALTAR_ZIN + god - 1);
+}
+
bool grid_is_branch_stairs( unsigned char grid )
{
return ((grid >= DNGN_ENTER_ORCISH_MINES && grid <= DNGN_ENTER_RESERVED_4)
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index be5195e193..5e00b7f20a 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -134,6 +134,7 @@ bool grid_is_solid(int grid);
bool grid_is_water(int grid);
bool grid_is_watery( int grid );
god_type grid_altar_god( unsigned char grid );
+int altar_for_god( god_type god );
bool grid_is_branch_stairs( unsigned char grid );
int grid_secret_door_appearance( int gx, int gy );
bool grid_destroys_items( int grid );
diff --git a/crawl-ref/source/overmap.cc b/crawl-ref/source/overmap.cc
index d83f87cbb1..5e1360c427 100644
--- a/crawl-ref/source/overmap.cc
+++ b/crawl-ref/source/overmap.cc
@@ -25,6 +25,7 @@
#include "externs.h"
+#include "direct.h"
// for #definitions of MAX_BRANCHES & MAX_LEVELS
#include "files.h"
#include "menu.h"
@@ -34,10 +35,15 @@
#include "stuff.h"
#include "view.h"
-std::map<branch_type, level_id> stair_level;
-std::map<level_pos, shop_type> shops_present;
-std::map<level_pos, god_type> altars_present;
-std::map<level_pos, portal_type> portals_present;
+typedef std::map<branch_type, level_id> stair_map_type;
+typedef std::map<level_pos, shop_type> shop_map_type;
+typedef std::map<level_pos, god_type> altar_map_type;
+typedef std::map<level_pos, portal_type> portal_map_type;
+
+stair_map_type stair_level;
+shop_map_type shops_present;
+altar_map_type altars_present;
+portal_map_type portals_present;
static void seen_altar( god_type god, const coord_def& pos );
static void seen_staircase(unsigned char which_staircase,const coord_def& pos);
@@ -60,6 +66,23 @@ void seen_notable_thing( int which_thing, int x, int y )
seen_other_thing( which_thing, pos );
}
+static int portal_to_feature(portal_type p)
+{
+ switch ( p )
+ {
+ case PORTAL_LABYRINTH:
+ return DNGN_ENTER_LABYRINTH;
+ case PORTAL_HELL:
+ return DNGN_ENTER_HELL;
+ case PORTAL_ABYSS:
+ return DNGN_ENTER_ABYSS;
+ case PORTAL_PANDEMONIUM:
+ return DNGN_ENTER_PANDEMONIUM;
+ default:
+ return DNGN_FLOOR;
+ }
+}
+
static const char* portaltype_to_string(portal_type p)
{
switch ( p )
@@ -107,6 +130,81 @@ static char shoptype_to_char(shop_type s)
}
}
+static altar_map_type get_notable_altars(const altar_map_type &altars)
+{
+ altar_map_type notable_altars;
+ for ( altar_map_type::const_iterator na_iter = altars.begin();
+ na_iter != altars.end(); ++na_iter )
+ {
+ if (na_iter->first.id.branch != BRANCH_ECUMENICAL_TEMPLE)
+ notable_altars[na_iter->first] = na_iter->second;
+ }
+ return (notable_altars);
+}
+
+inline static std::string place_desc(const level_pos &pos)
+{
+ return "[" + pos.id.describe(false, true) + "] ";
+}
+
+inline static std::string altar_description(god_type god)
+{
+ return feature_description( altar_for_god(god) );
+}
+
+inline static std::string portal_description(portal_type portal)
+{
+ return feature_description( portal_to_feature(portal) );
+}
+
+static void get_matching_altars(
+ const base_pattern &pattern, std::vector<stash_search_result> &results)
+{
+ for ( altar_map_type::const_iterator na_iter = altars_present.begin();
+ na_iter != altars_present.end(); ++na_iter )
+ {
+ const std::string adesc =
+ altar_description(na_iter->second);
+
+ if (pattern.matches(place_desc(na_iter->first) + adesc))
+ {
+ stash_search_result sr;
+ sr.pos = na_iter->first;
+ sr.match = adesc;
+ results.push_back(sr);
+ }
+ }
+}
+
+static void get_matching_portals(
+ const base_pattern &pattern, std::vector<stash_search_result> &results)
+{
+ for ( portal_map_type::const_iterator pl_iter = portals_present.begin();
+ pl_iter != portals_present.end(); ++pl_iter )
+ {
+ const std::string desc =
+ portal_description(pl_iter->second);
+
+ if (pattern.matches(place_desc(pl_iter->first) + desc + " [portal]"))
+ {
+ stash_search_result sr;
+ sr.pos = pl_iter->first;
+ sr.match = desc;
+ results.push_back(sr);
+ }
+ }
+}
+
+void get_matching_features(
+ const base_pattern &pattern, std::vector<stash_search_result> &results)
+{
+ if (!pattern.valid())
+ return;
+
+ get_matching_altars(pattern, results);
+ get_matching_portals(pattern, results);
+}
+
std::string overview_description_string()
{
char buffer[100];
@@ -156,10 +254,14 @@ std::string overview_description_string()
}
if ( branchcount && (branchcount % 4) )
disp += "\n";
+
+ // remove unworthy altars from the list we show the user. Yeah,
+ // one more round of map iteration.
+ const altar_map_type notable_altars = get_notable_altars(altars_present);
// print altars
// we loop through everything a dozen times, oh well
- if ( !altars_present.empty() )
+ if ( !notable_altars.empty() )
{
disp += "\n<white>Altars:</white>\n";
seen_anything = true;
@@ -175,8 +277,8 @@ std::string overview_description_string()
if ( cur_god == you.religion )
continue;
- for ( ci_altar = altars_present.begin();
- ci_altar != altars_present.end();
+ for ( ci_altar = notable_altars.begin();
+ ci_altar != notable_altars.end();
++ci_altar )
{
if ( ci_altar->second == real_god )
@@ -382,18 +484,19 @@ void seen_altar( god_type god, const coord_def& pos )
if ( you.level_type != LEVEL_DUNGEON )
return;
- // no point in recording Temple altars
- if ( you.where_are_you == BRANCH_ECUMENICAL_TEMPLE )
- return;
-
- // portable; no point in recording
- if ( god == GOD_NEMELEX_XOBEH )
- return;
-
level_pos where(level_id::get_current_level_id(), pos);
altars_present[where] = god;
}
+void unnotice_altar()
+{
+ const coord_def pos = { you.x_pos, you.y_pos };
+ const level_pos curpos(level_id::get_current_level_id(), pos);
+ // Hmm, what happens when erasing a nonexistent key directly?
+ if (altars_present.find(curpos) != altars_present.end())
+ altars_present.erase(curpos);
+}
+
portal_type feature_to_portal( unsigned char feat )
{
switch ( feat )
diff --git a/crawl-ref/source/overmap.h b/crawl-ref/source/overmap.h
index 7c10bd3493..e08af57ffd 100644
--- a/crawl-ref/source/overmap.h
+++ b/crawl-ref/source/overmap.h
@@ -12,9 +12,15 @@
#ifndef OVERMAP_H
#define OVERMAP_H
+#include "stash.h"
+#include <vector>
+
void seen_notable_thing( int which_thing, int x, int y );
void display_overmap();
void unnotice_labyrinth_portal();
+void unnotice_altar();
std::string overview_description_string();
+void get_matching_features(
+ const base_pattern &pattern, std::vector<stash_search_result> &results);
#endif
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index 02e7ec5125..8efae5058d 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -19,6 +19,7 @@
#include "libutil.h"
#include "menu.h"
#include "misc.h"
+#include "overmap.h"
#include "shopping.h"
#include "spl-book.h"
#include "stash.h"
@@ -475,8 +476,9 @@ bool Stash::matches_search(const std::string &prefix,
if (res.matches)
{
res.stash = this;
- res.pos.x = x;
- res.pos.y = y;
+ // XXX pos.pos looks lame. Lameness is not solicited.
+ res.pos.pos.x = x;
+ res.pos.pos.y = y;
}
return !!res.matches;
@@ -760,8 +762,8 @@ bool ShopInfo::matches_search(const std::string &prefix,
if (match || res.matches)
{
res.shop = this;
- res.pos.x = x;
- res.pos.y = y;
+ res.pos.pos.x = x;
+ res.pos.pos.y = y;
}
return match || res.matches;
@@ -1040,7 +1042,7 @@ void LevelStashes::get_matching_stashes(
stash_search_result res;
if (iter->second.matches_search(lplace, search, res))
{
- res.level = clid;
+ res.pos.id = clid;
results.push_back(res);
}
}
@@ -1051,7 +1053,7 @@ void LevelStashes::get_matching_stashes(
stash_search_result res;
if (shops[i].matches_search(lplace, search, res))
{
- res.level = clid;
+ res.pos.id = clid;
results.push_back(res);
}
}
@@ -1314,11 +1316,11 @@ void StashTracker::search_stashes()
char prompt[200];
if (lastsearch.length())
snprintf(prompt, sizeof prompt,
- "Search your stashes for what item [Enter for \"%s\"]?",
+ "Search for what [Enter for \"%s\"]?",
lastsearch.c_str());
else
snprintf(prompt, sizeof prompt,
- "Search your stashes for what item?");
+ "Search for what?");
mpr(prompt, MSGCH_PROMPT);
// Push the cursor down to the next line.
@@ -1358,7 +1360,7 @@ void StashTracker::search_stashes()
if (results.empty())
{
- mpr("That item is not present in any of your stashes.",
+ mpr("Can't find anything matching that.",
MSGCH_PLAIN);
return;
}
@@ -1385,11 +1387,11 @@ void StashTracker::get_matching_stashes(
return;
}
+ get_matching_features(search, results);
+
level_id curr = level_id::get_current_level_id();
for (unsigned i = 0; i < results.size(); ++i)
- {
- results[i].player_distance = level_distance(curr, results[i].level);
- }
+ results[i].player_distance = level_distance(curr, results[i].pos.id);
// Sort stashes so that closer stashes come first and stashes on the same
// levels with more items come first.
@@ -1420,9 +1422,9 @@ void StashSearchMenu::draw_title()
title->quantity > 1? "es" : "");
if (meta_key)
- draw_title_suffix(" (x - examine stash)", false);
+ draw_title_suffix(" (x - examine)", false);
else
- draw_title_suffix(" (x - go to stash; ? - examine stash)", false);
+ draw_title_suffix(" (x - travel; ? - examine)", false);
}
}
@@ -1449,7 +1451,7 @@ void StashTracker::display_search_results(
StashSearchMenu stashmenu;
stashmenu.can_travel = travelable;
- std::string title = "matching stash";
+ std::string title = "match";
MenuEntry *mtitle = new MenuEntry(title, MEL_TITLE);
// Abuse of the quantity field.
@@ -1461,7 +1463,7 @@ void StashTracker::display_search_results(
{
stash_search_result &res = results[i];
char matchtitle[ITEMNAME_SIZE];
- std::string place = short_place_name(res.level);
+ std::string place = short_place_name(res.pos.id);
if (res.matches > 1 && res.count > 1)
{
snprintf(matchtitle, sizeof matchtitle,
@@ -1501,21 +1503,19 @@ void StashTracker::display_search_results(
bool dotravel = false;
if (res->shop)
{
- dotravel = res->shop->show_menu(short_place_name(res->level),
+ dotravel = res->shop->show_menu(short_place_name(res->pos.id),
travelable);
}
else if (res->stash)
{
- dotravel = res->stash->show_menu(short_place_name(res->level),
+ dotravel = res->stash->show_menu(short_place_name(res->pos.id),
travelable);
}
if (dotravel && travelable)
{
redraw_screen();
- level_pos lp;
- lp.id = res->level;
- lp.pos = res->pos;
+ const level_pos lp = res->pos;
start_translevel_travel(lp);
return ;
}
@@ -1529,9 +1529,7 @@ void StashTracker::display_search_results(
{
const stash_search_result *res =
static_cast<stash_search_result *>(sel[0]->data);
- level_pos lp;
- lp.id = res->level;
- lp.pos = res->pos;
+ const level_pos lp = res->pos;
start_translevel_travel(lp);
return ;
}
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h
index 9727102067..58c6d3ce2a 100644
--- a/crawl-ref/source/stash.h
+++ b/crawl-ref/source/stash.h
@@ -159,10 +159,8 @@ private:
struct stash_search_result
{
- // What level is this stash or shop on.
- level_id level;
-
- coord_def pos;
+ // Where's this thingummy of interest.
+ level_pos pos;
// Number of levels the player must cross to reach the level the stash/shop
// is on.
@@ -178,11 +176,11 @@ struct stash_search_result
// First item in stash that matched
std::string match;
- // The stash or shop in question.
+ // The stash or shop in question. Both can be null if this is a feature.
const Stash *stash;
const ShopInfo *shop;
- stash_search_result() : level(), player_distance(0), matches(0),
+ stash_search_result() : pos(), player_distance(0), matches(0),
count(0), match(), stash(NULL), shop(NULL)
{
}