diff options
author | Chuck Miller <shadowmil@gmail.com> | 2010-06-08 08:39:20 -0400 |
---|---|---|
committer | Chuck Miller <shadowmil@gmail.com> | 2010-06-08 10:20:15 -0400 |
commit | 891d14807cd042aa90aed94558c2c8eda66d6859 (patch) | |
tree | 0cf99075b54abc5afc8640c91f801a65743da63f | |
parent | 8ed2b20d767891a27a271b3c3259d06c083ce00c (diff) | |
download | mana-891d14807cd042aa90aed94558c2c8eda66d6859.tar.gz mana-891d14807cd042aa90aed94558c2c8eda66d6859.tar.bz2 mana-891d14807cd042aa90aed94558c2c8eda66d6859.tar.xz mana-891d14807cd042aa90aed94558c2c8eda66d6859.zip |
Handle not loading target files more gracyfully
It no longer crashes, but will write to the log file instead
Also added checks so it does not crash elsewhere when the
target cursors are unloaded
The game is still playable without the target cursor
because the display name of a being changes when it
gets targetted... so no need to be a fatel error.
Reviewed-by: Thorbjørn Lindeijer
-rw-r--r-- | src/actorsprite.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 92894b04..a7821699 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -115,7 +115,8 @@ void ActorSprite::actorLogic() { for (int type = TCT_NORMAL; type < NUM_TCT; type++) { - targetCursor[type][size]->update(tick_time * MILLISECONDS_IN_A_TICK); + if (targetCursor[type][size]) + targetCursor[type][size]->update(tick_time * MILLISECONDS_IN_A_TICK); } } } @@ -405,7 +406,8 @@ void ActorSprite::cleanupTargetCursors() for (int type = TCT_NORMAL; type < NUM_TCT; type++) { delete targetCursor[type][size]; - targetCursorImages[type][size]->decRef(); + if (targetCursorImages[type][size]) + targetCursorImages[type][size]->decRef(); } } } @@ -419,6 +421,12 @@ void ActorSprite::loadTargetCursor(const std::string &filename, ResourceManager *resman = ResourceManager::getInstance(); ImageSet *currentImageSet = resman->getImageSet(filename, width, height); + if (!currentImageSet) + { + logger->log("Error loading target cursor: %s", filename.c_str()); + return; + } + Animation *anim = new Animation; for (unsigned int i = 0; i < currentImageSet->size(); ++i) |