]> git.localhorst.tv Git - l2e.git/blobdiff - src/map/Area.cpp
added debug mode for maps
[l2e.git] / src / map / Area.cpp
index 292b8952f21ecca579aa4af9a18112e968e5810a..0b25a04bd7b512e9ca1f913856ff410f602b5667 100644 (file)
@@ -44,4 +44,49 @@ void Area::Render(SDL_Surface *dest, const graphics::Sprite *tileset, const Vect
        }
 }
 
+void Area::RenderDebug(SDL_Surface *dest, const graphics::Sprite *tileset, const Vector<int> &inOffset) const {
+       for (int i(0); i < numTiles; ++i) {
+               Vector<int> offset(
+                               inOffset.X() + (i % width) * tileset->Width(),
+                               inOffset.Y() + (i / width) * tileset->Height());
+               const Tile &tile(tiles[i]);
+
+               if (tile.BlocksNorth()) {
+                       SDL_Rect destRect;
+                       destRect.x = offset.X();
+                       destRect.y = offset.Y();
+                       destRect.w = tileset->Width();
+                       destRect.h = 1;
+                       SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+               }
+
+               if (tile.BlocksEast()) {
+                       SDL_Rect destRect;
+                       destRect.x = offset.X() + tileset->Width() - 1;
+                       destRect.y = offset.Y();
+                       destRect.w = 1;
+                       destRect.h = tileset->Height();
+                       SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+               }
+
+               if (tile.BlocksSouth()) {
+                       SDL_Rect destRect;
+                       destRect.x = offset.X();
+                       destRect.y = offset.Y() + tileset->Height() - 1;
+                       destRect.w = tileset->Width();
+                       destRect.h = 1;
+                       SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+               }
+
+               if (tile.BlocksWest()) {
+                       SDL_Rect destRect;
+                       destRect.x = offset.X();
+                       destRect.y = offset.Y();
+                       destRect.w = 1;
+                       destRect.h = tileset->Height();
+                       SDL_FillRect(dest, &destRect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00));
+               }
+       }
+}
+
 }