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.
merge-requests/24/head
Nemirtingas 2019-10-20 13:46:25 +02:00
parent 42d9217f00
commit ef5693d9f8
2 changed files with 5 additions and 11 deletions

View File

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

View File

@ -350,9 +350,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
static std::string display_name;
display_name = it.value()["displayName"].get<std::string>();
return display_name.c_str();
return it.value()["displayName"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}
@ -363,9 +361,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
static std::string description;
description = it.value()["description"].get<std::string>();
return description.c_str();
return it.value()["description"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}
@ -376,9 +372,7 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) {
static std::string hidden;
hidden = it.value()["hidden"].get<std::string>();
return hidden.c_str();
return it.value()["hidden"].get_ptr<std::string*>()->c_str();
}
} catch (...) {}
}