summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/shout.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/shout.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/shout.cc')
-rw-r--r--crawl-ref/source/shout.cc70
1 files changed, 35 insertions, 35 deletions
diff --git a/crawl-ref/source/shout.cc b/crawl-ref/source/shout.cc
index ce0ad3ce5e..8e943e5c85 100644
--- a/crawl-ref/source/shout.cc
+++ b/crawl-ref/source/shout.cc
@@ -76,7 +76,7 @@ void handle_monster_shouts(monster* mons, bool force)
mon_acting mact(mons);
- std::string default_msg_key = "";
+ string default_msg_key = "";
switch (s_type)
{
@@ -146,8 +146,8 @@ void handle_monster_shouts(monster* mons, bool force)
if (s_type == S_DEMON_TAUNT)
s_type = mons_shouts(mons->type, true);
- std::string msg, suffix;
- std::string key = mons_type_name(mons->type, DESC_PLAIN);
+ string msg, suffix;
+ string key = mons_type_name(mons->type, DESC_PLAIN);
// Pandemonium demons have random names, so use "pandemonium lord"
if (mons->type == MONS_PANDEMONIUM_LORD)
@@ -156,7 +156,7 @@ void handle_monster_shouts(monster* mons, bool force)
else if (mons->type == MONS_PLAYER_GHOST)
{
const ghost_demon &ghost = *(mons->ghost);
- std::string ghost_job = get_job_name(ghost.job);
+ string ghost_job = get_job_name(ghost.job);
key = ghost_job + " player ghost";
@@ -185,7 +185,7 @@ void handle_monster_shouts(monster* mons, bool force)
// See if there's a shout for all monsters using the
// same glyph/symbol
- std::string glyph_key = "'";
+ string glyph_key = "'";
// Database keys are case-insensitve.
if (isaupper(mchar))
@@ -202,7 +202,7 @@ void handle_monster_shouts(monster* mons, bool force)
if (default_msg_key == "__BUGGY")
{
msg::streams(MSGCH_SOUND) << "You hear something buggy!"
- << std::endl;
+ << endl;
}
else if (s_type == S_SILENT && (msg.empty() || msg == "__NONE"))
; // No "visual shout" defined for silent monster, do nothing.
@@ -210,18 +210,18 @@ void handle_monster_shouts(monster* mons, bool force)
{
msg::streams(MSGCH_DIAGNOSTICS)
<< "No shout entry for default shout type '"
- << default_msg_key << "'" << std::endl;
+ << default_msg_key << "'" << endl;
msg::streams(MSGCH_SOUND) << "You hear something buggy!"
- << std::endl;
+ << endl;
}
else if (msg == "__NONE")
{
msg::streams(MSGCH_DIAGNOSTICS)
<< "__NONE returned as shout for non-silent monster '"
- << default_msg_key << "'" << std::endl;
+ << default_msg_key << "'" << endl;
msg::streams(MSGCH_SOUND) << "You hear something buggy!"
- << std::endl;
+ << endl;
}
else
{
@@ -263,7 +263,7 @@ void handle_monster_shouts(monster* mons, bool force)
}
msg = do_mon_str_replacements(msg, mons, s_type);
- msg::streams(channel) << msg << std::endl;
+ msg::streams(channel) << msg << endl;
}
}
@@ -344,7 +344,7 @@ bool check_awaken(monster* mons)
return false;
}
-void item_noise(const item_def &item, std::string msg, int loudness)
+void item_noise(const item_def &item, string msg, int loudness)
{
if (is_unrandom_artefact(item))
{
@@ -357,10 +357,10 @@ void item_noise(const item_def &item, std::string msg, int loudness)
// Set appropriate channel (will usually be TALK).
msg_channel_type channel = MSGCH_TALK;
- std::string param;
- const std::string::size_type pos = msg.find(":");
+ string param;
+ const string::size_type pos = msg.find(":");
- if (pos != std::string::npos)
+ if (pos != string::npos)
param = msg.substr(0, pos);
if (!param.empty())
@@ -420,7 +420,7 @@ void noisy_equipment()
if (silenced(you.pos()) || !one_chance_in(20))
return;
- std::string msg;
+ string msg;
const item_def* weapon = you.weapon();
if (!weapon)
@@ -428,8 +428,8 @@ void noisy_equipment()
if (is_unrandom_artefact(*weapon))
{
- std::string name = weapon->name(DESC_PLAIN, false, true, false, false,
- ISFLAG_IDENT_MASK);
+ string name = weapon->name(DESC_PLAIN, false, true, false, false,
+ ISFLAG_IDENT_MASK);
msg = getSpeakString(name);
if (msg == "NONE")
return;
@@ -484,12 +484,12 @@ bool noisy(int original_loudness, const coord_def& where,
// [ds] Reduce noise propagation for Sprint.
const int scaled_loudness =
- crawl_state.game_is_sprint()? std::max(1, div_rand_round(loudness, 2))
+ crawl_state.game_is_sprint()? max(1, div_rand_round(loudness, 2))
: loudness;
// Add +1 to scaled_loudness so that all squares adjacent to a
// sound of loudness 1 will hear the sound.
- const std::string noise_msg(msg? msg : "");
+ const string noise_msg(msg? msg : "");
_noise_grid.register_noise(
noise_t(where,
noise_msg,
@@ -504,7 +504,7 @@ bool noisy(int original_loudness, const coord_def& where,
// these reasons, use the simple old noise system to check if the
// player heard the noise:
const int dist = loudness * loudness + 1;
- const int player_distance = distance(you.pos(), where);
+ const int player_distance = distance2(you.pos(), where);
// Message the player.
if (player_distance <= dist && player_can_hear(where))
@@ -557,7 +557,7 @@ static const char* _player_spider_senses_web(int dist)
void check_player_sense(sense_type sense, int range, const coord_def& where)
{
- const int player_distance = distance(you.pos(), where);
+ const int player_distance = distance2(you.pos(), where);
if (player_distance <= range)
{
@@ -644,7 +644,7 @@ void check_monsters_sense(sense_type sense, int range, const coord_def& where)
int level = ench.degree;
if (level < 4 && one_chance_in(2*level))
ench.degree++;
- ench.duration = std::max(ench.duration, dur);
+ ench.duration = max(ench.duration, dur);
mi->update_ench(ench);
}
else
@@ -771,8 +771,8 @@ int noise_cell::turn_angle(const coord_def &next_delta) const
return 4;
}
- const int xdiff = std::abs(neighbour_delta.x - next_delta.x);
- const int ydiff = std::abs(neighbour_delta.y - next_delta.y);
+ const int xdiff = abs(neighbour_delta.x - next_delta.x);
+ const int ydiff = abs(neighbour_delta.y - next_delta.y);
return xdiff + ydiff;
}
@@ -811,7 +811,7 @@ void noise_grid::propagate_noise()
#ifdef DEBUG_NOISE_PROPAGATION
dprf("noise_grid: %u noises to apply", (unsigned int)noises.size());
#endif
- std::vector<coord_def> noise_perimeter[2];
+ vector<coord_def> noise_perimeter[2];
int circ_index = 0;
for (int i = 0, size = noises.size(); i < size; ++i)
@@ -820,8 +820,8 @@ void noise_grid::propagate_noise()
int travel_distance = 0;
while (!noise_perimeter[circ_index].empty())
{
- const std::vector<coord_def> &perimeter(noise_perimeter[circ_index]);
- std::vector<coord_def> &next_perimeter(noise_perimeter[!circ_index]);
+ const vector<coord_def> &perimeter(noise_perimeter[circ_index]);
+ vector<coord_def> &next_perimeter(noise_perimeter[!circ_index]);
++travel_distance;
for (int i = 0, size = perimeter.size(); i < size; ++i)
{
@@ -953,8 +953,8 @@ void noise_grid::apply_noise_effects(const coord_def &pos,
static coord_def _point_clamped_in_bounds(const coord_def &p)
{
return coord_def(
- std::min(X_BOUND_2 - 1, std::max(X_BOUND_1 + 1, p.x)),
- std::min(Y_BOUND_2 - 1, std::max(Y_BOUND_1 + 1, p.y)));
+ min(X_BOUND_2 - 1, max(X_BOUND_1 + 1, p.x)),
+ min(Y_BOUND_2 - 1, max(Y_BOUND_1 + 1, p.y)));
}
// Given an actor at affected_pos and a given noise, calculates where
@@ -1044,7 +1044,7 @@ coord_def noise_grid::noise_perceived_position(actor *act,
#include <math.h>
// Return HTML RGB triple given a hue and assuming chroma of 0.86 (220)
-static std::string _hue_rgb(int hue)
+static string _hue_rgb(int hue)
{
const int chroma = 220;
const double hue2 = hue / 60.0;
@@ -1064,7 +1064,7 @@ static std::string _hue_rgb(int hue)
return make_stringf("%02x%02x%02x", red, green, blue);
}
-static std::string _noise_intensity_styles()
+static string _noise_intensity_styles()
{
// Hi-intensity sound will be red (HSV 0), low intensity blue (HSV 240).
const int hi_hue = 0;
@@ -1072,7 +1072,7 @@ static std::string _noise_intensity_styles()
const int huespan = lo_hue - hi_hue;
const int max_intensity = 25;
- std::string styles;
+ string styles;
for (int intensity = 1; intensity <= max_intensity; ++intensity)
{
const int hue = lo_hue - intensity * huespan / max_intensity;
@@ -1096,7 +1096,7 @@ static void _write_noise_grid_css(FILE *outf)
void noise_grid::write_cell(FILE *outf, coord_def p, int ch) const
{
- const int intensity = std::min(25, cells(p).noise_intensity_millis / 1000);
+ const int intensity = min(25, cells(p).noise_intensity_millis / 1000);
if (intensity)
fprintf(outf,
"<span class='i%d'>&#%d;</span>",
@@ -1132,7 +1132,7 @@ void noise_grid::write_noise_grid(FILE *outf) const
fprintf(outf, "</div>\n");
}
-void noise_grid::dump_noise_grid(const std::string &filename) const
+void noise_grid::dump_noise_grid(const string &filename) const
{
FILE *outf = fopen(filename.c_str(), "w");
fprintf(outf, "<!DOCTYPE html><html><head>");