Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with unisolid tiles and frozen enemies #2933

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/badguy/bouncing_snowball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BouncingSnowball::active_update(float dt_sec)
Rectf side_look_box = get_bbox().grown(-1.f);
side_look_box.set_left(get_bbox().get_left() + (m_dir == Direction::LEFT ? -1.f : 1.f));
side_look_box.set_right(get_bbox().get_right() + (m_dir == Direction::LEFT ? -1.f : 1.f));
if (!Sector::get().is_free_of_statics(side_look_box))
if (!Sector::get().is_free_of_statics(side_look_box, nullptr, true))
{
m_dir = m_dir == Direction::LEFT ? Direction::RIGHT : Direction::LEFT;
set_action(m_dir);
Expand Down
4 changes: 2 additions & 2 deletions src/collision/collision_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,11 @@ CollisionSystem::is_free_of_statics(const Rectf& rect, const CollisionObject* ig
}

bool
CollisionSystem::is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const
CollisionSystem::is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignore_unisolid) const
{
using namespace collision;

if (!is_free_of_tiles(rect)) return false;
if (!is_free_of_tiles(rect, ignore_unisolid)) return false;

for (const auto& object : m_objects) {
if (object == ignore_object) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/collision/collision_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CollisionSystem final

bool is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid = false, uint32_t tiletype = Tile::SOLID) const;
bool is_free_of_statics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignoreUnisolid, uint32_t tiletype = Tile::SOLID) const;
bool is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const;
bool is_free_of_movingstatics(const Rectf& rect, const CollisionObject* ignore_object, const bool ignore_unisolid = false) const;
bool is_free_of_specifically_movingstatics(const Rectf& rect, const CollisionObject* ignore_object) const;

enum RaycastIgnore {
Expand Down
5 changes: 4 additions & 1 deletion src/object/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,7 @@ Player::do_standup(bool force_standup)
float new_height = m_swimming ? TUX_WIDTH : BIG_TUX_HEIGHT;
new_bbox.move(Vector(0, m_col.m_bbox.get_height() - new_height));
new_bbox.set_height(new_height);
if (!Sector::get().is_free_of_movingstatics(new_bbox, this) && !force_standup)
if (!Sector::get().is_free_of_movingstatics(new_bbox, this, true) && !force_standup)
{
m_crawl = true;
return;
Expand Down Expand Up @@ -2385,6 +2385,9 @@ Player::collision(MovingObject& other, const CollisionHit& hit)
return FORCE_MOVE;
if (m_stone)
return ABORT_MOVE;

if (hit.bottom && badguy->is_frozen())
m_on_ground_flag = true;
}

return CONTINUE;
Expand Down
2 changes: 1 addition & 1 deletion src/object/pushbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const std::string BUTTON_SOUND = "sounds/switch.ogg";
}

PushButton::PushButton(const ReaderMapping& mapping) :
StickyObject(mapping, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING),
StickyObject(mapping, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_STATIC),
m_script(),
m_state(OFF),
m_dir(Direction::UP)
Expand Down
5 changes: 3 additions & 2 deletions src/supertux/sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,11 @@ Sector::is_free_of_statics(float left, float top, float right, float bottom,
}

bool
Sector::is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object) const
Sector::is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object, bool ignore_unisolid) const
{
return m_collision_system->is_free_of_movingstatics(rect,
ignore_object ? ignore_object->get_collision_object() : nullptr);
ignore_object ? ignore_object->get_collision_object() : nullptr,
ignore_unisolid);
}

bool
Expand Down
3 changes: 2 additions & 1 deletion src/supertux/sector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class Sector final : public Base::Sector
1.) solid tiles and
2.) MovingObjects in COLGROUP_STATIC, COLGROUP_MOVINGSTATIC or COLGROUP_MOVING.
This includes badguys and players. */
bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = nullptr) const;
bool is_free_of_movingstatics(const Rectf& rect, const MovingObject* ignore_object = nullptr,
bool ignore_unisolid = false) const;
/**
* @scripting
* @description Checks if the specified sector-relative rectangle is free of both:
Expand Down
Loading