pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2765 - branches/pingus_sdl/src


From: jsalmon3
Subject: [Pingus-CVS] r2765 - branches/pingus_sdl/src
Date: Fri, 20 Jul 2007 07:39:49 +0200

Author: jsalmon3
Date: 2007-07-20 07:39:41 +0200 (Fri, 20 Jul 2007)
New Revision: 2765

Modified:
   branches/pingus_sdl/src/col_map.cpp
   branches/pingus_sdl/src/collision_mask.cpp
   branches/pingus_sdl/src/collision_mask.hpp
Log:
Fixed collision map bug using width instead of pitch

Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-07-19 16:27:27 UTC (rev 2764)
+++ branches/pingus_sdl/src/col_map.cpp 2007-07-20 05:39:41 UTC (rev 2765)
@@ -82,6 +82,7 @@
        ++serial;
 
        int swidth  = mask.get_width();
+       int spitch  = mask.get_pitch();
        int sheight = mask.get_height();
        int y_offset = -y;
        int x_offset = -x;
@@ -113,7 +114,7 @@
                {
                        for (int i = x_offset; i < swidth && (i+x) < width; ++i)
                        {
-                               if (buffer[i + (swidth*line)])
+                               if (buffer[i + (spitch*line)])
                                {
                                        if (colmap[i + (width*(line+y) + x)] != 
Groundtype::GP_SOLID)
                                                colmap[i + (width*(line+y) + 
x)] = Groundtype::GP_NOTHING;
@@ -265,31 +266,59 @@
       switch(colmap[i])
        {
        case Groundtype::GP_NOTHING:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
          buffer[i * 4 + 0] = 0;
          buffer[i * 4 + 1] = 0;
          buffer[i * 4 + 2] = 0;
          buffer[i * 4 + 3] = 0;
+#else
+         buffer[i * 4 + 3] = 0;
+         buffer[i * 4 + 2] = 0;
+         buffer[i * 4 + 1] = 0;
+         buffer[i * 4 + 30] = 0;
+#endif
          break;
 
        case Groundtype::GP_SOLID:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
          buffer[i * 4 + 0] = 255;
          buffer[i * 4 + 1] = 100;
          buffer[i * 4 + 2] = 100;
          buffer[i * 4 + 3] = 100;
+#else
+         buffer[i * 4 + 3] = 255;
+         buffer[i * 4 + 2] = 100;
+         buffer[i * 4 + 1] = 100;
+         buffer[i * 4 + 30] = 100;
+#endif
          break;
 
        case Groundtype::GP_BRIDGE:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
          buffer[i * 4 + 0] = 255;
          buffer[i * 4 + 1] = 0;
          buffer[i * 4 + 2] = 0;
          buffer[i * 4 + 3] = 200;
+#else
+         buffer[i * 4 + 3] = 255;
+         buffer[i * 4 + 2] = 0;
+         buffer[i * 4 + 1] = 0;
+         buffer[i * 4 + 0] = 200;
+#endif
          break;
 
        default:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
          buffer[i * 4 + 0] = 255;
          buffer[i * 4 + 1] = 200;
          buffer[i * 4 + 2] = 200;
          buffer[i * 4 + 3] = 200;
+#else
+         buffer[i * 4 + 3] = 255;
+         buffer[i * 4 + 2] = 200;
+         buffer[i * 4 + 1] = 200;
+         buffer[i * 4 + 0] = 200;
+#endif
          break;
        }
     }

Modified: branches/pingus_sdl/src/collision_mask.cpp
===================================================================
--- branches/pingus_sdl/src/collision_mask.cpp  2007-07-19 16:27:27 UTC (rev 
2764)
+++ branches/pingus_sdl/src/collision_mask.cpp  2007-07-20 05:39:41 UTC (rev 
2765)
@@ -87,6 +87,12 @@
   return height;
 }
 
+int
+CollisionMask::get_pitch() const
+{
+  return pixelbuffer.get_surface()->pitch;
+}
+
 PixelBuffer
 CollisionMask::get_pixelbuffer() const
 {

Modified: branches/pingus_sdl/src/collision_mask.hpp
===================================================================
--- branches/pingus_sdl/src/collision_mask.hpp  2007-07-19 16:27:27 UTC (rev 
2764)
+++ branches/pingus_sdl/src/collision_mask.hpp  2007-07-20 05:39:41 UTC (rev 
2765)
@@ -45,6 +45,7 @@
   
   int get_width() const;
   int get_height() const;
+  int get_pitch() const;
   
   PixelBuffer get_pixelbuffer() const;
   uint8_t* get_data() const;





reply via email to

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