diff options
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index a03541c..9525732 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -41,11 +41,47 @@ 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"); + //OSReport("Found CHANGE node: %d %p\n", changeID, node); + + // figure out where we should move to + dKPPath_s *exitTo = 0; + + for (int i = 0; i < 4; i++) { + dKPPath_s *candidateExit = node->exits[i]; + //OSReport("Candidate exit: %p\n", candidateExit); + 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; + //OSReport("Path: %p nodes %p to %p\n", path, srcNode, destNode); + int ct = destNode->getAvailableExitCount(); + //OSReport("Dest Node available exits: %d; type: %d\n", ct, destNode->type); + if (destNode == node || ct > 2 || destNode->type == dKPNode_s::LEVEL) { + exitTo = candidateExit; + //OSReport("Accepting this node\n"); + 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; } } @@ -54,7 +90,7 @@ void dWMPathManager_c::setup() { currentNode = pathLayer->nodes[0]; mustComplainToMapCreator = true; } - + } else { SpammyReport("saved path node: %d\n", save->current_path_node); if (save->current_path_node >= pathLayer->nodeCount) { @@ -435,26 +471,26 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { moveSpeed = 2.0f; break; case 13: - player->startAnimation(Tjumped, 2.0, 0.0, 0.0); - break; - case 14: player->startAnimation(b_dash2, 3.0, 10.0, 0.0); player->hasSound = true; player->soundName = SE_PLY_FOOTNOTE_DIRT; moveSpeed = 5.0f; break; - case 15: + case 14: player->startAnimation(wait, 2.0, 10.0, 0.0); player->rot.y = 0x0000; MapSoundPlayer(SoundRelatedClass, SE_PLY_DOKAN_IN_OUT, 1); moveSpeed = 1.0f; break; - case 16: + case 15: player->startAnimation(wait, 2.0, 10.0, 0.0); player->rot.y = 0x8000; MapSoundPlayer(SoundRelatedClass, SE_OBJ_DOOR_OPEN, 1); moveSpeed = 0.2f; break; + case 16: + player->startAnimation(Tjumped, 2.0, 0.0, 0.0); + break; default: SpammyReport("No animtaion?!"); player->startAnimation(run, 2.0, 10.0, 0.0); @@ -551,7 +587,15 @@ void dWMPathManager_c::moveThroughPath() { if (to->type == dKPNode_s::CHANGE) { // Go to another map - isMoving = false; + + // should we continue moving? + if (to->getAvailableExitCount() == 1) { + OSReport("Stopping"); + isMoving = false; + } else { + OSReport("Continuing"); + startMovementTo(to->getOppositeAvailableExitTo(currentPath)); + } SaveBlock *save = GetSaveFile()->GetBlock(-1); SpammyReport("node: %x, %s", to->destMap, to->destMap); |