From 2e4a257e45031b79b2931e38d56d7c09ea4286fd Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Mon, 7 Dec 2009 21:59:50 +0000 Subject: skip walkboxes that contain source or destination point. svn-id: r46286 --- engines/teenagent/scene.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'engines/teenagent') diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 0c826bdb87..ee3d8420ad 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -58,9 +58,12 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi p.push_back(src); p.push_back(dst); - Common::List boxes; - for(uint i = 0; i < scene_walkboxes.size(); ++i) - boxes.push_back(i); + Common::List boxes; + for(uint i = 0; i < scene_walkboxes.size(); ++i) { + const Walkbox & w = scene_walkboxes[i]; + if (!w.rect.in(src) && !w.rect.in(dst)) + boxes.push_back(i); + } for(Path::iterator i = p.begin(); i != p.end() && !boxes.empty(); ) { Path::iterator next = i; @@ -71,7 +74,7 @@ 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); - Common::List::iterator wi; + Common::List::iterator wi; for(wi = boxes.begin(); wi != boxes.end(); ++wi) { const Walkbox & w = scene_walkboxes[*wi]; int mask = w.rect.intersects_line(p1, p2); @@ -87,8 +90,6 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi debug(1, "hint left: %u", w.side_hint[3]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[3], p1); - if (w1 == p2) - continue; debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); boxes.erase(wi); @@ -99,8 +100,6 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi debug(1, "hint right: %u", w.side_hint[1]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[1], p1); - if (w1 == p2) - continue; debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); boxes.erase(wi); @@ -113,8 +112,6 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi debug(1, "hint top: %u", w.side_hint[0]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[0], p1); - if (w1 == p2) - continue; debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); boxes.erase(wi); @@ -125,8 +122,6 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi debug(1, "hint bottom: %u", w.side_hint[2]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[2], p1); - if (w1 == p2) - continue; debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); boxes.erase(wi); -- cgit v1.2.3