From af9d6c8e0e2e3f58d255449716ad7875cde5ae07 Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 12 Oct 2008 01:49:12 +0000 Subject: General code improvements. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7220 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/traps.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'crawl-ref/source/traps.cc') diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 6283c59aa5..5e100b44fd 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -148,7 +148,7 @@ bool trap_def::is_known(const actor* act) const rc = player_knows; else if (act->atype() == ACT_MONSTER) { - const monsters* monster = static_cast(act); + const monsters* monster = dynamic_cast(act); const bool mechanical = (this->category() == DNGN_TRAP_MECHANICAL); const int intel = mons_intel(monster); @@ -232,19 +232,19 @@ void monster_caught_in_net(monsters *mon, bolt &pbolt) if (mons_is_insubstantial(mon->type)) { if (mons_near(mon) && player_monster_visible(mon)) - mprf("The net passes right through %s!", mon->name(DESC_NOCAP_THE).c_str()); + mprf("The net passes right through %s!", + mon->name(DESC_NOCAP_THE).c_str()); return; } - const monsters* mons = static_cast(mon); - bool mon_flies = mons->flight_mode() == FL_FLY; - if (mon_flies && (!mons_is_confused(mons) || one_chance_in(3))) + bool mon_flies = mon->flight_mode() == FL_FLY; + if (mon_flies && (!mons_is_confused(mon) || one_chance_in(3))) { simple_monster_message(mon, " darts out from under the net!"); return; } - if (mons->type == MONS_OOZE || mons->type == MONS_PULSATING_LUMP) + if (mon->type == MONS_OOZE || mon->type == MONS_PULSATING_LUMP) { simple_monster_message(mon, " oozes right through the net!"); return; @@ -356,7 +356,7 @@ void trap_def::trigger(actor& triggerer, bool flat_footed) monsters* m = NULL; if (triggerer.atype() == ACT_MONSTER) - m = static_cast(&triggerer); + m = dynamic_cast(&triggerer); // Anything stepping onto a trap almost always reveals it. // (We can rehide it later for the exceptions.) @@ -1177,9 +1177,7 @@ void trap_def::shoot_ammo(actor& act, bool was_known) } else if (act.atype() == ACT_MONSTER) { - // XXX reveal the trap XXX - - monsters* monster = static_cast(&act); + monsters* monster = dynamic_cast(&act); // Determine whether projectile hits. bool hit = (((20+(you.your_level*2))*random2(200))/100 -- cgit v1.2.3-54-g00ecf