From ef456d5cbf1a159010d28f0ab5bd9ef3e35143c7 Mon Sep 17 00:00:00 2001 From: abrahamwl Date: Fri, 30 Oct 2009 18:06:32 -0700 Subject: Combine mons_is_sleeping(monsters *m) into monsters::asleep() ...and replace all references to mons_is_sleeping with asleep. --- crawl-ref/source/beam.cc | 4 ++-- crawl-ref/source/debug.cc | 2 +- crawl-ref/source/delay.cc | 2 +- crawl-ref/source/directn.cc | 4 ++-- crawl-ref/source/effects.cc | 2 +- crawl-ref/source/exclude.cc | 2 +- crawl-ref/source/misc.cc | 2 +- crawl-ref/source/mon-info.cc | 2 +- crawl-ref/source/mon-util.cc | 9 ++------- crawl-ref/source/mon-util.h | 1 - crawl-ref/source/monstuff.cc | 38 +++++++++++++++++++------------------- crawl-ref/source/religion.cc | 2 +- crawl-ref/source/spells1.cc | 2 +- crawl-ref/source/util/crawl.rc | 2 +- crawl-ref/source/view.cc | 12 ++++++------ 15 files changed, 40 insertions(+), 46 deletions(-) diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index c77a23f447..c129785ddc 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -4368,7 +4368,7 @@ void bolt::enchantment_affect_monster(monsters* mon) if (you.religion == GOD_BEOGH && mons_species(mon->type) == MONS_ORC - && mons_is_sleeping(mon) && !player_under_penance() + && mon->asleep() && !player_under_penance() && you.piety >= piety_breakpoint(2) && mons_near(mon)) { hit_woke_orc = true; @@ -4652,7 +4652,7 @@ void bolt::affect_monster(monsters* mon) } if (you.religion == GOD_BEOGH && mons_species(mon->type) == MONS_ORC - && mons_is_sleeping(mon) && YOU_KILL(thrower) + && mon->asleep() && YOU_KILL(thrower) && !player_under_penance() && you.piety >= piety_breakpoint(2) && mons_near(mon)) { diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 48b547cc04..7fd255e48a 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -2642,7 +2642,7 @@ void debug_stethoscope(int mon) (hab == HT_LAVA) ? "lava" : (hab == HT_ROCK) ? "rock" : "unknown"), - (mons_is_sleeping(&mons) ? "sleep" : + (mons.asleep() ? "sleep" : mons_is_wandering(&mons) ? "wander" : mons_is_seeking(&mons) ? "seek" : mons_is_fleeing(&mons) ? "flee" : diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index f8e6fbfbad..c2f64678bb 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -72,7 +72,7 @@ static bool _recite_mons_useless(const monsters *mon) && holiness != MH_DEMONIC || mons_is_stationary(mon) || mons_is_fleeing(mon) - || mons_is_sleeping(mon) + || mon->asleep() || mons_wont_attack(mon) || mons_neutral(mon) || mons_is_confused(mon) diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index fc161caa83..dfa9dfd251 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -3118,7 +3118,7 @@ static std::string _get_monster_desc(const monsters *mon) if (!mons_is_mimic(mon->type) && mons_behaviour_perceptible(mon)) { - if (mons_is_sleeping(mon)) + if (mon->asleep()) { text += pronoun + " appears to be " + (mons_is_confused(mon, true) ? "sleepwalking" @@ -3155,7 +3155,7 @@ static std::string _get_monster_desc(const monsters *mon) // Give an indication of monsters being capable of seeing/sensing // invisible creatures. - if (mons_behaviour_perceptible(mon) && !mons_is_sleeping(mon) + if (mons_behaviour_perceptible(mon) && !mon->asleep() && !mons_is_confused(mon) && (mon->can_see_invisible() || mons_sense_invis(mon))) { diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 9c803996b8..b3dbbc2602 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -4001,7 +4001,7 @@ static void _catchup_monster_moves(monsters *mon, int turns) } // Let sleeping monsters lie. - if (mons_is_sleeping(mon) || mons_is_paralysed(mon)) + if (mon->asleep() || mons_is_paralysed(mon)) return; const int range = (turns * mon->speed) / 10; diff --git a/crawl-ref/source/exclude.cc b/crawl-ref/source/exclude.cc index bafc2a738e..7c23cf55af 100644 --- a/crawl-ref/source/exclude.cc +++ b/crawl-ref/source/exclude.cc @@ -29,7 +29,7 @@ static bool _mon_needs_auto_exclude(const monsters *mon, bool sleepy = false) || testbits(mon->flags, MF_KNOWN_MIMIC)); } // Auto exclusion only makes sense if the monster is still asleep. - return (mons_is_sleeping(mon)); + return (mon->asleep()); } // Check whether a given monster is listed in the auto_exclude option. diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index f357884804..4cdd12829e 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2696,7 +2696,7 @@ static bool _mons_has_path_to_player(const monsters *mon) { // Don't consider sleeping monsters safe, in case the player would // rather retreat and try another path for maximum stabbing chances. - if (mons_is_sleeping(mon)) + if (mon->asleep()) return (true); // If the monster is awake and knows a path towards the player diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index 4c7e6e822b..07a0619bf8 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -163,7 +163,7 @@ static std::string _verbose_info(const monsters* m) return(" (confused)"); if (mons_is_fleeing(m)) return(" (fleeing)"); - if (mons_is_sleeping(m)) + if (m->asleep()) { if (mons_holiness(m) == MH_UNDEAD || mons_holiness(m) == MH_NONLIVING diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 739ef32b8e..6488529c0d 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2750,11 +2750,6 @@ bool mons_is_caught(const monsters *m) return (m->has_ench(ENCH_HELD)); } -bool mons_is_sleeping(const monsters *m) -{ - return (m->behaviour == BEH_SLEEP); -} - bool mons_is_wandering(const monsters *m) { return (m->behaviour == BEH_WANDER); @@ -5988,7 +5983,7 @@ bool monsters::cannot_move() const bool monsters::asleep() const { - return (mons_is_sleeping(this)); + return (behaviour == BEH_SLEEP); } bool monsters::backlit(bool check_haloed) const @@ -7415,7 +7410,7 @@ void monsters::apply_enchantment(const mon_enchant &me) case ENCH_HELD: { if (mons_is_stationary(this) || mons_cannot_act(this) - || mons_is_sleeping(this)) + || asleep()) { break; } diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index f712b310de..ca3d87c4f9 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -785,7 +785,6 @@ bool mons_is_chaotic(const monsters *mon); bool mons_is_poisoner(const monsters *mon); bool mons_is_confused(const monsters *m, bool class_too = false); bool mons_is_caught(const monsters *m); -bool mons_is_sleeping(const monsters *m); bool mons_is_wandering(const monsters *m); bool mons_is_seeking(const monsters *m); bool mons_is_fleeing(const monsters *m); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 0e153cefa0..866fd01d92 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2091,7 +2091,7 @@ void alert_nearby_monsters(void) // calling noisy() before calling this function. -- bwr if (monster->alive() && mons_near(monster) - && !mons_is_sleeping(monster)) + && !monster->asleep()) { behaviour_event(monster, ME_ALERT, MHITYOU); } @@ -2979,7 +2979,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, bool sourceWontAttack = false; bool setTarget = false; bool breakCharm = false; - bool was_sleeping = mons_is_sleeping(mon); + bool was_sleeping = mon->asleep(); if (src == MHITYOU) sourceWontAttack = true; @@ -2998,7 +2998,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, { case ME_DISTURB: // Assumes disturbed by noise... - if (mons_is_sleeping(mon)) + if (mon->asleep()) { mon->behaviour = BEH_WANDER; @@ -3049,7 +3049,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, mon->foe = src; - if (mons_is_sleeping(mon) && mons_near(mon)) + if (mon->asleep() && mons_near(mon)) remove_auto_exclude(mon, true); if (!mons_is_cornered(mon)) @@ -3072,12 +3072,12 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, // Allow monsters falling asleep while patrolling (can happen if // they're left alone for a long time) to be woken by this event. if (mons_friendly(mon) && mon->is_patrolling() - && !mons_is_sleeping(mon)) + && !mon->asleep()) { break; } - if (mons_is_sleeping(mon) && mons_near(mon)) + if (mon->asleep() && mons_near(mon)) remove_auto_exclude(mon, true); // Will alert monster to and turn them @@ -3206,7 +3206,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, ASSERT(in_bounds(mon->target) || mon->target.origin()); // If it woke up and you're its new foe, it might shout. - if (was_sleeping && !mons_is_sleeping(mon) && allow_shout + if (was_sleeping && !mon->asleep() && allow_shout && mon->foe == MHITYOU && !mons_wont_attack(mon)) { handle_monster_shouts(mon); @@ -5651,7 +5651,7 @@ static void _handle_nearby_ability(monsters *monster) actor *foe = monster->get_foe(); if (!foe || !monster->can_see(foe) - || mons_is_sleeping(monster) + || monster->asleep() || mons_is_submerged(monster)) { return; @@ -5802,7 +5802,7 @@ static bool _siren_movement_effect(const monsters *monster) if (mons_wont_attack(mon) && !mons_is_stationary(mon) && !mons_cannot_act(mon) - && !mons_is_sleeping(mon) + && !mon->asleep() && swap_check(mon, you.pos(), true)) { swapping = true; @@ -5863,7 +5863,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem) // Slime creatures can split while out of sight. if ((!mons_near(monster) - || mons_is_sleeping(monster) + || monster->asleep() || mons_is_submerged(monster)) && monster->mons_species() != MONS_SLIME_CREATURE) { @@ -6399,7 +6399,7 @@ static bool _handle_special_ability(monsters *monster, bolt & beem) //--------------------------------------------------------------- static bool _handle_potion(monsters *monster, bolt & beem) { - if (mons_is_sleeping(monster) + if (monster->asleep() || monster->inv[MSLOT_POTION] == NON_ITEM || !one_chance_in(3)) { @@ -6501,7 +6501,7 @@ static bool _handle_reaching(monsters *monster) static bool _handle_scroll(monsters *monster) { // Yes, there is a logic to this ordering {dlb}: - if (mons_is_sleeping(monster) + if (monster->asleep() || mons_is_confused(monster) || mons_is_submerged(monster) || monster->inv[MSLOT_SCROLL] == NON_ITEM @@ -6600,7 +6600,7 @@ static bool _handle_wand(monsters *monster, bolt &beem) { // Yes, there is a logic to this ordering {dlb}: if (!mons_near(monster) - || mons_is_sleeping(monster) + || monster->asleep() || monster->has_ench(ENCH_SUBMERGED) || monster->inv[MSLOT_WAND] == NON_ITEM || mitm[monster->inv[MSLOT_WAND]].plus <= 0 @@ -6843,7 +6843,7 @@ static bool _handle_spell(monsters *monster, bolt &beem) return (false); // Yes, there is a logic to this ordering {dlb}: - if (mons_is_sleeping(monster) + if (monster->asleep() || mons_is_submerged(monster) || !mons_class_flag(monster->type, M_SPELLCASTER) && !spellcasting_poly @@ -7850,7 +7850,7 @@ static void _handle_monster_move(monsters *monster) && monster->hit_points==monster->max_hit_points) _khufu_drop_tomb(monster); - if (!mons_is_sleeping(monster) && !mons_is_wandering(monster) + if (!monster->asleep() && !mons_is_wandering(monster) // Berserking monsters are limited to running up and // hitting their foes. && !monster->has_ench(ENCH_BERSERK) @@ -8338,7 +8338,7 @@ static bool _monster_eat_food(monsters *monster, bool nearby) //--------------------------------------------------------------- static bool _handle_pickup(monsters *monster) { - if (mons_is_sleeping(monster) || mons_is_submerged(monster)) + if (monster->asleep() || mons_is_submerged(monster)) return (false); const bool nearby = mons_near(monster); @@ -8426,7 +8426,7 @@ static bool _mons_can_displace(const monsters *mpusher, const monsters *mpushee) if (mons_is_confused(mpusher) || mons_is_confused(mpushee) || mons_cannot_move(mpusher) || mons_cannot_move(mpushee) || mons_is_stationary(mpusher) || mons_is_stationary(mpushee) - || mons_is_sleeping(mpusher)) + || mpusher->asleep()) { return (false); } @@ -8458,7 +8458,7 @@ static bool _monster_swaps_places( monsters *mon, const coord_def& delta ) if (!_mons_can_displace(mon, m2)) return (false); - if (mons_is_sleeping(m2)) + if (m2->asleep()) { if (coinflip()) { @@ -9534,7 +9534,7 @@ static void _mons_in_cloud(monsters *monster) } // A sleeping monster that sustains damage will wake up. - if ((wake || hurted > 0) && mons_is_sleeping(monster)) + if ((wake || hurted > 0) && monster->asleep()) { // We have no good coords to give the monster as the source of the // disturbance other than the cloud itself. diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index dd98b3ee1e..444520b01d 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -5666,7 +5666,7 @@ static bool _beogh_followers_abandon_you() num_followers++; if (you.visible_to(monster) - && !mons_is_sleeping(monster) + && !monster->asleep() && !mons_is_confused(monster) && !mons_cannot_act(monster)) { diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 668ff38dcc..40fdc8bcf5 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -684,7 +684,7 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) if (mons_is_stationary(mon)) // not able to leave the level return (false); - if (mons_is_sleeping(mon)) // not aware of what is happening + if (mon->asleep()) // not aware of what is happening return (false); const int factor = (mons_intel(mon) <= I_ANIMAL) ? 3 : // animals diff --git a/crawl-ref/source/util/crawl.rc b/crawl-ref/source/util/crawl.rc index 3311c43a86..a76f817dea 100644 --- a/crawl-ref/source/util/crawl.rc +++ b/crawl-ref/source/util/crawl.rc @@ -1 +1 @@ -IDI_ICON1 ICON DISCARDABLE "util/crawl.ico" +IDI_ICON1 ICON DISCARDABLE "util/crawl.ico" diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 67f208b715..85a06eea98 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -942,7 +942,7 @@ static void _good_god_follower_attitude_change(monsters *monster) && mons_is_holy(monster) && !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT) && !mons_wont_attack(monster) - && you.visible_to(monster) && !mons_is_sleeping(monster) + && you.visible_to(monster) && !monster->asleep() && !mons_is_confused(monster) && !mons_is_paralysed(monster)) { monster->flags |= MF_ATT_CHANGE_ATTEMPT; @@ -982,7 +982,7 @@ void beogh_follower_convert(monsters *monster, bool orc_hit) && !mons_is_shapeshifter(monster) && !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT) && !mons_friendly(monster) - && you.visible_to(monster) && !mons_is_sleeping(monster) + && you.visible_to(monster) && !monster->asleep() && !mons_is_confused(monster) && !mons_is_paralysed(monster)) { monster->flags |= MF_ATT_CHANGE_ATTEMPT; @@ -1017,7 +1017,7 @@ void slime_convert(monsters* monster) && !mons_neutral(monster) && !mons_friendly(monster) && !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT) - && you.visible_to(monster) && !mons_is_sleeping(monster) + && you.visible_to(monster) && !monster->asleep() && !mons_is_confused(monster) && !mons_is_paralysed(monster)) { monster->flags |= MF_ATT_CHANGE_ATTEMPT; @@ -1392,7 +1392,7 @@ void monster_grid(bool do_updates) if (monster->alive() && mons_near(monster)) { - if (do_updates && (mons_is_sleeping(monster) + if (do_updates && (monster->asleep() || mons_is_wandering(monster)) && check_awaken(monster)) { @@ -1515,7 +1515,7 @@ bool check_awaken(monsters* monster) unnatural_stealthy = true; } - if (mons_is_sleeping(monster)) + if (monster->asleep()) { if (mons_holiness(monster) == MH_NATURAL) { @@ -1900,7 +1900,7 @@ void blood_smell( int strength, const coord_def& where ) if (distance(monster->pos(), where) <= range) { // Let sleeping hounds lie. - if (mons_is_sleeping(monster) + if (monster->asleep() && mons_species(monster->type) != MONS_VAMPIRE && monster->type != MONS_SHARK) { -- cgit v1.2.3-54-g00ecf