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/hud.cpp | 2 ++ src/koopatlas/pathmanager.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp index 907f02c..892186e 100644 --- a/src/koopatlas/hud.cpp +++ b/src/koopatlas/hud.cpp @@ -246,6 +246,8 @@ int dWMHud_c::onCreate() { int dWMHud_c::onDelete() { + dWMHud_c::instance = 0; + if (!layoutLoaded) return true; 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