Skip to content

Commit 8665e18

Browse files
committed
Move players into its own variable in GameSession::update
1 parent af71224 commit 8665e18

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/supertux/game_session.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,8 @@ GameSession::update(float dt_sec, const Controller& controller)
556556

557557
check_end_conditions();
558558

559+
auto players = m_currentsector->get_players();
560+
559561
// Respawning in new sector?
560562
if (!m_newsector.empty() && !m_newspawnpoint.empty() && (m_spawn_fade_timer.check() || m_spawn_fade_type == ScreenFade::FadeType::NONE)) {
561563
auto sector = m_level->get_sector(m_newsector);
@@ -595,8 +597,7 @@ GameSession::update(float dt_sec, const Controller& controller)
595597
break;
596598
}
597599

598-
599-
for (auto* p : m_currentsector->get_players())
600+
for (auto* p : players)
600601
{
601602
// Give back control to the player
602603
p->activate();
@@ -626,7 +627,7 @@ GameSession::update(float dt_sec, const Controller& controller)
626627
m_level->m_stats.finish(m_play_time);
627628
}
628629

629-
for (Player* player : m_currentsector->get_players())
630+
for (Player* player : players)
630631
{
631632
if (player->is_active() && player->is_scripting_activated() &&
632633
player->get_controller().pressed(Control::ITEM) &&
@@ -641,7 +642,7 @@ GameSession::update(float dt_sec, const Controller& controller)
641642
} else {
642643
bool are_all_stopped = true;
643644

644-
for (const auto& player : m_currentsector->get_players())
645+
for (const auto& player : players)
645646
{
646647
if (!(m_end_sequence->is_tux_stopped(player->get_id())
647648
|| player->get_ending_direction() == 0))
@@ -672,7 +673,7 @@ GameSession::update(float dt_sec, const Controller& controller)
672673
bool invincible_timer_started = false;
673674
float max_invincible_timer_left = 0.f;
674675

675-
for (const auto* p : m_currentsector->get_players())
676+
for (const auto* p : players)
676677
{
677678
invincible_timer_started |= (p->m_invincible_timer.started() && !p->is_winning());
678679
max_invincible_timer_left = std::max(max_invincible_timer_left, p->m_invincible_timer.get_timeleft());

0 commit comments

Comments
 (0)