diff options
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 609b3a2..923d08c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -11,10 +11,35 @@ void dWMPathManager_c::setup() { pathLayer = dScKoopatlas_c::instance->mapData.pathLayer; SaveBlock *save = GetSaveFile()->GetBlock(-1); - if (save->current_path_node >= pathLayer->nodeCount) { - currentNode = pathLayer->nodes[0]; + + // Figure out what path node to start at + if (dScKoopatlas_c::instance->settings & 0x10000000) { + // Start off from a "Change" + u8 changeID = dScKoopatlas_c::instance->settings & 0xFF; + + bool found = false; + + for (int i = 0; i < pathLayer->nodeCount; i++) { + dKPNode_s *node = pathLayer->nodes[i]; + + if (node->type == dKPNode_s::CHANGE && node->thisID == changeID) { + found = true; + currentNode = node; + + startMovementTo(node->getAnyExit()); + } + } + + if (!found) { + OSReport("Couldn't find target node %d!\n", changeID); + } + } else { - currentNode = pathLayer->nodes[save->current_path_node]; + if (save->current_path_node >= pathLayer->nodeCount) { + currentNode = pathLayer->nodes[0]; + } else { + currentNode = pathLayer->nodes[save->current_path_node]; + } } // unlock all needed paths @@ -100,7 +125,16 @@ void dWMPathManager_c::moveThroughPath() { player->pos.x = to->x; player->pos.y = -to->y; - if (to->type != dKPNode_s::PASS_THROUGH) { + if (to->type == dKPNode_s::CHANGE) { + // Go to another map + isMoving = false; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + save->current_world = dScKoopatlas_c::instance->getIndexForMapName(to->destMap); + + DoSceneChange(WORLD_MAP, 0x10000000 | to->foreignID, 0); + + } else if (to->type != dKPNode_s::PASS_THROUGH) { // Stop here player->startAnimation(0, 1.2, 10.0, 0.0); |