- sounds are on both channels
[supertux.git] / src / object / tilemap.cpp
index 7dd4bb8..0adbb86 100644 (file)
@@ -192,8 +192,10 @@ TileMap::draw(DrawingContext& context)
   if (current_alpha == 0.0) return;
 
   context.push_transform();
-  context.push_target();
-  context.set_target(draw_target);
+  if(draw_target != DrawingContext::NORMAL) {
+    context.push_target();
+    context.set_target(draw_target);
+  }
 
   if(drawing_effect != 0) context.set_drawing_effect(drawing_effect);
   if(current_alpha != 1.0) context.set_alpha(current_alpha);
@@ -216,14 +218,16 @@ TileMap::draw(DrawingContext& context)
   int tx, ty;
   for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) {
     for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) {
-      if ((tx < 0) || (ty < 0)) continue;
+      if ((tx < 0) || (ty < 0) || (tiles[ty*width + tx] == 0)) continue;
       const Tile* tile = tileset->get(tiles[ty*width + tx]);
       assert(tile != 0);
       tile->draw(context, pos, z_pos);
     }
   }
 
-  context.pop_target();
+  if(draw_target != DrawingContext::NORMAL) {
+    context.pop_target();
+  }
   context.pop_transform();
 }
 
@@ -252,7 +256,7 @@ void
 TileMap::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  Scripting::TileMap* interface = new Scripting::TileMap(this);
+  scripting::TileMap* interface = new scripting::TileMap(this);
   expose_object(vm, table_idx, interface, name, true);
 }
 
@@ -260,7 +264,7 @@ void
 TileMap::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  Scripting::unexpose_object(vm, table_idx, name);
+  scripting::unexpose_object(vm, table_idx, name);
 }
 
 void
@@ -401,7 +405,6 @@ TileMap::get_alpha()
 {
   return this->current_alpha;
 }
-  
-IMPLEMENT_FACTORY(TileMap, "tilemap");
 
 /* EOF */