From 7b97377e3cb050b67dcff93da54142371213b1d7 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 22 Aug 2008 10:28:33 +0000 Subject: Trunk->0.4 r6834 (partial): Tweak some checks for travel_path to be on the safe side. Probably fixes [2038910]. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6843 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monstuff.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index e695b8974b..9adc4b1123 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2542,7 +2542,6 @@ static void _handle_behaviour(monsters *mon) bool isScared = mon->has_ench(ENCH_FEAR); bool isMobile = !mons_is_stationary(mon); bool isPacified = mons_is_pacified(mon); - bool travelling = mon->is_travelling(); bool patrolling = mon->is_patrolling(); static std::vector e; static int e_index = -1; @@ -2715,7 +2714,7 @@ static void _handle_behaviour(monsters *mon) // Foe gone out of LOS? if (!proxFoe) { - if (mon->foe == MHITYOU && travelling + if (mon->foe == MHITYOU && mon->is_travelling() && mon->travel_target == MTRAV_PLAYER) { // We've got a target, so we'll continue on our way. @@ -2876,7 +2875,7 @@ static void _handle_behaviour(monsters *mon) if (mon->travel_target != MTRAV_PATROL && mon->travel_target != MTRAV_NONE) { - if (travelling) + if (mon->is_travelling()) mon->travel_path.clear(); mon->travel_target = MTRAV_NONE; } @@ -2889,7 +2888,8 @@ static void _handle_behaviour(monsters *mon) mon->name(DESC_PLAIN).c_str()); #endif // If we're already on our way, do nothing. - if (travelling && mon->travel_target == MTRAV_PLAYER) + if (mon->is_travelling() + && mon->travel_target == MTRAV_PLAYER) { int len = mon->travel_path.size(); coord_def targ = mon->travel_path[len - 1]; @@ -3127,7 +3127,7 @@ static void _handle_behaviour(monsters *mon) || mons_is_batty(mon) || !isPacified && one_chance_in(20)) { bool need_target = true; - if (travelling) + if (mon->is_travelling()) { #ifdef DEBUG_PATHFIND mprf("Monster %s reached target (%d, %d)", @@ -3183,7 +3183,8 @@ static void _handle_behaviour(monsters *mon) // is rather small. int erase = -1; // Erase how many waypoints? - for (int i = mon->travel_path.size() - 1; i >= 0; --i) + int size = mon->travel_path.size(); + for (int i = size - 1; i >= 0; --i) { if (grid_see_grid(mon->x, mon->y, mon->travel_path[i].x, @@ -3355,7 +3356,7 @@ static void _handle_behaviour(monsters *mon) || isPacified && one_chance_in(isSmart ? 40 : 120)) { new_foe = MHITNOT; - if (travelling && mon->travel_target != MTRAV_PATROL + if (mon->is_travelling() && mon->travel_target != MTRAV_PATROL || isPacified) { #ifdef DEBUG_PATHFIND -- cgit v1.2.3