summaryrefslogtreecommitdiff
path: root/src/koopatlas/pathmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/koopatlas/pathmanager.cpp69
1 files changed, 54 insertions, 15 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 2b85aaa..8a05ea4 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -372,10 +372,12 @@ void dWMPathManager_c::execute() {
void dWMPathManager_c::startMovementTo(dKPPath_s *path) {
SpammyReport("moving to path %p [%d,%d to %d,%d]\n", path, path->start->x, path->start->y, path->end->x, path->end->y);
- dWMHud_c::instance->hidePointBar();
- SpammyReport("point bar hidden\n");
if (!path->isAvailable) { return; }
+ if (currentNode && dWMHud_c::instance)
+ dWMHud_c::instance->leftNode();
+
+ calledEnteredNode = false;
SpammyReport("a\n");
isMoving = true;
@@ -549,6 +551,18 @@ void dWMPathManager_c::moveThroughPath() {
player->pos.x += move.x;
player->pos.y -= move.y;
+ // what distance is left?
+ if (to->type == dKPNode_s::LEVEL && !calledEnteredNode) {
+ Vec toEndVec = {to->x - player->pos.x, to->y + player->pos.y, 0.0f};
+ float distToEnd = VECMag(&toEndVec);
+ //OSReport("Distance: %f; To:%d,%d; Player:%f,%f; Diff:%f,%f\n", distToEnd, to->x, to->y, player->pos.x, player->pos.y, toEndVec.x, toEndVec.y);
+
+ if (distToEnd < 64.0f && dWMHud_c::instance) {
+ calledEnteredNode = true;
+ dWMHud_c::instance->enteredNode(to);
+ }
+ }
+
// Check if we've reached the end yet
if (
(((move.x > 0) ? (player->pos.x >= to->x) : (player->pos.x <= to->x)) &&
@@ -564,15 +578,15 @@ void dWMPathManager_c::moveThroughPath() {
isJumping = false;
timer = 0.0;
- SpammyReport("reached path end (%p)\n", to);
+ SpammyReport("reached path end (%p) with type %d\n", to, to->type);
bool reallyStop = false;
if (to->type == dKPNode_s::LEVEL) {
// Always stop on levels
reallyStop = true;
- } else if (to->type == dKPNode_s::CHANGE) {
- // Never stop on entrances
+ } else if (to->type == dKPNode_s::CHANGE || to->type == dKPNode_s::WORLD_CHANGE) {
+ // Never stop on entrances or on world changes
reallyStop = false;
} else if (to->type == dKPNode_s::PASS_THROUGH) {
// If there's only one exit here, then stop even though
@@ -588,6 +602,39 @@ void dWMPathManager_c::moveThroughPath() {
reallyStop = true;
}
+ if (to->type == dKPNode_s::WORLD_CHANGE) {
+ // Set the current world info
+ SaveBlock *save = GetSaveFile()->GetBlock(-1);
+
+ OSReport("Activating world change %d\n", to->worldID);
+ const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID);
+ if (world) {
+ if (strncmp(save->newerWorldName, world->name, 36) == 0) {
+ OSReport("Already here\n");
+ } else {
+ OSReport("Found!\n");
+ strncpy(save->newerWorldName, world->name, 36);
+ save->newerWorldName[35] = 0;
+ save->currentMapMusic = world->trackID;
+
+ for (int i = 0; i < 2; i++) {
+ save->fsTextColours[i] = world->fsTextColours[i];
+ save->fsHintColours[i] = world->fsHintColours[i];
+ save->hudTextColours[i] = world->hudTextColours[i];
+ }
+
+ save->hudHintH = world->hudHintH;
+ save->hudHintS = world->hudHintS;
+ save->hudHintL = world->hudHintL;
+
+ if (dWMHud_c::instance)
+ dWMHud_c::instance->hideAndShowFooter();
+ }
+ } else {
+ OSReport("Not found!\n");
+ }
+ }
+
if (to->type == dKPNode_s::CHANGE) {
// Go to another map
@@ -621,16 +668,8 @@ 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");
+ if (!calledEnteredNode && dWMHud_c::instance)
+ dWMHud_c::instance->enteredNode();
} else {
startMovementTo(to->getOppositeAvailableExitTo(currentPath));
SpammyReport("passthrough node, continuing to next path\n");