summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-02-27 12:34:56 -0600
committerColin Noga <Tempus@chronometry.ca>2012-02-27 12:34:56 -0600
commitd6924bebc44bf904ec3e9ed8126614f67a04df88 (patch)
tree159e94b87aa174b4bc86f565db975adfab729efe /src/koopatlas/pathmanager.cpp
parent12e4a674748be41a0105f6a7b3b8132d0a3a65b4 (diff)
parent21d7e41b006b88aa79821610661fefc8fe14b7ca (diff)
downloadkamek-d6924bebc44bf904ec3e9ed8126614f67a04df88.tar.gz
kamek-d6924bebc44bf904ec3e9ed8126614f67a04df88.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r--src/koopatlas/pathmanager.cpp42
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);