summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-25 22:04:30 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-25 22:04:30 +0000
commit537d8cfed4159774f91ad8aa3b4d0f221b6f767d (patch)
treeadb857e3c42ec0545aa1671a9e1e708158d93155 /crawl-ref/source
parent7cfe05ee417670c6a409cb4beb999be06a01e301 (diff)
downloadcrawl-ref-537d8cfed4159774f91ad8aa3b4d0f221b6f767d.tar.gz
crawl-ref-537d8cfed4159774f91ad8aa3b4d0f221b6f767d.zip
Following dolorous's comments on 2488905, use random_in_bounds() instead
of manual randomization. Also fixes the bug where this was biased towards the bottom-right section of the map. Unfortunately, it doesn't fix 2488905. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8750 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/items.cc2
-rw-r--r--crawl-ref/source/monstuff.cc16
2 files changed, 6 insertions, 12 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index a8e235b098..07377e47b6 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2328,7 +2328,7 @@ bool item_needs_autopickup(const item_def &item)
if (item_is_stationary(item))
return (false);
- if (strstr(item.inscription.c_str(), "=g") != 0)
+ if (item.inscription.find("=g") != std::string::npos)
return (true);
if ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown)
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 328a02357e..8f7c849b53 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -3618,10 +3618,7 @@ static void _check_wander_target(monsters *mon, bool isPacified = false,
// wandering monsters at least appear to have some sort of
// attention span. -- bwr
if (need_target)
- {
- mon->target.set(10 + random2(X_BOUND_2 - 10),
- 10 + random2(Y_BOUND_2 - 10));
- }
+ mon->target = random_in_bounds();
}
}
@@ -3752,8 +3749,7 @@ static void _handle_behaviour(monsters *mon)
// Check for confusion -- early out.
if (mon->has_ench(ENCH_CONFUSION))
{
- mon->target.set(10 + random2(X_BOUND_2 - 10),
- 10 + random2(Y_BOUND_2 - 10));
+ mon->target = random_in_bounds();
return;
}
@@ -4050,8 +4046,7 @@ static void _handle_behaviour(monsters *mon)
// Sometimes, your friends will wander a bit.
if (isFriendly && one_chance_in(8))
{
- mon->target.set(10 + random2(X_BOUND_2 - 10),
- 10 + random2(Y_BOUND_2 - 10));
+ mon->target = random_in_bounds();
mon->foe = MHITNOT;
new_beh = BEH_WANDER;
}
@@ -4106,9 +4101,8 @@ static void _handle_behaviour(monsters *mon)
{
mon->travel_target = MTRAV_NONE;
patrolling = false;
- mon->patrol_point = coord_def(0, 0);
- mon->target.set(10 + random2(X_BOUND_2 - 10),
- 10 + random2(Y_BOUND_2 - 10));
+ mon->patrol_point.reset();
+ mon->target = random_in_bounds();
}
}