Skip to content

Commit

Permalink
Use unsigned integers for storing progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Vankata453 committed Aug 6, 2023
1 parent 827d922 commit 1149313
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/supertux/menu/world_set_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ WorldSetMenu::WorldSetMenu()

// Add Story Mode entry.
// Story Mode should not have its progress shown.
add_world(_("Story Mode"), "levels/world1", { -1, -1 }, find_preview("previews/world1.png", "levels/world1"));
add_world(_("Story Mode"), "levels/world1", { 0, 0 }, find_preview("previews/world1.png", "levels/world1"));

add_entry(1, _("Contrib Levels"));
add_hl();
Expand Down
4 changes: 2 additions & 2 deletions src/supertux/savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ LevelsetState::get_level_state(const std::string& filename) const
}
}

int
uint32_t
Savegame::Progress::get_percentage() const
{
return solved > 0 ? static_cast<int>(static_cast<float>(solved) / total * 100) : 0;
return solved > 0 ? static_cast<uint32_t>(static_cast<float>(solved) / static_cast<float>(total) * 100) : 0;
}

std::unique_ptr<Savegame>
Expand Down
6 changes: 3 additions & 3 deletions src/supertux/savegame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class Savegame final
solved(solved_),
total(total_)
{}
int solved;
int total;
uint32_t solved;
uint32_t total;

int get_percentage() const;
uint32_t get_percentage() const;
};

public:
Expand Down

0 comments on commit 1149313

Please sign in to comment.