From 79136298e9230c5f6fa23aacd9b28b204aed3694 Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 13 Jan 2009 22:57:15 +0000 Subject: More code cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8446 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 76 +++++++++++++++----------------------------- crawl-ref/source/beam.h | 9 +++--- crawl-ref/source/describe.cc | 6 ++-- 3 files changed, 32 insertions(+), 59 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 99059e85ff..1ee3838a4b 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -69,11 +69,8 @@ REVISION("$Rev$"); static void _ench_animation(int flavour, const monsters *mon = NULL, bool force = false); static void _zappy(zap_type z_type, int power, bolt &pbolt); - static beam_type _chaos_beam_flavour(); -static std::set beam_message_cache; - tracer_info::tracer_info() { reset(); @@ -175,53 +172,30 @@ static void _ench_animation( int flavour, const monsters *mon, bool force ) zap_animation( element_colour( elem ), mon, force ); } -static void _beam_set_default_values(bolt &beam, int power) -{ - beam.hit = 0; // default for "0" beams (I think) - beam.damage = dice_def( 1, 0 ); // default for "0" beams (I think) - beam.type = 0; // default for "0" beams - beam.flavour = BEAM_MAGIC; // default for "0" beams - beam.real_flavour = BEAM_MAGIC; // default for "0" beams - beam.ench_power = power; - beam.obvious_effect = false; - beam.is_beam = false; // default for all beams. - beam.is_tracer = false; // default for all player beams - beam.thrower = KILL_YOU_MISSILE; // missile from player - beam.reflections = 0; // no reflections yet - beam.bounces = 0; // no bounces yet - beam.seen = false; // not seen yet - beam.aux_source.clear(); // additional source info, unused -} - // If needs_tracer is true, we need to check the beam path for friendly -// monsters for *player beams* only! If allies are found, the player is -// prompted to stop or continue. -bool zapping(zap_type ztype, int power, bolt &pbolt, bool needs_tracer, - std::string msg) +// monsters. +bool zapping(zap_type ztype, int power, bolt &pbolt, + bool needs_tracer, const char* msg) { #if DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "zapping: power=%d", power ); #endif - _beam_set_default_values(pbolt, power); + pbolt.thrower = KILL_YOU_MISSILE; - // For player bolts, check whether tracer goes through friendlies. + // Check whether tracer goes through friendlies. // NOTE: Whenever zapping() is called with a randomized value for power // (or effect), player_tracer should be called directly with the highest // power possible respecting current skill, experience level, etc. - - if (needs_tracer && pbolt.thrower == KILL_YOU_MISSILE - && !player_tracer(ztype, power, pbolt)) - { + if (needs_tracer && !player_tracer(ztype, power, pbolt)) return (false); - } // Fill in the bolt structure. - _zappy( ztype, power, pbolt ); + _zappy(ztype, power, pbolt); - if (!msg.empty()) - mpr(msg.c_str()); + if (msg) + mpr(msg); if (ztype == ZAP_LIGHTNING) noisy(25, you.pos(), "You hear a mighty clap of thunder!"); @@ -244,8 +218,6 @@ bool player_tracer( zap_type ztype, int power, bolt &pbolt, int range) if (you.confused()) return (true); - // FIXME: can this be removed? - _beam_set_default_values(pbolt, power); _zappy(ztype, power, pbolt); pbolt.name = "unimportant"; @@ -1304,8 +1276,7 @@ const zap_info zap_data[] = { }; -// Need to see zapping() for default values not set within this function {dlb} -static void _zappy( zap_type z_type, int power, bolt &pbolt ) +static void _zappy(zap_type z_type, int power, bolt &pbolt) { const zap_info* zinfo = NULL; @@ -1360,7 +1331,7 @@ static void _zappy( zap_type z_type, int power, bolt &pbolt ) // One special case if (z_type == ZAP_ICE_STORM) - pbolt.ench_power = power; // used for radius + pbolt.ench_power = power; // used for radius } // Affect monster in wall unless it can shield itself using the wall. @@ -1736,7 +1707,10 @@ void bolt::nuke_wall_effect() || feat == DNGN_WAX_WALL || feat == DNGN_CLEAR_ROCK_WALL) { - // FIXME: Blood *does* transfer to the floor here? + // Blood does not transfer onto floor. + if (is_bloodcovered(pos())) + env.map(pos()).property &= ~(FPROP_BLOODY); + grd(pos()) = DNGN_FLOOR; if (player_can_hear(pos())) { @@ -1900,6 +1874,7 @@ void bolt::fire() colour = boltcopy.colour; flavour = boltcopy.flavour; real_flavour = boltcopy.real_flavour; + seen = boltcopy.seen; } else do_fire(); @@ -5118,6 +5093,7 @@ static sweep_type _radial_sweep(int r) #define MAX_EXPLOSION_RADIUS 9 +// Returns true if we saw something happening. bool bolt::explode(bool show_more, bool hole_in_the_middle) { ASSERT(!in_explosion_phase); @@ -5194,6 +5170,7 @@ bool bolt::explode(bool show_more, bool hole_in_the_middle) for (viter cci = ci->begin(); cci != ci->end(); ++cci) { const coord_def delta = *cci; + if (delta.origin() && hole_in_the_middle) continue; @@ -5274,15 +5251,14 @@ void bolt::determine_affected_cells(explosion_map& m, const coord_def& delta, const dungeon_feature_type dngn_feat = grd(loc); - // Check to see if we're blocked by something specifically, we're - // blocked by WALLS. Not statues, idols, etc. Special case: - // Explosion originates from rock/statue (e.g. Lee's rapid - // deconstruction) - in this case, ignore solid cells at the - // center of the explosion. + // Check to see if we're blocked by a wall. if (grid_is_wall(dngn_feat) || dngn_feat == DNGN_SECRET_DOOR || dngn_feat == DNGN_CLOSED_DOOR) { + // Special case: explosion originates from rock/statue + // (e.g. Lee's Rapid Deconstruction) - in this case, ignore + // solid cells at the center of the explosion. if (stop_at_walls && !(delta.origin() && affects_wall(dngn_feat))) return; } @@ -5469,7 +5445,7 @@ void bolt::set_agent(actor *actor) else { thrower = KILL_MON_MISSILE; - beam_source = monster_index(dynamic_cast(actor)); + beam_source = actor->mindex(); } } @@ -5478,7 +5454,7 @@ actor* bolt::agent() const if (YOU_KILL(this->thrower)) return (&you); else if (!invalid_monster_index(beam_source)) - return (&menv[this->beam_source]); + return (&menv[beam_source]); else return (NULL); } @@ -5489,7 +5465,7 @@ bool bolt::is_enchantment() const && this->flavour <= BEAM_LAST_ENCHANTMENT); } -std::string bolt::get_short_name() +std::string bolt::get_short_name() const { if (!short_name.empty()) return (short_name); @@ -5500,7 +5476,7 @@ std::string bolt::get_short_name() | ISFLAG_RACIAL_MASK); if (real_flavour == BEAM_RANDOM || real_flavour == BEAM_CHAOS) - flavour = real_flavour; + return beam_type_name(real_flavour); if (flavour == BEAM_FIRE && name == "sticky fire") return ("sticky fire"); diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index 0ae871b6ee..924e1cd7c4 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -142,7 +142,7 @@ public: // Returns member short_name if set, otherwise some reasonable string // for a short name, most likely the name of the beam's flavour. - std::string get_short_name(); + std::string get_short_name() const; // Assume that all saving throws are failed, actually apply // the enchantment. @@ -273,10 +273,9 @@ void fire_tracer( const monsters *monster, struct bolt &pbolt, bool explode_only = false ); bool check_line_of_sight( const coord_def& source, const coord_def& target ); void mimic_alert( monsters *mimic ); -bool zapping( zap_type ztype, int power, struct bolt &pbolt, - bool needs_tracer = false, std::string msg = "" ); -bool player_tracer( zap_type ztype, int power, struct bolt &pbolt, - int range = 0 ); +bool zapping(zap_type ztype, int power, bolt &pbolt, + bool needs_tracer = false, const char* msg = NULL); +bool player_tracer(zap_type ztype, int power, bolt &pbolt, int range = 0); std::string beam_type_name(beam_type type); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 000302d9fd..ce6056b292 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -521,10 +521,8 @@ static std::string _randart_descrip( const item_def &item ) if (propdescs[i].is_graded_resist) { int idx = proprt[propdescs[i].property] + 3; - if (idx < 0) - idx = 0; - if (idx > 6) - idx = 6; + idx = std::min(idx, 6); + idx = std::max(idx, 0); const char* prefixes[] = { "It makes you extremely vulnerable to ", -- cgit v1.2.3-54-g00ecf