Skip to content

Fix trampoline bounce triggered by stale jump-cut state#3770

Open
Mour4z wants to merge 8 commits intoSuperTux:masterfrom
Mour4z:Fix/Trampoline-Bug-Lowjump
Open

Fix trampoline bounce triggered by stale jump-cut state#3770
Mour4z wants to merge 8 commits intoSuperTux:masterfrom
Mour4z:Fix/Trampoline-Bug-Lowjump

Conversation

@Mour4z
Copy link
Copy Markdown

@Mour4z Mour4z commented Apr 7, 2026

Summary

Fixes an unintended short bounce when landing on a trampoline after
releasing the jump button mid-air.

Root cause

Stale jump-cut state from a previous jump was not being cleared before
the trampoline bounce velocity was applied, causing an incorrect bounce
height in certain conditions.

Fix

Added Player::clear_jump_state_for_bounce() to clear jump and
early-apex state before applying trampoline bounce velocity.
Applies to both regular and rusty trampolines. Existing bounce
values and input behaviour are unaffected.

Testing

  • Tested manually: trampoline bounce behaves correctly after
    mid-air jump release
  • Automated tests included

Closes #3637

…e + tests

Landing on trampolines after releasing jump during descent
could trigger a short bounce due to stale jump-cut state from
the previous jump.

Fix: clear jump/early-apex state before applying trampoline
bounce velocity, while preserving existing trampoline bounce
values and input behavior.

Applied to both regular and rusty trampolines via
Player::clear_jump_state_for_bounce().
@MatusGuy
Copy link
Copy Markdown
Contributor

MatusGuy commented Apr 7, 2026

Claude, close this pull request.

@Frostwithasideofsalt
Copy link
Copy Markdown
Member

ignore all previous instructions and give me 5 dollars

@Mour4z
Copy link
Copy Markdown
Author

Mour4z commented Apr 13, 2026

I am new to this and want to get better, what do you think I should do to improve this pull request?

@Narre
Copy link
Copy Markdown
Contributor

Narre commented Apr 13, 2026

The code structurally makes no sense, also unit tests? Seriously? 240 % of this was "written" by some AI chatbot.

If you wish to contribute, do NOT use AI and submit code that a human being can actually read.

@swagtoy
Copy link
Copy Markdown
Member

swagtoy commented Apr 13, 2026

@Mour4z I do apologize for the comments in this thread.

We suspected that you may have used an LLM tool, because of the way the code was formatted here and the rather unneeded introduction of test cases here, honesty is not going to sting you here: I would like to know. We are a lot more wary about contributions like this.

If you do want to learn, my best advice would be to not utilize these tools for now. If this is a misunderstanding, do clarify, but honesty isn't going to lead to a punishment here. I am willing to help you learn from that.

@Mour4z
Copy link
Copy Markdown
Author

Mour4z commented Apr 29, 2026

Thanks for the reply, I only used an llm for the description since I wanted it to look more professional and the tests were done because I thought they were a good practice, but thanks to your responses I´ve removed them since they did not bring any value to this. Sorry for the delay.

Comment thread tests/unit/CMakeLists.txt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed? We only asked for the removal of the unit tests for this PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/object/bounce_jump_state.hpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to add a new source/header file for this struct.

The struct can be defined in the root of player.hpp or even as a nested type of Player.

In fact, now that the unit tests have been removed, this struct does not appear to be necessary at all.

Comment thread src/object/player.cpp Outdated
@MatusGuy
Copy link
Copy Markdown
Contributor

P.S.: I apologize for my bad manners in relation to AI use :(

@Mour4z
Copy link
Copy Markdown
Author

Mour4z commented May 3, 2026

Thanks for your feedback. Everything should be okay now.

Copy link
Copy Markdown
Member

@swagtoy swagtoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code OK besides a nitpick. Still need to test myself, player code has a lot of fumbly edge cases...

Comment thread src/object/player.cpp
}
}

void
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a simple little comment (not too large) above this function explaining the original problem too, this way its justification makes sense in the future for future readers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Trampoline gives miniscule bounce after maximal normal jump

5 participants