Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Tux being permanently safe after mix of using door and scripting …
Browse files Browse the repository at this point in the history
…Tux safe

Splitted the flags for making Tux intentionally safe and avoiding the
blinking effect while Tux is safe after using a door.

Fixes #3186
Brockengespenst committed Jan 22, 2025
1 parent e43838b commit 49d73db
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/object/player.cpp
Original file line number Diff line number Diff line change
@@ -211,6 +211,7 @@ Player::Player(PlayerStatus& player_status, const std::string& name_, int player
m_skidding_timer(),
m_safe_timer(),
m_is_intentionally_safe(false),
m_avoid_blinking_while_safe(false),
m_kick_timer(),
m_buttjump_timer(),
m_dying_timer(),
@@ -2256,7 +2257,7 @@ Player::draw(DrawingContext& context)
Vector draw_pos = get_pos() + context.get_time_offset() * m_physic.get_velocity();

/* Draw Tux */
if (!m_visible || (m_safe_timer.started() && !m_is_intentionally_safe && size_t(g_game_time * 40) % 2))
if (!m_visible || (m_safe_timer.started() && !m_avoid_blinking_while_safe && size_t(g_game_time * 40) % 2))
{
} // don't draw Tux

@@ -2424,7 +2425,7 @@ void
Player::make_temporarily_safe(float safe_time)
{
m_safe_timer.start(safe_time);
m_is_intentionally_safe = true;
m_avoid_blinking_while_safe = true;
}

void
@@ -2452,13 +2453,13 @@ Player::kill(bool completely)
if (get_bonus() > BONUS_GROWUP)
{
m_safe_timer.start(TUX_SAFE_TIME);
m_is_intentionally_safe = false;
m_avoid_blinking_while_safe = false;
set_bonus(BONUS_GROWUP, true);
}
else if (get_bonus() == BONUS_GROWUP)
{
m_safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */);
m_is_intentionally_safe = false;
m_avoid_blinking_while_safe = false;
m_duck = false;
m_crawl = false;
stop_backflipping();
@@ -2571,7 +2572,7 @@ Player::check_bounds()
/* fallen out of the level? */
if ((get_pos().y > Sector::get().get_height())
&& !m_ghost_mode
&& !(m_is_intentionally_safe && m_safe_timer.started())) {
&& !(m_avoid_blinking_while_safe && m_safe_timer.started())) {
kill(true);
return;
}
5 changes: 5 additions & 0 deletions src/object/player.hpp
Original file line number Diff line number Diff line change
@@ -575,6 +575,11 @@ class Player final : public MovingObject
*/
bool m_is_intentionally_safe;

/**
* @description Flag indicating that Tux shall not blink while being safe
*/
bool m_avoid_blinking_while_safe;

Timer m_kick_timer;
Timer m_buttjump_timer;

0 comments on commit 49d73db

Please sign in to comment.