From ef5693d9f811922e3bdb92507958c0f0b2c1cca8 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Sun, 20 Oct 2019 13:46:25 +0200 Subject: [PATCH] Little improvements steam_user_stats: Use the value stored in the JSON object. steal_inventory: use 'empty' that is guaranteed to be constant in time. --- dll/steam_inventory.h | 4 ++-- dll/steam_user_stats.h | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dll/steam_inventory.h b/dll/steam_inventory.h index 895e49b9..32201e7b 100644 --- a/dll/steam_inventory.h +++ b/dll/steam_inventory.h @@ -840,7 +840,7 @@ bool SubmitUpdateProperties( SteamInventoryUpdateHandle_t handle, SteamInventory void RunCallbacks() { - if (call_definition_update || inventory_requests.size()) { + if (call_definition_update || !inventory_requests.empty()) { if (!item_definitions_loaded) { read_items_db(); item_definitions_loaded = true; @@ -854,7 +854,7 @@ void RunCallbacks() call_definition_update = false; } - if (inventory_requests.size() && !inventory_loaded) { + if (!inventory_requests.empty() && !inventory_loaded) { read_inventory_db(); inventory_loaded = true; } diff --git a/dll/steam_user_stats.h b/dll/steam_user_stats.h index 2a0e9512..03a41378 100644 --- a/dll/steam_user_stats.h +++ b/dll/steam_user_stats.h @@ -350,9 +350,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc return static_cast(item["name"]) == pchName; }); if (it != defined_achievements.end()) { - static std::string display_name; - display_name = it.value()["displayName"].get(); - return display_name.c_str(); + return it.value()["displayName"].get_ptr()->c_str(); } } catch (...) {} } @@ -363,9 +361,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc return static_cast(item["name"]) == pchName; }); if (it != defined_achievements.end()) { - static std::string description; - description = it.value()["description"].get(); - return description.c_str(); + return it.value()["description"].get_ptr()->c_str(); } } catch (...) {} } @@ -376,9 +372,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc return static_cast(item["name"]) == pchName; }); if (it != defined_achievements.end()) { - static std::string hidden; - hidden = it.value()["hidden"].get(); - return hidden.c_str(); + return it.value()["hidden"].get_ptr()->c_str(); } } catch (...) {} }