From dcfa552900d3e1a1a9c0990003f11b9eae55413e Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Thu, 18 Apr 2024 09:46:04 -0300 Subject: [PATCH] title system: trying to enable title menu on cyclopedia window. --- src/game/game.cpp | 1 + src/server/network/protocol/protocolgame.cpp | 22 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 3b05387d5d6..cdb6daa058f 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -8237,6 +8237,7 @@ void Game::playerCyclopediaCharacterInfo(std::shared_ptr player, uint32_ return; } + g_logger().debug("Selected characterInfoType: {}", characterInfoType); switch (characterInfoType) { case CYCLOPEDIA_CHARACTERINFO_BASEINFORMATION: player->sendCyclopediaCharacterBaseInformation(); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 5d12bb0eebb..2d2bbf3c1d0 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -3382,7 +3382,9 @@ void ProtocolGame::sendCyclopediaCharacterBaseInformation() { AddOutfit(msg, player->getDefaultOutfit(), false); msg.addByte(g_configManager().getBoolean(STAMINA_SYSTEM, __FUNCTION__) ? 0x00 : 0x01); // hide stamina - msg.addString(player->title()->getCurrentTitleName(), "ProtocolGame::sendCyclopediaCharacterBaseInformation - player->title()->getCurrentTitleName()"); // character title + msg.addByte(0x01); // Store summary & Character titles + msg.addString("", "ProtocolGame::sendCyclopediaCharacterBaseInformation - player->title()->getCurrentTitleName()"); // character title + // msg.addString(player->title()->getCurrentTitleName(), "ProtocolGame::sendCyclopediaCharacterBaseInformation - player->title()->getCurrentTitleName()"); // character title writeToOutputBuffer(msg); } @@ -4034,17 +4036,29 @@ void ProtocolGame::sendCyclopediaCharacterTitles() { msg.addByte(0x00); // 0x00 Here means 'no error' msg.addByte(player->title()->getCurrentTitle()); msg.addByte(static_cast(titles.size())); + + uint8_t titlesSize = 0; + auto titlesSizePosition = msg.getBufferPosition(); std::string messageTitleName = "ProtocolGame::sendCyclopediaCharacterTitles - title.name"; std::string messageTitleDesc = "ProtocolGame::sendCyclopediaCharacterTitles - title.description"; for (const auto &title : titles) { - msg.addByte(title.m_id); + // msg.addByte(title.m_id); + msg.add(title.m_id); auto titleName = player->getSex() == PLAYERSEX_FEMALE && !title.m_femaleName.empty() ? title.m_femaleName : title.m_maleName; msg.addString(titleName, messageTitleName); msg.addString(title.m_description, messageTitleDesc); msg.addByte(title.m_permanent ? 0x01 : 0x00); - msg.addByte(player->title()->isTitleUnlocked(title.m_id) ? 0x01 : 0x00); - g_logger().debug("ProtocolGame::addBytes - titles: {}, unlocked: {}", title.m_id, player->title()->isTitleUnlocked(title.m_id)); + auto isUnlocked = player->title()->isTitleUnlocked(title.m_id); + msg.addByte(isUnlocked ? 0x01 : 0x00); + if (isUnlocked) { + titlesSize++; + } + g_logger().debug("ProtocolGame::addByte - titles: {}, unlocked: {}", title.m_id, player->title()->isTitleUnlocked(title.m_id)); } + + msg.setBufferPosition(titlesSizePosition); + msg.addByte(titlesSize); + writeToOutputBuffer(msg); }