pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r4029 - in trunk/pingus/src: actions editor pingus util


From: grumbel at BerliOS
Subject: [Pingus-CVS] r4029 - in trunk/pingus/src: actions editor pingus util
Date: Thu, 5 Nov 2009 03:45:18 +0100

Author: grumbel
Date: 2009-11-05 03:45:14 +0100 (Thu, 05 Nov 2009)
New Revision: 4029

Modified:
   trunk/pingus/src/actions/angel.cpp
   trunk/pingus/src/actions/boarder.cpp
   trunk/pingus/src/editor/level_objs.cpp
   trunk/pingus/src/pingus/credits.cpp
   trunk/pingus/src/pingus/story_screen.cpp
   trunk/pingus/src/pingus/surface.cpp
   trunk/pingus/src/util/debug_stream.cpp
   trunk/pingus/src/util/string_util.cpp
   trunk/pingus/src/util/utf8.cpp
Log:
Some -Wconversion cleanups


Modified: trunk/pingus/src/actions/angel.cpp
===================================================================
--- trunk/pingus/src/actions/angel.cpp  2009-11-05 02:23:50 UTC (rev 4028)
+++ trunk/pingus/src/actions/angel.cpp  2009-11-05 02:45:14 UTC (rev 4029)
@@ -35,7 +35,7 @@
 {
   sprite.update ();
 
-  counter += game_speed;
+  counter += static_cast<float>(game_speed);
   pingu->set_pos(x_pos + 20 * Math::sin(counter * 3.0f), pingu->get_y() - 
50.0f * 0.025f);
 
   // Out of screen, let the pingu die

Modified: trunk/pingus/src/actions/boarder.cpp
===================================================================
--- trunk/pingus/src/actions/boarder.cpp        2009-11-05 02:23:50 UTC (rev 
4028)
+++ trunk/pingus/src/actions/boarder.cpp        2009-11-05 02:45:14 UTC (rev 
4029)
@@ -40,10 +40,10 @@
 
   if (on_ground())
   {
-    if (speed < 15.0)
-      speed += 15.0 * 25.0f/1000.0f;
+    if (speed < 15.0f)
+      speed += 15.0f * 25.0f/1000.0f;
     else {
-      speed = 15.0;
+      speed = 15.0f;
     }
 
     // Incremental update so that we don't skip pixels

Modified: trunk/pingus/src/editor/level_objs.cpp
===================================================================
--- trunk/pingus/src/editor/level_objs.cpp      2009-11-05 02:23:50 UTC (rev 
4028)
+++ trunk/pingus/src/editor/level_objs.cpp      2009-11-05 02:45:14 UTC (rev 
4029)
@@ -138,7 +138,9 @@
     if (attribs & HAS_REPEAT)
     {
       for(int x = int(pos.x); x < pos.x + sprite.get_width()*repeat; x += 
sprite.get_width())
+      {
         gc.draw(sprite, Vector3f(static_cast<float>(x), pos.y, pos.z));
+      }
     }
 #if 0
     else if(attribs & HAS_STRETCH)

Modified: trunk/pingus/src/pingus/credits.cpp
===================================================================
--- trunk/pingus/src/pingus/credits.cpp 2009-11-05 02:23:50 UTC (rev 4028)
+++ trunk/pingus/src/pingus/credits.cpp 2009-11-05 02:45:14 UTC (rev 4029)
@@ -225,10 +225,10 @@
     switch ((*i)[0])
     {
       case '-':
-        end_offset += font.get_height() + 5;
+        end_offset += static_cast<float>(font.get_height() + 5);
         break;
       case '_':
-        end_offset += font_small.get_height() + 5;
+        end_offset += static_cast<float>(font_small.get_height() + 5);
         break;
       case 'n':
         end_offset += 50;

Modified: trunk/pingus/src/pingus/story_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/story_screen.cpp    2009-11-05 02:23:50 UTC (rev 
4028)
+++ trunk/pingus/src/pingus/story_screen.cpp    2009-11-05 02:45:14 UTC (rev 
4029)
@@ -116,9 +116,13 @@
     gc.print_right(Fonts::chalk_small, Vector2i(x_pos, y_pos), _("skip"));
   }
 
-  bool is_at(int x, int y) {
-         return x > x_pos - Fonts::chalk_small.get_width(_("skip")) && x < 
x_pos
-               && y > y_pos && y < y_pos + Fonts::chalk_small.get_height();
+  bool is_at(int x, int y) 
+  {
+    return
+      x > x_pos - Fonts::chalk_small.get_width(_("skip")) && 
+      x < x_pos &&
+      y > y_pos &&
+      y < y_pos + Fonts::chalk_small.get_height();
   }
 
   void on_pointer_enter()

Modified: trunk/pingus/src/pingus/surface.cpp
===================================================================
--- trunk/pingus/src/pingus/surface.cpp 2009-11-05 02:23:50 UTC (rev 4028)
+++ trunk/pingus/src/pingus/surface.cpp 2009-11-05 02:45:14 UTC (rev 4029)
@@ -120,8 +120,8 @@
     {
       SDL_Rect dstrect;
 
-      dstrect.x = x;
-      dstrect.y = y;
+      dstrect.x = static_cast<Sint16>(x);
+      dstrect.y = static_cast<Sint16>(y);
 
       SDL_BlitSurface(src.get_surface(), NULL, get_surface(), &dstrect);
     }
@@ -289,8 +289,8 @@
   new_surface = Blitter::create_surface_from_format(impl->surface,
                                                     rect.get_width(), 
rect.get_height());
   SDL_Rect dst_rect;
-  dst_rect.x = rect.left;
-  dst_rect.y = rect.top;
+  dst_rect.x = static_cast<Sint16>(rect.left);
+  dst_rect.y = static_cast<Sint16>(rect.top);
 
   if (impl->surface->format->palette)
     SDL_SetPalette(new_surface, SDL_LOGPAL, 
impl->surface->format->palette->colors, 

Modified: trunk/pingus/src/util/debug_stream.cpp
===================================================================
--- trunk/pingus/src/util/debug_stream.cpp      2009-11-05 02:23:50 UTC (rev 
4028)
+++ trunk/pingus/src/util/debug_stream.cpp      2009-11-05 02:45:14 UTC (rev 
4029)
@@ -54,7 +54,7 @@
          str = "";
        }
     }
-  str += c;
+  str += static_cast<char>(c);
   put_line (str);
 
   setp (char_buffer, char_buffer + buffersize - 1);

Modified: trunk/pingus/src/util/string_util.cpp
===================================================================
--- trunk/pingus/src/util/string_util.cpp       2009-11-05 02:23:50 UTC (rev 
4028)
+++ trunk/pingus/src/util/string_util.cpp       2009-11-05 02:45:14 UTC (rev 
4029)
@@ -27,14 +27,14 @@
        i != lower_impl.end();
        ++i )
     {
-      *i = tolower(*i);
+      *i = static_cast<char>(tolower(*i));
     }
 
   return lower_impl;
 }
 
 std::string
-StringUtil::to_upper(const std::string &str)
+StringUtil::to_upper(const std::string& str)
 {
   std::string upper_impl = str;
 
@@ -42,7 +42,7 @@
        i != upper_impl.end();
        ++i )
     {
-      *i = toupper(*i);
+      *i = static_cast<char>(toupper(*i));
     }
 
   return upper_impl;

Modified: trunk/pingus/src/util/utf8.cpp
===================================================================
--- trunk/pingus/src/util/utf8.cpp      2009-11-05 02:23:50 UTC (rev 4028)
+++ trunk/pingus/src/util/utf8.cpp      2009-11-05 02:45:14 UTC (rev 4029)
@@ -128,9 +128,9 @@
 uint32_t
 UTF8::decode_utf8(const std::string& text, size_t& p)
 {
-  uint32_t c1 = (unsigned char) text[p+0];
+  uint32_t c1 = static_cast<uint32_t>(text[p+0]);
 
-  if (has_multibyte_mark(c1)) 
+  if (has_multibyte_mark(c1))
     {
       throw std::runtime_error("Malformed utf-8 sequence");
     }
@@ -145,7 +145,7 @@
     {
       // 110x.xxxx: 2 byte sequence
       if(p+1 >= text.size()) throw std::range_error("Malformed utf-8 
sequence");
-      uint32_t c2 = (unsigned char) text[p+1];
+      uint32_t c2 = static_cast<uint32_t>(text[p+1]);
       if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8 
sequence");
       p+=2;
 
@@ -155,8 +155,8 @@
     {
       // 1110.xxxx: 3 byte sequence
       if(p+2 >= text.size()) throw std::range_error("Malformed utf-8 
sequence");
-      uint32_t c2 = (unsigned char) text[p+1];
-      uint32_t c3 = (unsigned char) text[p+2];
+      uint32_t c2 = static_cast<uint32_t>(text[p+1]);
+      uint32_t c3 = static_cast<uint32_t>(text[p+2]);
       if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8 
sequence");
       if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8 
sequence");
       p+=3;
@@ -167,9 +167,9 @@
     {
       // 1111.0xxx: 4 byte sequence
       if(p+3 >= text.size()) throw std::range_error("Malformed utf-8 
sequence");
-      uint32_t c2 = (unsigned char) text[p+1];
-      uint32_t c3 = (unsigned char) text[p+2];
-      uint32_t c4 = (unsigned char) text[p+4];
+      uint32_t c2 = static_cast<uint32_t>(text[p+1]);
+      uint32_t c3 = static_cast<uint32_t>(text[p+2]);
+      uint32_t c4 = static_cast<uint32_t>(text[p+4]);
       if (!has_multibyte_mark(c2)) throw std::runtime_error("Malformed utf-8 
sequence");
       if (!has_multibyte_mark(c3)) throw std::runtime_error("Malformed utf-8 
sequence");
       if (!has_multibyte_mark(c4)) throw std::runtime_error("Malformed utf-8 
sequence");





reply via email to

[Prev in Thread] Current Thread [Next in Thread]