Skip to content

Commit

Permalink
title system: trying to enable title menu on cyclopedia window.
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel committed Apr 18, 2024
1 parent c21014d commit dcfa552
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8237,6 +8237,7 @@ void Game::playerCyclopediaCharacterInfo(std::shared_ptr<Player> player, uint32_
return;
}

g_logger().debug("Selected characterInfoType: {}", characterInfoType);
switch (characterInfoType) {
case CYCLOPEDIA_CHARACTERINFO_BASEINFORMATION:
player->sendCyclopediaCharacterBaseInformation();
Expand Down
22 changes: 18 additions & 4 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -4034,17 +4036,29 @@ void ProtocolGame::sendCyclopediaCharacterTitles() {
msg.addByte(0x00); // 0x00 Here means 'no error'
msg.addByte(player->title()->getCurrentTitle());
msg.addByte(static_cast<uint8_t>(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<uint32_t>(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);
}

Expand Down

0 comments on commit dcfa552

Please sign in to comment.