From 0c148ac7195562f93baf5f9bc2b44aace8067c0c Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 12 Apr 2024 01:54:35 +0000 Subject: [PATCH] Code format - (Clang-format) --- src/canary_server.cpp | 2 +- .../players/cyclopedia/player_badge.cpp | 72 ++--- .../players/cyclopedia/player_badge.hpp | 46 +-- .../players/cyclopedia/player_cyclopedia.hpp | 2 +- .../players/cyclopedia/player_title.cpp | 90 +++--- .../players/cyclopedia/player_title.hpp | 140 ++++----- src/creatures/players/player.cpp | 14 +- src/creatures/players/player.hpp | 22 +- src/game/game.cpp | 56 ++-- src/game/game.hpp | 292 ++++++++---------- src/game/game_definitions.hpp | 62 ++-- src/io/functions/iologindata_load_player.cpp | 4 +- .../functions/core/game/game_functions.cpp | 132 ++++---- .../functions/core/game/game_functions.hpp | 26 +- .../creatures/player/player_functions.hpp | 2 +- src/server/network/protocol/protocolgame.cpp | 14 +- 16 files changed, 459 insertions(+), 517 deletions(-) diff --git a/src/canary_server.cpp b/src/canary_server.cpp index 2970ab2ea5f..2bf02624a2d 100644 --- a/src/canary_server.cpp +++ b/src/canary_server.cpp @@ -374,7 +374,7 @@ void CanaryServer::loadModules() { modulesLoadHelper((g_npcs().load(false, true)), "npc"); g_game().loadBoostedCreature(); - // TODO: g_game().initializeCyclopedia(); + // TODO: g_game().initializeCyclopedia(); // TODO: verify g_game().initializeGameWorldHighscores(); g_ioBosstiary().loadBoostedBoss(); g_ioprey().initializeTaskHuntOptions(); diff --git a/src/creatures/players/cyclopedia/player_badge.cpp b/src/creatures/players/cyclopedia/player_badge.cpp index e8f79343810..9cd81a504fe 100644 --- a/src/creatures/players/cyclopedia/player_badge.cpp +++ b/src/creatures/players/cyclopedia/player_badge.cpp @@ -19,9 +19,9 @@ PlayerBadge::PlayerBadge(Player &player) : m_player(player) { } bool PlayerBadge::hasBadge(uint8_t id) const { - if (id == 0) { - return false; - } + if (id == 0) { + return false; + } if (auto it = std::find_if(m_badgesUnlocked.begin(), m_badgesUnlocked.end(), [id](auto badge_it) { return badge_it.first == id; @@ -34,47 +34,47 @@ bool PlayerBadge::hasBadge(uint8_t id) const { } bool PlayerBadge::add(uint8_t id, uint32_t timestamp /* = 0*/) { - if (hasBadge(id)) { - return false; - } - - const Badge &badge = g_game().getBadgeById(id); - if (badge.m_id == 0) { - return false; - } - - int toSaveTimeStamp = timestamp != 0 ? timestamp : (OTSYS_TIME() / 1000); - getUnlockedKV()->set(badge.m_name, toSaveTimeStamp); - m_badgesUnlocked.push_back({badge.m_id, toSaveTimeStamp}); - m_badgesUnlocked.shrink_to_fit(); - return true; + if (hasBadge(id)) { + return false; + } + + const Badge &badge = g_game().getBadgeById(id); + if (badge.m_id == 0) { + return false; + } + + int toSaveTimeStamp = timestamp != 0 ? timestamp : (OTSYS_TIME() / 1000); + getUnlockedKV()->set(badge.m_name, toSaveTimeStamp); + m_badgesUnlocked.push_back({ badge.m_id, toSaveTimeStamp }); + m_badgesUnlocked.shrink_to_fit(); + return true; } std::vector> PlayerBadge::getUnlockedBadges() const { - return m_badgesUnlocked; + return m_badgesUnlocked; } void PlayerBadge::loadUnlockedBadges() { - const auto &unlockedBadges = getUnlockedKV()->keys(); - g_logger().debug("[{}] - Loading unlocked badges: {}", __FUNCTION__, unlockedBadges.size()); - for (const auto &uBadge: unlockedBadges) { - auto id = static_cast(std::stoul(uBadge)); - const Badge &badge = g_game().getBadgeById(static_cast(id)); - if (badge.m_id == 0) { - g_logger().error("[{}] - Badge {} not found.", __FUNCTION__, uBadge); - continue; - } - - g_logger().debug("[{}] - Badge {} found for player {}.", __FUNCTION__, badge.m_name, m_player.getName()); - - m_badgesUnlocked.push_back({badge.m_id, getUnlockedKV()->get(uBadge)->getNumber()}); - } + const auto &unlockedBadges = getUnlockedKV()->keys(); + g_logger().debug("[{}] - Loading unlocked badges: {}", __FUNCTION__, unlockedBadges.size()); + for (const auto &uBadge : unlockedBadges) { + auto id = static_cast(std::stoul(uBadge)); + const Badge &badge = g_game().getBadgeById(static_cast(id)); + if (badge.m_id == 0) { + g_logger().error("[{}] - Badge {} not found.", __FUNCTION__, uBadge); + continue; + } + + g_logger().debug("[{}] - Badge {} found for player {}.", __FUNCTION__, badge.m_name, m_player.getName()); + + m_badgesUnlocked.push_back({ badge.m_id, getUnlockedKV()->get(uBadge)->getNumber() }); + } } const std::shared_ptr &PlayerBadge::getUnlockedKV() { - if (m_badgeUnlockedKV == nullptr) { - m_badgeUnlockedKV = m_player.kv()->scoped("badges")->scoped("unlocked"); - } + if (m_badgeUnlockedKV == nullptr) { + m_badgeUnlockedKV = m_player.kv()->scoped("badges")->scoped("unlocked"); + } - return m_badgeUnlockedKV; + return m_badgeUnlockedKV; } diff --git a/src/creatures/players/cyclopedia/player_badge.hpp b/src/creatures/players/cyclopedia/player_badge.hpp index 88da24381a9..2bffab0764d 100644 --- a/src/creatures/players/cyclopedia/player_badge.hpp +++ b/src/creatures/players/cyclopedia/player_badge.hpp @@ -13,28 +13,28 @@ class Player; class KV; struct Badge { - uint8_t m_id = 0; - CyclopediaBadgeType_t m_type; - std::string m_name; - uint16_t m_amount = 0; + uint8_t m_id = 0; + CyclopediaBadgeType_t m_type; + std::string m_name; + uint16_t m_amount = 0; - Badge() = default; + Badge() = default; - Badge(uint8_t id, CyclopediaBadgeType_t type, const std::string &name, uint16_t amount) : - m_id(id), m_type(type), m_name(name), m_amount(amount) {} + Badge(uint8_t id, CyclopediaBadgeType_t type, const std::string &name, uint16_t amount) : + m_id(id), m_type(type), m_name(name), m_amount(amount) { } - bool operator==(const Badge &other) const { - return m_id == other.m_id; - } + bool operator==(const Badge &other) const { + return m_id == other.m_id; + } }; namespace std { - template<> - struct hash { - std::size_t operator()(const Badge &b) const { - return hash()(b.m_id); // Use o ID como base para o hash - } - }; + template <> + struct hash { + std::size_t operator()(const Badge &b) const { + return hash()(b.m_id); // Use o ID como base para o hash + } + }; } class PlayerBadge { @@ -42,14 +42,14 @@ class PlayerBadge { explicit PlayerBadge(Player &player); bool hasBadge(uint8_t id) const; - bool add(uint8_t id, uint32_t timestamp = 0); - std::vector> getUnlockedBadges() const; - void loadUnlockedBadges(); - const std::shared_ptr &getUnlockedKV(); + bool add(uint8_t id, uint32_t timestamp = 0); + std::vector> getUnlockedBadges() const; + void loadUnlockedBadges(); + const std::shared_ptr &getUnlockedKV(); private: - // {badge ID, time when it was unlocked} - std::shared_ptr m_badgeUnlockedKV; - std::vector> m_badgesUnlocked; + // {badge ID, time when it was unlocked} + std::shared_ptr m_badgeUnlockedKV; + std::vector> m_badgesUnlocked; Player &m_player; }; diff --git a/src/creatures/players/cyclopedia/player_cyclopedia.hpp b/src/creatures/players/cyclopedia/player_cyclopedia.hpp index 58098f84861..5b190fb12c7 100644 --- a/src/creatures/players/cyclopedia/player_cyclopedia.hpp +++ b/src/creatures/players/cyclopedia/player_cyclopedia.hpp @@ -41,5 +41,5 @@ class PlayerCyclopedia { std::vector m_deathHistory; std::vector m_pvpKillsHistory; -// std::map> m_accountLevelSummary; + // std::map> m_accountLevelSummary; }; diff --git a/src/creatures/players/cyclopedia/player_title.cpp b/src/creatures/players/cyclopedia/player_title.cpp index 348ccae4fd9..77e5ce6c032 100644 --- a/src/creatures/players/cyclopedia/player_title.cpp +++ b/src/creatures/players/cyclopedia/player_title.cpp @@ -19,39 +19,39 @@ PlayerTitle::PlayerTitle(Player &player) : m_player(player) { } bool PlayerTitle::isTitleUnlocked(uint8_t id) const { - if (id == 0) { - return false; - } - - if (auto it = std::find_if(m_titlesUnlocked.begin(), m_titlesUnlocked.end(), [id](auto title_it) { - return title_it == id; - }); - it != m_titlesUnlocked.end()) { - return true; - } - - return false; + if (id == 0) { + return false; + } + + if (auto it = std::find_if(m_titlesUnlocked.begin(), m_titlesUnlocked.end(), [id](auto title_it) { + return title_it == id; + }); + it != m_titlesUnlocked.end()) { + return true; + } + + return false; } bool PlayerTitle::add(uint8_t id, uint32_t timestamp /* = 0*/) { - if (isTitleUnlocked(id)) { - return false; - } - - const Title &title = g_game().getTitleById(id); - if (title.m_id == 0) { - return false; - } - - int toSaveTimeStamp = timestamp != 0 ? timestamp : (OTSYS_TIME() / 1000); - getUnlockedKV()->set(title.m_maleName, toSaveTimeStamp); - m_titlesUnlocked.push_back({title.m_id, toSaveTimeStamp}); - m_titlesUnlocked.shrink_to_fit(); - return true; + if (isTitleUnlocked(id)) { + return false; + } + + const Title &title = g_game().getTitleById(id); + if (title.m_id == 0) { + return false; + } + + int toSaveTimeStamp = timestamp != 0 ? timestamp : (OTSYS_TIME() / 1000); + getUnlockedKV()->set(title.m_maleName, toSaveTimeStamp); + m_titlesUnlocked.push_back({ title.m_id, toSaveTimeStamp }); + m_titlesUnlocked.shrink_to_fit(); + return true; } std::vector> PlayerTitle::getUnlockedTitles() const { - return m_titlesUnlocked; + return m_titlesUnlocked; } uint8_t PlayerTitle::getCurrentTitle() const { @@ -77,26 +77,26 @@ void PlayerTitle::setCurrentTitle(uint8_t id) { } void PlayerTitle::loadUnlockedTitles() { - const auto &unlockedTitles = getUnlockedKV()->keys(); - g_logger().debug("[{}] - Loading unlocked titles: {}", __FUNCTION__, unlockedTitles.size()); - for (const auto &uTitle: unlockedTitles) { - auto id = static_cast(std::stoul(uTitle)); - const Title &title = g_game().getTitleById(static_cast(id)); - if (title.m_id == 0) { - g_logger().error("[{}] - Title {} not found.", __FUNCTION__, uTitle); - continue; - } - - g_logger().debug("[{}] - Title {} found for player {}.", __FUNCTION__, title.m_maleName, m_player.getName()); - - m_titlesUnlocked.push_back({title.m_id, getUnlockedKV()->get(uTitle)->getNumber()}); - } + const auto &unlockedTitles = getUnlockedKV()->keys(); + g_logger().debug("[{}] - Loading unlocked titles: {}", __FUNCTION__, unlockedTitles.size()); + for (const auto &uTitle : unlockedTitles) { + auto id = static_cast(std::stoul(uTitle)); + const Title &title = g_game().getTitleById(static_cast(id)); + if (title.m_id == 0) { + g_logger().error("[{}] - Title {} not found.", __FUNCTION__, uTitle); + continue; + } + + g_logger().debug("[{}] - Title {} found for player {}.", __FUNCTION__, title.m_maleName, m_player.getName()); + + m_titlesUnlocked.push_back({ title.m_id, getUnlockedKV()->get(uTitle)->getNumber() }); + } } const std::shared_ptr &PlayerTitle::getUnlockedKV() { - if (m_titleUnlockedKV == nullptr) { - m_titleUnlockedKV = m_player.kv()->scoped("titles")->scoped("unlocked"); - } + if (m_titleUnlockedKV == nullptr) { + m_titleUnlockedKV = m_player.kv()->scoped("titles")->scoped("unlocked"); + } - return m_titleUnlockedKV; + return m_titleUnlockedKV; } diff --git a/src/creatures/players/cyclopedia/player_title.hpp b/src/creatures/players/cyclopedia/player_title.hpp index 82b512c765e..4fe3f494575 100644 --- a/src/creatures/players/cyclopedia/player_title.hpp +++ b/src/creatures/players/cyclopedia/player_title.hpp @@ -13,91 +13,85 @@ class Player; class KV; struct TitleStorage { - uint32_t key; - uint32_t value; - bool kv = false; + uint32_t key; + uint32_t value; + bool kv = false; - TitleStorage() = default; + TitleStorage() = default; - TitleStorage(uint32_t key, uint32_t value, bool kv) : key(key), value(value), kv(kv) {} + TitleStorage(uint32_t key, uint32_t value, bool kv) : + key(key), value(value), kv(kv) { } }; struct Title { - uint8_t m_id; - CyclopediaTitleType_t m_type; - std::string m_maleName; - std::string m_femaleName = ""; - std::string m_description; - uint32_t m_amount = 0; - bool m_permanent = false; - uint8_t m_skill = 0; - uint16_t m_race = 0; - TitleStorage m_storage = {}; - - Title() = default; - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, - uint32_t amount) - : m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount) {} - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, - uint32_t amount, bool permanent) - : m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount), - m_permanent(permanent) {} - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, - uint32_t amount, bool permanent, const std::string &femaleName) - : m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount), - m_permanent(permanent), m_femaleName(femaleName) {} - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &femaleName, - const std::string &description, uint8_t skill) - : m_id(id), m_type(type), m_maleName(maleName), m_femaleName(femaleName), m_description(description), - m_skill(skill) {} - - Title(uint8_t id, CyclopediaTitleType_t type, uint16_t race, const std::string &maleName, - const std::string &femaleName, const std::string &description) - : m_id(id), m_type(type), m_race(race), m_maleName(maleName), m_femaleName(femaleName), - m_description(description) {} - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, - TitleStorage titleStorage, bool permanent) - : m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_storage(titleStorage), m_permanent(permanent) {} - - Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, - bool permanent) - : m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_permanent(permanent) {} - - bool operator==(const Title &other) const { - return m_id == other.m_id; - } + uint8_t m_id; + CyclopediaTitleType_t m_type; + std::string m_maleName; + std::string m_femaleName = ""; + std::string m_description; + uint32_t m_amount = 0; + bool m_permanent = false; + uint8_t m_skill = 0; + uint16_t m_race = 0; + TitleStorage m_storage = {}; + + Title() = default; + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, uint32_t amount) : + m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount) { } + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, uint32_t amount, bool permanent) : + m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount), + m_permanent(permanent) { } + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, uint32_t amount, bool permanent, const std::string &femaleName) : + m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_amount(amount), + m_permanent(permanent), m_femaleName(femaleName) { } + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &femaleName, const std::string &description, uint8_t skill) : + m_id(id), m_type(type), m_maleName(maleName), m_femaleName(femaleName), m_description(description), + m_skill(skill) { } + + Title(uint8_t id, CyclopediaTitleType_t type, uint16_t race, const std::string &maleName, const std::string &femaleName, const std::string &description) : + m_id(id), m_type(type), m_race(race), m_maleName(maleName), m_femaleName(femaleName), + m_description(description) { } + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, TitleStorage titleStorage, bool permanent) : + m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_storage(titleStorage), m_permanent(permanent) { } + + Title(uint8_t id, CyclopediaTitleType_t type, const std::string &maleName, const std::string &description, bool permanent) : + m_id(id), m_type(type), m_maleName(maleName), m_description(description), m_permanent(permanent) { } + + bool operator==(const Title &other) const { + return m_id == other.m_id; + } }; namespace std { - template<> - struct hash { - std::size_t operator()(const Title &t) const { - return hash<uint8_t>()(t.m_id); // Use o ID como base para o hash - } - }; + template <> + struct hash<Title> { + std::size_t operator()(const Title &t) const { + return hash<uint8_t>()(t.m_id); // Use o ID como base para o hash + } + }; } class PlayerTitle { public: - explicit PlayerTitle(Player &player); - bool isTitleUnlocked(uint8_t id) const; - bool add(uint8_t id, uint32_t timestamp = 0); - std::vector<std::pair<uint8_t, uint32_t>> getUnlockedTitles() const; - uint8_t getCurrentTitle() const; - std::string getCurrentTitleName() const; - void setCurrentTitle(uint8_t id); - void loadUnlockedTitles(); - const std::shared_ptr<KV> &getUnlockedKV(); + explicit PlayerTitle(Player &player); + bool isTitleUnlocked(uint8_t id) const; + bool add(uint8_t id, uint32_t timestamp = 0); + std::vector<std::pair<uint8_t, uint32_t>> getUnlockedTitles() const; + uint8_t getCurrentTitle() const; + std::string getCurrentTitleName() const; + void setCurrentTitle(uint8_t id); + void loadUnlockedTitles(); + const std::shared_ptr<KV> &getUnlockedKV(); private: - // {title ID, time when it was unlocked} - std::shared_ptr<KV> m_titleUnlockedKV; - std::vector<std::pair<uint8_t, uint32_t>> m_titlesUnlocked; - uint8_t m_currentTitle; - Player &m_player; + // {title ID, time when it was unlocked} + std::shared_ptr<KV> m_titleUnlockedKV; + std::vector<std::pair<uint8_t, uint32_t>> m_titlesUnlocked; + uint8_t m_currentTitle; + Player &m_player; }; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index b06e0be2861..ceacf55531e 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -52,9 +52,9 @@ Player::Player(ProtocolGame_ptr p) : client(std::move(p)) { m_wheelPlayer = std::make_unique<PlayerWheel>(*this); m_playerAchievement = std::make_unique<PlayerAchievement>(*this); - m_playerBadge = std::make_unique<PlayerBadge>(*this); - m_playerCyclopedia = std::make_unique<PlayerCyclopedia>(*this); - m_playerTitle = std::make_unique<PlayerTitle>(*this); + m_playerBadge = std::make_unique<PlayerBadge>(*this); + m_playerCyclopedia = std::make_unique<PlayerCyclopedia>(*this); + m_playerTitle = std::make_unique<PlayerTitle>(*this); } Player::~Player() { @@ -8011,11 +8011,11 @@ const std::unique_ptr<PlayerAchievement> &Player::achiev() const { // Badge interface std::unique_ptr<PlayerBadge> &Player::badge() { - return m_playerBadge; + return m_playerBadge; } const std::unique_ptr<PlayerBadge> &Player::badge() const { - return m_playerBadge; + return m_playerBadge; } std::unique_ptr<PlayerCyclopedia> &Player::cyclopedia() { @@ -8027,11 +8027,11 @@ const std::unique_ptr<PlayerCyclopedia> &Player::cyclopedia() const { } std::unique_ptr<PlayerTitle> &Player::title() { - return m_playerTitle; + return m_playerTitle; } const std::unique_ptr<PlayerTitle> &Player::title() const { - return m_playerTitle; + return m_playerTitle; } void Player::sendLootMessage(const std::string &message) const { diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index c0075be101c..27301ead0b6 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -2602,17 +2602,17 @@ class Player final : public Creature, public Cylinder, public Bankable { std::unique_ptr<PlayerAchievement> &achiev(); const std::unique_ptr<PlayerAchievement> &achiev() const; - // Player badge interface - std::unique_ptr<PlayerBadge> &badge(); - const std::unique_ptr<PlayerBadge> &badge() const; + // Player badge interface + std::unique_ptr<PlayerBadge> &badge(); + const std::unique_ptr<PlayerBadge> &badge() const; // Player summary interface std::unique_ptr<PlayerCyclopedia> &cyclopedia(); const std::unique_ptr<PlayerCyclopedia> &cyclopedia() const; - // Player title interface - std::unique_ptr<PlayerTitle> &title(); - const std::unique_ptr<PlayerTitle> &title() const; + // Player title interface + std::unique_ptr<PlayerTitle> &title(); + const std::unique_ptr<PlayerTitle> &title() const; void sendLootMessage(const std::string &message) const; @@ -3007,15 +3007,15 @@ class Player final : public Creature, public Cylinder, public Bankable { friend class IOLoginDataLoad; friend class IOLoginDataSave; friend class PlayerAchievement; - friend class PlayerBadge; - friend class PlayerCyclopedia; - friend class PlayerTitle; + friend class PlayerBadge; + friend class PlayerCyclopedia; + friend class PlayerTitle; std::unique_ptr<PlayerWheel> m_wheelPlayer; std::unique_ptr<PlayerAchievement> m_playerAchievement; std::unique_ptr<PlayerBadge> m_playerBadge; - std::unique_ptr<PlayerCyclopedia> m_playerCyclopedia; - std::unique_ptr<PlayerTitle> m_playerTitle; + std::unique_ptr<PlayerCyclopedia> m_playerCyclopedia; + std::unique_ptr<PlayerTitle> m_playerTitle; std::mutex quickLootMutex; diff --git a/src/game/game.cpp b/src/game/game.cpp index c6a9ff9f9e4..fb21a81c684 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -10499,46 +10499,46 @@ std::map<uint16_t, Achievement> Game::getAchievements() { return m_achievements; } -//void Game::initializeCyclopedia() { +// void Game::initializeCyclopedia() { // -//} +// } const Badge Game::getBadgeById(uint8_t id) { - auto it = std::find_if(m_badges.begin(), m_badges.end(), [id](const Badge &b) { - return b.m_id == id; - }); - if (it != m_badges.end()) { - return *it; - } - return Badge(); + auto it = std::find_if(m_badges.begin(), m_badges.end(), [id](const Badge &b) { + return b.m_id == id; + }); + if (it != m_badges.end()) { + return *it; + } + return Badge(); } std::unordered_set<Badge> Game::getBadges() { - return m_badges; + return m_badges; } -//void Game::registerTitle(uint8_t id, std::string maleName, std::string femaleName, std::string type, std::string description, bool permanent) { -// m_titles[id] = Title(); -// m_titles[id].id = id; -// m_titles[id].maleName = maleName; -// m_titles[id].femaleName = femaleName; -// m_titles[id].type = type; -// m_titles[id].description = description; -// m_titles[id].permanent = permanent; +// void Game::registerTitle(uint8_t id, std::string maleName, std::string femaleName, std::string type, std::string description, bool permanent) { +// m_titles[id] = Title(); +// m_titles[id].id = id; +// m_titles[id].maleName = maleName; +// m_titles[id].femaleName = femaleName; +// m_titles[id].type = type; +// m_titles[id].description = description; +// m_titles[id].permanent = permanent; // -// m_titlesNames.emplace(id, maleName); -//} +// m_titlesNames.emplace(id, maleName); +// } const Title Game::getTitleById(uint8_t id) { - auto it = std::find_if(m_titles.begin(), m_titles.end(), [id](const Title &t) { - return t.m_id == id; - }); - if (it != m_titles.end()) { - return *it; - } - return Title(); + auto it = std::find_if(m_titles.begin(), m_titles.end(), [id](const Title &t) { + return t.m_id == id; + }); + if (it != m_titles.end()) { + return *it; + } + return Title(); } std::map<uint8_t, Title> Game::getTitles() { - return m_titles; + return m_titles; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 3ac2a1a0a0e..dc4cd94d450 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -100,7 +100,7 @@ class Game { void forceRemoveCondition(uint32_t creatureId, ConditionType_t type, ConditionId_t conditionId); -// void initializeCyclopedia(); + // void initializeCyclopedia(); /** * Load the main map @@ -721,182 +721,132 @@ class Game { std::vector<Achievement> getPublicAchievements(); std::map<uint16_t, Achievement> getAchievements(); -// void registerBadge(uint8_t id, std::string name, uint16_t amount); - const Badge getBadgeById(uint8_t id); - std::unordered_set<Badge> getBadges(); + // void registerBadge(uint8_t id, std::string name, uint16_t amount); + const Badge getBadgeById(uint8_t id); + std::unordered_set<Badge> getBadges(); - void registerTitle(uint8_t id, std::string maleName, std::string femaleName, std::string type, std::string description, bool permanent); - Title getTitleById(uint8_t id); - std::map<uint8_t, Title> getTitles(); + void registerTitle(uint8_t id, std::string maleName, std::string femaleName, std::string type, std::string description, bool permanent); + Title getTitleById(uint8_t id); + std::map<uint8_t, Title> getTitles(); private: std::map<uint16_t, Achievement> m_achievements; std::map<std::string, uint16_t> m_achievementsNameToId; - std::unordered_set<Badge> m_badges = { - Badge(1, CyclopediaBadgeType_t::ACCOUNT_AGE, "Fledegeling Hero", 1), - Badge(2, CyclopediaBadgeType_t::ACCOUNT_AGE, "Veteran Hero", 5), - Badge(3, CyclopediaBadgeType_t::ACCOUNT_AGE, "Senior Hero", 10), - Badge(4, CyclopediaBadgeType_t::ACCOUNT_AGE, "Ancient Hero", 15), - Badge(5, CyclopediaBadgeType_t::ACCOUNT_AGE, "Exalted Hero", 20), - - Badge(6, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 1)", 100), - Badge(7, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 2)", 1000), - Badge(8, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 3)", 5000), - - Badge(9, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 1)", 500), - Badge(10, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 2)", 1000), - Badge(11, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 3)", 2000), - - Badge(12, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 1)", 100), - Badge(13, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 2)", 250), - Badge(14, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 3)", 500), - - Badge(15, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Freshman of the Tournament", 1), - Badge(16, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Regular of the Tournament", 5), - Badge(17, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Hero of the Tournament", 10), - - Badge(18, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Competitor", 1000), - Badge(19, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Challenger", 2500), - Badge(20, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Master", 5000), - Badge(21, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Champion", 10000), - }; - std::map<uint8_t, std::string> m_badgesNames; - - std::unordered_set<Title> m_titles = { - Title(1, CyclopediaTitleType_t::GOLD, "Gold Hoarder", "Earned at least 1,000,000 gold.", 1000000), - Title(2, CyclopediaTitleType_t::GOLD, "Platinum Hoarder", "Earned at least 10,000,000 gold.", 10000000), - Title(3, CyclopediaTitleType_t::GOLD, "Crystal Hoarder", "Earned at least 100,000,000 gold.", 100000000), - - Title(4, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 1)", "Unlocked 10 or more Mounts.", 10, true), - Title(5, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 2)", "Unlocked 20 or more Mounts.", 20, true), - Title(6, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 3)", "Unlocked 30 or more Mounts.", 30, true), - Title(7, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 4)", "Unlocked 40 or more Mounts.", 40, true), - Title(8, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 5)", "Unlocked 50 or more Mounts.", 50, true), - - Title(9, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 1)", "Unlocked 10 or more Outfits.", 10, - true), - Title(10, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 2)", "Unlocked 20 or more Outfits.", 20, - true), - Title(11, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 3)", "Unlocked 30 or more Outfits.", 30, - true), - Title(12, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 4)", "Unlocked 40 or more Outfits.", 40, - true), - Title(13, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 5)", "Unlocked 50 or more Outfits.", 50, - true), - - Title(14, CyclopediaTitleType_t::LEVEL, "Trolltrasher", "Reached level 50.", 50), - Title(15, CyclopediaTitleType_t::LEVEL, "Cyclopscamper", "Reached level 100.", 100), - Title(16, CyclopediaTitleType_t::LEVEL, "Dragondouser", "Reached level 200.", 200), - Title(17, CyclopediaTitleType_t::LEVEL, "Demondoom", "Reached level 300.", 300), - Title(18, CyclopediaTitleType_t::LEVEL, "Drakenbane", "Reached level 400.", 400), - Title(19, CyclopediaTitleType_t::LEVEL, "Silencer", "Reached level 500.", 500), - Title(20, CyclopediaTitleType_t::LEVEL, "Exalted", "Reached level 1000.", 1000), - - Title(21, CyclopediaTitleType_t::HIGHSCORES, "Legend of Fishing", "", - "Highest fishing level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::FISHING )), - Title(22, CyclopediaTitleType_t::HIGHSCORES, "Legend of Magic", "", - "Highest magic level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::MAGIC_LEVEL )), - Title(23, CyclopediaTitleType_t::HIGHSCORES, "Legend of Marksmanship", "", - "Highest distance level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::DISTANCE_FIGHTING )), - Title(24, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Axe", "", - "Highest axe level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::AXE_FIGHTING )), - Title(25, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Club", "", - "Highest club level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::CLUB_FIGHTING )), - Title(26, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Fist", "", - "Highest fist level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::FIST_FIGHTING )), - Title(27, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Shield", "", - "Highest shielding level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::SHIELDING )), - Title(28, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Sword", "", - "Highest sword level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::SWORD_FIGHTING )), - Title(29, CyclopediaTitleType_t::HIGHSCORES, "Apex Predator", "", "Highest Level on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::EXPERIENCE )), - Title(30, CyclopediaTitleType_t::HIGHSCORES, "Prince Charming", "Princess Charming", - "Highest score of accumulated charm points on character's world.", - static_cast<uint8_t>(HighscoreCategories_t::CHARMS)), - - Title(31, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_HUMANOID), - "Bipedantic", "", "Unlocked All Humanoid Bestiary entries." ), - Title(32, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_LYCANTHROPE), - "Blood Moon Hunter", "Blood Moon Huntress", "Unlocked All Lycanthrope Bestiary entries." ), - Title(33, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_AMPHIBIC), - "Coldblooded", "", "Unlocked All Amphibic Bestiary entries."), - Title(34, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_BIRD), - "Death from Below", "", "Unlocked all Bird Bestiary entries."), - Title(35, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_DEMON), - "Demonator", "", "Unlocked all Demon Bestiary entries."), - Title(36, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_DRAGON), - "Dragonslayer", "", "Unlocked all Dragon Bestiary entries."), - Title(37, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_ELEMENTAL), - "Elementalist", "", "Unlocked all Elemental Bestiary entries."), - Title(38, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_VERMIN), - "Exterminator", "", "Unlocked all Vermin Bestiary entries."), - Title(39, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_FEY), - "Fey Swatter", "", "Unlocked all Fey Bestiary entries."), - Title(40, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_UNDEAD), - "Ghosthunter", "Ghosthuntress", "Unlocked all Undead Bestiary entries."), - Title(41, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_CONSTRUCT), - "Handyman", "Handywoman", "Unlocked all Construct Bestiary entries."), - Title(42, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_MAMMAL), - "Huntsman", "Huntress", "Unlocked all Mammal Bestiary entries."), - Title(43, CyclopediaTitleType_t::BESTIARY, - static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_EXTRA_DIMENSIONAL), "Interdimensional Destroyer", "", - "Unlocked all Extra Dimensional Bestiary entries."), - Title(44, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_HUMAN), - "Manhunter", "Manhuntress", "Unlocked all Human Bestiary entries."), - Title(45, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_MAGICAL), - "Master of Illusion", "Mistress of Illusion", "Unlocked all Magical Bestiary entries."), - Title(46, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_SLIME), - "Ooze Blues", "", "Unlocked all Slime Bestiary entries."), - Title(47, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_AQUATIC), - "Sea Bane", "", "Unlocked all Aquatic Bestiary entries."), - Title(48, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_REPTILE), - "Snake Charmer", "", "Unlocked all Reptile Bestiary entries."), - Title(49, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_GIANT), - "Tumbler", "", "Unlocked all Giant Bestiary entries."), - Title(50, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_PLANT), - "Weedkiller", "", "Unlocked all Plant Bestiary entries."), - Title(51, CyclopediaTitleType_t::BESTIARY, 0, "Executioner", "", "Unlocked all Bestiary entries."), - - Title(52, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 1)", "Reward Streak of at least 7 days of consecutive logins.", 7, true), - Title(53, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 2)", "Reward Streak of at least 30 days of consecutive logins.", 30, true), - Title(54, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 3)", "Reward Streak of at least 90 days of consecutive logins.", 90, true), - Title(55, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 4)", "Reward Streak of at least 180 days of consecutive logins.", 180, true), - Title(56, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 5)", "Reward Streak of at least 365 days of consecutive logins.", 365, true), - - Title(57, CyclopediaTitleType_t::TASK, "Aspiring Huntsman", "Invested 160,000 tasks points.", 160000, true, "Aspiring Huntswoman"), - Title(58, CyclopediaTitleType_t::TASK, "Competent Beastslayer", "Invested 320,000 tasks points.", 320000, true), - Title(59, CyclopediaTitleType_t::TASK, "Feared Bountyhunter", "Invested 430,000 tasks points.", 430000, true), - - Title(60, CyclopediaTitleType_t::MAP, "Dedicated Entrepreneur", "Explored 50% of all the map areas.", 50), - Title(61, CyclopediaTitleType_t::MAP, "Globetrotter", "Explored all map areas.", 100), - - Title(62, CyclopediaTitleType_t::QUEST, "Planegazer", "Followed the trail of the Planestrider to the end.", - TitleStorage(1000, 1, false), true), - Title(63, CyclopediaTitleType_t::QUEST, "Hero of Bounac", "You prevailed during the battle of Bounac and broke the siege that held Bounac's people in its firm grasp.", - TitleStorage(1000, 1, false), true), - Title(64, CyclopediaTitleType_t::QUEST, "Royal Bounacean Advisor", "Called to the court of Bounac by Kesar the Younger himself.", - TitleStorage(1000, 1, false), true), - Title(65, CyclopediaTitleType_t::QUEST, "Time Traveller", "Anywhere in time or space.", - TitleStorage(1000, 1, false), true), - - Title(66, CyclopediaTitleType_t::OTHERS, "Admirer of the Crown", "Adjust your crown and handle it.", true), - Title(67, CyclopediaTitleType_t::OTHERS, "Big Spender", "Unlocked the full Golden Outfit.", true), - Title(68, CyclopediaTitleType_t::OTHERS, "Guild Leader", "Leading a Guild.", true), - Title(69, CyclopediaTitleType_t::OTHERS, "Jack of all Taints", "Highest score for killing Goshnar and his aspects on character's world.", true), - Title(70, CyclopediaTitleType_t::OTHERS, "Reigning Drome Champion", "Finished most recent Tibiadrome rota ranked in the top 5.", true), - - - - }; - std::map<uint8_t, std::string> m_titlesNames; + std::unordered_set<Badge> m_badges = { + Badge(1, CyclopediaBadgeType_t::ACCOUNT_AGE, "Fledegeling Hero", 1), + Badge(2, CyclopediaBadgeType_t::ACCOUNT_AGE, "Veteran Hero", 5), + Badge(3, CyclopediaBadgeType_t::ACCOUNT_AGE, "Senior Hero", 10), + Badge(4, CyclopediaBadgeType_t::ACCOUNT_AGE, "Ancient Hero", 15), + Badge(5, CyclopediaBadgeType_t::ACCOUNT_AGE, "Exalted Hero", 20), + + Badge(6, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 1)", 100), + Badge(7, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 2)", 1000), + Badge(8, CyclopediaBadgeType_t::LOYALTY, "Tibia Loyalist (Grade 3)", 5000), + + Badge(9, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 1)", 500), + Badge(10, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 2)", 1000), + Badge(11, CyclopediaBadgeType_t::ACCOUNT_ALL_LEVEL, "Global Player (Grade 3)", 2000), + + Badge(12, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 1)", 100), + Badge(13, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 2)", 250), + Badge(14, CyclopediaBadgeType_t::ACCOUNT_ALL_VOCATIONS, "Master Class (Grade 3)", 500), + + Badge(15, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Freshman of the Tournament", 1), + Badge(16, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Regular of the Tournament", 5), + Badge(17, CyclopediaBadgeType_t::TOURNAMENT_PARTICIPATION, "Hero of the Tournament", 10), + + Badge(18, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Competitor", 1000), + Badge(19, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Challenger", 2500), + Badge(20, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Master", 5000), + Badge(21, CyclopediaBadgeType_t::TOURNAMENT_POINTS, "Tournament Champion", 10000), + }; + std::map<uint8_t, std::string> m_badgesNames; + + std::unordered_set<Title> m_titles = { + Title(1, CyclopediaTitleType_t::GOLD, "Gold Hoarder", "Earned at least 1,000,000 gold.", 1000000), + Title(2, CyclopediaTitleType_t::GOLD, "Platinum Hoarder", "Earned at least 10,000,000 gold.", 10000000), + Title(3, CyclopediaTitleType_t::GOLD, "Crystal Hoarder", "Earned at least 100,000,000 gold.", 100000000), + + Title(4, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 1)", "Unlocked 10 or more Mounts.", 10, true), + Title(5, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 2)", "Unlocked 20 or more Mounts.", 20, true), + Title(6, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 3)", "Unlocked 30 or more Mounts.", 30, true), + Title(7, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 4)", "Unlocked 40 or more Mounts.", 40, true), + Title(8, CyclopediaTitleType_t::MOUNTS, "Beaststrider (Grade 5)", "Unlocked 50 or more Mounts.", 50, true), + + Title(9, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 1)", "Unlocked 10 or more Outfits.", 10, true), + Title(10, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 2)", "Unlocked 20 or more Outfits.", 20, true), + Title(11, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 3)", "Unlocked 30 or more Outfits.", 30, true), + Title(12, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 4)", "Unlocked 40 or more Outfits.", 40, true), + Title(13, CyclopediaTitleType_t::OUTFITS, "Tibia's Topmodel (Grade 5)", "Unlocked 50 or more Outfits.", 50, true), + + Title(14, CyclopediaTitleType_t::LEVEL, "Trolltrasher", "Reached level 50.", 50), + Title(15, CyclopediaTitleType_t::LEVEL, "Cyclopscamper", "Reached level 100.", 100), + Title(16, CyclopediaTitleType_t::LEVEL, "Dragondouser", "Reached level 200.", 200), + Title(17, CyclopediaTitleType_t::LEVEL, "Demondoom", "Reached level 300.", 300), + Title(18, CyclopediaTitleType_t::LEVEL, "Drakenbane", "Reached level 400.", 400), + Title(19, CyclopediaTitleType_t::LEVEL, "Silencer", "Reached level 500.", 500), + Title(20, CyclopediaTitleType_t::LEVEL, "Exalted", "Reached level 1000.", 1000), + + Title(21, CyclopediaTitleType_t::HIGHSCORES, "Legend of Fishing", "", "Highest fishing level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::FISHING)), + Title(22, CyclopediaTitleType_t::HIGHSCORES, "Legend of Magic", "", "Highest magic level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::MAGIC_LEVEL)), + Title(23, CyclopediaTitleType_t::HIGHSCORES, "Legend of Marksmanship", "", "Highest distance level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::DISTANCE_FIGHTING)), + Title(24, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Axe", "", "Highest axe level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::AXE_FIGHTING)), + Title(25, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Club", "", "Highest club level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::CLUB_FIGHTING)), + Title(26, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Fist", "", "Highest fist level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::FIST_FIGHTING)), + Title(27, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Shield", "", "Highest shielding level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::SHIELDING)), + Title(28, CyclopediaTitleType_t::HIGHSCORES, "Legend of the Sword", "", "Highest sword level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::SWORD_FIGHTING)), + Title(29, CyclopediaTitleType_t::HIGHSCORES, "Apex Predator", "", "Highest Level on character's world.", static_cast<uint8_t>(HighscoreCategories_t::EXPERIENCE)), + Title(30, CyclopediaTitleType_t::HIGHSCORES, "Prince Charming", "Princess Charming", "Highest score of accumulated charm points on character's world.", static_cast<uint8_t>(HighscoreCategories_t::CHARMS)), + + Title(31, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_HUMANOID), "Bipedantic", "", "Unlocked All Humanoid Bestiary entries."), + Title(32, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_LYCANTHROPE), "Blood Moon Hunter", "Blood Moon Huntress", "Unlocked All Lycanthrope Bestiary entries."), + Title(33, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_AMPHIBIC), "Coldblooded", "", "Unlocked All Amphibic Bestiary entries."), + Title(34, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_BIRD), "Death from Below", "", "Unlocked all Bird Bestiary entries."), + Title(35, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_DEMON), "Demonator", "", "Unlocked all Demon Bestiary entries."), + Title(36, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_DRAGON), "Dragonslayer", "", "Unlocked all Dragon Bestiary entries."), + Title(37, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_ELEMENTAL), "Elementalist", "", "Unlocked all Elemental Bestiary entries."), + Title(38, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_VERMIN), "Exterminator", "", "Unlocked all Vermin Bestiary entries."), + Title(39, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_FEY), "Fey Swatter", "", "Unlocked all Fey Bestiary entries."), + Title(40, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_UNDEAD), "Ghosthunter", "Ghosthuntress", "Unlocked all Undead Bestiary entries."), + Title(41, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_CONSTRUCT), "Handyman", "Handywoman", "Unlocked all Construct Bestiary entries."), + Title(42, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_MAMMAL), "Huntsman", "Huntress", "Unlocked all Mammal Bestiary entries."), + Title(43, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_EXTRA_DIMENSIONAL), "Interdimensional Destroyer", "", "Unlocked all Extra Dimensional Bestiary entries."), + Title(44, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_HUMAN), "Manhunter", "Manhuntress", "Unlocked all Human Bestiary entries."), + Title(45, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_MAGICAL), "Master of Illusion", "Mistress of Illusion", "Unlocked all Magical Bestiary entries."), + Title(46, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_SLIME), "Ooze Blues", "", "Unlocked all Slime Bestiary entries."), + Title(47, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_AQUATIC), "Sea Bane", "", "Unlocked all Aquatic Bestiary entries."), + Title(48, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_REPTILE), "Snake Charmer", "", "Unlocked all Reptile Bestiary entries."), + Title(49, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_GIANT), "Tumbler", "", "Unlocked all Giant Bestiary entries."), + Title(50, CyclopediaTitleType_t::BESTIARY, static_cast<uint16_t>(BestiaryType_t::BESTY_RACE_PLANT), "Weedkiller", "", "Unlocked all Plant Bestiary entries."), + Title(51, CyclopediaTitleType_t::BESTIARY, 0, "Executioner", "", "Unlocked all Bestiary entries."), + + Title(52, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 1)", "Reward Streak of at least 7 days of consecutive logins.", 7, true), + Title(53, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 2)", "Reward Streak of at least 30 days of consecutive logins.", 30, true), + Title(54, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 3)", "Reward Streak of at least 90 days of consecutive logins.", 90, true), + Title(55, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 4)", "Reward Streak of at least 180 days of consecutive logins.", 180, true), + Title(56, CyclopediaTitleType_t::LOGIN, "Creature of Habit (Grade 5)", "Reward Streak of at least 365 days of consecutive logins.", 365, true), + + Title(57, CyclopediaTitleType_t::TASK, "Aspiring Huntsman", "Invested 160,000 tasks points.", 160000, true, "Aspiring Huntswoman"), + Title(58, CyclopediaTitleType_t::TASK, "Competent Beastslayer", "Invested 320,000 tasks points.", 320000, true), + Title(59, CyclopediaTitleType_t::TASK, "Feared Bountyhunter", "Invested 430,000 tasks points.", 430000, true), + + Title(60, CyclopediaTitleType_t::MAP, "Dedicated Entrepreneur", "Explored 50% of all the map areas.", 50), + Title(61, CyclopediaTitleType_t::MAP, "Globetrotter", "Explored all map areas.", 100), + + Title(62, CyclopediaTitleType_t::QUEST, "Planegazer", "Followed the trail of the Planestrider to the end.", TitleStorage(1000, 1, false), true), + Title(63, CyclopediaTitleType_t::QUEST, "Hero of Bounac", "You prevailed during the battle of Bounac and broke the siege that held Bounac's people in its firm grasp.", TitleStorage(1000, 1, false), true), + Title(64, CyclopediaTitleType_t::QUEST, "Royal Bounacean Advisor", "Called to the court of Bounac by Kesar the Younger himself.", TitleStorage(1000, 1, false), true), + Title(65, CyclopediaTitleType_t::QUEST, "Time Traveller", "Anywhere in time or space.", TitleStorage(1000, 1, false), true), + + Title(66, CyclopediaTitleType_t::OTHERS, "Admirer of the Crown", "Adjust your crown and handle it.", true), + Title(67, CyclopediaTitleType_t::OTHERS, "Big Spender", "Unlocked the full Golden Outfit.", true), + Title(68, CyclopediaTitleType_t::OTHERS, "Guild Leader", "Leading a Guild.", true), + Title(69, CyclopediaTitleType_t::OTHERS, "Jack of all Taints", "Highest score for killing Goshnar and his aspects on character's world.", true), + Title(70, CyclopediaTitleType_t::OTHERS, "Reigning Drome Champion", "Finished most recent Tibiadrome rota ranked in the top 5.", true), + + }; + std::map<uint8_t, std::string> m_titlesNames; std::vector<HighscoreCategory> m_highscoreCategories; std::unordered_map<uint8_t, std::string> m_highscoreCategoriesNames; diff --git a/src/game/game_definitions.hpp b/src/game/game_definitions.hpp index 4b507147303..b6228f7bbde 100644 --- a/src/game/game_definitions.hpp +++ b/src/game/game_definitions.hpp @@ -62,26 +62,26 @@ enum LightState_t { }; enum class CyclopediaBadgeType_t : uint8_t { - ACCOUNT_AGE = 1, - LOYALTY, - ACCOUNT_ALL_LEVEL, - ACCOUNT_ALL_VOCATIONS, - TOURNAMENT_PARTICIPATION, - TOURNAMENT_POINTS, + ACCOUNT_AGE = 1, + LOYALTY, + ACCOUNT_ALL_LEVEL, + ACCOUNT_ALL_VOCATIONS, + TOURNAMENT_PARTICIPATION, + TOURNAMENT_POINTS, }; enum class CyclopediaTitleType_t : uint8_t { - GOLD = 1, - MOUNTS, - OUTFITS, - LEVEL, - HIGHSCORES, - BESTIARY, - LOGIN, - TASK, - MAP, - QUEST, - OTHERS, + GOLD = 1, + MOUNTS, + OUTFITS, + LEVEL, + HIGHSCORES, + BESTIARY, + LOGIN, + TASK, + MAP, + QUEST, + OTHERS, }; enum CyclopediaCharacterInfoType_t : uint8_t { @@ -108,20 +108,20 @@ enum CyclopediaCharacterInfo_RecentKillStatus_t : uint8_t { }; enum class HighscoreCategories_t : uint8_t { - EXPERIENCE = 0, - FIST_FIGHTING = 1, - CLUB_FIGHTING = 2, - SWORD_FIGHTING = 3, - AXE_FIGHTING = 4, - DISTANCE_FIGHTING = 5, - SHIELDING = 6, - FISHING = 7, - MAGIC_LEVEL = 8, - LOYALTY = 9, - ACHIEVEMENTS = 10, - CHARMS = 11, - DROME = 12, - GOSHNAR = 13, + EXPERIENCE = 0, + FIST_FIGHTING = 1, + CLUB_FIGHTING = 2, + SWORD_FIGHTING = 3, + AXE_FIGHTING = 4, + DISTANCE_FIGHTING = 5, + SHIELDING = 6, + FISHING = 7, + MAGIC_LEVEL = 8, + LOYALTY = 9, + ACHIEVEMENTS = 10, + CHARMS = 11, + DROME = 12, + GOSHNAR = 13, }; enum HighscoreType_t : uint8_t { diff --git a/src/io/functions/iologindata_load_player.cpp b/src/io/functions/iologindata_load_player.cpp index bf2e886e729..55174b5be44 100644 --- a/src/io/functions/iologindata_load_player.cpp +++ b/src/io/functions/iologindata_load_player.cpp @@ -889,8 +889,8 @@ void IOLoginDataLoad::loadPlayerInitializeSystem(std::shared_ptr<Player> player) player->wheel()->initializePlayerData(); player->achiev()->loadUnlockedAchievements(); - player->badge()->loadUnlockedBadges(); - player->title()->loadUnlockedTitles(); + player->badge()->loadUnlockedBadges(); + player->title()->loadUnlockedTitles(); player->initializePrey(); player->initializeTaskHunting(); diff --git a/src/lua/functions/core/game/game_functions.cpp b/src/lua/functions/core/game/game_functions.cpp index 828a3494fa9..3663505076f 100644 --- a/src/lua/functions/core/game/game_functions.cpp +++ b/src/lua/functions/core/game/game_functions.cpp @@ -908,69 +908,69 @@ int GameFunctions::luaGameGetAchievements(lua_State* L) { return 1; } -//int GameFunctions::luaGameGetAllMounts(lua_State *L) { -// // Game.getMounts() -// const auto &mounts = g_game().mounts.getMounts(); -// int index = 0; -// lua_createtable(L, mounts.size(), 0); -// for (const auto &mount: mounts) { -// lua_createtable(L, 0, 6); -// setField(L, "id", mount->id); -// setField(L, "clientId", mount->clientId); -// setField(L, "name", mount->name); -// setField(L, "speed", mount->speed); -// setField(L, "premium", mount->premium); -// setField(L, "type", mount->type); -// lua_rawseti(L, -2, ++index); -// } -// return 1; -//} +// int GameFunctions::luaGameGetAllMounts(lua_State *L) { +// // Game.getMounts() +// const auto &mounts = g_game().mounts.getMounts(); +// int index = 0; +// lua_createtable(L, mounts.size(), 0); +// for (const auto &mount: mounts) { +// lua_createtable(L, 0, 6); +// setField(L, "id", mount->id); +// setField(L, "clientId", mount->clientId); +// setField(L, "name", mount->name); +// setField(L, "speed", mount->speed); +// setField(L, "premium", mount->premium); +// setField(L, "type", mount->type); +// lua_rawseti(L, -2, ++index); +// } +// return 1; +// } // -//int GameFunctions::luaGameGetAllOutfits(lua_State *L) { -// // Game.getOutfits(sex) -// int index = 0; -// const auto &outfits = Outfits::getInstance().getOutfits(static_cast<PlayerSex_t>(getNumber<uint8_t>(L, 1, 1))); -// lua_createtable(L, outfits.size(), 0); -// for (const auto &outfit: outfits) { -// lua_createtable(L, 0, 5); -// setField(L, "lookType", outfit->lookType); -// setField(L, "name", outfit->name); -// setField(L, "unlocked", outfit->unlocked); -// setField(L, "premium", outfit->premium); -// setField(L, "from", outfit->from); -// lua_rawseti(L, -2, ++index); -// } -// return 1; -//} - -//int GameFunctions::luaGameGetHighscoresLeaderId(lua_State* L) { -// // Game.getHighscoresLeaderId(skill) -// const auto highscoreVector = g_game().getHighscoreByCategory(static_cast<HighscoreCategories_t>(getNumber<uint16_t>(L, 1, 0))); -// if (highscoreVector.size() != 0) { -// lua_pushnumber(L, highscoreVector.front().id); -// } else { -// lua_pushnumber(L, 0); -// } +// int GameFunctions::luaGameGetAllOutfits(lua_State *L) { +// // Game.getOutfits(sex) +// int index = 0; +// const auto &outfits = Outfits::getInstance().getOutfits(static_cast<PlayerSex_t>(getNumber<uint8_t>(L, 1, 1))); +// lua_createtable(L, outfits.size(), 0); +// for (const auto &outfit: outfits) { +// lua_createtable(L, 0, 5); +// setField(L, "lookType", outfit->lookType); +// setField(L, "name", outfit->name); +// setField(L, "unlocked", outfit->unlocked); +// setField(L, "premium", outfit->premium); +// setField(L, "from", outfit->from); +// lua_rawseti(L, -2, ++index); +// } +// return 1; +// } + +// int GameFunctions::luaGameGetHighscoresLeaderId(lua_State* L) { +// // Game.getHighscoresLeaderId(skill) +// const auto highscoreVector = g_game().getHighscoreByCategory(static_cast<HighscoreCategories_t>(getNumber<uint16_t>(L, 1, 0))); +// if (highscoreVector.size() != 0) { +// lua_pushnumber(L, highscoreVector.front().id); +// } else { +// lua_pushnumber(L, 0); +// } // -// return 1; -//} - -//int GameFunctions::luaGameGetBestiaryRaceAmount(lua_State *L) { -// // Game.getBestiaryRaceAmount(race) -// uint16_t entries = 0; -// auto race = static_cast<BestiaryType_t>(getNumber<uint16_t>(L, 1, 0)); -// for (const auto &mType_it: g_game().getBestiaryList()) { -// if (std::shared_ptr<MonsterType> mType = g_monsters().getMonsterType(mType_it.second); -// mType && mType->info.bestiaryRace == race) { -// entries++; -// } -// } +// return 1; +// } + +// int GameFunctions::luaGameGetBestiaryRaceAmount(lua_State *L) { +// // Game.getBestiaryRaceAmount(race) +// uint16_t entries = 0; +// auto race = static_cast<BestiaryType_t>(getNumber<uint16_t>(L, 1, 0)); +// for (const auto &mType_it: g_game().getBestiaryList()) { +// if (std::shared_ptr<MonsterType> mType = g_monsters().getMonsterType(mType_it.second); +// mType && mType->info.bestiaryRace == race) { +// entries++; +// } +// } // -// lua_pushnumber(L, entries); -// return 1; -//} +// lua_pushnumber(L, entries); +// return 1; +// } -//int GameFunctions::luaGameRegisterBadge(lua_State* L) { +// int GameFunctions::luaGameRegisterBadge(lua_State* L) { // // Game.registerBadge(id, name, amount) // if (lua_gettop(L) < 2) { // reportErrorFunc("Badge can only be registered with all params."); @@ -980,9 +980,9 @@ int GameFunctions::luaGameGetAchievements(lua_State* L) { // pushBoolean(L, true); // } // return 1; -//} +// } // -//int GameFunctions::luaGameRegisterTitle(lua_State* L) { +// int GameFunctions::luaGameRegisterTitle(lua_State* L) { // // Game.registerTitle(id, maleName, femaleName, type, description, permanent) // if (lua_gettop(L) < 5) { // reportErrorFunc("Title can only be registered with all params."); @@ -990,12 +990,12 @@ int GameFunctions::luaGameGetAchievements(lua_State* L) { // } else { // uint16_t id = getNumber<uint16_t>(L, 1); // std::string maleName = getString(L, 2); -// std::string femaleName = getString(L, 3); -// std::string type = getString(L, 4); -// std::string description = getString(L, 5); -// bool permanent = getBoolean(L, 6); +// std::string femaleName = getString(L, 3); +// std::string type = getString(L, 4); +// std::string description = getString(L, 5); +// bool permanent = getBoolean(L, 6); // g_game().registerTitle(id, maleName, femaleName, type, description, permanent); // pushBoolean(L, true); // } // return 1; -//} +// } diff --git a/src/lua/functions/core/game/game_functions.hpp b/src/lua/functions/core/game/game_functions.hpp index 9dce38fd462..1caf780ca30 100644 --- a/src/lua/functions/core/game/game_functions.hpp +++ b/src/lua/functions/core/game/game_functions.hpp @@ -89,13 +89,12 @@ class GameFunctions final : LuaScriptInterface { registerMethod(L, "Game", "getPublicAchievements", GameFunctions::luaGameGetPublicAchievements); registerMethod(L, "Game", "getAchievements", GameFunctions::luaGameGetAchievements); -// registerMethod(L, "Game", "registerBadge", GameFunctions::luaGameRegisterBadge); -// registerMethod(L, "Game", "registerTitle", GameFunctions::luaGameRegisterTitle); -// registerMethod(L, "Game", "getMounts", GameFunctions::luaGameGetMounts); -// registerMethod(L, "Game", "getOutfits", GameFunctions::luaGameGetOutfits); -// registerMethod(L, "Game", "getHighscoresLeaderId", GameFunctions::luaGameGetHighscoresLeaderId); -// registerMethod(L, "Game", "getBestiaryRaceAmount", GameFunctions::luaGameGetBestiaryRaceAmount); - + // registerMethod(L, "Game", "registerBadge", GameFunctions::luaGameRegisterBadge); + // registerMethod(L, "Game", "registerTitle", GameFunctions::luaGameRegisterTitle); + // registerMethod(L, "Game", "getMounts", GameFunctions::luaGameGetMounts); + // registerMethod(L, "Game", "getOutfits", GameFunctions::luaGameGetOutfits); + // registerMethod(L, "Game", "getHighscoresLeaderId", GameFunctions::luaGameGetHighscoresLeaderId); + // registerMethod(L, "Game", "getBestiaryRaceAmount", GameFunctions::luaGameGetBestiaryRaceAmount); } private: @@ -173,12 +172,11 @@ class GameFunctions final : LuaScriptInterface { static int luaGameGetPublicAchievements(lua_State* L); static int luaGameGetAchievements(lua_State* L); -// static int luaGameRegisterBadge(lua_State* L); -// static int luaGameRegisterTitle(lua_State* L); - -// static int luaGameGetMounts(lua_State* L); -// static int luaGameGetOutfits(lua_State* L); -// static int luaGameGetHighscoresLeaderId(lua_State* L); -// static int luaGameGetBestiaryRaceAmount(lua_State* L); + // static int luaGameRegisterBadge(lua_State* L); + // static int luaGameRegisterTitle(lua_State* L); + // static int luaGameGetMounts(lua_State* L); + // static int luaGameGetOutfits(lua_State* L); + // static int luaGameGetHighscoresLeaderId(lua_State* L); + // static int luaGameGetBestiaryRaceAmount(lua_State* L); }; diff --git a/src/lua/functions/creatures/player/player_functions.hpp b/src/lua/functions/creatures/player/player_functions.hpp index a3e88783647..1ac135e5cbc 100644 --- a/src/lua/functions/creatures/player/player_functions.hpp +++ b/src/lua/functions/creatures/player/player_functions.hpp @@ -365,7 +365,7 @@ class PlayerFunctions final : LuaScriptInterface { registerMethod(L, "Player", "removeAchievementPoints", PlayerFunctions::luaPlayerRemoveAchievementPoints); // Cyclopedia Functions - registerMethod(L, "Player", "load", PlayerFunctions::luaPlayerAddBadge); + registerMethod(L, "Player", "load", PlayerFunctions::luaPlayerAddBadge); registerMethod(L, "Player", "addBadge", PlayerFunctions::luaPlayerAddBadge); registerMethod(L, "Player", "addTitle", PlayerFunctions::luaPlayerAddTitle); registerMethod(L, "Player", "getTitles", PlayerFunctions::luaPlayerGetTitles); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index d5f28694c4c..7884f392166 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -3988,13 +3988,13 @@ void ProtocolGame::sendCyclopediaCharacterBadges() { uint8_t badgesSize = 0; auto badgesSizePosition = msg.getBufferPosition(); msg.skipBytes(1); - for (const auto &badge: g_game().getBadges()) { - if (player->summary()->hasBadge(badge.m_id)) { - msg.add<uint32_t>(badge.m_id); - msg.addString(badge.m_name, "ProtocolGame::sendCyclopediaCharacterBadges - name"); - badgesSize++; - } - } + for (const auto &badge : g_game().getBadges()) { + if (player->summary()->hasBadge(badge.m_id)) { + msg.add<uint32_t>(badge.m_id); + msg.addString(badge.m_name, "ProtocolGame::sendCyclopediaCharacterBadges - name"); + badgesSize++; + } + } msg.setBufferPosition(badgesSizePosition); msg.addByte(badgesSize);