Allow Tux to unduck in unisolid tiles.
authorWolfgang Becker <uafr@gmx.de>
Sun, 28 Jan 2007 19:17:55 +0000 (19:17 +0000)
committerWolfgang Becker <uafr@gmx.de>
Sun, 28 Jan 2007 19:17:55 +0000 (19:17 +0000)
SVN-Revision: 4714

src/object/player.cpp
src/sector.cpp
src/sector.hpp

index bcde741..bec1102 100644 (file)
@@ -216,7 +216,7 @@ Player::adjust_height(float new_height)
   if(new_height > bbox.get_height()) {
     Rect additional_space = bbox2;
     additional_space.set_height(new_height - bbox.get_height());
-    if(!Sector::current()->is_free_of_statics(additional_space, this))
+    if(!Sector::current()->is_free_of_statics(additional_space, this, true))
       return false;
   }
 
index 3b3cbc8..79ad459 100644 (file)
@@ -1288,7 +1288,7 @@ Sector::handle_collisions()
 }
 
 bool
-Sector::is_free_of_tiles(const Rect& rect) const
+Sector::is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid) const
 {
   using namespace collision;
 
@@ -1313,7 +1313,8 @@ Sector::is_free_of_tiles(const Rect& rect) const
          Constraints constraints;
          return collision::rectangle_aatriangle(&constraints, rect, triangle);
        }
-       if(tile->getAttributes() & Tile::SOLID) return false;
+       if((tile->getAttributes() & Tile::SOLID) && !ignoreUnisolid) return false;
+       if((tile->getAttributes() & Tile::SOLID) && !(tile->getAttributes() & Tile::UNISOLID)) return false;
       }
     }
   }
@@ -1322,11 +1323,11 @@ Sector::is_free_of_tiles(const Rect& rect) const
 }
 
 bool
-Sector::is_free_of_statics(const Rect& rect, const MovingObject* ignore_object) const
+Sector::is_free_of_statics(const Rect& rect, const MovingObject* ignore_object, const bool ignoreUnisolid) const
 {
   using namespace collision;
 
-  if (!is_free_of_tiles(rect)) return false;
+  if (!is_free_of_tiles(rect, ignoreUnisolid)) return false;
 
   for(MovingObjects::const_iterator i = moving_objects.begin();
       i != moving_objects.end(); ++i) {
index 487f4a2..777ce93 100644 (file)
@@ -138,14 +138,14 @@ public:
    * Checks if the specified rectangle is free of (solid) tiles.
    * Note that this does not include static objects, e.g. bonus blocks.
    */
-  bool is_free_of_tiles(const Rect& rect) const;
+  bool is_free_of_tiles(const Rect& rect, const bool ignoreUnisolid = false) const;
   /**
    * Checks if the specified rectangle is free of both
    * 1.) solid tiles and
    * 2.) MovingObjects in COLGROUP_STATIC.
    * Note that this does not include badguys or players.
    */
-  bool is_free_of_statics(const Rect& rect, const MovingObject* ignore_object = 0) const;
+  bool is_free_of_statics(const Rect& rect, const MovingObject* ignore_object = 0, const bool ignoreUnisolid = false) const;
   /**
    * Checks if the specified rectangle is free of both
    * 1.) solid tiles and