Fixed wrong "top-edge" tiles in data/levels/bonus2/level11.stl ("The long cave")
[supertux.git] / src / worldmap / tux.cpp
index 40c1327..7f5c50a 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: worldmap.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//  $Id$
 //
 //  SuperTux -  A Jump'n Run
 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
@@ -170,7 +170,7 @@ Tux::tryContinueWalking(float elapsed_time)
   SpriteChange* sprite_change = worldmap->at_sprite_change(tile_pos);
   if(sprite_change != NULL) {
     sprite.reset(new Sprite( *(sprite_change->sprite.get()) ));
-    sprite_change->in_stay_action = false;
+    sprite_change->clear_stay_action();
   }
 
   // if this is a special_tile with passive_message, display it
@@ -199,11 +199,15 @@ Tux::tryContinueWalking(float elapsed_time)
     }
   }
 
-  // stop if we reached a level, a WORLDMAP_STOP tile or a special tile without a passive_message
+  // check if we are at a Teleporter
+  Teleporter* teleporter = worldmap->at_teleporter(tile_pos);
+
+  // stop if we reached a level, a WORLDMAP_STOP tile, a teleporter or a special tile without a passive_message
   if ((worldmap->at_level())
       || (worldmap->at(tile_pos)->getData() & Tile::WORLDMAP_STOP)
       || (special_tile && !special_tile->passive_message
-                       && special_tile->script == "")) {
+                       && special_tile->script == "")
+      || (teleporter)) {
     if(special_tile && !special_tile->map_message.empty()
         && !special_tile->passive_message)
       worldmap->passive_message_timer.start(0);
@@ -255,12 +259,12 @@ Tux::tryContinueWalking(float elapsed_time)
   SpriteChange* next_sprite = worldmap->at_sprite_change(next_tile);
   if(next_sprite != NULL && next_sprite->change_on_touch) {
     sprite.reset(new Sprite( *(next_sprite->sprite.get()) ));
-    next_sprite->in_stay_action = false;
+    next_sprite->clear_stay_action();
   }
   SpriteChange* last_sprite = worldmap->at_sprite_change(tile_pos);
   if(last_sprite != NULL && next_sprite != NULL) {
     log_debug << "Old: " << tile_pos << " New: " << next_tile << std::endl;
-    last_sprite->in_stay_action = true;
+    last_sprite->set_stay_action();
   }
 
   tile_pos = next_tile;
@@ -289,4 +293,15 @@ Tux::update(float elapsed_time)
     tryStartWalking();
 }
 
+void
+Tux::setup()
+{
+  // check if we already touch a SpriteChange object
+  SpriteChange* sprite_change = worldmap->at_sprite_change(tile_pos);
+  if(sprite_change != NULL) {
+    sprite.reset(new Sprite( *(sprite_change->sprite.get()) ));
+    sprite_change->clear_stay_action();
+  }
+}
+
 }