don't spam loading achievements forever on failure

This commit is contained in:
otavepto 2024-01-24 02:21:09 +02:00
parent b8e305bc41
commit 5ec61403f5
3 changed files with 11 additions and 5 deletions

View File

@ -96,6 +96,8 @@ class Steam_Overlay
// friend id, show client window (to chat and accept invite maybe)
std::map<Friend, friend_window_state, Friend_Less> friends;
// avoids spam loading on failure
std::atomic<int32_t> load_achievements_trials = 3;
bool setup_overlay_called;
bool is_ready;
bool show_overlay;

View File

@ -458,6 +458,7 @@ void Steam_Overlay::AddMessageNotification(std::string const& message)
PRINT_DEBUG("No more free id to create a notification window\n");
}
// show a notification when the user unlocks an achievement
void Steam_Overlay::AddAchievementNotification(nlohmann::json const& ach)
{
std::lock_guard<std::recursive_mutex> lock(notifications_mutex);
@ -1113,7 +1114,7 @@ void Steam_Overlay::OverlayProc()
}
}
if (show_achievements && achievements.size()) {
if (show_achievements && achievements.size()) { // display achievements list when the button "show achievements" is pressed
ImGui::SetNextWindowSizeConstraints(ImVec2(ImGui::GetFontSize() * 32, ImGui::GetFontSize() * 32), ImVec2(8192, 8192));
bool show = show_achievements;
if (ImGui::Begin(translationAchievementWindow[current_language], &show)) {
@ -1314,7 +1315,8 @@ void Steam_Overlay::Callback(Common_Message *msg)
void Steam_Overlay::RunCallbacks()
{
if (!achievements.size()) {
if (!achievements.size() && load_achievements_trials > 0) {
--load_achievements_trials;
Steam_User_Stats* steamUserStats = get_steam_client()->steam_user_stats;
uint32 achievements_num = steamUserStats->GetNumAchievements();
if (achievements_num) {

View File

@ -438,9 +438,11 @@ Check the exaxmple files in the `steam_settings` folder
## Auto accept game/lobby invites:
When the overlay is enabled and working, you can bypass it and auto-accept invites (lobby or game) from a list of Steam IDs (SteamID64 format).
The configuration file `auto_accept_invite.txt` allows you to do that, add each SteamID64 on a separate line.
Also you can auto-accept invites from anyone by leaving the file empty.
The configuration file `auto_accept_invite.txt` allows you to do that, it works like this:
* Adding an empty file: will accept invites from anyone (same behavior as if the overlay was disabled)
* Adding a file with some friends IDs (each on a separate line):
* If the friend ID is found in this file, the invitation will be accepted automatically
* If the friend ID is not found, you'll get the regular overlay invitation
Check the exaxmple file in the `steam_settings` folder