From 528120d1021f567ca5dc9e08cb1e140afbc7a39d Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Fri, 5 Aug 2022 18:44:49 -0400 Subject: [PATCH] Multiple achievements can now use the same stat as a trigger. --- .gitlab-ci.yml | 2 +- dll/steam_user_stats.h | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f9da43..115d1a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ build_windows: - DLL_FILES="$(ls overlay_experimental/System/*.cpp | tr "\n" " ")"; sed "s|overlay_experimental/System/\*.cpp|$DLL_FILES|g" -i *.bat - DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat - DLL_FILES="$(ls steamclient_loader/*.cpp | tr "\n" " ")"; sed "s|steamclient_loader/\*.cpp|$DLL_FILES|g" -i *.bat - - sed "s| /MP12 | /MP5 |g" -i *.bat + - sed "s| /MP12 | /MP4 |g" -i *.bat - export WINEDEBUG=-all - wine cmd /c build_win_debug_experimental.bat - mkdir debug_experimental diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index 3461ead..995bd84 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -81,7 +81,7 @@ private: std::map stats_cache_int; std::map stats_cache_float; - std::map achievement_stat_trigger; + std::map> achievement_stat_trigger; unsigned int find_leaderboard(std::string name) { @@ -159,7 +159,7 @@ Steam_User_Stats(Settings *settings, Local_Storage *local_storage, class SteamCa std::string stat_name = ascii_to_lowercase(static_cast(it["progress"]["value"]["operand1"])); trig.min_value = static_cast(it["progress"]["min_val"]); trig.max_value = static_cast(it["progress"]["max_val"]); - achievement_stat_trigger[stat_name] = trig; + achievement_stat_trigger[stat_name].push_back(trig); } catch (...) {} try { @@ -283,8 +283,10 @@ bool SetStat( const char *pchName, int32 nData ) auto stat_trigger = achievement_stat_trigger.find(stat_name); if (stat_trigger != achievement_stat_trigger.end()) { - if (stat_trigger->second.check_triggered(nData)) { - SetAchievement(stat_trigger->second.name.c_str()); + for (auto &t : stat_trigger->second) { + if (t.check_triggered(nData)) { + SetAchievement(t.name.c_str()); + } } } @@ -310,8 +312,10 @@ bool SetStat( const char *pchName, float fData ) auto stat_trigger = achievement_stat_trigger.find(stat_name); if (stat_trigger != achievement_stat_trigger.end()) { - if (stat_trigger->second.check_triggered(fData)) { - SetAchievement(stat_trigger->second.name.c_str()); + for (auto &t : stat_trigger->second) { + if (t.check_triggered(fData)) { + SetAchievement(t.name.c_str()); + } } }