Explorar el Código

Do not crash on invalid animation file

Ivan Savenko hace 4 semanas
padre
commit
35dad6db4e
Se han modificado 1 ficheros con 9 adiciones y 4 borrados
  1. 9 4
      client/widgets/Images.cpp

+ 9 - 4
client/widgets/Images.cpp

@@ -353,11 +353,16 @@ CShowableAnim::CShowableAnim(int x, int y, const AnimationPath & name, ui8 Flags
 	last = anim->size(group);
 
 	auto image = anim->getImage(0, group);
-	if (!image)
-		throw std::runtime_error("Failed to load group " + std::to_string(group) + " of animation file " + name.getOriginalName());
+	if (image)
+	{
+		pos.w = image->width();
+		pos.h = image->height();
+	}
+	else
+	{
+		logGlobal->error("Failed to load group %d of animation file %s", group,  name.getOriginalName());
+	}
 
-	pos.w = image->width();
-	pos.h = image->height();
 	pos.x+= x;
 	pos.y+= y;