diff options
author | Treeki <treeki@gmail.com> | 2012-09-27 15:35:54 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-27 15:35:54 +0200 |
commit | cd2ceff21f680a7d33b43a6926b4e556e81d625b (patch) | |
tree | 25ac0285c6cf813224c7534edcb802251e3149f2 /src/koopatlas | |
parent | 261cd42b5eaad3add529a7464410fcb256fefeab (diff) | |
download | kamek-cd2ceff21f680a7d33b43a6926b4e556e81d625b.tar.gz kamek-cd2ceff21f680a7d33b43a6926b4e556e81d625b.zip |
fixed a possible crash bug where the HUD was accessed before it was created
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/hud.cpp | 2 | ||||
-rw-r--r-- | 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)); |