Skip to content

Commit

Permalink
Prevent Tux from climbing while swimming (#3017)
Browse files Browse the repository at this point in the history
Climbable did not check if Tux is swimming and thus affects Tux's velocity. A check for is_swimming() is added to prevent this.

Fixes #2981
  • Loading branch information
Brockengespenst authored Aug 30, 2024
1 parent 3577d25 commit d0b492a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/trigger/climbable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void
Climbable::event(Player& player, EventType type)
{
if (type == EVENT_ACTIVATE || (type == EVENT_TOUCH && player.get_controller().hold(Control::UP))) {
if (player.get_grabbed_object() == nullptr){
if (player.get_grabbed_object() == nullptr && !player.is_swimming()){
auto it = std::find_if(trying_to_climb.begin(), trying_to_climb.end(),
[&player](const ClimbPlayer& element)
{
Expand Down Expand Up @@ -161,6 +161,7 @@ Climbable::event(Player& player, EventType type)
bool
Climbable::may_climb(const Player& player) const
{
if (player.is_swimming()) return false;
if (player.get_bbox().get_left() < m_col.m_bbox.get_left() - GRACE_DX) return false;
if (player.get_bbox().get_right() > m_col.m_bbox.get_right() + GRACE_DX) return false;
if (player.get_bbox().get_top() < m_col.m_bbox.get_top() - GRACE_DY) return false;
Expand Down

0 comments on commit d0b492a

Please sign in to comment.