aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorVladimir Menshakov2009-12-05 06:00:00 +0000
committerVladimir Menshakov2009-12-05 06:00:00 +0000
commit7aa92b7dcc8ae0e8019fb0bc72f4eb6dfdaec92e (patch)
tree834d321a1f5de4da22ee71365c0e3b78979ac25b /engines
parent60fa351d32a0d133583662bc4cd20057be418b7a (diff)
downloadscummvm-rg350-7aa92b7dcc8ae0e8019fb0bc72f4eb6dfdaec92e.tar.gz
scummvm-rg350-7aa92b7dcc8ae0e8019fb0bc72f4eb6dfdaec92e.tar.bz2
scummvm-rg350-7aa92b7dcc8ae0e8019fb0bc72f4eb6dfdaec92e.zip
do not use walkbox more than once.
svn-id: r46263
Diffstat (limited to 'engines')
-rw-r--r--engines/teenagent/scene.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 56df743e14..d64c00c9c4 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -57,8 +57,12 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
p.clear();
p.push_back(src);
p.push_back(dst);
+
+ Common::List<int> boxes;
+ for(uint i = 0; i < scene_walkboxes.size(); ++i)
+ boxes.push_back(i);
- for(Path::iterator i = p.begin(); i != p.end(); ) {
+ for(Path::iterator i = p.begin(); i != p.end() && !boxes.empty(); ) {
Path::iterator next = i;
++next;
if (next == p.end())
@@ -67,16 +71,16 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
const Common::Point &p1 = *i, &p2 = *next;
debug(1, "%d,%d -> %d,%d", p1.x, p1.y, p2.x, p2.y);
- byte wi;
- for(wi = 0; wi < scene_walkboxes.size(); ++wi) {
- const Walkbox & w = scene_walkboxes[wi];
+ Common::List<int>::iterator wi;
+ for(wi = boxes.begin(); wi != boxes.end(); ++wi) {
+ const Walkbox & w = scene_walkboxes[*wi];
int mask = w.rect.intersects_line(p1, p2);
if (mask == 0) {
continue;
}
w.dump();
- debug(1, "%u: intersection mask 0x%04x, searching hints", wi, mask);
+ debug(1, "%u: intersection mask 0x%04x, searching hints", *wi, mask);
int dx = p2.x - p1.x, dy = p2.y - p1.y;
if (dx >= 0) {
if ((mask & 8) != 0 && w.side_hint[3] != 0) {
@@ -87,6 +91,7 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
continue;
debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y);
p.insert(next, w1);
+ boxes.erase(wi);
break;
}
} else {
@@ -98,6 +103,7 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
continue;
debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y);
p.insert(next, w1);
+ boxes.erase(wi);
break;
}
}
@@ -111,6 +117,7 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
continue;
debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y);
p.insert(next, w1);
+ boxes.erase(wi);
break;
}
} else {
@@ -122,11 +129,12 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi
continue;
debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y);
p.insert(next, w1);
+ boxes.erase(wi);
break;
}
}
}
- if (wi >= scene_walkboxes.size())
+ if (wi == boxes.end())
++i;
}