Skip to content

Commit

Permalink
Fix PlayerStatusHUD addition being pushed to GameObjectManager un…
Browse files Browse the repository at this point in the history
…do stack

`PlayerStatusHUD` is no longer added in editor levels. This fixes a bug where it would be pushed to the undo stack and opening a level in the editor without doing anything would still have it marked as having unsaved changes.

`PlayerStatusHUD` now also overrides `track_state` to indicate that it shouldn't be tracked, just in case.
  • Loading branch information
Vankata453 committed Nov 25, 2024
1 parent b39f219 commit b2f3de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/supertux/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ Level::initialize(const Statistics::Preferences& stat_preferences)
&GameSession::current()->get_savegame() : nullptr);
PlayerStatus& player_status = savegame ? savegame->get_player_status() : s_dummy_player_status;

if (Editor::current() || (savegame && !savegame->is_title_screen() && !m_suppress_pause_menu))
// Condition 1: If there is a savegame, it shouldn't be from the title screen. (Don't load HUD on title screen)
// Condition 2: Pause menu shouldn't be suppressed.
// Condition 3: The level shouldn't be loaded in the editor.
if ((!savegame || !savegame->is_title_screen()) &&
!m_suppress_pause_menu && !Editor::is_active())
{
for (auto& sector : m_sectors)
sector->add<PlayerStatusHUD>(player_status);
Expand Down
1 change: 1 addition & 0 deletions src/supertux/player_status_hud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PlayerStatusHUD : public GameObject

virtual bool is_saveable() const override { return false; }
virtual bool is_singleton() const override { return true; }
virtual bool track_state() const override { return false; }

void reset();

Expand Down

0 comments on commit b2f3de9

Please sign in to comment.