summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.cpp
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-09-21 20:43:21 -0500
committerColin Noga <Tempus@chronometry.ca>2012-09-21 20:43:21 -0500
commitd47a9ed57a826d60c37bfa8a4ae00ccaba0ed806 (patch)
treec3f6657118d71abcd1ce3b4584b3e0472841e53f /src/koopatlas/pathmanager.cpp
parent8d0a306f0a526a76182c8d2b513d7a0441d6f466 (diff)
parent5654d5c0a056f9cfc99ac608d16aa0a601b997f5 (diff)
downloadkamek-d47a9ed57a826d60c37bfa8a4ae00ccaba0ed806.tar.gz
kamek-d47a9ed57a826d60c37bfa8a4ae00ccaba0ed806.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to '')
-rw-r--r--src/koopatlas/pathmanager.cpp57
1 files changed, 47 insertions, 10 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index ffc4dfd..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;
}
}
@@ -433,26 +463,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);
@@ -560,6 +590,13 @@ void dWMPathManager_c::moveThroughPath() {
SaveBlock *save = GetSaveFile()->GetBlock(-1);
save->current_path_node = pathLayer->findNodeID(to);
+ if (to->type == dKPNode_s::LEVEL) {
+ NWRWorld nWorld = NewerWorldForLevelID(to->levelNumber[0], to->levelNumber[1]);
+ if (nWorld != UNKNOWN_WORLD) {
+ save->currentNewerWorld = (u8)nWorld;
+ }
+ }
+
dWMHud_c::instance->showPointBar();
SpammyReport("Point bar shown\n");
} else {