diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.cpp b/src/creatures/players/cyclopedia/player_cyclopedia.cpp deleted file mode 100644 index 5261d2a2ca5..00000000000 --- a/src/creatures/players/cyclopedia/player_cyclopedia.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Canary - A free and open-source MMORPG server emulator - * Copyright (©) 2019-2024 OpenTibiaBR - * Repository: https://github.com/opentibiabr/canary - * License: https://github.com/opentibiabr/canary/blob/main/LICENSE - * Contributors: https://github.com/opentibiabr/canary/graphs/contributors - * Website: https://docs.opentibiabr.com/ - */ - -#include "pch.hpp" - -#include "player_cyclopedia.hpp" - -#include "creatures/players/player.hpp" -#include "game/game.hpp" -#include "kv/kv.hpp" - -PlayerCyclopedia::PlayerCyclopedia(Player &player) : - m_player(player) { } - -void PlayerCyclopedia::loadSummaryData() { - // todo create player summary -} - -void PlayerCyclopedia::addXpBoostsObtained(uint16_t amount) { - m_storeXpBoosts += amount; -} - -void PlayerCyclopedia::addRewardCollectionObtained(uint16_t amount) { - m_dailyRewardCollections += amount; -} - -void PlayerCyclopedia::addHirelingsObtained(uint16_t amount) { - m_hirelings += amount; -} - -void PlayerCyclopedia::addPreyCardsObtained(uint16_t amount) { - m_preyCards += amount; -} - -void PlayerCyclopedia::addCharmsPointsObtained(uint16_t amount) { - m_charms += amount; -} - -void PlayerCyclopedia::addGoshnarTaintsObtained(uint16_t amount) { - m_goshnar += amount; -} - -void PlayerCyclopedia::addDromePointsObtained(uint16_t amount) { - m_drome += amount; -} - -void PlayerCyclopedia::addLoginStreak(uint16_t amount) { - m_loginStreak += amount; -} - -void PlayerCyclopedia::addTaskHuntingPointsObtained(uint16_t amount) { - m_taskHuntingPoints += amount; -} - -void PlayerCyclopedia::addMapAreaDiscoveredPercentage(uint16_t amount) { - m_mapAreaDiscoveredPercentage += amount; -} - -void PlayerCyclopedia::addHirelingOutfitObtained(uint16_t lookType) { - m_hirelingOutfits.push_back(lookType); -} - -void PlayerCyclopedia::addHirelingJobsObtained(uint8_t jobId) { - m_hirelingJobs.push_back(jobId); -} - -void PlayerCyclopedia::addBlessingsObtained(Blessings_t id, uint16_t amount) { - m_blessings[id] += amount; -} - -// void PlayerCyclopedia::addHouseItemsObtained(uint16_t itemId, uint32_t amount) { -// m_houseItems[itemId] += amount; -// } - -// std::map> PlayerCyclopedia::getAccountLevelVocation() const { -// return accountLevelSummary; -// } - -std::vector PlayerCyclopedia::getDeathHistory() const { - return m_deathHistory; -} - -void PlayerCyclopedia::insertDeathOnHistory(std::string cause, uint32_t timestamp) { - m_deathHistory.emplace_back(std::move(cause), timestamp); -} - -std::vector PlayerCyclopedia::getPvpKillsHistory() const { - return m_pvpKillsHistory; -} - -void PlayerCyclopedia::insertPvpKillOnHistory(std::string cause, uint32_t timestamp, uint8_t status) { - m_pvpKillsHistory.emplace_back(std::move(cause), timestamp, status); -} - -// const std::shared_ptr &PlayerTitle::getSummary(std::string &key) { -// return m_player.kv()->scoped("titles")->scoped("summary")->get(key); -// } -// -// uint16_t PlayerAchievement::getPoints() const { -// return m_player.kv()->scoped("achievements")->get("points")->getNumber(); -// } -// -// void PlayerAchievement::addPoints(uint16_t toAddPoints) { -// auto oldPoints = getPoints(); -// m_player.kv()->scoped("achievements")->set("points", oldPoints + toAddPoints); -// } diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.hpp b/src/creatures/players/cyclopedia/player_cyclopedia.hpp deleted file mode 100644 index 0cb431847b2..00000000000 --- a/src/creatures/players/cyclopedia/player_cyclopedia.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Canary - A free and open-source MMORPG server emulator - * Copyright (©) 2019-2024 OpenTibiaBR - * Repository: https://github.com/opentibiabr/canary - * License: https://github.com/opentibiabr/canary/blob/main/LICENSE - * Contributors: https://github.com/opentibiabr/canary/graphs/contributors - * Website: https://docs.opentibiabr.com/ - */ - -#pragma once - -class Player; -class KV; - -struct Summary { - uint16_t m_storeXpBoosts = 0; - uint16_t m_dailyRewardCollections = 0; - uint16_t m_hirelings = 0; - uint16_t m_preyCards = 0; - uint16_t m_charms = 0; - uint16_t m_goshnar = 0; - uint16_t m_drome = 0; - uint16_t m_loginStreak = 0; - uint16_t m_taskHuntingPoints = 0; - uint16_t m_mapAreaDiscoveredPercentage = 0; - - std::vector m_hirelingOutfits; - std::vector m_hirelingJobs; - std::map m_blessings; - - Summary(uint16_t mStoreXpBoosts, uint16_t mDailyRewardCollections, uint16_t mHirelings, uint16_t mPreyCards, uint16_t mCharms, uint16_t mGoshnar, uint16_t mDrome, uint16_t mLoginStreak, uint16_t mTaskHuntingPoints, uint16_t mMapAreaDiscoveredPercentage, const std::vector &mHirelingOutfits, const std::vector &mHirelingJobs, const std::map &mBlessings) : - m_storeXpBoosts(mStoreXpBoosts), m_dailyRewardCollections(mDailyRewardCollections), m_hirelings(mHirelings), m_preyCards(mPreyCards), m_charms(mCharms), m_goshnar(mGoshnar), m_drome(mDrome), m_loginStreak(mLoginStreak), m_taskHuntingPoints(mTaskHuntingPoints), m_mapAreaDiscoveredPercentage(mMapAreaDiscoveredPercentage), m_hirelingOutfits(mHirelingOutfits), m_hirelingJobs(mHirelingJobs), m_blessings(mBlessings) { } -}; - -class PlayerCyclopedia { -public: - explicit PlayerCyclopedia(Player &player); - - Summary getSummary() { - return Summary(m_storeXpBoosts, m_dailyRewardCollections, m_hirelings, m_preyCards, m_charms, m_goshnar, m_drome, m_loginStreak, m_taskHuntingPoints, m_mapAreaDiscoveredPercentage, m_hirelingOutfits, m_hirelingJobs, m_blessings); - } - void loadSummaryData(); - - void addXpBoostsObtained(uint16_t amount); - void addRewardCollectionObtained(uint16_t amount); - void addHirelingsObtained(uint16_t amount); - void addPreyCardsObtained(uint16_t amount); - void addCharmsPointsObtained(uint16_t amount); - void addGoshnarTaintsObtained(uint16_t amount); - void addDromePointsObtained(uint16_t amount); - void addLoginStreak(uint16_t amount); - void addTaskHuntingPointsObtained(uint16_t amount); - void addMapAreaDiscoveredPercentage(uint16_t amount); - - void addHirelingOutfitObtained(uint16_t lookType); - void addHirelingJobsObtained(uint8_t jobId); - void addBlessingsObtained(Blessings_t id, uint16_t amount); - // void addHouseItemsObtained(uint16_t itemId, uint32_t amount); - - [[nodiscard]] std::vector getDeathHistory() const; - void insertDeathOnHistory(std::string cause, uint32_t timestamp); - [[nodiscard]] std::vector getPvpKillsHistory() const; - void insertPvpKillOnHistory(std::string cause, uint32_t timestamp, uint8_t status); - -private: - uint16_t m_storeXpBoosts = 0; - uint16_t m_dailyRewardCollections = 0; - uint16_t m_hirelings = 0; - uint16_t m_preyCards = 0; - uint16_t m_charms = 0; - uint16_t m_goshnar = 0; - uint16_t m_drome = 0; - uint16_t m_loginStreak = 0; - uint16_t m_taskHuntingPoints = 0; - uint16_t m_mapAreaDiscoveredPercentage = 0; - - std::vector m_hirelingOutfits; - std::vector m_hirelingJobs; - std::map m_blessings; - - // StashItemList houseItems; - // std::map> m_accountLevelSummary; - - std::vector m_deathHistory; - std::vector m_pvpKillsHistory; - - Player &m_player; -}; diff --git a/src/game/game.cpp b/src/game/game.cpp index 6b21c42baf9..8afc605bd83 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -8500,15 +8500,10 @@ void Game::processHighscoreResults(DBResult_ptr result, uint32_t playerID, uint8 characters.reserve(result->countResults()); if (result) { do { - uint8_t characterVocation; const auto &voc = g_vocations().getVocation(result->getNumber("vocation")); - if (voc) { - characterVocation = voc->getClientId(); - } else { - characterVocation = 0; - } - // todo get char title - characters.emplace_back(std::move(result->getString("name")), result->getNumber("points"), result->getNumber("id"), result->getNumber("rank"), result->getNumber("level"), characterVocation, 0); + uint8_t characterVocation = voc ? voc->getClientId() : 0; + std::string characterTitle = ""; + characters.emplace_back(std::move(result->getString("name")), result->getNumber("points"), result->getNumber("id"), result->getNumber("rank"), result->getNumber("level"), characterVocation, characterTitle); } while (result->next()); } diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 0fdf3644710..da95f563516 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -2190,7 +2190,7 @@ void ProtocolGame::sendHighscores(const std::vector &charact for (const HighscoreCharacter &character : characters) { msg.add(character.rank); // Rank msg.addString(character.name, "ProtocolGame::sendHighscores - character.name"); // Character Name - msg.addString("", "ProtocolGame::sendHighscores - empty"); // Probably Character Title(not visible in window) + msg.addString(character.title, "ProtocolGame::sendHighscores - character.title"); // Character Title msg.addByte(character.vocation); // Vocation Id msg.addString(g_configManager().getString(SERVER_NAME, __FUNCTION__), "ProtocolGame::sendHighscores - g_configManager().getString(SERVER_NAME)"); // World msg.add(character.level); // Level diff --git a/src/server/server_definitions.hpp b/src/server/server_definitions.hpp index 151f0e2e23b..3223b077bf0 100644 --- a/src/server/server_definitions.hpp +++ b/src/server/server_definitions.hpp @@ -113,7 +113,7 @@ enum Supply_Stash_Actions_t : uint8_t { }; struct HighscoreCharacter { - HighscoreCharacter(std::string name, uint64_t points, uint32_t id, uint32_t rank, uint16_t level, uint8_t vocation, uint8_t title) : + HighscoreCharacter(std::string name, uint64_t points, uint32_t id, uint32_t rank, uint16_t level, uint8_t vocation, std::string title) : name(std::move(name)), points(points), id(id), @@ -128,5 +128,5 @@ struct HighscoreCharacter { uint32_t rank; uint16_t level; uint8_t vocation; - uint8_t title; + std::string title; }; diff --git a/src/utils/const.hpp b/src/utils/const.hpp index 581fb36ff5f..c3f82df7ff7 100644 --- a/src/utils/const.hpp +++ b/src/utils/const.hpp @@ -21,9 +21,6 @@ static constexpr int32_t CHANNEL_GUILD = 0x00; static constexpr int32_t CHANNEL_PARTY = 0x01; static constexpr int32_t CHANNEL_PRIVATE = 0xFFFF; -// Highscore interval time to reload from database in seconds -static constexpr int64_t EVENT_HIGHSCORE_INTERVAL = 3600; - // This is in miliseconds static constexpr int32_t EVENT_IMBUEMENT_INTERVAL = 1000; static constexpr uint8_t IMBUEMENT_MAX_TIER = 3;