diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:28:27 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-15 04:28:27 -0800 |
commit | fa1a2da73b9b0e7e272cf1d26c6333f26404efd4 (patch) | |
tree | 1d1b3ee1e76c9c03d4a21d63072198450ae6dfd7 /crawl-ref/source/teleport.cc | |
parent | 287d2535c79d1643338b466c3bbb5f729cb1e9bd (diff) | |
download | crawl-ref-fa1a2da73b9b0e7e272cf1d26c6333f26404efd4.tar.gz crawl-ref-fa1a2da73b9b0e7e272cf1d26c6333f26404efd4.zip |
random_space_weighted() memory bug fixed
Bug was fixed in random-weight.h, reverting work-around.
Diffstat (limited to 'crawl-ref/source/teleport.cc')
-rw-r--r-- | crawl-ref/source/teleport.cc | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/crawl-ref/source/teleport.cc b/crawl-ref/source/teleport.cc index e7ffb3e528..c3b553552f 100644 --- a/crawl-ref/source/teleport.cc +++ b/crawl-ref/source/teleport.cc @@ -99,12 +99,6 @@ static coord_def random_space_weighted(actor* moved, actor* target, dests.push_back(coord_weight(*ri, weight)); } - // XXX: Sometimes this results in a memory problem, where it seems as - // if the dests vector is free'd before copying the result. When - // this happens, an out-of-bounds coordinate is usually returned. - // - // This is with GCC 4.4.1, -O2, 32 bit Linux, -march-native on a - // Family 10 AMD chip. coord_def* choice = random_choose_weighted(dests); return (choice ? *choice : coord_def(0, 0)); } @@ -134,7 +128,7 @@ void blink_away(monsters* mon) if (!foe || !mon->can_see(foe)) return; coord_def dest = random_space_weighted(mon, foe, false, false); - if (!in_bounds(dest)) + if (dest.origin()) return; bool success = mon->blink_to(dest); ASSERT(success); @@ -150,7 +144,7 @@ void blink_range(monsters* mon) if (!foe || !mon->can_see(foe)) return; coord_def dest = random_space_weighted(mon, foe, false, true); - if (!in_bounds(dest)) + if (dest.origin()) return; bool success = mon->blink_to(dest); ASSERT(success); @@ -166,7 +160,7 @@ void blink_close(monsters* mon) if (!foe || !mon->can_see(foe)) return; coord_def dest = random_space_weighted(mon, foe, true); - if (!in_bounds(dest)) + if (dest.origin()) return; bool success = mon->blink_to(dest); ASSERT(success); |