Skip to content

Commit

Permalink
improvements and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel committed May 24, 2024
1 parent 834a686 commit bc1df9f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 64 deletions.
2 changes: 1 addition & 1 deletion data/modules/scripts/blessings/blessings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Blessings.Credits = {

Blessings.Config = {
AdventurerBlessingLevel = configManager.getNumber(configKeys.ADVENTURERSBLESSING_LEVEL), -- Free full bless until level
HasToF = false, -- Enables/disables twist of fate
HasToF = true, -- Enables/disables twist of fate
InquisitonBlessPriceMultiplier = 1.1, -- Bless price multiplied by henricus
SkulledDeathLoseStoreItem = configManager.getBoolean(configKeys.SKULLED_DEATH_LOSE_STORE_ITEM), -- Destroy all items on store when dying with red/blackskull
InventoryGlowOnFiveBless = configManager.getBoolean(configKeys.INVENTORY_GLOW), -- Glow in yellow inventory items when the player has 5 or more bless,
Expand Down
16 changes: 1 addition & 15 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,6 @@ phmap::flat_hash_map<uint8_t, std::shared_ptr<Item>> Player::getAllSlotItems() c
return itemMap;
}

phmap::flat_hash_map<Blessings_t, std::string> Player::getBlessingNames() const {
static phmap::flat_hash_map<Blessings_t, std::string> blessingNames = {
{ TWIST_OF_FATE, "Twist of Fate" },
{ WISDOM_OF_SOLITUDE, "The Wisdom of Solitude" },
{ SPARK_OF_THE_PHOENIX, "The Spark of the Phoenix" },
{ FIRE_OF_THE_SUNS, "The Fire of the Suns" },
{ SPIRITUAL_SHIELDING, "The Spiritual Shielding" },
{ EMBRACE_OF_TIBIA, "The Embrace of Tibia" },
{ BLOOD_OF_THE_MOUNTAIN, "Blood of the Mountain" },
{ HEARTH_OF_THE_MOUNTAIN, "Heart of the Mountain" },
};
return blessingNames;
}

void Player::setTraining(bool value) {
for (const auto &[key, player] : g_game().getPlayers()) {
if (!this->isInGhostMode() || player->isAccessPlayer()) {
Expand Down Expand Up @@ -6628,7 +6614,7 @@ std::string Player::getBlessingsName() const {
}
});

auto BlessingNames = getBlessingNames();
auto BlessingNames = g_game().getBlessingNames();
std::ostringstream os;
for (uint8_t i = 1; i <= 8; i++) {
if (hasBlessing(i)) {
Expand Down
3 changes: 0 additions & 3 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2595,9 +2595,6 @@ class Player final : public Creature, public Cylinder, public Bankable {
// This get all players slot items
phmap::flat_hash_map<uint8_t, std::shared_ptr<Item>> getAllSlotItems() const;

// This get all blessings
phmap::flat_hash_map<Blessings_t, std::string> getBlessingNames() const;

// Gets the equipped items with augment by type
std::vector<std::shared_ptr<Item>> getEquippedAugmentItemsByType(Augment_t augmentType) const;

Expand Down
15 changes: 15 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ Game::Game() {
HighscoreCategory("Magic Level", static_cast<uint8_t>(HighscoreCategories_t::MAGIC_LEVEL))
};

m_blessingNames = {
{ static_cast<uint8_t>(TWIST_OF_FATE), "Twist of Fate" },
{ static_cast<uint8_t>(WISDOM_OF_SOLITUDE), "The Wisdom of Solitude" },
{ static_cast<uint8_t>(SPARK_OF_THE_PHOENIX), "The Spark of the Phoenix" },
{ static_cast<uint8_t>(FIRE_OF_THE_SUNS), "The Fire of the Suns" },
{ static_cast<uint8_t>(SPIRITUAL_SHIELDING), "The Spiritual Shielding" },
{ static_cast<uint8_t>(EMBRACE_OF_TIBIA), "The Embrace of Tibia" },
{ static_cast<uint8_t>(BLOOD_OF_THE_MOUNTAIN), "Blood of the Mountain" },
{ static_cast<uint8_t>(HEARTH_OF_THE_MOUNTAIN), "Heart of the Mountain" },
};

m_summaryCategories = {
{ static_cast<uint8_t>(Summary_t::HOUSE_ITEMS), "house-items" },
{ static_cast<uint8_t>(Summary_t::BOOSTS), "xp-boosts" },
Expand Down Expand Up @@ -10668,6 +10679,10 @@ Title Game::getTitleByName(const std::string &name) {
return {};
}

std::unordered_map<uint8_t, std::string> Game::getBlessingNames() {
return m_blessingNames;
}

std::unordered_map<uint16_t, std::string> Game::getHirelingSkills() {
return m_hirelingSkills;
}
Expand Down
3 changes: 3 additions & 0 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ class Game {
return m_summaryCategories[type];
}

std::unordered_map<uint8_t, std::string> getBlessingNames();
std::unordered_map<uint16_t, std::string> getHirelingSkills();
std::unordered_map<uint16_t, std::string> getHirelingOutfits();

Expand All @@ -748,6 +749,8 @@ class Game {
std::vector<HighscoreCategory> m_highscoreCategories;
std::unordered_map<uint8_t, std::string> m_highscoreCategoriesNames;

std::unordered_map<uint8_t, std::string> m_blessingNames;

std::unordered_map<uint8_t, std::string> m_summaryCategories;
std::unordered_map<uint16_t, std::string> m_hirelingSkills;
std::unordered_map<uint16_t, std::string> m_hirelingOutfits;
Expand Down
11 changes: 11 additions & 0 deletions src/game/game_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ enum class HighscoreCategories_t : uint8_t {
BOSS_POINTS = 14,
};

enum Blessings_t : uint8_t {
TWIST_OF_FATE = 1,
WISDOM_OF_SOLITUDE = 2,
SPARK_OF_THE_PHOENIX = 3,
FIRE_OF_THE_SUNS = 4,
SPIRITUAL_SHIELDING = 5,
EMBRACE_OF_TIBIA = 6,
BLOOD_OF_THE_MOUNTAIN = 7,
HEARTH_OF_THE_MOUNTAIN = 8,
};

enum HighscoreType_t : uint8_t {
HIGHSCORE_GETENTRIES = 0,
HIGHSCORE_OURRANK = 1
Expand Down
50 changes: 16 additions & 34 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3976,30 +3976,14 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() {
auto cyclopediaSummary = player->cyclopedia()->getSummary();

// getBlessingsObtained
auto blessingNames = player->getBlessingNames();
auto blessingNames = g_game().getBlessingNames();
std::vector<std::pair<Blessings_t, std::string>> orderedBlessings;
for (const auto &bless : blessingNames) {
orderedBlessings.emplace_back(bless.first, bless.second);
}
std::sort(orderedBlessings.begin(), orderedBlessings.end(), [](const std::pair<Blessings_t, std::string> &a, const std::pair<Blessings_t, std::string> &b) {
return a.first < b.first;
});

msg.addByte(static_cast<uint8_t>(blessingNames.size()));
// auto blessingsObtained = player->cyclopedia()->getResult(static_cast<uint8_t>(Summary_t::BLESSINGS));
for (const auto &bless : orderedBlessings) {
for (const auto &bless : blessingNames) {
g_logger().info("bless: {} - {}", bless.first, bless.second);
msg.addString(bless.second, "ProtocolGame::sendCyclopediaCharacterStoreSummary - blessing.name");
uint8_t blessingIndex = bless.first - 1;
msg.addByte((blessingIndex < player->blessings.size()) ? static_cast<uint16_t>(player->blessings[blessingIndex]) : 0);

// msg.addByte(static_cast<uint16_t>(player->blessings[bless.first - 1]));
// msg.addByte(std::find(player->blessings.begin(), player->blessings.end(), )//player->getBlessingCount(bless.first));
// 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;
// });
// msg.addByte((it != blessingsObtained.end()) ? static_cast<uint16_t>(it->second) : 0x00);
}

uint8_t preySlotsUnlocked = 0;
Expand Down Expand Up @@ -4029,22 +4013,20 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() {
}
msg.addByte(m_hSkills.size());
for (const auto &id : m_hSkills) {
msg.add<uint16_t>(id - 1000);
// msg.addByte(id);
}

// std::vector<uint16_t> m_hOutfits;
// for (const auto &it : g_game().getHirelingOutfits()) {
// if (player->kv()->scoped("hireling-outfits")->get(it.second)) {
// m_hOutfits.emplace_back(it.first);
// g_logger().info("outfit id: {}, name: {}", it.first, it.second);
// }
// }
// msg.addByte(m_hOutfits.size());
// for (const auto &id : m_hOutfits) {
// msg.add<uint16_t>(id);
// // msg.addByte(id);
// }
msg.addByte(id - 1000);
}

std::vector<uint16_t> m_hOutfits;
for (const auto &it : g_game().getHirelingOutfits()) {
if (player->kv()->scoped("hireling-outfits")->get(it.second)) {
m_hOutfits.emplace_back(it.first);
g_logger().info("outfit id: {}, name: {}", it.first, it.second);
}
}
msg.addByte(m_hOutfits.size());
for (const auto &id : m_hOutfits) {
msg.addByte(id - 2000);
}
msg.addByte(0x00);

auto houseItems = player->cyclopedia()->getResult(static_cast<uint8_t>(Summary_t::HOUSE_ITEMS));
Expand Down
11 changes: 0 additions & 11 deletions src/utils/utils_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,17 +709,6 @@ enum class PlayerFlags_t : uint8_t {
FlagLast
};

enum Blessings_t : uint8_t {
TWIST_OF_FATE = 1,
WISDOM_OF_SOLITUDE = 2,
SPARK_OF_THE_PHOENIX = 3,
FIRE_OF_THE_SUNS = 4,
SPIRITUAL_SHIELDING = 5,
EMBRACE_OF_TIBIA = 6,
BLOOD_OF_THE_MOUNTAIN = 7,
HEARTH_OF_THE_MOUNTAIN = 8,
};

enum BedItemPart_t : uint8_t {
BED_NONE_PART,
BED_PILLOW_PART,
Expand Down

0 comments on commit bc1df9f

Please sign in to comment.