summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 06:27:58 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-23 06:27:58 +0000
commit922cba628d3d6377574a90c7a817c10d84ed7f85 (patch)
treeae983cf4a6d1e2dc85fd5c58754f2ec06d25afae /crawl-ref
parent7c2f45cfd1fed2a890780bdf2b7e3d1cd105dfb5 (diff)
downloadcrawl-ref-922cba628d3d6377574a90c7a817c10d84ed7f85.tar.gz
crawl-ref-922cba628d3d6377574a90c7a817c10d84ed7f85.zip
"stashes" was both a global variable and a member variable... confusing!
Renamed both of them. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3827 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc10
-rw-r--r--crawl-ref/source/chardump.cc2
-rw-r--r--crawl-ref/source/delay.cc2
-rw-r--r--crawl-ref/source/files.cc4
-rw-r--r--crawl-ref/source/items.cc2
-rw-r--r--crawl-ref/source/shopping.cc4
-rw-r--r--crawl-ref/source/stash.cc109
-rw-r--r--crawl-ref/source/stash.h21
-rw-r--r--crawl-ref/source/travel.cc10
9 files changed, 84 insertions, 80 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 83058e5978..58ca6ca19b 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1868,23 +1868,23 @@ void process_command( command_type cmd )
case CMD_DROP:
drop();
if (Options.stash_tracking >= STM_DROPPED)
- stashes.add_stash();
+ StashTrack.add_stash();
break;
case CMD_SEARCH_STASHES:
if (Options.tut_stashes)
Options.tut_stashes = 0;
- stashes.search_stashes();
+ StashTrack.search_stashes();
break;
case CMD_MARK_STASH:
if (Options.stash_tracking >= STM_EXPLICIT)
- stashes.add_stash(-1, -1, true);
+ StashTrack.add_stash(-1, -1, true);
break;
case CMD_FORGET_STASH:
if (Options.stash_tracking >= STM_EXPLICIT)
- stashes.no_stash();
+ StashTrack.no_stash();
break;
case CMD_BUTCHER:
@@ -2963,7 +2963,7 @@ static void world_reacts()
viewwindow(true, true);
if (Options.stash_tracking)
- stashes.update_visible_stashes(
+ StashTrack.update_visible_stashes(
Options.stash_tracking == STM_ALL?
StashTracker::ST_AGGRESSIVE :
StashTracker::ST_PASSIVE);
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 86c0675d4a..65ec415c04 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1186,7 +1186,7 @@ static bool write_dump(
std::string stash_file_name;
stash_file_name = file_name;
stash_file_name += ".lst";
- stashes.dump(stash_file_name.c_str(), par.full_id);
+ StashTrack.dump(stash_file_name.c_str(), par.full_id);
std::string map_file_name = file_name + ".map";
dump_map(map_file_name.c_str());
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 84f4e5886b..adfdad2bbf 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -913,7 +913,7 @@ static void finish_delay(const delay_queue_item &delay)
"bottling this corpse's blood"
: "butchering the corpse");
}
- stashes.update_stash(); // Stash-track the generated item(s)
+ StashTrack.update_stash(); // Stash-track the generated item(s)
break;
}
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index ec3ec235aa..e473a1a23a 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1220,7 +1220,7 @@ void save_game(bool leave_game, const char *farewellmsg)
FILE *stashf = fopen(stashFile.c_str(), "wb");
if (stashf)
{
- stashes.save(stashf);
+ StashTrack.save(stashf);
fclose(stashf);
DO_CHMOD_PRIVATE(stashFile.c_str());
}
@@ -1421,7 +1421,7 @@ void restore_game(void)
FILE *stashf = fopen(stashFile.c_str(), "rb");
if (stashf)
{
- stashes.load(stashf);
+ StashTrack.load(stashf);
fclose(stashf);
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e736224964..5202aaa865 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1897,7 +1897,7 @@ bool drop_item( int item_dropped, int quant_drop, bool try_offer )
item_was_destroyed(you.inv[item_dropped], NON_MONSTER);
}
else if (strstr(you.inv[item_dropped].inscription.c_str(), "=s") != 0)
- stashes.add_stash();
+ StashTrack.add_stash();
dec_inv_item_quantity( item_dropped, quant_drop );
you.turn_is_over = true;
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 1fab34bb59..4b92a783f0 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -140,7 +140,7 @@ static int shop_item_value(const item_def& item, int greed, bool id)
static std::string shop_print_stock( const std::vector<int>& stock,
const shop_struct& shop )
{
- ShopInfo &si = stashes.get_shop(shop.x, shop.y);
+ ShopInfo &si = StashTrack.get_shop(shop.x, shop.y);
const bool id = shoptype_identifies_stock(shop.type);
std::string purchasable;
for (unsigned int i = 0; i < stock.size(); ++i)
@@ -185,7 +185,7 @@ static void in_a_shop( int shopidx )
while ( true )
{
- stashes.get_shop(shop.x, shop.y).reset();
+ StashTrack.get_shop(shop.x, shop.y).reset();
std::vector<int> stock = shop_stock(shopidx);
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index dc77699437..9d561e79ae 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -45,14 +45,17 @@
#include <sstream>
#include <algorithm>
+// Global
+StashTracker StashTrack;
+
#define ST_MAJOR_VER ((unsigned char) 4)
#define ST_MINOR_VER ((unsigned char) 7)
void stash_init_new_level()
{
// If there's an existing stash level for Pan, blow it away.
- stashes.remove_level( level_id(LEVEL_PANDEMONIUM) );
- stashes.remove_level( level_id(LEVEL_PORTAL_VAULT) );
+ StashTrack.remove_level( level_id(LEVEL_PANDEMONIUM) );
+ StashTrack.remove_level( level_id(LEVEL_PORTAL_VAULT) );
}
std::string userdef_annotate_item(const char *s, const item_def *item,
@@ -98,7 +101,7 @@ std::string stash_annotate_item(const char *s,
bool is_stash(int x, int y)
{
- LevelStashes *ls = stashes.find_current_level();
+ LevelStashes *ls = StashTrack.find_current_level();
if (ls)
{
Stash *s = ls->find_stash(x, y);
@@ -109,7 +112,7 @@ bool is_stash(int x, int y)
void describe_stash(int x, int y)
{
- LevelStashes *ls = stashes.find_current_level();
+ LevelStashes *ls = StashTrack.find_current_level();
if (ls)
{
Stash *s = ls->find_stash(x, y);
@@ -936,13 +939,16 @@ std::ostream &operator << (std::ostream &os, const ShopInfo &s)
return os;
}
-LevelStashes::LevelStashes() : place(level_id::current()), stashes(), shops()
+LevelStashes::LevelStashes()
+ : m_place(level_id::current()),
+ m_stashes(),
+ m_shops()
{
}
level_id LevelStashes::where() const
{
- return (place);
+ return m_place;
}
Stash *LevelStashes::find_stash(int x, int y)
@@ -959,16 +965,16 @@ const Stash *LevelStashes::find_stash(int x, int y) const
y = you.y_pos;
}
const int abspos = (GXM * y) + x;
- stashes_t::const_iterator st = stashes.find(abspos);
- return (st == stashes.end()? NULL : &st->second);
+ stashes_t::const_iterator st = m_stashes.find(abspos);
+ return (st == m_stashes.end()? NULL : &st->second);
}
const ShopInfo *LevelStashes::find_shop(int x, int y) const
{
- for (unsigned i = 0; i < shops.size(); ++i)
+ for (unsigned i = 0; i < m_shops.size(); ++i)
{
- if (shops[i].isAt(x, y))
- return (&shops[i]);
+ if (m_shops[i].isAt(x, y))
+ return (&m_shops[i]);
}
return (NULL);
}
@@ -990,14 +996,14 @@ bool LevelStashes::needs_visit(int x, int y) const
ShopInfo &LevelStashes::get_shop(int x, int y)
{
- for (unsigned i = 0; i < shops.size(); ++i)
+ for (unsigned i = 0; i < m_shops.size(); ++i)
{
- if (shops[i].isAt(x, y))
- return shops[i];
+ if (m_shops[i].isAt(x, y))
+ return m_shops[i];
}
ShopInfo si(x, y);
si.set_name(shop_name(x, y));
- shops.push_back(si);
+ m_shops.push_back(si);
return get_shop(x, y);
}
@@ -1019,7 +1025,7 @@ bool LevelStashes::update_stash(int x, int y)
// Removes a Stash from the level.
void LevelStashes::kill_stash(const Stash &s)
{
- stashes.erase(s.abs_pos());
+ m_stashes.erase(s.abs_pos());
}
void LevelStashes::no_stash(int x, int y)
@@ -1038,7 +1044,7 @@ void LevelStashes::no_stash(int x, int y)
Stash newStash(x, y);
newStash.enabled = false;
- stashes[ newStash.abs_pos() ] = newStash;
+ m_stashes[ newStash.abs_pos() ] = newStash;
}
mpr(en? "I'll no longer ignore what I see on this square."
@@ -1058,33 +1064,33 @@ void LevelStashes::add_stash(int x, int y)
{
Stash new_stash(x, y);
if (!new_stash.empty())
- stashes[ new_stash.abs_pos() ] = new_stash;
+ m_stashes[ new_stash.abs_pos() ] = new_stash;
}
}
bool LevelStashes::is_current() const
{
- return (place == level_id::current());
+ return (m_place == level_id::current());
}
std::string LevelStashes::level_name() const
{
- return place.describe(true, true);
+ return m_place.describe(true, true);
}
std::string LevelStashes::short_level_name() const
{
- return place.describe();
+ return m_place.describe();
}
-int LevelStashes::count_stashes() const
+int LevelStashes::_num_enabled_stashes() const
{
- int rawcount = stashes.size();
+ int rawcount = m_stashes.size();
if (!rawcount)
return (0);
- for (stashes_t::const_iterator iter = stashes.begin();
- iter != stashes.end(); iter++)
+ for (stashes_t::const_iterator iter = m_stashes.begin();
+ iter != m_stashes.end(); iter++)
{
if (!iter->second.enabled)
--rawcount;
@@ -1097,27 +1103,27 @@ void LevelStashes::get_matching_stashes(
std::vector<stash_search_result> &results)
const
{
- std::string lplace = "{" + place.describe() + "}";
- for (stashes_t::const_iterator iter = stashes.begin();
- iter != stashes.end(); iter++)
+ std::string lplace = "{" + m_place.describe() + "}";
+ for (stashes_t::const_iterator iter = m_stashes.begin();
+ iter != m_stashes.end(); iter++)
{
if (iter->second.enabled)
{
stash_search_result res;
if (iter->second.matches_search(lplace, search, res))
{
- res.pos.id = place;
+ res.pos.id = m_place;
results.push_back(res);
}
}
}
- for (unsigned i = 0; i < shops.size(); ++i)
+ for (unsigned i = 0; i < m_shops.size(); ++i)
{
stash_search_result res;
- if (shops[i].matches_search(lplace, search, res))
+ if (m_shops[i].matches_search(lplace, search, res))
{
- res.pos.id = place;
+ res.pos.id = m_place;
results.push_back(res);
}
}
@@ -1128,18 +1134,18 @@ void LevelStashes::write(std::ostream &os, bool identify) const
if (visible_stash_count() == 0) return ;
os << level_name() << std::endl;
- for (unsigned i = 0; i < shops.size(); ++i)
+ for (unsigned i = 0; i < m_shops.size(); ++i)
{
- shops[i].write(os, identify);
+ m_shops[i].write(os, identify);
}
- if (stashes.size())
+ if (m_stashes.size())
{
- const Stash &s = stashes.begin()->second;
+ const Stash &s = m_stashes.begin()->second;
int refx = s.getX(), refy = s.getY();
std::string levname = short_level_name();
- for (stashes_t::const_iterator iter = stashes.begin();
- iter != stashes.end(); iter++)
+ for (stashes_t::const_iterator iter = m_stashes.begin();
+ iter != m_stashes.end(); iter++)
{
iter->second.write(os, refx, refy, levname, identify);
}
@@ -1150,42 +1156,42 @@ void LevelStashes::write(std::ostream &os, bool identify) const
void LevelStashes::save(FILE *file) const
{
// How many stashes on this level?
- writeShort(file, (short) stashes.size());
+ writeShort(file, (short) m_stashes.size());
- place.save(file);
+ m_place.save(file);
// And write the individual stashes
- for (stashes_t::const_iterator iter = stashes.begin();
- iter != stashes.end(); iter++)
+ for (stashes_t::const_iterator iter = m_stashes.begin();
+ iter != m_stashes.end(); iter++)
iter->second.save(file);
- writeShort(file, (short) shops.size());
- for (unsigned i = 0; i < shops.size(); ++i)
- shops[i].save(file);
+ writeShort(file, (short) m_shops.size());
+ for (unsigned i = 0; i < m_shops.size(); ++i)
+ m_shops[i].save(file);
}
void LevelStashes::load(FILE *file)
{
int size = readShort(file);
- place.load(file);
+ m_place.load(file);
- stashes.clear();
+ m_stashes.clear();
for (int i = 0; i < size; ++i)
{
Stash s;
s.load(file);
if (!s.empty())
- stashes[ s.abs_pos() ] = s;
+ m_stashes[ s.abs_pos() ] = s;
}
- shops.clear();
+ m_shops.clear();
int shopc = readShort(file);
for (int i = 0; i < shopc; ++i)
{
ShopInfo si(0, 0);
si.load(file);
- shops.push_back(si);
+ m_shops.push_back(si);
}
}
@@ -1723,6 +1729,3 @@ bool StashTracker::display_search_results(
}
return false;
}
-
-// Global
-StashTracker stashes;
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h
index c46534ebf3..6102f013fd 100644
--- a/crawl-ref/source/stash.h
+++ b/crawl-ref/source/stash.h
@@ -239,21 +239,22 @@ public:
std::string level_name() const;
std::string short_level_name() const;
- int stash_count() const { return stashes.size() + shops.size(); }
- int visible_stash_count() const { return count_stashes() + shops.size(); }
+ int stash_count() const { return m_stashes.size() + m_shops.size(); }
+ int visible_stash_count() const { return _num_enabled_stashes() + m_shops.size(); }
bool is_current() const;
-private:
- // which level
- level_id place;
+ private:
+ int _num_enabled_stashes() const;
+
+ private:
typedef std::map<int, Stash> stashes_t;
typedef std::vector<ShopInfo> shops_t;
- stashes_t stashes;
- shops_t shops;
-
- int count_stashes() const;
+ // which level
+ level_id m_place;
+ stashes_t m_stashes;
+ shops_t m_shops;
};
extern std::ostream &operator << (std::ostream &, const LevelStashes &);
@@ -326,7 +327,7 @@ private:
stash_levels_t levels;
};
-extern StashTracker stashes;
+extern StashTracker StashTrack;
bool is_stash(int x, int y);
void describe_stash(int x, int y);
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index d308d9cdf3..68470edd73 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -847,7 +847,7 @@ static bool is_valid_explore_target(int x, int y)
if (you.running == RMODE_EXPLORE_GREEDY)
{
- LevelStashes *lev = stashes.find_current_level();
+ LevelStashes *lev = StashTrack.find_current_level();
return (lev && lev->needs_visit(x, y));
}
@@ -1118,7 +1118,7 @@ command_type travel()
if (grd[you.x_pos][you.y_pos] == DNGN_ENTER_SHOP
&& you.running == RMODE_EXPLORE_GREEDY)
{
- LevelStashes *lev = stashes.find_current_level();
+ LevelStashes *lev = StashTrack.find_current_level();
if (lev && lev->shop_needs_visit(you.x_pos, you.y_pos))
{
you.running = 0;
@@ -1178,7 +1178,7 @@ command_type travel()
if (new_x == you.running.x && new_y == you.running.y)
{
- const LevelStashes *lev = stashes.find_current_level();
+ const LevelStashes *lev = StashTrack.find_current_level();
if (lev && lev->needs_visit(new_x, new_y)
&& !lev->shop_needs_visit(new_x, new_y))
{
@@ -1463,7 +1463,7 @@ const coord_def travel_pathfind::pathfind(run_mode_type rmode)
(rmode == RMODE_EXPLORE_GREEDY && can_autopickup());
if (!ls && (annotate_map || need_for_greed))
- ls = stashes.find_current_level();
+ ls = StashTrack.find_current_level();
next_travel_move.reset();
@@ -4022,7 +4022,7 @@ void explore_discoveries::found_item(const coord_def &pos, const item_def &i)
{
// The things we need to do...
if (!current_level)
- current_level = stashes.find_current_level();
+ current_level = StashTrack.find_current_level();
if (current_level
&& !(Options.explore_stop & ES_GREEDY_ITEM)