Skip to content

Commit

Permalink
updateing stat check for (progress - last_notified) >= min_diff
Browse files Browse the repository at this point in the history
setting min diff for float to 0.1 instead of 1
adding last_notified_progress into achievement_stat_trigger
  • Loading branch information
Detanup01 authored Sep 30, 2024
1 parent 623ba90 commit 58ae7e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dll/dll/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class Settings {
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 = 1;
float stat_float_min_diff_progress = 0.1;
// 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()`
Expand Down
1 change: 1 addition & 0 deletions dll/dll/steam_user_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct achievement_trigger {
std::string value_operation{};
std::string min_value{}; // min progress
std::string max_value{}; // max progress
std::string last_notified_progress{};

bool should_unlock_ach(float stat) const;
bool should_unlock_ach(int32 stat) const;
Expand Down
1 change: 1 addition & 0 deletions dll/steam_user_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network
std::string stat_name = common_helpers::ascii_to_lowercase(static_cast<std::string const&>(it["progress"]["value"]["operand1"]));
trig.min_value = static_cast<std::string const&>(it["progress"]["min_val"]);
trig.max_value = static_cast<std::string const&>(it["progress"]["max_val"]);
trig.last_notified_progress = static_cast<std::string const&>(it["progress"]["min_val"]);
achievement_stat_trigger[stat_name].push_back(trig);
} catch(...) {}

Expand Down
9 changes: 6 additions & 3 deletions dll/steam_user_stats_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ Steam_User_Stats::InternalSetResult<int32> Steam_User_Stats::set_stat_internal(
}
} catch(...){}
}

if (indicate_progress && (stats_data->second.default_value_int + settings->stat_int_min_diff_progress) >= nData) {
// Alternative progress based on %:
// ((nData - std:stoi(t.last_notified_progress)) / std::stoi(t.max_value)) >= settings->stat_int_min_diff_progress_presentage
if (indicate_progress && (nData - std:stoi(t.last_notified_progress)) >= settings->stat_int_min_diff_progress) {
IndicateAchievementProgress(t.name.c_str(), nData, std::stoi(t.max_value));
t.last_notified_progress = std::to_string(nData);
}
}
}
Expand Down Expand Up @@ -202,8 +204,9 @@ Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo
} catch(...){}
}

if (indicate_progress && (stats_data->second.default_value_float + settings->stat_float_min_diff_progress) >= fData) {
if (indicate_progress && ((nData - std:stof(t.last_notified_progress)) >= settings->stat_float_min_diff_progress) {
IndicateAchievementProgress(t.name.c_str(), (uint32)fData, (uint32)std::stof(t.max_value));
t.last_notified_progress = std::to_string(nData);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ paginated_achievements_icons=10
# 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=1
stat_float_min_diff_progress=1
# default=0.1
stat_float_min_diff_progress=0.1

[main::connectivity]
# 1=prevent hooking OS networking APIs and allow any external requests
Expand Down

0 comments on commit 58ae7e7

Please sign in to comment.