From 9ddfa82878fb16de7ce8391f14b6cf0ffff3ef20 Mon Sep 17 00:00:00 2001 From: Detanup01 <91248446+Detanup01@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:23:30 +0200 Subject: [PATCH] adding stats diff check for not spam the users --- dll/dll/settings.h | 3 +++ dll/settings_parser.cpp | 17 +++++++++++++++++ dll/steam_user_stats_stats.cpp | 4 ++-- .../configs.main.EXAMPLE.ini | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 9dc86352..7a0375af 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -258,6 +258,9 @@ public: // when a stat that's tied to an achievement gets a new value, should the emu save that progress only if it's higher? // the stat itself is always saved regardless of that flag, only affects the achievement progress bool save_only_higher_stat_achievement_progress = true; + // Minimum value to indicate progress being made for the user. + int stat_int_min_diff_progress = 1; + float stat_float_min_diff_progress = 1f; // the emulator loads the achievements icons is memory mainly for `ISteamUserStats::GetAchievementIcon()` // this defines how many icons to load each iteration when the periodic callback in `Steam_User_Stats` is triggered // or when the app calls `SteamAPI_RunCallbacks()` diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 31ce0323..b630fe70 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -1448,6 +1448,23 @@ static void parse_stats_features(class Settings *settings_client, class Settings long val_server = ini.GetLongValue("main::stats", "paginated_achievements_icons", settings_server->paginated_achievements_icons); settings_server->paginated_achievements_icons = static_cast(val_server); } + + { + long val_client_i = ini.GetLongValue("main::stats", "stat_int_min_diff_progress", settings_client->stat_int_min_diff_progress); + settings_client->stat_int_min_diff_progress = static_cast(val_client_i); + + long val_server_i = ini.GetLongValue("main::stats", "stat_int_min_diff_progress", settings_server->stat_int_min_diff_progress); + settings_server->stat_int_min_diff_progress = static_cast(val_server_i); + } + + { + double val_client_d = ini.GetDoubleValue("main::stats", "stat_float_min_diff_progress", settings_client->stat_float_min_diff_progress); + settings_client->stat_float_min_diff_progress = static_cast(val_client_d); + + double val_server_d = ini.GetDoubleValue("main::stats", "stat_float_min_diff_progress", settings_server->stat_float_min_diff_progress); + settings_server->stat_float_min_diff_progress = static_cast(val_server_d); + } + } diff --git a/dll/steam_user_stats_stats.cpp b/dll/steam_user_stats_stats.cpp index 6b8a20a0..41ab7d82 100644 --- a/dll/steam_user_stats_stats.cpp +++ b/dll/steam_user_stats_stats.cpp @@ -128,7 +128,7 @@ Steam_User_Stats::InternalSetResult Steam_User_Stats::set_stat_internal( } catch(...){} } - if (indicate_progress) { + if (indicate_progress && (stats_data->second + settings->start_int_min_diff_progress) >= nData) { IndicateAchievementProgress(t.name.c_str(), nData, std::stoi(t.max_value)); } } @@ -202,7 +202,7 @@ Steam_User_Stats::InternalSetResultsecond + settings->start_float_min_diff_progress) >= fData) { IndicateAchievementProgress(t.name.c_str(), (uint32)fData, (uint32)std::stof(t.max_value)); } } diff --git a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini index 967297a3..d29187e8 100644 --- a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini +++ b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini @@ -70,6 +70,13 @@ save_only_higher_stat_achievement_progress=1 # default=10 paginated_achievements_icons=10 +# Minimum value to indicate progress being made for the user. +# Usually good for achievement that use stat values and contains high number (ie: kill 200 cops) +# default=1 +stat_int_min_diff_progress=1 +# default=1f +stat_float_min_diff_progress=1f + [main::connectivity] # 1=prevent hooking OS networking APIs and allow any external requests # only used by the experimental builds on **Windows**