summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/coordit.cc
diff options
context:
space:
mode:
authorreaver <address.auto@gmail.com>2014-04-05 00:40:42 -0400
committerShmuale Mark <shm.mark@gmail.com>2014-04-07 00:10:09 -0400
commit8db4111ab453120265e9cec2d12f982a148f25b8 (patch)
tree6dbc1fc77ef9ec9428af3e96ba8edc049558b1ad /crawl-ref/source/coordit.cc
parente495eb6ae1ceead0085c87b41fbe6984bab8d7eb (diff)
downloadcrawl-ref-8db4111ab453120265e9cec2d12f982a148f25b8.tar.gz
crawl-ref-8db4111ab453120265e9cec2d12f982a148f25b8.zip
Fix another goto (in coordit.cc)
Diffstat (limited to 'crawl-ref/source/coordit.cc')
-rw-r--r--crawl-ref/source/coordit.cc98
1 files changed, 50 insertions, 48 deletions
diff --git a/crawl-ref/source/coordit.cc b/crawl-ref/source/coordit.cc
index 96efd57b7b..309f58b40c 100644
--- a/crawl-ref/source/coordit.cc
+++ b/crawl-ref/source/coordit.cc
@@ -351,60 +351,62 @@ distance_iterator::distance_iterator(const coord_def& _center, bool _fair,
bool distance_iterator::advance()
{
-again:
- if (++icur >= vcur->size())
- icur = 0;
- if (icur == iend)
+ while (true)
{
- // Advance to the next radius.
- vector<coord_def> *tmp = vcur;
- vcur = vnear;
- vnear = vfar;
- vfar = tmp;
- tmp->clear();
-
- if (!vcur->size())
- return false;
- // Randomize the order various directions are returned.
- // Just the initial angle is enough.
- if (fair)
- icur = iend = random2(vcur->size());
- else
- icur = iend = 0; // randomness is costly
-
- if (r++ >= max_radius)
+ if (++icur >= vcur->size())
+ icur = 0;
+ if (icur == iend)
{
- vcur->clear();
- return false;
+ // Advance to the next radius.
+ vector<coord_def> *tmp = vcur;
+ vcur = vnear;
+ vnear = vfar;
+ vfar = tmp;
+ tmp->clear();
+
+ if (!vcur->size())
+ return false;
+ // Randomize the order various directions are returned.
+ // Just the initial angle is enough.
+ if (fair)
+ icur = iend = random2(vcur->size());
+ else
+ icur = iend = 0; // randomness is costly
+
+ if (r++ >= max_radius)
+ {
+ vcur->clear();
+ return false;
+ }
+ threshold = (r+1) * (r+1) + 1;
}
- threshold = (r+1) * (r+1) + 1;
- }
- coord_def d = (*vcur)[icur];
- if (!in_bounds(current = center + d))
- goto again;
+ coord_def d = (*vcur)[icur];
+ if (in_bounds(current = center + d))
+ {
+ ASSERT(d.x || d.y);
+ if (!d.y)
+ push_neigh(d, sgn(d.x), 0);
+ if (!d.x)
+ push_neigh(d, 0, sgn(d.y));
+ if (d.x <= 0)
+ {
+ if (d.y <= 0)
+ push_neigh(d, -1, -1);
+ if (d.y >= 0)
+ push_neigh(d, -1, +1);
+ }
+ if (d.x >= 0)
+ {
+ if (d.y <= 0)
+ push_neigh(d, +1, -1);
+ if (d.y >= 0)
+ push_neigh(d, +1, +1);
+ }
- ASSERT(d.x || d.y);
- if (!d.y)
- push_neigh(d, sgn(d.x), 0);
- if (!d.x)
- push_neigh(d, 0, sgn(d.y));
- if (d.x <= 0)
- {
- if (d.y <= 0)
- push_neigh(d, -1, -1);
- if (d.y >= 0)
- push_neigh(d, -1, +1);
- }
- if (d.x >= 0)
- {
- if (d.y <= 0)
- push_neigh(d, +1, -1);
- if (d.y >= 0)
- push_neigh(d, +1, +1);
+ return true;
+ }
}
-
- return true;
}
void distance_iterator::push_neigh(coord_def d, int dx, int dy)