pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r2769 - branches/pingus_sdl/src
Date: Thu, 2 Aug 2007 04:24:59 +0200

Author: grumbel
Date: 2007-08-02 04:24:58 +0200 (Thu, 02 Aug 2007)
New Revision: 2769

Modified:
   branches/pingus_sdl/src/col_map.cpp
   branches/pingus_sdl/src/collision_mask.cpp
Log:
- fixed the colmap blitting (pitch != width issue)

Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-08-02 01:57:45 UTC (rev 2768)
+++ branches/pingus_sdl/src/col_map.cpp 2007-08-02 02:24:58 UTC (rev 2769)
@@ -133,7 +133,7 @@
 void
 ColMap::put(int x, int y, Groundtype::GPType p)
 {
-  ++serial;
+  ++serial; // FIXME: Shouldn't be here but at a more heigher level function
 
   if (x > 0 && x < width
       && y > 0 && y < height)
@@ -181,8 +181,8 @@
     }
 
   uint8_t* source = mask.get_data();
-  for (int y=0; y < mask.get_height(); ++y)
-    for (int x=0; x < mask.get_width(); ++x)
+  for (int y = 0; y < mask.get_height(); ++y)
+    for (int x = 0; x < mask.get_width(); ++x)
       {
         if (source[y * mask.get_width() + x])
           if (blit_allowed(x + sur_x, y + sur_y, pixel))

Modified: branches/pingus_sdl/src/collision_mask.cpp
===================================================================
--- branches/pingus_sdl/src/collision_mask.cpp  2007-08-02 01:57:45 UTC (rev 
2768)
+++ branches/pingus_sdl/src/collision_mask.cpp  2007-08-02 02:24:58 UTC (rev 
2769)
@@ -41,24 +41,23 @@
   pixelbuffer = Resource::load_pixelbuffer(name);
   //PixelBuffer cmap = pixelbuffer; // 
Resource::load_pixelbuffer(System::cut_ext(name) + "_cmap");
 
-  width  = pixelbuffer.get_width();
-  height = pixelbuffer.get_height();
-  
-  buffer = new uint8_t[width * height];
-
   SDL_Surface* surface = pixelbuffer.get_surface();
   SDL_LockSurface(surface);
 
-  if (surface->format->BytesPerPixel == 1)
+  width  = surface->w;
+  height = surface->h;
+  buffer = new uint8_t[width * height];
+
+  if (surface->format->palette)
     {
       uint8_t* source = static_cast<uint8_t*>(surface->pixels);
       for(int y = 0; y < height; ++y)
         for(int x = 0; x < width; ++x)
           {
-            if (source[y * width + x] == surface->format->colorkey)
-              buffer[y * width + x] = 0;
+            if (source[y*surface->pitch+x] == surface->format->colorkey)
+              buffer[y*width + x] = 0;
             else
-              buffer[y * width + x] = 1;
+              buffer[y*width + x] = 1;
           }
     }
   else





reply via email to

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