diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 71efb37dc0a..a21ede580bc 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -149,7 +149,7 @@ Dispenser::active_update(float dt_sec) auto player = get_nearest_player(); if (player) { - if(player->is_dying() || player->is_dead()) + if(!player->is_alive()) { return; } diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 65ed00eb89d..13dabd4276a 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -572,7 +572,7 @@ Camera::update_scroll_normal_multiplayer(float dt_sec) for (const auto* p : Sector::get().get_players()) { - if (p->is_dead() || p->is_dying()) + if (!p->is_alive()) continue; float lft = p->get_bbox().get_left() - HORIZONTAL_MARGIN; @@ -636,7 +636,7 @@ Camera::update_scroll_normal_multiplayer(float dt_sec) void Camera::update_scroll_autoscroll(float dt_sec) { - if (!get_parent()->get_object_count([](const Player& p) { return !p.is_dead() && !p.is_dying(); })) + if (!get_parent()->get_object_count([](const Player& p) { return p.is_alive(); })) return; get_walker()->update(dt_sec); diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index ea7449ad649..51a0f7a46e9 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -63,7 +63,7 @@ LevelTime::update(float dt_sec) if (!running) return; int players_alive = Sector::current() ? Sector::current()->get_object_count([](const Player& p) { - return !p.is_dead() && !p.is_dying() && !p.is_winning(); + return p.is_active(); }) : 0; if (!players_alive) @@ -89,7 +89,7 @@ LevelTime::update(float dt_sec) { for (auto& p : Sector::get().get_players()) { - if (p->is_dead() || p->is_dying() || p->is_winning()) + if (!p->is_active()) continue; p->add_coins(-1); diff --git a/src/object/player.cpp b/src/object/player.cpp index b3f503ed1d2..168a2a35244 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -413,10 +413,10 @@ Player::update(float dt_sec) } // Skip if in multiplayer respawn - if (is_dead() && m_target && Sector::get().get_object_count([this](const Player& p) { return !p.is_dead() && !p.is_dying() && !p.is_winning() && &p != this; })) + if (is_dead() && m_target && Sector::get().get_object_count([this](const Player& p) { return p.is_active() && &p != this; })) { auto* target = Sector::get().get_object_by_uid(*m_target); - if (!target || target->is_dying() || target->is_dead() || target->is_winning()) + if (!target || !target->is_active()) { next_target(); } @@ -545,7 +545,7 @@ Player::update(float dt_sec) set_bonus(NO_BONUS, true); m_dead = true; - if (!Sector::get().get_object_count([](const Player& p) { return !p.is_dead() && !p.is_dying(); })) + if (!Sector::get().get_object_count([](const Player& p) { return p.is_alive(); })) { Sector::get().stop_looping_sounds(); } @@ -1992,7 +1992,7 @@ Player::draw(DrawingContext& context) if(Editor::is_active()) return; - if (is_dead() && m_target && Sector::get().get_object_count([this](const Player& p){ return !p.is_dead() && !p.is_dying() && !p.is_winning() && &p != this; })) + if (is_dead() && m_target && Sector::get().get_object_count([this](const Player& p){ return p.is_active() && &p != this; })) { auto* target = Sector::get().get_object_by_uid(*m_target); if (target) @@ -2463,7 +2463,7 @@ Player::kill(bool completely) m_dying_timer.start(3.0); set_group(COLGROUP_DISABLED); - auto alive_players = Sector::get().get_object_count([](const Player& p){ return !p.is_dead() && !p.is_dying(); }); + auto alive_players = Sector::get().get_object_count([](const Player& p){ return p.is_alive(); }); if (!alive_players) { @@ -2539,7 +2539,7 @@ Player::check_bounds() } // If Tux is swimming, don't allow him to go below the sector - if (m_swimming && !m_ghost_mode && !is_dying() && !is_dead() + if (m_swimming && !m_ghost_mode && is_alive() && m_col.m_bbox.get_bottom() > Sector::get().get_height()) { m_col.set_pos(Vector(m_col.m_bbox.get_left(), Sector::get().get_height() - m_col.m_bbox.get_height())); @@ -2910,7 +2910,7 @@ Player::next_target() bool is_next = false; for (auto* player : players) { - if (!player->is_dead() && !player->is_dying() && !player->is_winning()) + if (player->is_active()) { if (!first) { @@ -2950,7 +2950,7 @@ Player::prev_target() Player* last = nullptr; for (auto* player : players) { - if (!player->is_dead() && !player->is_dying() && !player->is_winning()) + if (player->is_active()) { if (m_target && player->get_uid() == *m_target && last) { diff --git a/src/object/player.hpp b/src/object/player.hpp index fa78b451647..720ec781949 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -135,6 +135,18 @@ class Player final : public MovingObject bool is_invincible() const { return m_invincible_timer.started(); } bool is_dying() const { return m_dying; } + /** + * Returns true if the player is currently alive + * (not dying or dead) + */ + bool is_alive() const { return !is_dying() && !is_dead(); } + + /** + * Returns true if the player can be controlled. + * (alive and not currently in a win sequence) + */ + bool is_active() const { return is_alive() && !is_winning(); } + Direction peeking_direction_x() const { return m_peekingX; } Direction peeking_direction_y() const { return m_peekingY; } diff --git a/src/supertux/error_handler.cpp b/src/supertux/error_handler.cpp index 9cc7d041292..82dc03d05b7 100644 --- a/src/supertux/error_handler.cpp +++ b/src/supertux/error_handler.cpp @@ -301,6 +301,8 @@ ErrorHandler::error_dialog_exception(const std::string& exception) std::string msg = stream.str(); + std::cerr << msg << std::endl; + SDL_MessageBoxButtonData btns[] = { #ifdef WIN32 { diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index ce9ff0d6285..3a602556e7b 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -267,7 +267,7 @@ GameSession::on_escape_press(bool force_quick_respawn) auto players = m_currentsector->get_players(); int alive = m_currentsector->get_object_count([](const Player& p) { - return !p.is_dead() && !p.is_dying(); + return p.is_alive(); }); if ((!alive && (m_play_time > 2.0f || force_quick_respawn)) || m_end_sequence) @@ -336,7 +336,7 @@ GameSession::get_fade_point(const Vector& position) const for (const auto* player : m_currentsector->get_players()) { - if (!player->is_dead() && !player->is_dying()) + if (player->is_alive()) { average_position += player->get_bbox().get_middle(); alive_players++; @@ -417,7 +417,7 @@ GameSession::check_end_conditions() bool all_dead_or_winning = true; for (const auto* p : m_currentsector->get_players()) - if (!(all_dead_or_winning &= (p->is_dead() || p->is_dying() || p->is_winning()))) + if (!(all_dead_or_winning &= (!p->is_active()))) break; /* End of level? */ @@ -861,7 +861,7 @@ GameSession::start_sequence(Player* caller, Sequence seq, const SequenceData* da caller->set_winning(); int remaining_players = get_current_sector().get_object_count([](const Player& p){ - return !p.is_dead() && !p.is_dying() && !p.is_winning(); + return p.is_active(); }); // Abort if a sequence is already playing. diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index b21eb3fb8c3..16c4d58000b 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -234,16 +234,17 @@ LevelIntro::push_player() if (m_player_status.bonus[i] == FIRE_BONUS && g_config->christmas_mode) { m_player_sprite[i]->set_action("big-walk-right"); - m_santa_sprite[i]->set_action("santa-walk-right"); + m_santa_sprite[i]->set_action("default"); } else { m_player_sprite[i]->set_action(m_player_status.get_bonus_prefix(i) + "-walk-right"); } + m_player_sprite_jump_timer[i]->start(graphicsRandom.randf(5,10)); /* Set Tux powerup sprite action */ - m_santa_sprite[i]->set_action(m_player_sprite[i]->get_action()); + //m_santa_sprite[i]->set_action(m_player_sprite[i]->get_action()); } void diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 672d3f11f6b..62ef6224e5d 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -728,7 +728,7 @@ Sector::get_nearest_player (const Vector& pos) const for (auto player_ptr : get_objects_by_type_index(typeid(Player))) { Player& player = *static_cast(player_ptr); - if (player.is_dying() || player.is_dead()) + if (!player.is_alive()) continue; float dist = player.get_bbox ().distance(pos);