From 111787503763e9d3eeb4eef2248926bf4a4eeb98 Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 24 Jul 2008 10:38:05 +0000 Subject: More cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6669 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 12 +- crawl-ref/source/beam.cc | 2 +- crawl-ref/source/decks.cc | 8 +- crawl-ref/source/delay.cc | 4 +- crawl-ref/source/effects.cc | 20 ++-- crawl-ref/source/effects.h | 8 +- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/it_use3.cc | 2 +- crawl-ref/source/item_use.cc | 6 +- crawl-ref/source/luadgn.cc | 2 +- crawl-ref/source/mstuff2.cc | 2 +- crawl-ref/source/religion.cc | 2 +- crawl-ref/source/spells3.cc | 2 +- crawl-ref/source/spells4.cc | 200 ++++++++++++++----------------- crawl-ref/source/spells4.h | 4 +- crawl-ref/source/spl-cast.cc | 6 +- crawl-ref/source/spl-util.cc | 276 ++++++++++++++++++------------------------- crawl-ref/source/spl-util.h | 37 ++---- crawl-ref/source/stuff.cc | 4 +- crawl-ref/source/stuff.h | 14 +-- crawl-ref/source/view.cc | 3 +- 21 files changed, 258 insertions(+), 358 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 858e5ceed9..e49ad38e76 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1348,7 +1348,7 @@ static bool _do_ability(const ability_def& abil) return (false); } - torment(TORMENT_GENERIC, you.x_pos, you.y_pos); + torment(TORMENT_GENERIC, you.pos()); break; case ABIL_RAISE_DEAD: @@ -1881,7 +1881,7 @@ static bool _do_ability(const ability_def& abil) return (false); } - torment(TORMENT_GENERIC, you.x_pos, you.y_pos); + torment(TORMENT_GENERIC, you.pos()); exercise(SK_INVOCATIONS, 2 + random2(4)); break; @@ -2381,12 +2381,12 @@ static int _find_ability_slot( ability_type which_ability ) //////////////////////////////////////////////////////////////////////////// -static int _lugonu_warp_monster(int x, int y, int pow, int) +static int _lugonu_warp_monster(coord_def where, int pow, int) { - if (!in_bounds(x, y) || mgrd[x][y] == NON_MONSTER) + if (!in_bounds(where) || mgrd(where) == NON_MONSTER) return (0); - monsters &mon = menv[ mgrd[x][y] ]; + monsters &mon = menv[ mgrd(where) ]; if (!mons_friendly(&mon)) behaviour_event( &mon, ME_ANNOY, MHITYOU ); @@ -2415,7 +2415,7 @@ static int _lugonu_warp_monster(int x, int y, int pow, int) static void _lugonu_warp_area(int pow) { - apply_area_around_square( _lugonu_warp_monster, you.x_pos, you.y_pos, pow ); + apply_area_around_square( _lugonu_warp_monster, you.pos(), pow ); } static void _lugonu_bends_space() diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 53f243b776..98aaad6d35 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -5087,7 +5087,7 @@ static int _affect_monster_enchantment(bolt &beam, monsters *mon) if (beam.flavour == BEAM_BACKLIGHT) { - if (backlight_monsters(mon->x, mon->y, beam.hit, 0)) + if (backlight_monsters(mon->pos(), beam.hit, 0)) { beam.obvious_effect = true; return (MON_AFFECTED); diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 0629fc1c3d..62d558fdd4 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -1561,14 +1561,14 @@ static void _minefield_card(int power, deck_rarity_type rarity) } } -static int _drain_monsters(int x, int y, int pow, int garbage) +static int _drain_monsters(coord_def where, int pow, int garbage) { UNUSED( garbage ); - if (coord_def(x,y) == you.pos()) + if (where == you.pos()) drain_exp(); else { - const int mnstr = mgrd[x][y]; + const int mnstr = mgrd(where); if (mnstr == NON_MONSTER) return 0; @@ -2811,7 +2811,7 @@ bool card_effect(card_type which_card, deck_rarity_type rarity, case CARD_TROWEL: rc = _trowel_card(power, rarity); break; case CARD_SPADE: your_spells(SPELL_DIG, random2(power/4), false); break; case CARD_BANSHEE: mass_enchantment(ENCH_FEAR, power, MHITYOU); break; - case CARD_TORMENT: torment(TORMENT_CARDS, you.x_pos, you.y_pos); break; + case CARD_TORMENT: torment(TORMENT_CARDS, you.pos()); break; case CARD_VENOM: if (coinflip()) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index e4ee95d88e..861b68bb1e 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -81,11 +81,11 @@ static bool _recite_mons_useless(const monsters *mon) } // Power is maximum 50. -static int _recite_to_monsters(int x, int y, int pow, int unused) +static int _recite_to_monsters(coord_def where, int pow, int unused) { UNUSED(unused); - const int mon = mgrd[x][y]; + const int mon = mgrd(where); if (mon == NON_MONSTER) return (0); diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 3534df0588..baaecf2767 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -105,7 +105,7 @@ int holy_word_player(int pow, int caster) return 1; } -int holy_word_monsters(int x, int y, int pow, int caster) +int holy_word_monsters(coord_def where, int pow, int caster) { int retval = 0; @@ -113,11 +113,11 @@ int holy_word_monsters(int x, int y, int pow, int caster) pow = std::min(300, pow); // Is the player in this cell? - if (x == you.x_pos && y == you.y_pos) + if (where == you.pos()) retval = holy_word_player(pow, caster); // Is a monster in this cell? - int mon = mgrd[x][y]; + int mon = mgrd(where); if (mon == NON_MONSTER) return retval; @@ -162,12 +162,12 @@ int holy_word_monsters(int x, int y, int pow, int caster) return retval; } -int holy_word(int pow, int caster, int x, int y, bool silent) +int holy_word(int pow, int caster, const coord_def& where, bool silent) { if (!silent) mpr("You speak a Word of immense power!"); - return apply_area_within_radius(holy_word_monsters, x, y, pow, 8, caster); + return apply_area_within_radius(holy_word_monsters, where, pow, 8, caster); } int torment_player(int pow, int caster) @@ -234,18 +234,18 @@ int torment_player(int pow, int caster) // maximum power of 1000, high level monsters and characters would save // too often. (GDL) -int torment_monsters(int x, int y, int pow, int caster) +int torment_monsters(coord_def where, int pow, int caster) { UNUSED(pow); int retval = 0; // Is the player in this cell? - if (x == you.x_pos && y == you.y_pos) + if (where == you.pos()) retval = torment_player(0, caster); // Is a monster in this cell? - int mon = mgrd[x][y]; + int mon = mgrd(where); if (mon == NON_MONSTER) return retval; @@ -276,9 +276,9 @@ int torment_monsters(int x, int y, int pow, int caster) return retval; } -int torment(int caster, int x, int y) +int torment(int caster, const coord_def& where) { - return apply_area_within_radius(torment_monsters, x, y, 0, 8, caster); + return apply_area_within_radius(torment_monsters, where, 0, 8, caster); } static std::string _who_banished(const std::string &who) diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index f46bf26d2b..f19888b1d4 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -100,10 +100,10 @@ void yell(bool force = false); /* *********************************************************************** * called from: item_use - spell * *********************************************************************** */ -int holy_word(int pow, int caster, int x, int y, bool silent); +int holy_word(int pow, int caster, const coord_def& where, bool silent); int holy_word_player(int pow, int caster); -int holy_word_monsters(int x, int y, int pow, int caster); +int holy_word_monsters(coord_def where, int pow, int caster); // last updated 12may2000 {dlb} @@ -111,10 +111,10 @@ int holy_word_monsters(int x, int y, int pow, int caster); * called from: ability - decks - fight - it_use3 - item_use - mstuff2 - * spell * *********************************************************************** */ -int torment(int caster, int x, int y); +int torment(int caster, const coord_def& where); int torment_player(int pow, int caster); -int torment_monsters(int x, int y, int pow, int caster); +int torment_monsters(coord_def where, int pow, int caster); bool forget_inventory(bool quiet = false); bool vitrify_area(int radius); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 82460bd819..2ca6e34dbe 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -1764,7 +1764,7 @@ void melee_attack::player_check_weapon_effects() { if (spwld == SPWLD_TORMENT && coinflip()) { - torment(TORMENT_SPWLD, you.x_pos, you.y_pos); + torment(TORMENT_SPWLD, you.pos()); did_god_conduct(DID_UNHOLY, 5); } diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 180922e03c..a4bdde12f1 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -192,7 +192,7 @@ void special_wielded() case SPWLD_TORMENT: if (one_chance_in(200)) { - torment(TORMENT_SPWLD, you.x_pos, you.y_pos); + torment(TORMENT_SPWLD, you.pos()); did_god_conduct(DID_UNHOLY, 1); } break; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 9e7c67f718..6d541d6951 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -3880,7 +3880,7 @@ static bool affix_weapon_enchantment() // Can't fix pain brand (balance)...you just get tormented. mprf("%s shrieks out in agony!", itname.c_str()); - torment_monsters(you.x_pos, you.y_pos, 0, TORMENT_GENERIC); + torment_monsters(you.pos(), 0, TORMENT_GENERIC); success = false; // Is only naughty if you know you're doing it. @@ -4397,7 +4397,7 @@ void read_scroll( int slot ) break; case SCR_TORMENT: - torment( TORMENT_SCROLL, you.x_pos, you.y_pos ); + torment( TORMENT_SCROLL, you.pos() ); // Is only naughty if you know you're doing it. did_god_conduct(DID_UNHOLY, 10, item_type_known(scroll)); @@ -4573,7 +4573,7 @@ void read_scroll( int slot ) you.piety / 2; } - if (!holy_word(pow, HOLY_WORD_SCROLL, you.x_pos, you.y_pos, + if (!holy_word(pow, HOLY_WORD_SCROLL, you.pos(), !item_type_known(scroll))) { canned_msg(MSG_NOTHING_HAPPENS); diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index b72ecbf038..60a33a077c 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -2262,7 +2262,7 @@ static const struct luaL_reg file_lib[] = }; LUARET1(you_can_hear_pos, boolean, - player_can_hear(luaL_checkint(ls,1), luaL_checkint(ls, 2))) + player_can_hear(coord_def(luaL_checkint(ls,1), luaL_checkint(ls, 2)))) LUARET1(you_x_pos, number, you.x_pos) LUARET1(you_y_pos, number, you.y_pos) LUARET2(you_pos, number, you.x_pos, you.y_pos) diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 77aeaeb7ff..2d39f2122c 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -751,7 +751,7 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) simple_monster_message(monster, " calls on the powers of Hell!"); - torment(monster_index(monster), monster->x, monster->y); + torment(monster_index(monster), monster->pos()); return; case SPELL_SUMMON_GREATER_DEMON: diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index f3409195a3..f7fbfef2fc 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -4991,7 +4991,7 @@ static bool _bless_weapon( god_type god, int brand, int colour ) if ( god == GOD_SHINING_ONE ) { - holy_word(100, HOLY_WORD_SHINING_ONE, you.x_pos, you.y_pos, true); + holy_word(100, HOLY_WORD_SHINING_ONE, you.pos(), true); // Un-bloodify surrounding squares. for (int i = -3; i <= 3; ++i) diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index cc3a436b99..d973fda8c3 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1637,7 +1637,7 @@ bool cast_sanctuary(const int power) you.flash_colour = WHITE; viewwindow( true, false ); - holy_word(100, HOLY_WORD_ZIN, you.x_pos, you.y_pos, true); + holy_word(100, HOLY_WORD_ZIN, you.pos(), true); #ifndef USE_TILE delay(1000); #endif diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index c32d0c1578..3cd219f7ff 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -69,8 +69,8 @@ enum DEBRIS // jmf: add for shatter, dig, and Giants to throw NUM_DEBRIS }; // jmf: ...and I'll actually implement the items Real Soon Now... -static int _make_a_rot_cloud(int x, int y, int pow, cloud_type ctype); -static int _quadrant_blink(int x, int y, int pow, int garbage); +static int _make_a_rot_cloud(const coord_def& where, int pow, cloud_type ctype); +static int _quadrant_blink(coord_def where, int pow, int garbage); void do_monster_rot(int mon); @@ -100,12 +100,12 @@ inline bool player_hurt_monster(int monster, int damage) } // Here begin the actual spells: -static int _shatter_monsters(int x, int y, int pow, int garbage) +static int _shatter_monsters(coord_def where, int pow, int garbage) { UNUSED( garbage ); dice_def dam_dice( 0, 5 + pow / 3 ); // number of dice set below - const int monster = mgrd[x][y]; + const int monster = mgrd(where); if (monster == NON_MONSTER) return (0); @@ -195,40 +195,25 @@ static int _shatter_monsters(int x, int y, int pow, int garbage) return (damage); } -static int _shatter_items(int x, int y, int pow, int garbage) +static int _shatter_items(coord_def where, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); - int broke_stuff = 0, next, obj = igrd[x][y]; + int broke_stuff = 0; - if (obj == NON_ITEM) - return 0; - - while (obj != NON_ITEM) + for ( stack_iterator si(where); si; ++si ) { - next = mitm[obj].link; - - switch (mitm[obj].base_type) + if (si->base_type == OBJ_POTIONS && !one_chance_in(10)) { - case OBJ_POTIONS: - if (!one_chance_in(10)) - { - broke_stuff++; - destroy_item(obj); - } - break; - - default: - break; + broke_stuff++; + destroy_item(si->index()); } - - obj = next; } if (broke_stuff) { - if (!silenced(coord_def(x, y)) && !silenced(you.pos())) + if (player_can_hear(where)) mpr("You hear glass break.", MSGCH_SOUND); return 1; @@ -237,30 +222,30 @@ static int _shatter_items(int x, int y, int pow, int garbage) return 0; } -static int _shatter_walls(int x, int y, int pow, int garbage) +static int _shatter_walls(coord_def where, int pow, int garbage) { UNUSED( garbage ); int chance = 0; // if not in-bounds then we can't really shatter it -- bwr - if (x <= 5 || x >= GXM - 5 || y <= 5 || y >= GYM - 5) - return (0); + if ( !in_bounds(where) ) + return 0; - switch (grd[x][y]) + switch (grd(where)) { case DNGN_SECRET_DOOR: - if (see_grid(x, y)) + if (see_grid(where)) mpr("A secret door shatters!"); - grd[x][y] = DNGN_FLOOR; + grd(where) = DNGN_FLOOR; chance = 100; break; case DNGN_CLOSED_DOOR: case DNGN_OPEN_DOOR: - if (see_grid(x, y)) + if (see_grid(where)) mpr("A door shatters!"); - grd[x][y] = DNGN_FLOOR; + grd(where) = DNGN_FLOOR; chance = 100; break; @@ -293,9 +278,9 @@ static int _shatter_walls(int x, int y, int pow, int garbage) if (x_chance_in_y(chance, 100)) { - noisy(30, coord_def(x, y)); + noisy(30, where); - grd[x][y] = DNGN_FLOOR; + grd(where) = DNGN_FLOOR; return (1); } @@ -348,11 +333,9 @@ void cast_shatter(int pow) int rad = 3 + (you.skills[SK_EARTH_MAGIC] / 5); - apply_area_within_radius(_shatter_items, you.x_pos, you.y_pos, - pow, rad, 0); - apply_area_within_radius(_shatter_monsters, you.x_pos, you.y_pos, - pow, rad, 0); - int dest = apply_area_within_radius( _shatter_walls, you.x_pos, you.y_pos, + apply_area_within_radius(_shatter_items, you.pos(), pow, rad, 0); + apply_area_within_radius(_shatter_monsters, you.pos(), pow, rad, 0); + int dest = apply_area_within_radius( _shatter_walls, you.pos(), pow, rad, 0 ); if (dest && !silence) @@ -419,10 +402,10 @@ void cast_detect_secret_doors(int pow) mprf("You detect %s", (found > 0) ? "secret doors!" : "nothing."); } -static int _sleep_monsters(int x, int y, int pow, int garbage) +static int _sleep_monsters(coord_def where, int pow, int garbage) { UNUSED( garbage ); - const int mnstr = mgrd[x][y]; + const int mnstr = mgrd(where); if (mnstr == NON_MONSTER) return 0; @@ -477,10 +460,10 @@ static bool _is_domesticated_animal(int type) return (false); } -static int _tame_beast_monsters(int x, int y, int pow, int garbage) +static int _tame_beast_monsters(coord_def where, int pow, int garbage) { UNUSED( garbage ); - const int which_mons = mgrd[x][y]; + const int which_mons = mgrd(where); if (which_mons == NON_MONSTER) return 0; @@ -518,22 +501,18 @@ void cast_tame_beasts(int pow) apply_area_visible(_tame_beast_monsters, pow); } -static int _ignite_poison_objects(int x, int y, int pow, int garbage) +static int _ignite_poison_objects(coord_def where, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); - int obj = igrd[x][y], next, strength = 0; - - if (obj == NON_ITEM) - return (0); + int strength = 0; - while (obj != NON_ITEM) + for ( stack_iterator si(where); si; ++si ) { - next = mitm[obj].link; - if (mitm[obj].base_type == OBJ_POTIONS) + if (si->base_type == OBJ_POTIONS) { - switch (mitm[obj].sub_type) + switch (si->sub_type) { // intentional fall-through all the way down case POT_STRONG_POISON: @@ -542,37 +521,32 @@ static int _ignite_poison_objects(int x, int y, int pow, int garbage) strength += 10; case POT_POISON: strength += 10; - destroy_item(obj); + destroy_item(si->index()); default: break; } } // FIXME: implement burning poisoned ammo - // else if ( it's ammo that's poisoned) { - // strength += number_of_ammo; - // destroy_item(ammo); - // } - obj = next; } if (strength > 0) { - place_cloud(CLOUD_FIRE, coord_def(x, y), + place_cloud(CLOUD_FIRE, where, strength + roll_dice(3, strength / 4), KC_YOU); } return (strength); } -static int _ignite_poison_clouds( int x, int y, int pow, int garbage ) +static int _ignite_poison_clouds( coord_def where, int pow, int garbage ) { UNUSED( pow ); UNUSED( garbage ); bool did_anything = false; - const int cloud = env.cgrid[x][y]; + const int cloud = env.cgrid(where); if (cloud != EMPTY_CLOUD) { @@ -596,16 +570,16 @@ static int _ignite_poison_clouds( int x, int y, int pow, int garbage ) return did_anything; } -static int _ignite_poison_monsters(int x, int y, int pow, int garbage) +static int _ignite_poison_monsters(coord_def where, int pow, int garbage) { UNUSED( garbage ); - struct bolt beam; + bolt beam; beam.flavour = BEAM_FIRE; // This is dumb, only used for adjust! dice_def dam_dice( 0, 5 + pow / 7 ); // Dice added below if applicable. - const int mon_index = mgrd[x][y]; + const int mon_index = mgrd(where); if (mon_index == NON_MONSTER) return (0); @@ -817,17 +791,17 @@ void cast_silence(int pow) } } -static int _discharge_monsters( int x, int y, int pow, int garbage ) +static int _discharge_monsters( coord_def where, int pow, int garbage ) { UNUSED( garbage ); - const int mon = mgrd[x][y]; + const int mon = mgrd(where); int damage = 0; - struct bolt beam; + bolt beam; beam.flavour = BEAM_ELECTRICITY; // used for mons_adjust_flavoured - if (x == you.x_pos && y == you.y_pos) + if (where == you.pos()) { mpr( "You are struck by lightning." ); damage = 3 + random2( 5 + pow / 10 ); @@ -859,7 +833,7 @@ static int _discharge_monsters( int x, int y, int pow, int garbage ) { mpr( "The lightning arcs!" ); pow /= (coinflip() ? 2 : 3); - damage += apply_random_around_square( _discharge_monsters, x, y, + damage += apply_random_around_square( _discharge_monsters, where, true, pow, 1 ); } else if (damage > 0) @@ -877,7 +851,7 @@ void cast_discharge( int pow ) int num_targs = 1 + random2( 1 + pow / 25 ); int dam; - dam = apply_random_around_square( _discharge_monsters, you.x_pos, you.y_pos, + dam = apply_random_around_square( _discharge_monsters, you.pos(), true, pow, num_targs ); #if DEBUG_DIAGNOSTICS @@ -904,20 +878,12 @@ void cast_discharge( int pow ) // NB: this must be checked against the same effects // in fight.cc for all forms of attack !!! {dlb} // This function should be currently unused (the effect is too powerful). -static int _distortion_monsters(int x, int y, int pow, int message) +static int _distortion_monsters(coord_def where, int pow, int message) { - int specdam = 0; - int monster_attacked = mgrd[x][y]; - - if (monster_attacked == NON_MONSTER) - return 0; - - struct monsters *defender = &menv[monster_attacked]; - if (pow > 100) pow = 100; - if (x == you.x_pos && y == you.y_pos) + if (where == you.pos()) { if (you.skills[SK_TRANSLOCATIONS] < random2(8)) { @@ -933,6 +899,14 @@ static int _distortion_monsters(int x, int y, int pow, int message) return 1; } + int monster_attacked = mgrd(where); + + if (monster_attacked == NON_MONSTER) + return 0; + + int specdam = 0; + monsters *defender = &menv[monster_attacked]; + if (defender->type == MONS_BLINK_FROG) // any others resist? { int hp = defender->hit_points; @@ -995,16 +969,16 @@ void cast_bend(int pow) // Really this is just applying the best of Band/Warp weapon/Warp field // into a spell that gives the "make monsters go away" benefit without // the insane damage potential. -- bwr -int disperse_monsters(int x, int y, int pow, int message) +int disperse_monsters(coord_def where, int pow, int message) { UNUSED( message ); - const int monster_attacked = mgrd[x][y]; + const int monster_attacked = mgrd(where); if (monster_attacked == NON_MONSTER) return 0; - struct monsters *defender = &menv[monster_attacked]; + monsters *defender = &menv[monster_attacked]; if (defender->type == MONS_BLINK_FROG) { @@ -1035,23 +1009,22 @@ int disperse_monsters(int x, int y, int pow, int message) void cast_dispersal(int pow) { - if (apply_area_around_square( disperse_monsters, - you.x_pos, you.y_pos, pow ) == 0) + if (apply_area_around_square( disperse_monsters, you.pos(), pow ) == 0) { mpr( "The air shimmers briefly around you." ); } } -static int _spell_swap_func(int x, int y, int pow, int message) +static int _spell_swap_func(coord_def where, int pow, int message) { UNUSED( message ); - int monster_attacked = mgrd[x][y]; + int monster_attacked = mgrd(where); if (monster_attacked == NON_MONSTER) return 0; - struct monsters *defender = &menv[monster_attacked]; + monsters *defender = &menv[monster_attacked]; if (defender->type == MONS_BLINK_FROG || check_mons_resist_magic( defender, pow )) @@ -1068,11 +1041,10 @@ static int _spell_swap_func(int x, int y, int pow, int message) // standard swap procedure here... since we really want to apply // the same swap_places function as with friendly monsters... // see note over there. -- bwr - int old_x = defender->x; - int old_y = defender->y; + coord_def old_pos = defender->pos(); if (swap_places( defender )) - you.moveto(old_x, old_y); + you.moveto(old_pos); } return 1; @@ -1083,9 +1055,9 @@ void cast_swap(int pow) apply_one_neighbouring_square( _spell_swap_func, pow ); } -static int _make_a_rot_cloud(int x, int y, int pow, cloud_type ctype) +static int _make_a_rot_cloud(const coord_def& where, int pow, cloud_type ctype) { - for ( stack_iterator si(coord_def(x,y)); si; ++si ) + for ( stack_iterator si(where); si; ++si ) { if (si->base_type == OBJ_CORPSES && si->sub_type == CORPSE_BODY) @@ -1095,7 +1067,7 @@ static int _make_a_rot_cloud(int x, int y, int pow, cloud_type ctype) else turn_corpse_into_skeleton(*si); - place_cloud(ctype, coord_def(x,y), + place_cloud(ctype, where, (3 + random2(pow / 4) + random2(pow / 4) + random2(pow / 4)), KC_YOU); @@ -1116,10 +1088,12 @@ int make_a_normal_cloud(int x, int y, int pow, int spread_rate, return 1; } -static int _passwall(int x, int y, int pow, int garbage) +static int _passwall(coord_def where, int pow, int garbage) { UNUSED( garbage ); + int x = where.x, y = where.y; + int dx, dy, nx = x, ny = y; int howdeep = 0; bool done = false; @@ -1204,12 +1178,12 @@ void cast_passwall(int pow) apply_one_neighbouring_square(_passwall, pow); } -static int _intoxicate_monsters(int x, int y, int pow, int garbage) +static int _intoxicate_monsters(coord_def where, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); - int mon = mgrd[x][y]; + int mon = mgrd(where); if (mon == NON_MONSTER || mons_intel(menv[mon].type) < I_NORMAL @@ -1237,12 +1211,12 @@ void cast_intoxicate(int pow) apply_area_visible(_intoxicate_monsters, pow); } -bool backlight_monsters(int x, int y, int pow, int garbage) +bool backlight_monsters(coord_def where, int pow, int garbage) { UNUSED( pow ); UNUSED( garbage ); - int mon = mgrd[x][y]; + int mon = mgrd(where); if (mon == NON_MONSTER) return (false); @@ -1603,11 +1577,11 @@ void cast_fulsome_distillation( int powc ) mpr( "Unfortunately, you can't carry it right now!" ); } -static int _rot_living(int x, int y, int pow, int message) +static int _rot_living(coord_def where, int pow, int message) { UNUSED( message ); - int mon = mgrd[x][y]; + int mon = mgrd(where); int ench; if (mon == NON_MONSTER) @@ -1627,11 +1601,11 @@ static int _rot_living(int x, int y, int pow, int message) return 1; } -static int _rot_undead(int x, int y, int pow, int garbage) +static int _rot_undead(coord_def where, int pow, int garbage) { UNUSED( garbage ); - int mon = mgrd[x][y]; + int mon = mgrd(where); int ench; if (mon == NON_MONSTER) @@ -1685,11 +1659,11 @@ static int _rot_undead(int x, int y, int pow, int garbage) return 1; } -static int _rot_corpses(int x, int y, int pow, int garbage) +static int _rot_corpses(coord_def where, int pow, int garbage) { UNUSED( garbage ); - return _make_a_rot_cloud(x, y, pow, CLOUD_MIASMA); + return _make_a_rot_cloud(where, pow, CLOUD_MIASMA); } void cast_rotting(int pow) @@ -1714,11 +1688,11 @@ void do_monster_rot(int mon) return; } -static int _snake_charm_monsters(int x, int y, int pow, int message) +static int _snake_charm_monsters(coord_def where, int pow, int message) { UNUSED( message ); - int mon = mgrd[x][y]; + int mon = mgrd(where); if (mon == NON_MONSTER || one_chance_in(4) @@ -2501,11 +2475,11 @@ void cast_divine_shield() return; } -static int _quadrant_blink(int x, int y, int pow, int garbage) +static int _quadrant_blink(coord_def where, int pow, int garbage) { UNUSED( garbage ); - if (x == you.x_pos && y == you.y_pos) + if (where == you.pos()) return (0); if (you.level_type == LEVEL_ABYSS) @@ -2520,9 +2494,7 @@ static int _quadrant_blink(int x, int y, int pow, int garbage) pow = 100; const int dist = random2(6) + 2; // 2-7 - coord_def orig; - orig.x = you.x_pos + (x - you.x_pos) * dist; - orig.y = you.y_pos + (y - you.y_pos) * dist; + coord_def orig = you.pos() + (where - you.pos()) * dist; // This can take a while if pow is high and there's lots of translucent // walls nearby. diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h index e1b9d2140a..aea2d92342 100644 --- a/crawl-ref/source/spells4.h +++ b/crawl-ref/source/spells4.h @@ -18,10 +18,10 @@ struct bolt; -bool backlight_monsters(int x, int y, int pow, int garbage); +bool backlight_monsters(coord_def where, int pow, int garbage); int make_a_normal_cloud(int x, int y, int pow, int spread_rate, cloud_type ctype, kill_category); -int disperse_monsters(int x, int y, int pow, int message); +int disperse_monsters(coord_def where, int pow, int message); void cast_bend(int pow); void cast_condensation_shield(int pow); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 3833cbf483..33d31faeb5 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1344,7 +1344,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) break; case SPELL_HOLY_WORD: - holy_word(50, HOLY_WORD_SPELL, you.x_pos, you.y_pos, true); + holy_word(50, HOLY_WORD_SPELL, you.pos(), true); break; case SPELL_REPEL_UNDEAD: @@ -1477,7 +1477,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) break; case SPELL_SYMBOL_OF_TORMENT: - torment(TORMENT_SPELL, you.x_pos, you.y_pos); + torment(TORMENT_SPELL, you.pos()); break; case SPELL_OZOCUBUS_REFRIGERATION: @@ -3043,7 +3043,7 @@ static void _miscast_necromancy(int severity, const char* cause) break; } - torment_monsters(you.x_pos, you.y_pos, 0, TORMENT_GENERIC); + torment_monsters(you.pos(), 0, TORMENT_GENERIC); break; case 1: diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index e36d9528f2..8e4d320447 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -357,37 +357,25 @@ const char *spell_title(spell_type spell) // Apply a function-pointer to all visible squares // Returns summation of return values from passed in function. -int apply_area_visible( int (*func) (int, int, int, int), int power, - bool pass_through_trans) +int apply_area_visible( cell_func cf, int power, bool pass_through_trans) { - int x, y; int rv = 0; - //jmf: FIXME: randomly start from other quadrants, like raise_dead? - for (x = you.x_pos - 8; x <= you.x_pos + 8; x++) - { - for (y = you.y_pos - 8; y <= you.y_pos + 8; y++) - { - if ((pass_through_trans && see_grid(x, y)) - || (!pass_through_trans && see_grid_no_trans(x, y))) - rv += func(x, y, power, 0); - } - } + for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri) + if ( pass_through_trans || see_grid_no_trans(*ri) ) + rv += cf(*ri, power, 0); return (rv); } // Applies the effect to all nine squares around/including the target. // Returns summation of return values from passed in function. -int apply_area_square( int (*func) (int, int, int, int), int cx, int cy, - int power ) +int apply_area_square( cell_func cf, const coord_def& where, int power ) { - int x, y; int rv = 0; - for (x = cx - 1; x <= cx + 1; x++) - for (y = cy - 1; y <= cy + 1; y++) - rv += func(x, y, power, 0); + for (adjacent_iterator ai(where, false); ai; ++ai) + rv += cf(*ai, power, 0); return (rv); } @@ -395,142 +383,123 @@ int apply_area_square( int (*func) (int, int, int, int), int cx, int cy, // Applies the effect to the eight squares beside the target. // Returns summation of return values from passed in function. -int apply_area_around_square( int (*func) (int, int, int, int), - int targ_x, int targ_y, int power) +int apply_area_around_square( cell_func cf, const coord_def& where, int power) { - int x, y; int rv = 0; - for (x = targ_x - 1; x <= targ_x + 1; x++) - for (y = targ_y - 1; y <= targ_y + 1; y++) - { - if (x == targ_x && y == targ_y) - continue; - else - rv += func(x, y, power, 0); - } + for (adjacent_iterator ai(where, true); ai; ++ai) + rv += cf(*ai, power, 0); return (rv); } // Effect up to max_targs monsters around a point, chosen randomly // Return varies with the function called; return values will be added up. -int apply_random_around_square( int (*func) (int, int, int, int), - int targ_x, int targ_y, - bool hole_in_middle, int power, int max_targs ) +int apply_random_around_square( cell_func cf, const coord_def& where, + bool exclude_center, int power, int max_targs ) { int rv = 0; if (max_targs <= 0) return 0; - if (max_targs >= 9 && !hole_in_middle) - return (apply_area_square( func, targ_x, targ_y, power )); + if (max_targs >= 9 && !exclude_center) + return (apply_area_square( cf, where, power )); + + if (max_targs >= 8 && exclude_center) + return (apply_area_around_square( cf, where, power )); - if (max_targs >= 8 && hole_in_middle) - return (apply_area_around_square( func, targ_x, targ_y, power )); + coord_def targs[8]; - FixedVector< coord_def, 8 > targs; int count = 0; - for (int x = targ_x - 1; x <= targ_x + 1; x++) + for (adjacent_iterator ai(where, exclude_center); ai; ++ai) { - for (int y = targ_y - 1; y <= targ_y + 1; y++) + if (mgrd(*ai) == NON_MONSTER && *ai != you.pos()) + continue; + + // Found target + count++; + + // Slight difference here over the basic algorithm... + // + // For cases where the number of choices <= max_targs it's + // obvious (all available choices will be selected). + // + // For choices > max_targs, here's a brief proof: + // + // Let m = max_targs, k = choices - max_targs, k > 0. + // + // Proof, by induction (over k): + // + // 1) Show n = m + 1 (k = 1) gives uniform distribution, + // P(new one not chosen) = 1 / (m + 1). + // m 1 1 + // P(specific previous one replaced) = --- * --- = --- + // m+1 m m+1 + // + // So the probablity is uniform (ie. any element has + // a 1/(m+1) chance of being in the unchosen slot). + // + // 2) Assume the distribution is uniform at n = m+k. + // (ie. the probablity that any of the found elements + // was chosen = m / (m+k) (the slots are symetric, + // so it's the sum of the probabilities of being in + // any of them)). + // + // 3) Show n = m + k + 1 gives a uniform distribution. + // P(new one chosen) = m / (m + k + 1) + // P(any specific previous choice remaining chosen) + // = [1 - P(swaped into m+k+1 position)] * P(prev. chosen) + // m 1 m + // = [ 1 - ----- * --- ] * --- + // m+k+1 m m+k + // + // m+k m m + // = ----- * --- = ----- + // m+k+1 m+k m+k+1 + // + // Therefore, it's uniform for n = m + k + 1. QED + // + // The important thing to note in calculating the last + // probability is that the chosen elements have already + // passed tests which verify that they *don't* belong + // in slots m+1...m+k, so the only positions an already + // chosen element can end up in are its original + // position (in one of the chosen slots), or in the + // new slot. + // + // The new item can, of course, be placed in any slot, + // swapping the value there into the new slot... we + // just don't care about the non-chosen slots enough + // to store them, so it might look like the item + // automatically takes the new slot when not chosen + // (although, by symetry all the non-chosen slots are + // the same... and similarly, by symetry, all chosen + // slots are the same). + // + // Yes, that's a long comment for a short piece of + // code, but I want people to have an understanding + // of why this works (or at least make them wary about + // changing it without proof and breaking this code). -- bwr + + // Accept the first max_targs choices, then when + // new choices come up, replace one of the choices + // at random, max_targs/count of the time (the rest + // of the time it replaces an element in an unchosen + // slot -- but we don't care about them). + if (count <= max_targs) + { + targs[ count - 1 ] = *ai; + } + else if (x_chance_in_y(max_targs, count)) { - if (hole_in_middle && (x == targ_x && y == targ_y)) - continue; - - if (mgrd[x][y] == NON_MONSTER - && !(x == you.x_pos && y == you.y_pos)) - { - continue; - } - - // Found target - count++; - - // Slight difference here over the basic algorithm... - // - // For cases where the number of choices <= max_targs it's - // obvious (all available choices will be selected). - // - // For choices > max_targs, here's a brief proof: - // - // Let m = max_targs, k = choices - max_targs, k > 0. - // - // Proof, by induction (over k): - // - // 1) Show n = m + 1 (k = 1) gives uniform distribution, - // P(new one not chosen) = 1 / (m + 1). - // m 1 1 - // P(specific previous one replaced) = --- * --- = --- - // m+1 m m+1 - // - // So the probablity is uniform (ie. any element has - // a 1/(m+1) chance of being in the unchosen slot). - // - // 2) Assume the distribution is uniform at n = m+k. - // (ie. the probablity that any of the found elements - // was chosen = m / (m+k) (the slots are symetric, - // so it's the sum of the probabilities of being in - // any of them)). - // - // 3) Show n = m + k + 1 gives a uniform distribution. - // P(new one chosen) = m / (m + k + 1) - // P(any specific previous choice remaining chosen) - // = [1 - P(swaped into m+k+1 position)] * P(prev. chosen) - // m 1 m - // = [ 1 - ----- * --- ] * --- - // m+k+1 m m+k - // - // m+k m m - // = ----- * --- = ----- - // m+k+1 m+k m+k+1 - // - // Therefore, it's uniform for n = m + k + 1. QED - // - // The important thing to note in calculating the last - // probability is that the chosen elements have already - // passed tests which verify that they *don't* belong - // in slots m+1...m+k, so the only positions an already - // chosen element can end up in are its original - // position (in one of the chosen slots), or in the - // new slot. - // - // The new item can, of course, be placed in any slot, - // swapping the value there into the new slot... we - // just don't care about the non-chosen slots enough - // to store them, so it might look like the item - // automatically takes the new slot when not chosen - // (although, by symetry all the non-chosen slots are - // the same... and similarly, by symetry, all chosen - // slots are the same). - // - // Yes, that's a long comment for a short piece of - // code, but I want people to have an understanding - // of why this works (or at least make them wary about - // changing it without proof and breaking this code). -- bwr - - // Accept the first max_targs choices, then when - // new choices come up, replace one of the choices - // at random, max_targs/count of the time (the rest - // of the time it replaces an element in an unchosen - // slot -- but we don't care about them). - if (count <= max_targs) - { - targs[ count - 1 ].x = x; - targs[ count - 1 ].y = y; - } - else if (x_chance_in_y(max_targs, count)) - { - const int pick = random2( max_targs ); - targs[ pick ].x = x; - targs[ pick ].y = y; - } + const int pick = random2( max_targs ); + targs[ pick ] = *ai; } } - const int targs_found = (count < max_targs) ? count : max_targs; + const int targs_found = std::min(count, max_targs); if (targs_found) { @@ -539,18 +508,18 @@ int apply_random_around_square( int (*func) (int, int, int, int), // balance the called function. -- bwr for (int i = 0; i < targs_found; i++) { - ASSERT( targs[i].x && targs[i].y ); - rv += func( targs[i].x, targs[i].y, power, 0 ); + ASSERT( !targs[i].origin() ); + rv += cf( targs[i], power, 0 ); } } return (rv); -} // end apply_random_around_square() +} // Apply func to one square of player's choice beside the player. -int apply_one_neighbouring_square(int (*func) (int, int, int, int), int power) +int apply_one_neighbouring_square(cell_func cf, int power) { - struct dist bmove; + dist bmove; mpr("Which direction? [ESC to cancel]", MSGCH_PROMPT); direction( bmove, DIR_DIR, TARG_ENEMY ); @@ -561,7 +530,8 @@ int apply_one_neighbouring_square(int (*func) (int, int, int, int), int power) return (-1); } - int rv = func(you.x_pos + bmove.dx, you.y_pos + bmove.dy, power, 1); + int rv = cf(coord_def(you.x_pos + bmove.dx, you.y_pos + bmove.dy), + power, 1); if (rv == 0) canned_msg(MSG_NOTHING_HAPPENS); @@ -569,37 +539,17 @@ int apply_one_neighbouring_square(int (*func) (int, int, int, int), int power) return (rv); } -int apply_area_within_radius( int (*func) (int, int, int, int), - int x, int y, int pow, int radius, int ctype ) +int apply_area_within_radius( cell_func cf, const coord_def& where, + int pow, int radius, int ctype ) { - int ix, iy; - int sq_radius = radius * radius; - int sx, sy, ex, ey; // start and end x, y - bounds checked - int rv = 0; - // begin x,y - sx = x - radius; - sy = y - radius; - if (sx < 0) sx = 0; - if (sy < 0) sy = 0; - - // end x,y - ex = x + radius; - ey = y + radius; - if (ex > GXM) ex = GXM; - if (ey > GYM) ey = GYM; + int rv = 0; - for (ix = sx; ix < ex; ix++) - { - for (iy = sy; iy < ey; iy++) - { - if (distance(x, y, ix, iy) <= sq_radius) - rv += func(ix, iy, pow, ctype); - } - } + for ( radius_iterator ri(where, radius, false, false); ri; ++ri ) + rv += cf(*ri, pow, ctype); return (rv); -} // end apply_area_within_radius() +} // apply_area_cloud: // Try to make a realistic cloud by expanding from a point, filling empty diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index 8a76c039b5..6bbbfdd9b8 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -62,11 +62,8 @@ struct spell_desc bool is_valid_spell(spell_type spell); - -//* * called from: acr void init_spell_descs(void); - -void init_spell_name_cache(); +void init_spell_name_cache(); spell_type spell_by_name(std::string name, bool partial_match = false); int get_spell_slot_by_letter( char letter ); @@ -75,14 +72,8 @@ spell_type get_spell_by_letter( char letter ); bool add_spell_to_memory( spell_type spell ); bool del_spell_from_memory_by_slot( int slot ); -// * called from: spell int spell_hunger(spell_type which_spell); - -// * called from: it_use3 - spell - spells3 int spell_mana(spell_type which_spell); - -// * called from: chardump - it_use3 - player - spell - spl-book - -// * spells0 - spells3 int spell_difficulty(spell_type which_spell); int spell_power_cap(spell_type spell); @@ -98,36 +89,28 @@ int spell_levels_required(spell_type which_spell); unsigned int get_spell_flags( spell_type which_spell ); -// * called from: chardump - spell - spl-book - spells0 bool spell_typematch(spell_type which_spell, unsigned int which_discipline); unsigned int get_spell_disciplines( spell_type which_spell ); int count_bits( unsigned int bits ); -// * called from: chardump - command - debug - spl-book - spells0 const char *spell_title(spell_type which_spell); - const char* spelltype_short_name( int which_spelltype ); -//int spell_restriction(int which_spell, int which_restriction); - -int apply_area_visible(int (*func) (int, int, int, int), int power, +typedef int cell_func(coord_def where, int pow, int aux); +int apply_area_visible(cell_func cf, int power, bool pass_through_trans = false); -int apply_area_square(int (*func) (int, int, int, int), - int cx, int cy, int power); +int apply_area_square(cell_func cf, const coord_def& where, int power); -int apply_area_around_square( int (*func) (int, int, int, int), - int targ_x, int targ_y, int power ); +int apply_area_around_square(cell_func cf, const coord_def& where, int power ); -int apply_random_around_square( int (*func) (int, int, int, int), - int targ_x, int targ_y, bool hole_in_middle, - int power, int max_targs ); +int apply_random_around_square( cell_func cf, const coord_def& where, + bool hole_in_middle, int power, int max_targs ); -int apply_one_neighbouring_square(int (*func) (int, int, int, int), - int power); +int apply_one_neighbouring_square(cell_func cf, int power); -int apply_area_within_radius(int (*func) (int, int, int, int), - int x, int y, int pow, int radius, int ctype); +int apply_area_within_radius(cell_func cf, const coord_def& where, + int pow, int radius, int ctype); bool spell_direction( dist &spelld, bolt &pbolt, targeting_type restrict = DIR_NONE, diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index e7b54d6254..c9f00ece2d 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1237,9 +1237,9 @@ bool silenced(const coord_def& p) return (you.duration[DUR_SILENCE] > 0 && distance(p, you.pos()) <= 6*6); } -bool player_can_hear(int x, int y) +bool player_can_hear(const coord_def& p) { - return (!silenced(coord_def(x, y)) && !silenced(you.pos())); + return (!silenced(p) && !silenced(you.pos())); } // Returns true if inside the area the player can move and dig (ie exclusive). diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index 7a7183b60a..46dc76e103 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -59,8 +59,8 @@ class stack_iterator : public std::iterator { public: - stack_iterator( const coord_def& pos ); - stack_iterator( int start_link ); + explicit stack_iterator( const coord_def& pos ); + explicit stack_iterator( int start_link ); operator bool() const; item_def& operator *() const; @@ -122,8 +122,8 @@ private: class adjacent_iterator : public radius_iterator { public: - adjacent_iterator( const coord_def& pos = you.pos(), - bool _exclude_center = true ) : + explicit adjacent_iterator( const coord_def& pos = you.pos(), + bool _exclude_center = true ) : radius_iterator(pos, 1, true, false, _exclude_center) {} }; @@ -182,11 +182,7 @@ bool adjacent( const coord_def& p1, const coord_def& p2 ); bool silenced(const coord_def& p); -bool player_can_hear(int x, int y); -inline bool player_can_hear(const coord_def &p) -{ - return player_can_hear(p.x, p.y); -} +bool player_can_hear(const coord_def& p); unsigned char random_colour(); unsigned char random_uncommon_colour(); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index d5da2f7b3f..e4eab010a1 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -927,8 +927,7 @@ void handle_monster_shouts(monsters* monster, bool force) // Silent monsters can give noiseless "visual shouts" if the // player can see them, in which case silence isn't checked for. if (s_type == S_SILENT && !player_monster_visible(monster) - || s_type != S_SILENT && (silenced(you.pos()) - || silenced(monster->pos()))) + || s_type != S_SILENT && player_can_hear(monster->pos())) { return; } -- cgit v1.2.3-54-g00ecf