[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2865 - in branches/pingus_sdl: . src src/components
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2865 - in branches/pingus_sdl: . src src/components |
Date: |
Sun, 12 Aug 2007 18:54:06 +0200 |
Author: grumbel
Date: 2007-08-12 18:54:00 +0200 (Sun, 12 Aug 2007)
New Revision: 2865
Modified:
branches/pingus_sdl/TODO
branches/pingus_sdl/src/col_map.cpp
branches/pingus_sdl/src/col_map.hpp
branches/pingus_sdl/src/components/smallmap.cpp
branches/pingus_sdl/src/smallmap_image.cpp
Log:
- fixed off-by-one in colmap
Modified: branches/pingus_sdl/TODO
===================================================================
--- branches/pingus_sdl/TODO 2007-08-12 16:20:47 UTC (rev 2864)
+++ branches/pingus_sdl/TODO 2007-08-12 16:54:00 UTC (rev 2865)
@@ -42,9 +42,10 @@
- walker speed looks wrong, other actions might need fine tuning as well
-- in old levels the exits float high up in the air
+- in old levels the exits float high up in the air (conversion likely wrong)
-- one pixel border at top/left of smallmap
+- german translation has font align issue when not completling a level
successfully:
+http://pingus.seul.org/~grumbel/tmp/pingus-20070812-184308-1.png
- climber align in the actionbutton looks wrong
Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-08-12 16:20:47 UTC (rev 2864)
+++ branches/pingus_sdl/src/col_map.cpp 2007-08-12 16:54:00 UTC (rev 2865)
@@ -28,9 +28,6 @@
#include "gettext.h"
#include "sprite.hpp"
-#define COLMAP_WITH_MEMORY_HOLE 1
-
-
// Obtain the colmap from a memory area
ColMap::ColMap(int w, int h)
: serial(0),
@@ -58,6 +55,12 @@
}
}
+int
+ColMap::getpixel_fast(int x, int y)
+{
+ return colmap[x+y*width];
+}
+
unsigned char*
ColMap::get_data()
{
@@ -135,8 +138,8 @@
{
++serial; // FIXME: Shouldn't be here but at a more heigher level function
- if (x > 0 && x < width
- && y > 0 && y < height)
+ if (x >= 0 && x < width
+ && y >= 0 && y < height)
{
colmap[x+y*width] = p;
}
@@ -180,6 +183,7 @@
return;
}
+ // FIXME: This could be speed up quite a bit
uint8_t* source = mask.get_data();
for (int y = 0; y < mask.get_height(); ++y)
for (int x = 0; x < mask.get_width(); ++x)
@@ -273,5 +277,4 @@
return serial;
}
-
/* EOF */
Modified: branches/pingus_sdl/src/col_map.hpp
===================================================================
--- branches/pingus_sdl/src/col_map.hpp 2007-08-12 16:20:47 UTC (rev 2864)
+++ branches/pingus_sdl/src/col_map.hpp 2007-08-12 16:54:00 UTC (rev 2865)
@@ -68,6 +68,9 @@
int getpixel(int x, int y);
+ /** Same as getpixel() but without the range check */
+ int getpixel_fast(int x, int y);
+
/** @return a number which represents the state of the collision
map, once it changes the serial changes also */
unsigned get_serial();
Modified: branches/pingus_sdl/src/components/smallmap.cpp
===================================================================
--- branches/pingus_sdl/src/components/smallmap.cpp 2007-08-12 16:20:47 UTC
(rev 2864)
+++ branches/pingus_sdl/src/components/smallmap.cpp 2007-08-12 16:54:00 UTC
(rev 2865)
@@ -118,8 +118,8 @@
client->get_server()->get_world()->draw_smallmap(this);
+ // Draw Pingus
PinguHolder* pingus = world->get_pingus();
-
for(PinguIter i = pingus->begin(); i != pingus->end(); ++i)
{
int x = static_cast<int>(x_pos + ((*i)->get_x() * width /
world->get_width()));
Modified: branches/pingus_sdl/src/smallmap_image.cpp
===================================================================
--- branches/pingus_sdl/src/smallmap_image.cpp 2007-08-12 16:20:47 UTC (rev
2864)
+++ branches/pingus_sdl/src/smallmap_image.cpp 2007-08-12 16:54:00 UTC (rev
2865)
@@ -68,12 +68,9 @@
void
SmallMapImage::update_surface()
{
- unsigned char* buffer;
unsigned char* cbuffer;
- unsigned char current_pixel;
ColMap* colmap = server->get_world()->get_colmap();
- buffer = colmap->get_data();
colmap_serial = colmap->get_serial();
@@ -81,14 +78,15 @@
cbuffer = static_cast<unsigned char*>(canvas.get_data());
- int alpha = 255;
-
int cmap_width = colmap->get_width();
int cmap_height = colmap->get_height();
int width = canvas.get_width();
int height = canvas.get_height();
- int pitch = canvas.get_pitch();
+ int pitch = canvas.get_pitch();
+
+ assert(width < cmap_width && height < cmap_height);
+
for(int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
@@ -96,99 +94,65 @@
// Index on the smallmap canvas
int i = y * pitch + 4 * x;
- int tx = x * cmap_width / width;
- int ty = y * cmap_height / height;
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ const int red = 3;
+ const int green = 2;
+ const int blue = 1;
+ const int alpha = 0;
+#else
+ const int red = 0;
+ const int green = 1;
+ const int blue = 2;
+ const int alpha = 3;
+#endif
- current_pixel = buffer[tx + (ty * cmap_width)];
-
- switch (current_pixel)
+ switch (colmap->getpixel_fast(x * cmap_width / width,
+ y * cmap_height / height))
{
case Groundtype::GP_NOTHING:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = alpha;
- cbuffer[i + 1] = 0;
- cbuffer[i + 2] = 0;
- cbuffer[i + 3] = 0;
-#else
- cbuffer[i + 3] = alpha;
- cbuffer[i + 2] = 0;
- cbuffer[i + 1] = 0;
- cbuffer[i + 0] = 0;
-#endif
+ cbuffer[i + red] = 0;
+ cbuffer[i + green] = 0;
+ cbuffer[i + blue] = 0;
+ cbuffer[i + alpha] = 255;
break;
case Groundtype::GP_BRIDGE:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = 255;
- cbuffer[i + 1] = 100;
- cbuffer[i + 2] = 255;
- cbuffer[i + 3] = 0;
-#else
- cbuffer[i + 3] = 255;
- cbuffer[i + 2] = 100;
- cbuffer[i + 1] = 255;
- cbuffer[i + 0] = 0;
-#endif
+ cbuffer[i + red] = 0;
+ cbuffer[i + green] = 255;
+ cbuffer[i + blue] = 100;
+ cbuffer[i + alpha] = 255;
break;
case Groundtype::GP_WATER:
case Groundtype::GP_LAVA:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = 255;
- cbuffer[i + 1] = 200;
- cbuffer[i + 2] = 0;
- cbuffer[i + 3] = 0;
-#else
- cbuffer[i + 3] = 255;
- cbuffer[i + 2] = 200;
- cbuffer[i + 1] = 0;
- cbuffer[i + 0] = 0;
-#endif
+ cbuffer[i + red] = 0;
+ cbuffer[i + green] = 0;
+ cbuffer[i + blue] = 200;
+ cbuffer[i + alpha] = 255;
break;
#if 0
// FIXME: temporaty disabled for 0.6.0 release, since all
liquids are currently lava
case Groundtype::GP_LAVA:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = 255; // alpha
- cbuffer[i + 1] = 255; // blue
- cbuffer[i + 2] = 128; // green
- cbuffer[i + 3] = 128; // red
-#else
cbuffer[i + 3] = 255; // alpha
cbuffer[i + 2] = 255; // blue
cbuffer[i + 1] = 128; // green
cbuffer[i + 0] = 128; // red
-#endif
break;
#endif
case Groundtype::GP_SOLID:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = 255;
- cbuffer[i + 1] = 100;
- cbuffer[i + 2] = 100;
- cbuffer[i + 3] = 100;
-#else
- cbuffer[i + 3] = 255;
- cbuffer[i + 2] = 100;
- cbuffer[i + 1] = 100;
- cbuffer[i + 0] = 100;
-#endif
+ cbuffer[i + red] = 100;
+ cbuffer[i + green] = 100;
+ cbuffer[i + blue] = 100;
+ cbuffer[i + alpha] = 255;
break;
default:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- cbuffer[i + 0] = 255;
- cbuffer[i + 1] = 200;
- cbuffer[i + 2] = 200;
- cbuffer[i + 3] = 200;
-#else
- cbuffer[i + 3] = 255;
- cbuffer[i + 2] = 200;
- cbuffer[i + 1] = 200;
- cbuffer[i + 0] = 200;
-#endif
+ cbuffer[i + red] = 200;
+ cbuffer[i + green] = 200;
+ cbuffer[i + blue] = 200;
+ cbuffer[i + alpha] = 255;
break;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2865 - in branches/pingus_sdl: . src src/components,
grumbel at BerliOS <=