From 2bbcfa22843407f8e61e041164da937d0134c21e Mon Sep 17 00:00:00 2001 From: fgenesis Date: Wed, 19 Apr 2017 02:05:57 +0200 Subject: [PATCH] Fix some ANimationEditor crashes when loading not-existing or empty anim XML --- Aquaria/AnimationEditor.cpp | 2 ++ BBGE/SkeletalSprite.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index d0173e3..882b735 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -688,6 +688,8 @@ void AnimationEditor::selectNextBone() void AnimationEditor::update(float dt) { StateObject::update(dt); + if(!editSprite->getCurrentAnimation()) + return; std::ostringstream os; os << editingFile; os << " anim[" << editSprite->getCurrentAnimation()->name << "] "; diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 050aa42..19a91cb 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -1211,7 +1211,8 @@ void SkeletalSprite::loadSkin(const std::string &fn) void SkeletalSprite::stopAnimation(int layer) { - animLayers[layer].stopAnimation(); + if(size_t(layer) < animLayers.size()) + animLayers[layer].stopAnimation(); } void SkeletalSprite::stopAllAnimations() @@ -1224,7 +1225,8 @@ void SkeletalSprite::stopAllAnimations() void SkeletalSprite::playCurrentAnimation(int loop, int layer) { - animLayers[layer].playCurrentAnimation(loop); + if(size_t(layer) < animLayers.size()) + animLayers[layer].playCurrentAnimation(loop); } void SkeletalSprite::loadSkeletal(const std::string &fn)