Proper fix for waterfall tiles
[supertux.git] / src / object / gradient.cpp
index 7e325b1..ef86b11 100644 (file)
@@ -18,6 +18,8 @@
 #include "supertux/object_factory.hpp"
 #include "util/reader.hpp"
 
+#include <stdexcept>
+
 Gradient::Gradient() :
   layer(LAYER_BACKGROUND0),
   gradient_top(),
@@ -30,7 +32,7 @@ Gradient::Gradient(const Reader& reader) :
   gradient_top(),
   gradient_bottom()
 {
-  reader.get("layer", layer);
+  layer = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND0);
   std::vector<float> bkgd_top_color, bkgd_bottom_color;
   if(!reader.get("top_color", bkgd_top_color) ||
      !reader.get("bottom_color", bkgd_bottom_color))
@@ -55,12 +57,17 @@ Gradient::set_gradient(Color top, Color bottom)
   gradient_top = top;
   gradient_bottom = bottom;
 
-  if (gradient_top.red > 1.0 || gradient_top.green > 1.0
-      || gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
+  if (gradient_top.red > 1.0 || gradient_top.green > 1.0 ||
+      gradient_top.blue > 1.0 || gradient_top.alpha > 1.0)
+  {
     log_warning << "top gradient color has values above 1.0" << std::endl;
-  if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0
-      || gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
+  }
+
+  if (gradient_bottom.red > 1.0 || gradient_bottom.green > 1.0 ||
+       gradient_bottom.blue > 1.0 || gradient_bottom.alpha > 1.0)
+  {
     log_warning << "bottom gradient color has values above 1.0" << std::endl;
+  }
 }
 
 void