Added -Wnon-virtual-dtor and -Wcast-qual warning flags
[supertux.git] / src / video / color.hpp
index 434c03e..9155157 100644 (file)
@@ -26,21 +26,21 @@ class Color
 {
 public:
   Color() :
-    red(0), 
-    green(0), 
-    blue(0), 
+    red(0),
+    green(0),
+    blue(0),
     alpha(1.0f)
   {}
 
-  Color(float red, float green, float blue, float alpha = 1.0) :
-    red(red),
-    green(green), 
-    blue(blue), 
-    alpha(alpha)
+  Color(float red_, float green_, float blue_, float alpha_ = 1.0) :
+    red(red_),
+    green(green_),
+    blue(blue_),
+    alpha(alpha_)
   {
-#ifdef DEBUG
-    check_color_ranges();
-#endif
+    assert(0 <= red   && red <= 1.0);
+    assert(0 <= green && green <= 1.0);
+    assert(0 <= blue  && blue <= 1.0);
   }
 
   Color(const std::vector<float>& vals) :
@@ -57,9 +57,9 @@ public:
       alpha = vals[3];
     else
       alpha = 1.0;
-#ifdef DEBUG
-    check_color_ranges();
-#endif
+    assert(0 <= red   && red <= 1.0);
+    assert(0 <= green && green <= 1.0);
+    assert(0 <= blue  && blue <= 1.0);
   }
 
   bool operator==(const Color& other) const
@@ -68,17 +68,9 @@ public:
       && alpha == other.alpha;
   }
 
-  void check_color_ranges()
-  {
-    if(red < 0 || red > 1.0 || green < 0 || green > 1.0
-       || blue < 0 || blue > 1.0
-       || alpha < 0 || alpha > 1.0)
-      log_warning << "color value out of range: " << red << ", " << green << ", " << blue << ", " << alpha << std::endl;
-  }
-
   float greyscale() const
   {
-    return red * 0.30 + green * 0.59 + blue * 0.11;
+    return red * 0.30f + green * 0.59f + blue * 0.11f;
   }
 
   bool operator < (const Color& other) const