updateing stat check for (progress - last_notified) >= min_diff

setting min diff for float to 0.1 instead of 1
adding last_notified_progress into achievement_stat_trigger
This commit is contained in:
Detanup01 2024-09-30 09:45:44 +02:00 committed by GitHub
parent 623ba9025b
commit 58ae7e7b0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 6 deletions

View File

@ -260,7 +260,7 @@ public:
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()`

View File

@ -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;

View File

@ -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(...) {}

View File

@ -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);
}
}
}
@ -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);
}
}
}

View File

@ -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