diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.cpp b/src/creatures/players/cyclopedia/player_cyclopedia.cpp index ba7c01fe90c..43f622b6245 100644 --- a/src/creatures/players/cyclopedia/player_cyclopedia.cpp +++ b/src/creatures/players/cyclopedia/player_cyclopedia.cpp @@ -133,27 +133,27 @@ Summary PlayerCyclopedia::getSummary() { return { getAmount(Summary_t::BOOSTS), getAmount(Summary_t::PREY_CARDS), getAmount(Summary_t::INSTANT_REWARDS), getAmount(Summary_t::HIRELINGS) }; } -std::map PlayerCyclopedia::getResult(uint8_t type) const { +std::map PlayerCyclopedia::getResult(uint8_t type) const { auto kvScope = m_player.kv()->scoped("summary")->scoped(g_game().getSummaryKeyByType(type)); - std::map result; + std::map result; // ID, amount for (const auto &scope : kvScope->keys()) { size_t pos = scope.find('.'); if (pos == std::string::npos) { - g_logger().error("Invalid key format: {}", scope); + g_logger().error("[{}] Invalid key format: {}", __FUNCTION__, scope); continue; } std::string id = scope.substr(0, pos); auto amount = kvScope->scoped(id)->get("amount"); - result.emplace(id, static_cast(amount ? amount->getNumber() : 0)); + result.emplace(std::stoll(id), static_cast(amount ? amount->getNumber() : 0)); } return result; } void PlayerCyclopedia::insertValue(uint8_t type, uint16_t amount, const std::string &id) { auto result = getResult(type); - auto it = result.find(id); + auto it = result.find(std::stoll(id)); auto oldAmount = (it != result.end() ? it->second : 0); auto newAmount = oldAmount + amount; m_player.kv()->scoped("summary")->scoped(g_game().getSummaryKeyByType(type))->scoped(id)->set("amount", newAmount); - g_logger().info("type: {}, id: {}, old amount: {}, added amount: {}, new amount: {}", type, id, oldAmount, amount, newAmount); + g_logger().debug("type: {}, id: {}, old amount: {}, added amount: {}, new amount: {}", type, id, oldAmount, amount, newAmount); } diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.hpp b/src/creatures/players/cyclopedia/player_cyclopedia.hpp index 6791986c0fa..e437c6b937d 100644 --- a/src/creatures/players/cyclopedia/player_cyclopedia.hpp +++ b/src/creatures/players/cyclopedia/player_cyclopedia.hpp @@ -47,7 +47,7 @@ class PlayerCyclopedia { Summary getSummary(); - [[nodiscard]] std::map getResult(uint8_t type) const; + [[nodiscard]] std::map getResult(uint8_t type) const; void insertValue(uint8_t type, uint16_t amount = 1, const std::string &id = ""); private: diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 384c56ce60a..b8589d63e3a 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -3944,14 +3944,13 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() { auto blessingNames = player->getBlessingNames(); msg.addByte(static_cast(blessingNames.size())); auto blessingsObtained = player->cyclopedia()->getResult(static_cast(Summary_t::BLESSINGS)); - for (const auto &name_it : blessingNames) { - msg.addString(name_it.second, "ProtocolGame::sendCyclopediaCharacterStoreSummary - blessing.name"); - auto it = std::find_if(blessingsObtained.begin(), blessingsObtained.end(), [&name_it](const std::pair &bName_it) { - return bName_it.first == name_it.first; + for (const auto &bName_it : blessingNames) { + msg.addString(bName_it.second, "ProtocolGame::sendCyclopediaCharacterStoreSummary - blessing.name"); + uint16_t blessAmount = 0; + auto it = std::find_if(blessingsObtained.begin(), blessingsObtained.end(), [&bName_it](const auto &b_it) { + return b_it.first == bName_it.first; }); - uint16_t blessAmount = (it != blessingsObtained.end()) ? it->second : 0; - msg.addByte(static_cast(blessAmount)); - g_logger().info("bless id: {}, name: {}, amount: {}", name_it.first, name_it.second, blessAmount); + msg.addByte((it != blessingsObtained.end()) ? static_cast(it->second) : 0x00); } uint8_t preySlotsUnlocked = 0; @@ -4001,7 +4000,7 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() { auto houseItems = player->cyclopedia()->getResult(static_cast(Summary_t::HOUSE_ITEMS)); msg.add(houseItems.size()); for (const auto &hItem_it : houseItems) { - const ItemType &it = Item::items[std::stoll(hItem_it.first)]; + const ItemType &it = Item::items[hItem_it.first]; msg.add(it.id); // Item ID msg.addString(it.name, "ProtocolGame::sendCyclopediaCharacterStoreSummary - houseItem.name"); msg.addByte(hItem_it.second);