diff options
author | Treeki <treeki@gmail.com> | 2012-09-21 23:03:23 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-21 23:03:23 +0200 |
commit | 81740b6a0ec2815495751e5875f492b6dbd8ab0b (patch) | |
tree | 1002db45fa7efff2c3f7e7421f0d3a92a785c2a6 /src/koopatlas | |
parent | 8103666b9c6120cae9eb3551a6f1f8b3283a5876 (diff) | |
download | kamek-81740b6a0ec2815495751e5875f492b6dbd8ab0b.tar.gz kamek-81740b6a0ec2815495751e5875f492b6dbd8ab0b.zip |
a failed attempt at better changes, pushed so I can test at home
Diffstat (limited to 'src/koopatlas')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
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; } } |