From 2c119d1027bd81b53e2685988d10e95f6b666038 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 17 Jun 2011 04:33:54 +0200 Subject: you can now only travel through paths you've unlocked --- src/wm_path_manager.cpp | 25 +++++++++++++++++++------ src/worldmap.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/wm_path_manager.cpp b/src/wm_path_manager.cpp index 03c11d4..1f0b460 100644 --- a/src/wm_path_manager.cpp +++ b/src/wm_path_manager.cpp @@ -39,13 +39,13 @@ int dWMPathManager_c::onExecute() { if (isMoving) { moveThroughPath(); } else { - if (nowPressed & WPAD_LEFT && currentPoint->exits.asDirection.left.isValid()) + if (nowPressed & WPAD_LEFT && canUseEntrance(currentPoint->exits.asDirection.left)) startMovementTo(LEFT); - else if (nowPressed & WPAD_RIGHT && currentPoint->exits.asDirection.right.isValid()) + else if (nowPressed & WPAD_RIGHT && canUseEntrance(currentPoint->exits.asDirection.right)) startMovementTo(RIGHT); - else if (nowPressed & WPAD_UP && currentPoint->exits.asDirection.up.isValid()) + else if (nowPressed & WPAD_UP && canUseEntrance(currentPoint->exits.asDirection.up)) startMovementTo(UP); - else if (nowPressed & WPAD_DOWN && currentPoint->exits.asDirection.down.isValid()) + else if (nowPressed & WPAD_DOWN && canUseEntrance(currentPoint->exits.asDirection.down)) startMovementTo(DOWN); else if (nowPressed & WPAD_TWO) activatePoint(); @@ -55,6 +55,19 @@ int dWMPathManager_c::onExecute() { } +bool dWMPathManager_c::canUseEntrance(WMPathEntrance &entrance) { + if (!entrance.isValid()) + return false; + + if (entrance.path->eventRequired != 0xFFFF) { + if (!events[entrance.path->eventRequired]) + return false; + } + + return true; +} + + void dWMPathManager_c::moveThroughPath() { // figure out how much to move on each step Vec from, to; @@ -219,7 +232,7 @@ void dWMPathManager_c::setInitialPathVisibility() { u8 alphaToUse = 255; if (path->eventRequired != 0xFFFF) { if (!events[path->eventRequired]) - alphaToUse = 128; + alphaToUse = 92; } for (int j = 0; j < path->materialCount; j++) { @@ -243,7 +256,7 @@ void dWMPathManager_c::computeEvents() { if (point->type == WMPathPoint::LEVEL_TYPE) { // TODO: check if the world/level need to be -1 or not - u32 conds = save->GetLevelCondition(point->params[0], point->params[1]); + u32 conds = save->GetLevelCondition(point->params[0] - 1, point->params[1] - 1); if (conds & COND_NORMAL && point->params[2] != -1) events[point->params[2]] = true; diff --git a/src/worldmap.h b/src/worldmap.h index b356bac..304b08d 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -119,6 +119,8 @@ class dWMPathManager_c : public dBase_c { void moveThroughPath(); + bool canUseEntrance(WMPathEntrance &entrance); + /* Other Methods */ void setup(); -- cgit v1.2.3