From 05eb1400faaa957905fbbe8fa284df4ab1472a58 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 20 Sep 2012 15:30:05 +0200 Subject: cleaning up in preparation for the new HUD, plus a few other changes --- src/koopatlas/pathmanager.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 49ee728..3d85f4c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -300,8 +300,6 @@ void dWMPathManager_c::execute() { void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("moving to path %p\n", path); - dWMHud_c::instance->hidePointBar(); - SpammyReport("point bar hidden\n"); if (!path->isAvailable) { return; } @@ -566,9 +564,6 @@ void dWMPathManager_c::moveThroughPath() { save->currentNewerWorld = (u8)nWorld; } } - - dWMHud_c::instance->showPointBar(); - SpammyReport("Point bar shown\n"); } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); SpammyReport("passthrough node, continuing to next path\n"); -- cgit v1.2.3 From 955831a5bad45d39dfceb4a1741095b5d109b079 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 21 Sep 2012 13:24:57 +0200 Subject: still working on the new HUD... --- src/koopatlas/pathmanager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 3d85f4c..a03541c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -302,6 +302,10 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("moving to path %p\n", path); if (!path->isAvailable) { return; } + if (currentNode) + dWMHud_c::instance->leftNode(); + + calledEnteredNode = false; SpammyReport("a\n"); isMoving = true; @@ -496,6 +500,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) { + 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)) && @@ -557,6 +573,8 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); save->current_path_node = pathLayer->findNodeID(to); + if (!calledEnteredNode) + dWMHud_c::instance->enteredNode(); if (to->type == dKPNode_s::LEVEL) { NWRWorld nWorld = NewerWorldForLevelID(to->levelNumber[0], to->levelNumber[1]); -- cgit v1.2.3 From 014f3668eb47b1576bdc182b1db00417f9938cf1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 00:51:43 +0200 Subject: added untested support for world change nodes --- src/koopatlas/pathmanager.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index e42246e..2401e04 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -573,8 +573,8 @@ void dWMPathManager_c::moveThroughPath() { 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 @@ -590,6 +590,34 @@ 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); + dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); + if (world) { + 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; + + dWMHud_c::instance->hideAndShowFooter(); + } else { + OSReport("Not found!\n"); + } + } + if (to->type == dKPNode_s::CHANGE) { // Go to another map -- cgit v1.2.3 From 411c5a8e210b5cbca330a5438e2406dbe1ffecab Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 04:40:34 +0200 Subject: made world changes work, and HUD colourising and other fun things --- src/koopatlas/pathmanager.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 2401e04..896707a 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -566,7 +566,7 @@ 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; @@ -595,7 +595,7 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); OSReport("Activating world change %d\n", to->worldID); - dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); + const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); if (world) { OSReport("Found!\n"); strncpy(save->newerWorldName, world->name, 36); @@ -653,13 +653,6 @@ void dWMPathManager_c::moveThroughPath() { save->current_path_node = pathLayer->findNodeID(to); if (!calledEnteredNode) dWMHud_c::instance->enteredNode(); - - if (to->type == dKPNode_s::LEVEL) { - NWRWorld nWorld = NewerWorldForLevelID(to->levelNumber[0], to->levelNumber[1]); - if (nWorld != UNKNOWN_WORLD) { - save->currentNewerWorld = (u8)nWorld; - } - } } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); SpammyReport("passthrough node, continuing to next path\n"); -- cgit v1.2.3 From e30d836af369f251f83375dd9a9dbab435ee61f1 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 05:25:01 +0200 Subject: world change nodes now don't activate if you're already at that world --- src/koopatlas/pathmanager.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 896707a..97d9265 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -597,22 +597,26 @@ void dWMPathManager_c::moveThroughPath() { OSReport("Activating world change %d\n", to->worldID); const dKPWorldDef_s *world = dScKoopatlas_c::instance->mapData.findWorldDef(to->worldID); if (world) { - 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]; - } + 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; + save->hudHintH = world->hudHintH; + save->hudHintS = world->hudHintS; + save->hudHintL = world->hudHintL; - dWMHud_c::instance->hideAndShowFooter(); + dWMHud_c::instance->hideAndShowFooter(); + } } else { OSReport("Not found!\n"); } -- cgit v1.2.3 From cd2ceff21f680a7d33b43a6926b4e556e81d625b Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 27 Sep 2012 15:35:54 +0200 Subject: fixed a possible crash bug where the HUD was accessed before it was created --- src/koopatlas/pathmanager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/koopatlas/pathmanager.cpp') diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 97d9265..6134dc6 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -368,7 +368,7 @@ 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); if (!path->isAvailable) { return; } - if (currentNode) + if (currentNode && dWMHud_c::instance) dWMHud_c::instance->leftNode(); calledEnteredNode = false; @@ -545,7 +545,7 @@ void dWMPathManager_c::moveThroughPath() { 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) { + if (distToEnd < 64.0f && dWMHud_c::instance) { calledEnteredNode = true; dWMHud_c::instance->enteredNode(to); } @@ -615,7 +615,8 @@ void dWMPathManager_c::moveThroughPath() { save->hudHintS = world->hudHintS; save->hudHintL = world->hudHintL; - dWMHud_c::instance->hideAndShowFooter(); + if (dWMHud_c::instance) + dWMHud_c::instance->hideAndShowFooter(); } } else { OSReport("Not found!\n"); @@ -655,7 +656,7 @@ void dWMPathManager_c::moveThroughPath() { SaveBlock *save = GetSaveFile()->GetBlock(-1); save->current_path_node = pathLayer->findNodeID(to); - if (!calledEnteredNode) + if (!calledEnteredNode && dWMHud_c::instance) dWMHud_c::instance->enteredNode(); } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); -- cgit v1.2.3