Compare commits

..

2 Commits

Author SHA1 Message Date
Mr_Goldberg ad66573a20
Fix crashes. 2022-08-05 18:45:33 -04:00
Mr_Goldberg 528120d102
Multiple achievements can now use the same stat as a trigger. 2022-08-05 18:44:49 -04:00
4 changed files with 21 additions and 10 deletions

View File

@ -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 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 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 - 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 - export WINEDEBUG=-all
- wine cmd /c build_win_debug_experimental.bat - wine cmd /c build_win_debug_experimental.bat
- mkdir debug_experimental - mkdir debug_experimental

View File

@ -45,10 +45,17 @@ bool Steam_GameServer::InitGameServer( uint32 unIP, uint16 usGamePort, uint16 us
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (logged_in) return false; // may not be changed after logged in. if (logged_in) return false; // may not be changed after logged in.
if (!pchVersionString) pchVersionString = "";
std::string version(pchVersionString); std::string version(pchVersionString);
version.erase(std::remove(version.begin(), version.end(), ' '), version.end()); version.erase(std::remove(version.begin(), version.end(), ' '), version.end());
version.erase(std::remove(version.begin(), version.end(), '.'), version.end()); version.erase(std::remove(version.begin(), version.end(), '.'), version.end());
server_data.set_version(stoi(version)); try {
server_data.set_version(std::stoi(version));
} catch (...) {
PRINT_DEBUG("InitGameServer: not a number: %s\n", pchVersionString);
server_data.set_version(0);
}
server_data.set_ip(unIP); server_data.set_ip(unIP);
server_data.set_port(usGamePort); server_data.set_port(usGamePort);

View File

@ -81,7 +81,7 @@ private:
std::map<std::string, int32> stats_cache_int; std::map<std::string, int32> stats_cache_int;
std::map<std::string, float> stats_cache_float; std::map<std::string, float> stats_cache_float;
std::map<std::string, achievement_trigger> achievement_stat_trigger; std::map<std::string, std::vector<achievement_trigger>> achievement_stat_trigger;
unsigned int find_leaderboard(std::string name) 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<std::string const&>(it["progress"]["value"]["operand1"])); std::string stat_name = 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.min_value = static_cast<std::string const&>(it["progress"]["min_val"]);
trig.max_value = static_cast<std::string const&>(it["progress"]["max_val"]); trig.max_value = static_cast<std::string const&>(it["progress"]["max_val"]);
achievement_stat_trigger[stat_name] = trig; achievement_stat_trigger[stat_name].push_back(trig);
} catch (...) {} } catch (...) {}
try { try {
@ -283,8 +283,10 @@ bool SetStat( const char *pchName, int32 nData )
auto stat_trigger = achievement_stat_trigger.find(stat_name); auto stat_trigger = achievement_stat_trigger.find(stat_name);
if (stat_trigger != achievement_stat_trigger.end()) { if (stat_trigger != achievement_stat_trigger.end()) {
if (stat_trigger->second.check_triggered(nData)) { for (auto &t : stat_trigger->second) {
SetAchievement(stat_trigger->second.name.c_str()); 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); auto stat_trigger = achievement_stat_trigger.find(stat_name);
if (stat_trigger != achievement_stat_trigger.end()) { if (stat_trigger != achievement_stat_trigger.end()) {
if (stat_trigger->second.check_triggered(fData)) { for (auto &t : stat_trigger->second) {
SetAchievement(stat_trigger->second.name.c_str()); if (t.check_triggered(fData)) {
SetAchievement(t.name.c_str());
}
} }
} }

View File

@ -801,11 +801,11 @@ void Steam_Overlay::OverlayProc()
bool hidden = x.hidden && !achieved; bool hidden = x.hidden && !achieved;
ImGui::Separator(); ImGui::Separator();
ImGui::Text(x.title.c_str()); ImGui::Text("%s", x.title.c_str());
if (x.hidden) { if (x.hidden) {
ImGui::Text("hidden achievement"); ImGui::Text("hidden achievement");
} else { } else {
ImGui::TextWrapped(x.description.c_str()); ImGui::TextWrapped("%s", x.description.c_str());
} }
if (achieved) { if (achieved) {