Skip to content

Commit

Permalink
Run init-script only once after a sector has loaded
Browse files Browse the repository at this point in the history
Fixes #698
  • Loading branch information
tobbi committed Jul 11, 2024
1 parent be1b596 commit 6fdf49f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/supertux/sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Sector::Sector(Level& parent) :
m_foremost_opaque_layer(),
m_gravity(10.0f),
m_collision_system(new CollisionSystem(*this)),
m_text_object(add<TextObject>("Text"))
m_text_object(add<TextObject>("Text")),
m_init_script_run()
{
add<DisplayEffect>("Effect");
add<TextArrayObject>("TextArray");
Expand Down Expand Up @@ -287,8 +288,9 @@ Sector::activate(const Vector& player_pos)
}

// Run init script
if (!m_init_script.empty() && !Editor::is_active()) {
if (!m_init_script.empty() && !Editor::is_active() && !m_init_script_run) {
run_script(m_init_script, "init-script");
m_init_script_run = true;
}

// Do not interpolate camera after it has been warped
Expand Down
1 change: 1 addition & 0 deletions src/supertux/sector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class Sector final : public Base::Sector
Vector m_last_translation; // For camera interpolation at high frame rates
float m_last_scale;
float m_last_dt;
bool m_init_script_run;

private:
Sector(const Sector&) = delete;
Expand Down

0 comments on commit 6fdf49f

Please sign in to comment.