diff --git a/src/unit_animation.cpp b/src/unit_animation.cpp index 1609c653011..d736a120438 100644 --- a/src/unit_animation.cpp +++ b/src/unit_animation.cpp @@ -52,8 +52,8 @@ config unit_animation::prepare_animation(const config &cfg,const std::string ani expanded_chunk.append(*(*child).second); to_add.push_back(expanded_chunk); child++; - if(*(*child).first == "else") { - while(*(*child).first == "else") { + if(child != analyzed_anim.ordered_end() && *(*child).first == "else") { + while(child != analyzed_anim.ordered_end() && *(*child).first == "else") { expanded_chunk = expanded_anim; // add the content of else to the stored one expanded_chunk.append(*(*child).second); @@ -63,7 +63,7 @@ config unit_animation::prepare_animation(const config &cfg,const std::string ani } } else { - // add an animw with the if part removed + // add an anim with the if part removed to_add.push_back(expanded_anim); } // copy the end of the anim "as is" other if will be treated later