From 81740b6a0ec2815495751e5875f492b6dbd8ab0b Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 21 Sep 2012 23:03:23 +0200 Subject: a failed attempt at better changes, pushed so I can test at home --- src/koopatlas/pathmanager.cpp | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 2b817a4..a9cd003 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -41,11 +41,41 @@ void dWMPathManager_c::setup() { found = true; currentNode = node; - SpammyReport("a1 Node: %p\n", node); - dKPPath_s *exit = node->getAnyExit(); - SpammyReport("a2 Exit: %p\n", exit); - startMovementTo(exit); - SpammyReport("a3\n"); + // figure out where we should move to + dKPPath_s *exitTo = 0; + + for (int i = 0; i < 4; i++) { + dKPPath_s *candidateExit = node->exits[i]; + if (!candidateExit) + continue; + + // find out if this path is a candidate + dKPNode_s *srcNode = node; + dKPPath_s *path = candidateExit; + + while (true) { + dKPNode_s *destNode = (path->start == srcNode) ? path->end : path->start; + int ct = destNode->getAvailableExitCount(); + if (destNode == node || ct > 2 || destNode->type == dKPNode_s::LEVEL) { + exitTo = path; + break; + } + + if (ct == 1) + break; + + // where to next? + path = destNode->getOppositeAvailableExitTo(path); + srcNode = destNode; + } + + if (exitTo) + break; + } + + if (!exitTo) + exitTo = node->getAnyExit(); + startMovementTo(exitTo); break; } } -- cgit v1.2.3