pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2878 - in branches/pingus_sdl: . src


From: jsalmon3
Subject: [Pingus-CVS] r2878 - in branches/pingus_sdl: . src
Date: Mon, 13 Aug 2007 04:13:28 +0200

Author: jsalmon3
Date: 2007-08-13 04:13:21 +0200 (Mon, 13 Aug 2007)
New Revision: 2878

Modified:
   branches/pingus_sdl/TODO
   branches/pingus_sdl/src/col_map.cpp
   branches/pingus_sdl/src/ground_map.cpp
Log:
Cleaned up ColMap::remove



Modified: branches/pingus_sdl/TODO
===================================================================
--- branches/pingus_sdl/TODO    2007-08-13 00:57:56 UTC (rev 2877)
+++ branches/pingus_sdl/TODO    2007-08-13 02:13:21 UTC (rev 2878)
@@ -58,9 +58,6 @@
 
 - update INSTALL.* file
 
-- data/levels/tutorial/snow9-grumbel.scm, at the right corner there is
-  something wrong (hole in a surface), also see colmap which doesn't look 
correct either
-
 - fallen snow looks to blueish
 
 - remove all the remaining unneeded debuging std::cout's

Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-08-13 00:57:56 UTC (rev 2877)
+++ branches/pingus_sdl/src/col_map.cpp 2007-08-13 02:13:21 UTC (rev 2878)
@@ -25,6 +25,7 @@
 #include "collision_mask.hpp"
 #include "pixel_buffer.hpp"
 #include "pingus_error.hpp"
+#include "math.hpp"
 #include "gettext.h"
 #include "sprite.hpp"
 
@@ -82,55 +83,26 @@
 void
 ColMap::remove(const CollisionMask& mask, int x, int y)
 {
-       ++serial;
+  ++serial;
 
-       int swidth  = mask.get_width();
-       int spitch  = mask.get_pitch();
-       int sheight = mask.get_height();
-       int y_offset = -y;
-       int x_offset = -x;
-       if (y_offset < 0) y_offset = 0;
-       if (x_offset < 0) x_offset = 0;
+  int swidth  = mask.get_width();
+  int spitch  = mask.get_pitch();
+  int sheight = mask.get_height();
+  int y_offset = Math::max(-y, 0);
+  int x_offset = Math::max(-x, 0);
+  uint8_t* buffer = mask.get_data();
 
-       mask.get_pixelbuffer().lock();
-
-       if (mask.get_pixelbuffer().get_surface()->format->BitsPerPixel == 32)
-       {
-               for(int line = y_offset; line < sheight && (line + y) < height; 
++line)
-               {
-                       for (int i = x_offset; i < swidth && (i+x) < width; ++i)
-                       {
-                               if (mask.get_pixelbuffer().get_pixel(i, line).a 
!= 0)
-                               {
-                                       if (colmap[i + (width*(line+y) + x)] != 
Groundtype::GP_SOLID)
-                                               colmap[i + (width*(line+y) + 
x)] = Groundtype::GP_NOTHING;
-                               }
-                       }
-               }
-       }
-       else if (mask.get_pixelbuffer().get_surface()->format->BitsPerPixel == 
8)
-       {
-               unsigned char* buffer;
-               buffer = static_cast<unsigned 
char*>(mask.get_pixelbuffer().get_data());
-
-               for(int line = y_offset; line < sheight && (line + y) < height; 
++line)
-               {
-                       for (int i = x_offset; i < swidth && (i+x) < width; ++i)
-                       {
-                               if (buffer[i + (spitch*line)])
-                               {
-                                       if (colmap[i + (width*(line+y) + x)] != 
Groundtype::GP_SOLID)
-                                               colmap[i + (width*(line+y) + 
x)] = Groundtype::GP_NOTHING;
-                               }
-                       }
-               }
-       }
-       else
-       {
-               PingusError::raise("ColMap::remove() - image format not 
supported");
-       }
-
-       mask.get_pixelbuffer().unlock();
+  for (int line = y_offset; line < sheight && (line + y) < height; ++line)
+    {
+      for (int i = x_offset; i < swidth && (i+x) < width; ++i)
+        {
+          if (buffer[i + (spitch*line)])
+            {
+              if (colmap[i + (width*(line+y) + x)] != Groundtype::GP_SOLID)
+                colmap[i + (width*(line+y) + x)] = Groundtype::GP_NOTHING;
+            }
+        }
+    }
 }
 
 void
@@ -146,7 +118,7 @@
   else
     {
       if (verbose > 2)
-       std::cout << "ColMap: remove: Out of map" << std::endl;
+        std::cout << "ColMap: remove: Out of map" << std::endl;
     }
 }
 

Modified: branches/pingus_sdl/src/ground_map.cpp
===================================================================
--- branches/pingus_sdl/src/ground_map.cpp      2007-08-13 00:57:56 UTC (rev 
2877)
+++ branches/pingus_sdl/src/ground_map.cpp      2007-08-13 02:13:21 UTC (rev 
2878)
@@ -195,9 +195,6 @@
                                      + 
sprovider.get_surface()->format->BitsPerPixel));
     }
 
-  provider.lock();
-  sprovider.lock();
-
   int swidth  = sprovider.get_width();
   int twidth  = provider.get_width();
 
@@ -213,6 +210,9 @@
   if (end_x - start_x <= 0 || end_y - start_y <= 0)
     return;
 
+  provider.lock();
+  sprovider.lock();
+
   Uint8* target_buf = static_cast<Uint8*>(provider.get_data());
   Uint8* source_buf = static_cast<Uint8*>(sprovider.get_data());
 





reply via email to

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