summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-speak.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2012-08-26 22:50:06 +0200
committerRaphael Langella <raphael.langella@gmail.com>2012-08-26 23:06:30 +0200
commit770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch)
treee030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/mon-speak.cc
parenta6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff)
downloadcrawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz
crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts with the STL function to compare 2 iterators. Not a bad change given how it returns the square of the distance anyway. I also had to rename the message global variable (in message.cc) to buffer. I tried to fix and improve the coding style has much as I could, but I probably missed a few given how huge and tedious it is. I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/mon-speak.cc')
-rw-r--r--crawl-ref/source/mon-speak.cc126
1 files changed, 63 insertions, 63 deletions
diff --git a/crawl-ref/source/mon-speak.cc b/crawl-ref/source/mon-speak.cc
index ecea930f21..442040d17a 100644
--- a/crawl-ref/source/mon-speak.cc
+++ b/crawl-ref/source/mon-speak.cc
@@ -36,13 +36,13 @@
// If that fails, start ignoring hostile/religion/branch/silence, in that order,
// first skipping hostile, then hostile *and* religion, then hostile, religion
// *and* branch, then finally all five.
-static std::string __try_exact_string(const std::vector<std::string> &prefixes,
- const std::string &key,
- bool ignore_hostile = false,
- bool ignore_related = false,
- bool ignore_religion = false,
- bool ignore_branch = false,
- bool ignore_silenced = false)
+static string __try_exact_string(const vector<string> &prefixes,
+ const string &key,
+ bool ignore_hostile = false,
+ bool ignore_related = false,
+ bool ignore_religion = false,
+ bool ignore_branch = false,
+ bool ignore_silenced = false)
{
bool hostile = false;
bool related = false;
@@ -50,8 +50,8 @@ static std::string __try_exact_string(const std::vector<std::string> &prefixes,
bool branch = false;
bool silenced = false;
- std::string prefix = "";
- std::string msg = "";
+ string prefix = "";
+ string msg = "";
const int size = prefixes.size();
for (int i = 0; i < size; i++)
{
@@ -127,20 +127,20 @@ static std::string __try_exact_string(const std::vector<std::string> &prefixes,
return msg;
}
-static bool _invalid_msg(const std::string &msg, bool no_player, bool no_foe,
+static bool _invalid_msg(const string &msg, bool no_player, bool no_foe,
bool no_foe_name, bool no_god, bool unseen)
{
if (no_player
- && (msg.find("@player") != std::string::npos
- || msg.find("@Player") != std::string::npos
- || msg.find(":You") != std::string::npos))
+ && (msg.find("@player") != string::npos
+ || msg.find("@Player") != string::npos
+ || msg.find(":You") != string::npos))
{
return true;
}
if (no_player)
{
- std::vector<std::string> lines = split_string("\n", msg);
+ vector<string> lines = split_string("\n", msg);
for (unsigned int i = 0; i < lines.size(); i++)
{
if (starts_with(lines[i], "You")
@@ -151,41 +151,41 @@ static bool _invalid_msg(const std::string &msg, bool no_player, bool no_foe,
}
}
- if (no_foe && (msg.find("@foe") != std::string::npos
- || msg.find("@Foe") != std::string::npos
- || msg.find("foe@") != std::string::npos
- || msg.find("@species") != std::string::npos))
+ if (no_foe && (msg.find("@foe") != string::npos
+ || msg.find("@Foe") != string::npos
+ || msg.find("foe@") != string::npos
+ || msg.find("@species") != string::npos))
{
return true;
}
- if (no_god && (msg.find("_god@") != std::string::npos
- || msg.find("@god_") != std::string::npos))
+ if (no_god && (msg.find("_god@") != string::npos
+ || msg.find("@god_") != string::npos))
{
return true;
}
- if (no_foe_name && msg.find("@foe_name@") != std::string::npos)
+ if (no_foe_name && msg.find("@foe_name@") != string::npos)
return true;
- if (unseen && msg.find("VISUAL") != std::string::npos)
+ if (unseen && msg.find("VISUAL") != string::npos)
return true;
return false;
}
-static std::string _try_exact_string(const std::vector<std::string> &prefixes,
- const std::string &key,
- bool no_player, bool no_foe,
- bool no_foe_name, bool no_god,
- bool unseen,
- bool ignore_hostile = false,
- bool ignore_related = false,
- bool ignore_religion = false,
- bool ignore_branch = false,
- bool ignore_silenced = false)
+static string _try_exact_string(const vector<string> &prefixes,
+ const string &key,
+ bool no_player, bool no_foe,
+ bool no_foe_name, bool no_god,
+ bool unseen,
+ bool ignore_hostile = false,
+ bool ignore_related = false,
+ bool ignore_religion = false,
+ bool ignore_branch = false,
+ bool ignore_silenced = false)
{
- std::string msg;
+ string msg;
for (int tries = 0; tries < 10; tries++)
{
msg =
@@ -217,22 +217,22 @@ static std::string _try_exact_string(const std::vector<std::string> &prefixes,
return msg;
}
-static std::string __get_speak_string(const std::vector<std::string> &prefixes,
- const std::string &key,
- const monster* mons,
- bool no_player, bool no_foe,
- bool no_foe_name, bool no_god,
- bool unseen)
+static string __get_speak_string(const vector<string> &prefixes,
+ const string &key,
+ const monster* mons,
+ bool no_player, bool no_foe,
+ bool no_foe_name, bool no_god,
+ bool unseen)
{
- std::string msg = _try_exact_string(prefixes, key, no_player, no_foe,
- no_foe_name, no_god, unseen);
+ string msg = _try_exact_string(prefixes, key, no_player, no_foe,
+ no_foe_name, no_god, unseen);
if (!msg.empty())
return msg;
// Combinations of prefixes by threes
const int size = prefixes.size();
- std::string prefix = "";
+ string prefix = "";
if (size >= 3)
{
for (int i = 0; i < (size - 2); i++)
@@ -286,12 +286,12 @@ static std::string __get_speak_string(const std::vector<std::string> &prefixes,
return msg;
}
-static std::string _get_speak_string(const std::vector<std::string> &prefixes,
- std::string key,
- const monster* mons,
- bool no_player, bool no_foe,
- bool no_foe_name, bool no_god,
- bool unseen)
+static string _get_speak_string(const vector<string> &prefixes,
+ string key,
+ const monster* mons,
+ bool no_player, bool no_foe,
+ bool no_foe_name, bool no_god,
+ bool unseen)
{
int duration = 1;
if (mons->hit_points <= 0)
@@ -301,7 +301,7 @@ static std::string _get_speak_string(const std::vector<std::string> &prefixes,
else if (mons->is_summoned(&duration) && duration <= 0)
key += " unsummoned";
- std::string msg;
+ string msg;
for (int tries = 0; tries < 10; tries++)
{
msg =
@@ -445,7 +445,7 @@ bool mons_speaks(monster* mons)
return false;
}
- std::vector<std::string> prefixes;
+ vector<string> prefixes;
if (mons->neutral())
{
if (!force_speak && coinflip()) // Neutrals speak half as often.
@@ -535,11 +535,11 @@ bool mons_speaks(monster* mons)
// Include our current branch, too. It can make speech vary by branch for
// uniques and other monsters! Specifically, Donald.
- prefixes.push_back(std::string(branches[you.where_are_you].shortname));
+ prefixes.push_back(string(branches[you.where_are_you].shortname));
#ifdef DEBUG_MONSPEAK
{
- std::string prefix;
+ string prefix;
const int size = prefixes.size();
for (int i = 0; i < size; i++)
{
@@ -562,7 +562,7 @@ bool mons_speaks(monster* mons)
const bool no_foe_name = !named_foe
|| (mon_foe && (m_foe->flags & MF_NAME_MASK));
- std::string msg;
+ string msg;
// First, try its exact name.
if (mons->type == MONS_PLAYER_GHOST)
@@ -570,8 +570,8 @@ bool mons_speaks(monster* mons)
if (one_chance_in(5))
{
const ghost_demon &ghost = *(mons->ghost);
- std::string ghost_skill = skill_name(ghost.best_skill);
- std::vector<std::string> with_skill = prefixes;
+ string ghost_skill = skill_name(ghost.best_skill);
+ vector<string> with_skill = prefixes;
with_skill.push_back(ghost_skill);
msg = _get_speak_string(with_skill, "player ghost", mons,
no_player, no_foe, no_foe_name, no_god,
@@ -606,7 +606,7 @@ bool mons_speaks(monster* mons)
// Try again without the prefixes if the key is empty. Vaults
// *really* want monsters to use the key specified, rather than
// the key with prefixes.
- std::vector<std::string> faux_prefixes;
+ vector<string> faux_prefixes;
msg = _get_speak_string(faux_prefixes,
mons->props["dbname"].get_string(),
mons, no_player, no_foe, no_foe_name,
@@ -663,7 +663,7 @@ bool mons_speaks(monster* mons)
// so try the monster's glyph/symbol.
if (msg.empty() || msg == "__NEXT")
{
- std::string key = "'";
+ string key = "'";
// Database keys are case-insensitve.
if (isaupper(mons_base_char(mons->type)))
@@ -757,7 +757,7 @@ bool mons_speaks(monster* mons)
if (msg.empty() || msg == "__NONE" || msg == "__NEXT")
{
shape = MON_SHAPE_HUMANOID_WINGED;
- std::string msg2;
+ string msg2;
msg2 = _get_speak_string(prefixes, get_mon_shape_str(shape),
mons, no_player, no_foe,
no_foe_name, no_god, unseen);
@@ -797,14 +797,14 @@ bool mons_speaks(monster* mons)
{
msg::streams(MSGCH_DIAGNOSTICS)
<< "__NEXT used by shape-based speech string for monster '"
- << mons->name(DESC_PLAIN) << "'" << std::endl;
+ << mons->name(DESC_PLAIN) << "'" << endl;
return false;
}
return mons_speaks_msg(mons, msg, MSGCH_TALK, silence);
}
-bool mons_speaks_msg(monster* mons, const std::string &msg,
+bool mons_speaks_msg(monster* mons, const string &msg,
const msg_channel_type def_chan, bool silence)
{
if (!mons_near(mons))
@@ -813,14 +813,14 @@ bool mons_speaks_msg(monster* mons, const std::string &msg,
mon_acting mact(mons);
// We have a speech string, now parse and act on it.
- const std::string _msg = do_mon_str_replacements(msg, mons);
- const std::vector<std::string> lines = split_string("\n", _msg);
+ const string _msg = do_mon_str_replacements(msg, mons);
+ const vector<string> lines = split_string("\n", _msg);
bool noticed = false; // Any messages actually printed?
for (int i = 0, size = lines.size(); i < size; ++i)
{
- std::string line = lines[i];
+ string line = lines[i];
// This function is a little bit of a problem for the message
// channels since some of the messages it generates are "fake"