diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-08-31 00:44:20 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-08-31 00:44:20 +0200 |
commit | a9eeb4a370e85069c25286e5cedc9682d5d04b2e (patch) | |
tree | 450c0ccd5f5353553d5b96edee2850623dffcc03 /crawl-ref/source/shout.cc | |
parent | 57aec7d2a0ae1095fb1babd8f0fcc276927bf8e5 (diff) | |
parent | 35613e094ca5d0be028ee9261afebf3e35faa563 (diff) | |
download | crawl-ref-a9eeb4a370e85069c25286e5cedc9682d5d04b2e.tar.gz crawl-ref-a9eeb4a370e85069c25286e5cedc9682d5d04b2e.zip |
Merge branch 'master' into glasnost
Yay for conflicts galore (wax removal, std:: purge, tileidx changes).
Diffstat (limited to 'crawl-ref/source/shout.cc')
-rw-r--r-- | crawl-ref/source/shout.cc | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/crawl-ref/source/shout.cc b/crawl-ref/source/shout.cc index be14eee1b0..9ea04758df 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 @@ -698,8 +698,9 @@ void blood_smell(int strength, const coord_def& where) int vamp_range = vamp_strength * vamp_strength; check_player_sense(SENSE_SMELL_BLOOD, vamp_range, where); } - check_monsters_sense(SENSE_SMELL_BLOOD, range, where); } + + check_monsters_sense(SENSE_SMELL_BLOOD, range, where); } ////////////////////////////////////////////////////////////////////////////// @@ -765,10 +766,12 @@ int noise_cell::turn_angle(const coord_def &next_delta) const // Going in reverse? if (next_delta.x == -neighbour_delta.x && next_delta.y == -neighbour_delta.y) + { 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; } @@ -807,7 +810,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) @@ -816,8 +819,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) { @@ -885,9 +888,11 @@ bool noise_grid::propagate_noise_to_neighbour(int base_attenuation, const coord_def &next_pos) { noise_cell &neighbour(cells(next_pos)); - if (!neighbour.can_apply_noise(cell.noise_intensity_millis - - base_attenuation)) + if (!neighbour.can_apply_noise(cell.noise_intensity_millis + - base_attenuation)) + { return false; + } // Diagonals cost more. if ((next_pos - current_pos).abs() == 2) @@ -947,8 +952,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 @@ -1038,7 +1043,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; @@ -1058,7 +1063,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; @@ -1066,7 +1071,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; @@ -1090,7 +1095,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>", @@ -1126,7 +1131,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>"); |