From e0e7ab0d1d2c23eadcaabac907fce2eaecffa933 Mon Sep 17 00:00:00 2001 From: Pedro Cruz Date: Mon, 13 May 2024 18:35:04 -0300 Subject: [PATCH 1/8] feat: augments (#2602) --- config.lua.dist | 14 ++- data/items/items.xml | 105 +++++++++++++++++++ src/config/config_enums.hpp | 5 +- src/config/configmanager.cpp | 3 + src/creatures/combat/combat.cpp | 4 + src/creatures/combat/spells.cpp | 41 +++++++- src/creatures/combat/spells.hpp | 3 + src/creatures/players/player.cpp | 29 +++++ src/creatures/players/player.hpp | 6 ++ src/enums/item_attribute.hpp | 1 + src/items/functions/item/item_parse.cpp | 53 ++++++++++ src/items/functions/item/item_parse.hpp | 8 ++ src/items/item.cpp | 12 +++ src/items/item.hpp | 29 +++++ src/items/items.cpp | 41 ++++++++ src/items/items.hpp | 22 ++++ src/items/items_definitions.hpp | 21 ++++ src/server/network/protocol/protocolgame.cpp | 7 +- src/utils/tools.cpp | 16 +++ src/utils/tools.hpp | 1 + 20 files changed, 417 insertions(+), 4 deletions(-) diff --git a/config.lua.dist b/config.lua.dist index b731fadbcd7..ed2561d4532 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -52,7 +52,8 @@ cleanProtectionZones = false -- Connection Config -- NOTE: allowOldProtocol can allow login on 10x protocol. (11.00) -- NOTE: maxPlayers set to 0 means no limit --- NOTE: MaxPacketsPerSeconds if you change you will be subject to bugs by WPE, keep the default value of 25 +-- NOTE: MaxPacketsPerSeconds if you change you will be subject to bugs by WPE, keep the default value of 25, +-- It's recommended to use a range like min 50 in this function, otherwise you will be disconnected after equipping two-handed distance weapons. ip = "127.0.0.1" allowOldProtocol = false bindOnlyGlobalAddress = false @@ -80,6 +81,17 @@ freeDepotLimit = 2000 premiumDepotLimit = 10000 depotBoxes = 20 +-- Augments System (Get more info in: https://github.com/opentibiabr/canary/pull/2602) +-- NOTE: the following values are for all weapons and equipments that have type of "increase damage", "powerful impact" and "strong impact". +-- To customize the percentage of a particular item with these augment types, please add to the item "augments" section on items.xml as the example above. +-- NOTE: The values represent percentage. +-- NOTE: augmentIncreasedDamagePercent = value between 1 and 100 (damage percent to increase. ex: 5 = 5%, 50 = 50%) +-- NOTE: augmentPowerfulImpactPercent = value between 1 and 100 (damage percent to increase. ex: 10 = 10%, 100 = 100%) +-- NOTE: augmentStrongImpactPercent = value between 1 and 100 (damage percent to increase. ex: 7 = 7%, 70 = 70%) +augmentIncreasedDamagePercent = 5 +augmentPowerfulImpactPercent = 7 +augmentStrongImpactPercent = 10 + -- Prey system -- NOTE: preyRerollPricePerLevel: Price multiplier in gold coin for rerolling prey list. -- NOTE: preySelectListPrice: Price to manually select creature on list and to lock prey slot. diff --git a/data/items/items.xml b/data/items/items.xml index 0858df99219..45cde62bd9d 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -75009,6 +75009,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75032,6 +75035,12 @@ Granted by TibiaGoals.com"/> + + + + + + @@ -75055,6 +75064,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75078,6 +75090,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75101,6 +75116,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75124,6 +75142,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75149,6 +75170,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75173,6 +75197,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75197,6 +75224,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75221,6 +75251,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75245,6 +75278,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75269,6 +75305,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75285,6 +75324,14 @@ Granted by TibiaGoals.com"/> + + + + + + + + @@ -75311,6 +75358,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75338,6 +75388,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75365,6 +75418,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75392,6 +75448,9 @@ Granted by TibiaGoals.com"/> + + + @@ -75407,6 +75466,14 @@ Granted by TibiaGoals.com"/> + + + + + + + + @@ -75430,6 +75497,10 @@ Granted by TibiaGoals.com"/> + + + + @@ -75459,6 +75530,10 @@ Granted by TibiaGoals.com"/> + + + + @@ -75483,6 +75558,17 @@ Granted by TibiaGoals.com"/> + + + + + + + + + + + @@ -75506,6 +75592,10 @@ Granted by TibiaGoals.com"/> + + + + @@ -75535,6 +75625,10 @@ Granted by TibiaGoals.com"/> + + + + @@ -75559,6 +75653,17 @@ Granted by TibiaGoals.com"/> + + + + + + + + + + + diff --git a/src/config/config_enums.hpp b/src/config/config_enums.hpp index 4abf29c04cb..30a4b172af1 100644 --- a/src/config/config_enums.hpp +++ b/src/config/config_enums.hpp @@ -17,6 +17,9 @@ enum ConfigKey_t : uint16_t { ALLOW_BLOCK_SPAWN, ALLOW_CHANGEOUTFIT, ALLOW_RELOAD, + AUGMENT_INCREASED_DAMAGE_PERCENT, + AUGMENT_POWERFUL_IMPACT_PERCENT, + AUGMENT_STRONG_IMPACT_PERCENT, AUTH_TYPE, AUTOBANK, AUTOLOOT, @@ -324,5 +327,5 @@ enum ConfigKey_t : uint16_t { WHEEL_POINTS_PER_LEVEL, WHITE_SKULL_TIME, WORLD_TYPE, - XP_DISPLAY_MODE, + XP_DISPLAY_MODE }; diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 8d4ba7a77da..0525c5a560a 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -345,6 +345,9 @@ bool ConfigManager::load() { loadIntConfig(L, WHEEL_ATELIER_ROTATE_REGULAR_COST, "wheelAtelierRotateRegularCost", 250000); loadIntConfig(L, WHEEL_POINTS_PER_LEVEL, "wheelPointsPerLevel", 1); loadIntConfig(L, WHITE_SKULL_TIME, "whiteSkullTime", 15 * 60 * 1000); + loadIntConfig(L, AUGMENT_INCREASED_DAMAGE_PERCENT, "augmentIncreasedDamagePercent", 5); + loadIntConfig(L, AUGMENT_POWERFUL_IMPACT_PERCENT, "augmentPowerfulImpactPercent", 10); + loadIntConfig(L, AUGMENT_STRONG_IMPACT_PERCENT, "augmentStrongImpactPercent", 7); loadStringConfig(L, CORE_DIRECTORY, "coreDirectory", "data"); loadStringConfig(L, DATA_DIRECTORY, "dataPackDirectory", "data-otservbr-global"); diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 56cca63fe56..06812095cbf 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -98,7 +98,11 @@ CombatDamage Combat::getCombatDamage(std::shared_ptr creature, std::sh } } } + if (attackerPlayer && wheelSpell && wheelSpell->isInstant()) { + wheelSpell->getCombatDataAugment(attackerPlayer, damage); + } } + return damage; } diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index 60cc5e7d2a9..3aa445b34aa 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -630,6 +630,43 @@ void Spell::setWheelOfDestinyBoost(WheelSpellBoost_t boost, WheelSpellGrade_t gr } } +void Spell::getCombatDataAugment(std::shared_ptr player, CombatDamage &damage) { + if (!(damage.instantSpellName).empty()) { + const auto equippedAugmentItems = player->getEquippedAugmentItems(); + for (const auto &item : equippedAugmentItems) { + const auto augments = item->getAugmentsBySpellName(damage.instantSpellName); + for (auto &augment : augments) { + if (augment->value == 0) { + continue; + } + if (augment->type == Augment_t::IncreasedDamage || augment->type == Augment_t::PowerfulImpact || augment->type == Augment_t::StrongImpact) { + const float augmentPercent = augment->value / 100.0; + damage.primary.value += static_cast(damage.primary.value * augmentPercent); + damage.secondary.value += static_cast(damage.secondary.value * augmentPercent); + } else if (augment->type != Augment_t::Cooldown) { + const int32_t augmentValue = augment->value * 100; + damage.lifeLeech += augment->type == Augment_t::LifeLeech ? augmentValue : 0; + damage.manaLeech += augment->type == Augment_t::ManaLeech ? augmentValue : 0; + damage.criticalDamage += augment->type == Augment_t::CriticalExtraDamage ? augmentValue : 0; + } + } + } + } +}; + +int32_t Spell::calculateAugmentSpellCooldownReduction(std::shared_ptr player) const { + int32_t spellCooldown = 0; + const auto equippedAugmentItems = player->getEquippedAugmentItemsByType(Augment_t::Cooldown); + for (const auto &item : equippedAugmentItems) { + const auto augments = item->getAugmentsBySpellNameAndType(getName(), Augment_t::Cooldown); + for (auto &augment : augments) { + spellCooldown += augment->value; + } + } + + return spellCooldown; +} + void Spell::applyCooldownConditions(std::shared_ptr player) const { WheelSpellGrade_t spellGrade = player->wheel()->getSpellUpgrade(getName()); bool isUpgraded = getWheelOfDestinyUpgraded() && static_cast(spellGrade) > 0; @@ -644,8 +681,10 @@ void Spell::applyCooldownConditions(std::shared_ptr player) const { if (isUpgraded) { spellCooldown -= getWheelOfDestinyBoost(WheelSpellBoost_t::COOLDOWN, spellGrade); } - g_logger().debug("[{}] spell name: {}, spellCooldown: {}, bonus: {}", __FUNCTION__, name, spellCooldown, player->wheel()->getSpellBonus(name, WheelSpellBoost_t::COOLDOWN)); + int32_t augmentCooldownReduction = calculateAugmentSpellCooldownReduction(player); + g_logger().debug("[{}] spell name: {}, spellCooldown: {}, bonus: {}, augment {}", __FUNCTION__, name, spellCooldown, player->wheel()->getSpellBonus(name, WheelSpellBoost_t::COOLDOWN), augmentCooldownReduction); spellCooldown -= player->wheel()->getSpellBonus(name, WheelSpellBoost_t::COOLDOWN); + spellCooldown -= augmentCooldownReduction; if (spellCooldown > 0) { std::shared_ptr condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_SPELLCOOLDOWN, spellCooldown / rateCooldown, 0, false, m_spellId); player->addCondition(condition); diff --git a/src/creatures/combat/spells.hpp b/src/creatures/combat/spells.hpp index cd1a7aaa623..dce7b3caba4 100644 --- a/src/creatures/combat/spells.hpp +++ b/src/creatures/combat/spells.hpp @@ -345,6 +345,9 @@ class Spell : public BaseSpell { m_separator = newSeparator.data(); } + void getCombatDataAugment(std::shared_ptr player, CombatDamage &damage); + int32_t calculateAugmentSpellCooldownReduction(std::shared_ptr player) const; + protected: void applyCooldownConditions(std::shared_ptr player) const; bool playerSpellCheck(std::shared_ptr player) const; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 925086f2b53..78478953ade 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -4115,6 +4115,35 @@ std::vector> Player::getAllInventoryItems(bool ignoreEquip return itemVector; } +std::vector> Player::getEquippedAugmentItemsByType(Augment_t augmentType) const { + std::vector> equippedAugmentItemsByType; + const auto equippedAugmentItems = getEquippedItems(); + + for (const auto &item : equippedAugmentItems) { + for (auto &augment : item->getAugments()) { + if (augment->type == augmentType) { + equippedAugmentItemsByType.push_back(item); + } + } + } + + return equippedAugmentItemsByType; +} + +std::vector> Player::getEquippedAugmentItems() const { + std::vector> equippedAugmentItems; + const auto equippedItems = getEquippedItems(); + + for (const auto &item : equippedItems) { + if (item->getAugments().size() < 1) { + continue; + } + equippedAugmentItems.push_back(item); + } + + return equippedAugmentItems; +} + std::vector> Player::getEquippedItems() const { std::vector valid_slots { CONST_SLOT_HEAD, diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index da4c0cec9e8..b3bdd875b20 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -2601,6 +2601,12 @@ class Player final : public Creature, public Cylinder, public Bankable { // This get all blessings phmap::flat_hash_map getBlessingNames() const; + // Gets the equipped items with augment by type + std::vector> getEquippedAugmentItemsByType(Augment_t augmentType) const; + + // Gets the equipped items with augment + std::vector> getEquippedAugmentItems() const; + /** * @brief Get the equipped items of the player-> * @details This function returns a vector containing the items currently equipped by the player diff --git a/src/enums/item_attribute.hpp b/src/enums/item_attribute.hpp index adc49c11a19..be7b7445710 100644 --- a/src/enums/item_attribute.hpp +++ b/src/enums/item_attribute.hpp @@ -46,6 +46,7 @@ enum ItemAttribute_t : uint64_t { LOOTMESSAGE_SUFFIX = 33, STORE_INBOX_CATEGORY = 34, OBTAINCONTAINER = 35, + AUGMENTS = 36, }; enum ItemDecayState_t : uint8_t { diff --git a/src/items/functions/item/item_parse.cpp b/src/items/functions/item/item_parse.cpp index 2d1ba9301c5..1f247b611bc 100644 --- a/src/items/functions/item/item_parse.cpp +++ b/src/items/functions/item/item_parse.cpp @@ -68,6 +68,7 @@ void ItemParse::initParse(const std::string &tmpStrValue, pugi::xml_node attribu ItemParse::parseWalk(tmpStrValue, valueAttribute, itemType); ItemParse::parseAllowDistanceRead(tmpStrValue, valueAttribute, itemType); ItemParse::parseImbuement(tmpStrValue, attributeNode, valueAttribute, itemType); + ItemParse::parseAugment(tmpStrValue, attributeNode, valueAttribute, itemType); ItemParse::parseStackSize(tmpStrValue, valueAttribute, itemType); ItemParse::parseSpecializedMagicLevelPoint(tmpStrValue, valueAttribute, itemType); ItemParse::parseMagicShieldCapacity(tmpStrValue, valueAttribute, itemType); @@ -870,6 +871,58 @@ void ItemParse::parseImbuement(const std::string &tmpStrValue, pugi::xml_node at } } +void ItemParse::parseAugment(const std::string &tmpStrValue, pugi::xml_node attributeNode, pugi::xml_attribute valueAttribute, ItemType &itemType) { + if (tmpStrValue != "augments") { + return; + } + + // Check if the augments value is 1 or 0 (1 = enable - 0 = disable) + if (valueAttribute.as_bool()) { + for (const auto subAttributeNode : attributeNode.children()) { + const pugi::xml_attribute subKeyAttribute = subAttributeNode.attribute("key"); + if (!subKeyAttribute) { + continue; + } + + const pugi::xml_attribute subValueAttribute = subAttributeNode.attribute("value"); + if (!subValueAttribute) { + continue; + } + + const auto &augmentEnum = magic_enum::enum_cast(toPascalCase(subValueAttribute.as_string())); + if (augmentEnum.has_value()) { + const Augment_t augmentType = augmentEnum.value(); + g_logger().trace("[ParseAugment::initParseAugment] - Item '{}' has an augment '{}'", itemType.name, subValueAttribute.as_string()); + int32_t augmentValue = 0; + const bool hasValueDescrition = isAugmentWithoutValueDescription(augmentType); + + if (hasValueDescrition) { + const auto it = AugmentWithoutValueDescriptionDefaultKeys.find(augmentType); + if (it != AugmentWithoutValueDescriptionDefaultKeys.end()) { + augmentValue = g_configManager().getNumber(it->second, __FUNCTION__); + } + } + + const auto augmentName = asLowerCaseString(subKeyAttribute.as_string()); + const pugi::xml_object_range augmentValueAttributeNode = subAttributeNode.children(); + if (!augmentValueAttributeNode.empty()) { + const pugi::xml_node augmentValueNode = *augmentValueAttributeNode.begin(); + const pugi::xml_attribute augmentValueAttribute = augmentValueNode.attribute("value"); + augmentValue = augmentValueAttribute ? pugi::cast(augmentValueAttribute.value()) : augmentValue; + } else if (!hasValueDescrition) { + g_logger().warn("[{}] - Item '{}' has an augment '{}' without a value", __FUNCTION__, itemType.name, augmentName); + } + + if (augmentType != Augment_t::None) { + itemType.addAugment(augmentName, augmentType, augmentValue); + } + } else { + g_logger().warn("[{}] - Unknown type '{}'", __FUNCTION__, subValueAttribute.as_string()); + } + } + } +} + void ItemParse::parseStackSize(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType) { std::string stringValue = tmpStrValue; if (stringValue == "stacksize") { diff --git a/src/items/functions/item/item_parse.hpp b/src/items/functions/item/item_parse.hpp index 7859a77fe9c..f63b6bc0689 100644 --- a/src/items/functions/item/item_parse.hpp +++ b/src/items/functions/item/item_parse.hpp @@ -158,6 +158,7 @@ const phmap::flat_hash_map ItemParseAttribut { "primarytype", ITEM_PARSE_PRIMARYTYPE }, { "usedbyhouseguests", ITEM_PARSE_USEDBYGUESTS }, { "script", ITEM_PARSE_SCRIPT }, + { "augments", ITEM_PARSE_AUGMENT } }; const phmap::flat_hash_map ItemTypesMap = { @@ -247,6 +248,12 @@ const phmap::flat_hash_map ImbuementsTypeMap = { { "increase capacity", IMBUEMENT_INCREASE_CAPACITY } }; +const phmap::flat_hash_map AugmentWithoutValueDescriptionDefaultKeys = { + { Augment_t::IncreasedDamage, AUGMENT_INCREASED_DAMAGE_PERCENT }, + { Augment_t::PowerfulImpact, AUGMENT_POWERFUL_IMPACT_PERCENT }, + { Augment_t::StrongImpact, AUGMENT_STRONG_IMPACT_PERCENT }, +}; + class ItemParse : public Items { public: static void initParse(const std::string &tmpStrValue, pugi::xml_node attributeNode, pugi::xml_attribute valueAttribute, ItemType &itemType); @@ -304,6 +311,7 @@ class ItemParse : public Items { static void parseWalk(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType); static void parseAllowDistanceRead(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType); static void parseImbuement(const std::string &tmpStrValue, pugi::xml_node attributeNode, pugi::xml_attribute valueAttribute, ItemType &itemType); + static void parseAugment(const std::string &tmpStrValue, pugi::xml_node attributeNode, pugi::xml_attribute valueAttribute, ItemType &itemType); static void parseStackSize(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType); static void parseSpecializedMagicLevelPoint(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType); static void parseMagicShieldCapacity(const std::string &tmpStrValue, pugi::xml_attribute valueAttribute, ItemType &itemType); diff --git a/src/items/item.cpp b/src/items/item.cpp index 81d24a790e7..104efc7f925 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -1437,6 +1437,11 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr } } + std::string augmentsDescription = parseAugmentDescription(item, true); + if (!augmentsDescription.empty()) { + descriptions.emplace_back("Augments", augmentsDescription); + } + if (it.isKey()) { ss.str(""); ss << fmt::format("{:04}", item->getAttribute(ItemAttribute_t::ACTIONID)); @@ -1789,6 +1794,11 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr descriptions.emplace_back("Imbuement Slots", std::to_string(it.imbuementSlot)); } + std::string augmentsDescription = it.parseAugmentDescription(true); + if (!augmentsDescription.empty()) { + descriptions.emplace_back("Augments", augmentsDescription); + } + if (it.isKey()) { ss.str(""); ss << fmt::format("{:04}", 0); @@ -3017,6 +3027,8 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std:: s << '.'; } + s << parseAugmentDescription(item); + s << parseImbuementDescription(item); s << parseClassificationDescription(item); diff --git a/src/items/item.hpp b/src/items/item.hpp index 9ff0d3d15aa..a9774c902cd 100644 --- a/src/items/item.hpp +++ b/src/items/item.hpp @@ -291,6 +291,12 @@ class Item : virtual public Thing, public ItemProperties, public SharedObject { return isStoreItem() || hasOwner(); } + static std::string parseAugmentDescription(std::shared_ptr item, bool inspect = false) { + if (!item) { + return ""; + } + return items[item->getID()].parseAugmentDescription(inspect); + } static std::string parseImbuementDescription(std::shared_ptr item); static std::string parseShowDurationSpeed(int32_t speed, bool &begin); static std::string parseShowDuration(std::shared_ptr item); @@ -419,6 +425,29 @@ class Item : virtual public Thing, public ItemProperties, public SharedObject { } return items[id].extraDefense; } + std::vector> getAugments() const { + return items[id].augments; + } + std::vector> getAugmentsBySpellNameAndType(std::string spellName, Augment_t augmentType) const { + std::vector> augments; + for (auto &augment : items[id].augments) { + if (strcasecmp(augment->spellName.c_str(), spellName.c_str()) == 0 && augment->type == augmentType) { + augments.push_back(augment); + } + } + + return augments; + } + std::vector> getAugmentsBySpellName(std::string spellName) const { + std::vector> augments; + for (auto &augment : items[id].augments) { + if (strcasecmp(augment->spellName.c_str(), spellName.c_str()) == 0) { + augments.push_back(augment); + } + } + + return augments; + } uint8_t getImbuementSlot() const { if (hasAttribute(ItemAttribute_t::IMBUEMENT_SLOT)) { return getAttribute(ItemAttribute_t::IMBUEMENT_SLOT); diff --git a/src/items/items.cpp b/src/items/items.cpp index 9e31f5f105f..7d8ff0cf7c0 100644 --- a/src/items/items.cpp +++ b/src/items/items.cpp @@ -67,6 +67,47 @@ ItemTypes_t Items::getLootType(const std::string &strValue) { return ITEM_TYPE_NONE; } +const std::string Items::getAugmentNameByType(Augment_t augmentType) { + std::string augmentTypeName = magic_enum::enum_name(augmentType).data(); + augmentTypeName = toStartCaseWithSpace(augmentTypeName); + if (!isAugmentWithoutValueDescription(augmentType)) { + toLowerCaseString(augmentTypeName); + } + return augmentTypeName; +} + +std::string ItemType::parseAugmentDescription(bool inspect /*= false*/) const { + if (augments.empty()) { + return ""; + } + + std::vector descriptions; + for (const auto &augment : augments) { + descriptions.push_back(getFormattedAugmentDescription(augment)); + } + + if (inspect) { + return fmt::format("{}.", fmt::join(descriptions.begin(), descriptions.end(), ", ")); + } else { + return fmt::format("\nAugments: ({}).", fmt::join(descriptions.begin(), descriptions.end(), ", ")); + } +} + +std::string ItemType::getFormattedAugmentDescription(const std::shared_ptr &augmentInfo) const { + const std::string augmentName = Items::getAugmentNameByType(augmentInfo->type); + std::string augmentSpellNameCapitalized = augmentInfo->spellName; + capitalizeWordsIgnoringString(augmentSpellNameCapitalized, " of "); + + char signal = augmentInfo->value > 0 ? '-' : '+'; + + if (Items::isAugmentWithoutValueDescription(augmentInfo->type)) { + return fmt::format("{} -> {}", augmentSpellNameCapitalized, augmentName); + } else if (augmentInfo->type == Augment_t::Cooldown) { + return fmt::format("{} -> {}{}s {}", augmentSpellNameCapitalized, signal, augmentInfo->value / 1000, augmentName); + } + return fmt::format("{} -> {:+}% {}", augmentSpellNameCapitalized, augmentInfo->value, augmentName); +} + bool Items::reload() { clear(); loadFromProtobuf(); diff --git a/src/items/items.hpp b/src/items/items.hpp index f9e48ae1032..82af0659af4 100644 --- a/src/items/items.hpp +++ b/src/items/items.hpp @@ -252,6 +252,14 @@ class ItemType { return str; } + std::string parseAugmentDescription(bool inspect = false) const; + std::string getFormattedAugmentDescription(const std::shared_ptr &augmentInfo) const; + + void addAugment(std::string spellName, Augment_t augmentType, int32_t value) { + auto augmentInfo = std::make_shared(spellName, augmentType, value); + augments.emplace_back(augmentInfo); + } + void setImbuementType(ImbuementTypes_t imbuementType, uint16_t slotMaxTier) { imbuementTypes[imbuementType] = std::min(IMBUEMENT_MAX_TIER, slotMaxTier); } @@ -331,6 +339,8 @@ class ItemType { int8_t hitChance = 0; + std::vector> augments; + // 12.90 bool wearOut = false; bool clockExpire = false; @@ -435,6 +445,18 @@ class Items { return dummys; } + static const std::string getAugmentNameByType(Augment_t augmentType); + + static const bool isAugmentWithoutValueDescription(Augment_t augmentType) { + static std::vector vector = { + Augment_t::IncreasedDamage, + Augment_t::PowerfulImpact, + Augment_t::StrongImpact, + }; + + return std::find(vector.begin(), vector.end(), augmentType) != vector.end(); + } + private: std::vector items; std::vector ladders; diff --git a/src/items/items_definitions.hpp b/src/items/items_definitions.hpp index f044d4b5248..badac532951 100644 --- a/src/items/items_definitions.hpp +++ b/src/items/items_definitions.hpp @@ -270,6 +270,17 @@ enum ImbuementTypes_t : int64_t { IMBUEMENT_INCREASE_CAPACITY = 17 }; +enum class Augment_t : uint8_t { + None, + PowerfulImpact, + StrongImpact, + IncreasedDamage, + Cooldown, + CriticalExtraDamage, + LifeLeech, + ManaLeech +}; + enum class ContainerCategory_t : uint8_t { All, Ammunition, @@ -606,9 +617,19 @@ enum ItemParseAttributes_t { ITEM_PARSE_PRIMARYTYPE, ITEM_PARSE_USEDBYGUESTS, ITEM_PARSE_SCRIPT, + ITEM_PARSE_AUGMENT, }; struct ImbuementInfo { Imbuement* imbuement; uint32_t duration = 0; }; + +struct AugmentInfo { + AugmentInfo(std::string spellName, Augment_t type, int32_t value) : + spellName(std::move(spellName)), type(type), value(value) { } + + std::string spellName; + Augment_t type; + int32_t value; +}; diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index d924e0bfb0e..ab111fd3c8f 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5717,7 +5717,12 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { } if (!oldProtocol) { - msg.add(0x00); // Augment + std::string augmentsDescription = it.parseAugmentDescription(true); + if (!augmentsDescription.empty()) { + msg.addString(augmentsDescription, "ProtocolGame::sendMarketDetail - augmentsDescription"); + } else { + msg.add(0x00); // no augments + } } if (it.imbuementSlot > 0) { diff --git a/src/utils/tools.cpp b/src/utils/tools.cpp index 0d8b39a485d..b1fe671f416 100644 --- a/src/utils/tools.cpp +++ b/src/utils/tools.cpp @@ -1558,6 +1558,22 @@ void capitalizeWords(std::string &source) { } } +void capitalizeWordsIgnoringString(std::string &source, const std::string stringToIgnore) { + toLowerCaseString(source); + uint8_t size = (uint8_t)source.size(); + uint8_t indexFound = source.find(stringToIgnore); + for (uint8_t i = 0; i < size; i++) { + if (indexFound != std::string::npos && (i > indexFound - 1) && i < (indexFound + stringToIgnore.size())) { + continue; + } + if (i == 0) { + source[i] = (char)toupper(source[i]); + } else if (source[i - 1] == ' ' || source[i - 1] == '\'') { + source[i] = (char)toupper(source[i]); + } + } +} + /** * @details * Prevents the console from closing so there is time to read the error information diff --git a/src/utils/tools.hpp b/src/utils/tools.hpp index 769fb5d68d3..25683bf22bb 100644 --- a/src/utils/tools.hpp +++ b/src/utils/tools.hpp @@ -138,6 +138,7 @@ const char* getReturnMessage(ReturnValue value); void sleep_for(uint64_t ms); void capitalizeWords(std::string &source); +void capitalizeWordsIgnoringString(std::string &source, const std::string stringToIgnore); void consoleHandlerExit(); NameEval_t validateName(const std::string &name); From 1d025c2c7b17fdb4a9ba7cdde4687f9654dec018 Mon Sep 17 00:00:00 2001 From: Beats Date: Tue, 14 May 2024 12:22:07 -0300 Subject: [PATCH 2/8] fix: warning build ubuntu (#2490) --- CMakeLists.txt | 4 +- cmake/modules/BaseConfig.cmake | 4 +- src/canary_server.cpp | 2 +- src/canary_server.hpp | 2 +- src/config/configmanager.cpp | 1 - src/creatures/appearance/mounts/mounts.cpp | 9 +- src/creatures/appearance/mounts/mounts.hpp | 8 +- src/creatures/appearance/outfit/outfit.cpp | 31 +++--- src/creatures/appearance/outfit/outfit.hpp | 13 ++- src/creatures/combat/combat.cpp | 24 ++--- src/creatures/combat/combat.hpp | 8 +- src/creatures/combat/condition.cpp | 16 ++- src/creatures/combat/condition.hpp | 42 ++++---- src/creatures/combat/spells.cpp | 5 +- src/creatures/combat/spells.hpp | 6 +- src/creatures/creature.cpp | 36 +++---- src/creatures/creature.hpp | 12 +-- src/creatures/creatures_definitions.hpp | 54 ++-------- src/creatures/interactions/chat.hpp | 6 +- src/creatures/monsters/monster.cpp | 6 +- src/creatures/monsters/monster.hpp | 7 +- src/creatures/monsters/monsters.cpp | 8 +- src/creatures/monsters/monsters.hpp | 10 +- .../monsters/spawns/spawn_monster.cpp | 30 ++---- .../monsters/spawns/spawn_monster.hpp | 6 +- src/creatures/npcs/npc.cpp | 21 ++-- src/creatures/npcs/npc.hpp | 7 +- src/creatures/npcs/npcs.cpp | 10 +- src/creatures/npcs/npcs.hpp | 2 +- src/creatures/npcs/spawns/spawn_npc.cpp | 9 +- src/creatures/npcs/spawns/spawn_npc.hpp | 4 +- .../achievement/player_achievement.hpp | 2 +- src/creatures/players/grouping/familiars.cpp | 22 ++-- src/creatures/players/grouping/familiars.hpp | 30 +++++- src/creatures/players/grouping/groups.cpp | 13 +-- src/creatures/players/grouping/groups.hpp | 6 +- src/creatures/players/grouping/guild.cpp | 2 +- src/creatures/players/grouping/guild.hpp | 3 +- src/creatures/players/grouping/party.cpp | 53 +++++----- src/creatures/players/grouping/party.hpp | 2 +- .../players/grouping/team_finder.hpp | 4 +- src/creatures/players/highscore_category.hpp | 4 +- src/creatures/players/player.cpp | 100 +++++++++--------- src/creatures/players/player.hpp | 8 +- src/creatures/players/wheel/player_wheel.cpp | 14 +-- src/creatures/players/wheel/wheel_gems.hpp | 14 +-- src/game/functions/game_reload.cpp | 1 - src/game/game.cpp | 93 ++++++++-------- src/game/scheduling/events_scheduler.cpp | 1 - src/io/functions/iologindata_load_player.cpp | 4 +- src/io/functions/iologindata_save_player.cpp | 4 +- src/io/iobestiary.cpp | 11 +- src/io/iobestiary.hpp | 12 +-- src/io/iologindata.cpp | 2 +- src/io/iomap.cpp | 9 -- src/items/containers/container.cpp | 2 +- src/items/item.cpp | 2 +- src/items/tile.cpp | 4 +- src/items/weapons/weapons.hpp | 4 +- src/lib/metrics/metrics.cpp | 2 +- src/lib/metrics/metrics.hpp | 12 +-- src/lua/creature/movement.cpp | 2 - src/lua/creature/movement.hpp | 2 +- .../functions/core/game/config_functions.cpp | 1 - .../functions/core/game/game_functions.cpp | 8 +- .../creatures/creature_functions.cpp | 2 +- .../creatures/monster/charm_functions.cpp | 2 +- .../monster/monster_spell_functions.cpp | 2 +- .../functions/creatures/npc/npc_functions.cpp | 2 +- .../creatures/player/group_functions.cpp | 16 +-- .../creatures/player/group_functions.hpp | 2 +- .../creatures/player/player_functions.cpp | 2 +- src/map/house/house.cpp | 52 ++++----- src/map/map.cpp | 2 +- src/map/spectators.cpp | 6 +- src/server/network/protocol/protocolgame.cpp | 58 +++++----- 76 files changed, 482 insertions(+), 520 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4093f4de2d..52c35a471f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,10 +86,9 @@ endif() # === IPO === -option(OPTIONS_ENABLE_IPO "Check and Enable interprocedural optimization (IPO/LTO)" ON) if(OPTIONS_ENABLE_IPO) - log_option_enabled("IPO/LTO") if(MSVC) + log_option_enabled("IPO/LTO") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL") set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") @@ -97,6 +96,7 @@ if(OPTIONS_ENABLE_IPO) set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG") else() if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "Release") + log_option_enabled("IPO/LTO") include(CheckIPOSupported) check_ipo_supported(RESULT result OUTPUT output) if(result) diff --git a/cmake/modules/BaseConfig.cmake b/cmake/modules/BaseConfig.cmake index 7e3f6404b3f..a1980d0f604 100644 --- a/cmake/modules/BaseConfig.cmake +++ b/cmake/modules/BaseConfig.cmake @@ -121,7 +121,9 @@ if (MSVC) endforeach(type) add_compile_options(/MP /FS /Zf /EHsc) -endif (MSVC) +else() + add_compile_options(-Wno-unused-parameter -Wno-sign-compare -Wno-switch -Wno-implicit-fallthrough -Wno-extra) +endif() ## Link compilation files to build/bin folder, else link to the main dir function(set_output_directory target_name) diff --git a/src/canary_server.cpp b/src/canary_server.cpp index bfabbf51ab8..17a36ff3d23 100644 --- a/src/canary_server.cpp +++ b/src/canary_server.cpp @@ -327,7 +327,7 @@ void CanaryServer::loadModules() { // If "USE_ANY_DATAPACK_FOLDER" is set to true then you can choose any datapack folder for your server const auto useAnyDatapack = g_configManager().getBoolean(USE_ANY_DATAPACK_FOLDER, __FUNCTION__); auto datapackName = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__); - if (!useAnyDatapack && (datapackName != "data-canary" && datapackName != "data-otservbr-global" || datapackName != "data-otservbr-global" && datapackName != "data-canary")) { + if (!useAnyDatapack && datapackName != "data-canary" && datapackName != "data-otservbr-global") { throw FailedToInitializeCanary(fmt::format( "The datapack folder name '{}' is wrong, please select valid " "datapack name 'data-canary' or 'data-otservbr-global " diff --git a/src/canary_server.hpp b/src/canary_server.hpp index bb22232b8e4..57c931cd133 100644 --- a/src/canary_server.hpp +++ b/src/canary_server.hpp @@ -46,8 +46,8 @@ class CanaryServer { FAILED }; - RSA &rsa; Logger &logger; + RSA &rsa; ServiceManager &serviceManager; std::atomic loaderStatus = LoaderStatus::LOADING; diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 0525c5a560a..37634abf514 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -11,7 +11,6 @@ #include "config/configmanager.hpp" #include "lib/di/container.hpp" -#include "declarations.hpp" #include "game/game.hpp" #include "server/network/webhook/webhook.hpp" diff --git a/src/creatures/appearance/mounts/mounts.cpp b/src/creatures/appearance/mounts/mounts.cpp index dff0f02a451..7051d04ddb8 100644 --- a/src/creatures/appearance/mounts/mounts.cpp +++ b/src/creatures/appearance/mounts/mounts.cpp @@ -35,7 +35,7 @@ bool Mounts::loadFromXml() { continue; } - mounts.emplace_back(std::make_shared( + mounts.emplace(std::make_shared( static_cast(pugi::cast(mountNode.attribute("id").value())), lookType, mountNode.attribute("name").as_string(), @@ -44,12 +44,11 @@ bool Mounts::loadFromXml() { mountNode.attribute("type").as_string() )); } - mounts.shrink_to_fit(); return true; } std::shared_ptr Mounts::getMountByID(uint8_t id) { - auto it = std::find_if(mounts.begin(), mounts.end(), [id](const std::shared_ptr mount) { + auto it = std::find_if(mounts.begin(), mounts.end(), [id](const std::shared_ptr &mount) { return mount->id == id; // Note the use of -> operator to access the members of the Mount object }); @@ -58,7 +57,7 @@ std::shared_ptr Mounts::getMountByID(uint8_t id) { std::shared_ptr Mounts::getMountByName(const std::string &name) { auto mountName = name.c_str(); - auto it = std::find_if(mounts.begin(), mounts.end(), [mountName](const std::shared_ptr mount) { + auto it = std::find_if(mounts.begin(), mounts.end(), [mountName](const std::shared_ptr &mount) { return strcasecmp(mountName, mount->name.c_str()) == 0; }); @@ -66,7 +65,7 @@ std::shared_ptr Mounts::getMountByName(const std::string &name) { } std::shared_ptr Mounts::getMountByClientID(uint16_t clientId) { - auto it = std::find_if(mounts.begin(), mounts.end(), [clientId](const std::shared_ptr mount) { + auto it = std::find_if(mounts.begin(), mounts.end(), [clientId](const std::shared_ptr &mount) { return mount->clientId == clientId; // Note the use of -> operator to access the members of the Mount object }); diff --git a/src/creatures/appearance/mounts/mounts.hpp b/src/creatures/appearance/mounts/mounts.hpp index 05bd330a66b..ca4f969842a 100644 --- a/src/creatures/appearance/mounts/mounts.hpp +++ b/src/creatures/appearance/mounts/mounts.hpp @@ -11,8 +11,8 @@ struct Mount { Mount(uint8_t initId, uint16_t initClientId, std::string initName, int32_t initSpeed, bool initPremium, std::string initType) : - name(initName), speed(initSpeed), clientId(initClientId), id(initId), premium(initPremium), - type(initType) { } + name(std::move(initName)), speed(initSpeed), clientId(initClientId), id(initId), premium(initPremium), + type(std::move(initType)) { } std::string name; int32_t speed; @@ -30,10 +30,10 @@ class Mounts { std::shared_ptr getMountByName(const std::string &name); std::shared_ptr getMountByClientID(uint16_t clientId); - [[nodiscard]] const std::vector> &getMounts() const { + [[nodiscard]] const phmap::parallel_flat_hash_set> &getMounts() const { return mounts; } private: - std::vector> mounts; + phmap::parallel_flat_hash_set> mounts; }; diff --git a/src/creatures/appearance/outfit/outfit.cpp b/src/creatures/appearance/outfit/outfit.cpp index 6f0490339de..9e96c60e756 100644 --- a/src/creatures/appearance/outfit/outfit.cpp +++ b/src/creatures/appearance/outfit/outfit.cpp @@ -14,6 +14,13 @@ #include "utils/tools.hpp" #include "game/game.hpp" +bool Outfits::reload() { + for (auto &outfitsVector : outfits) { + outfitsVector.clear(); + } + return loadFromXml(); +} + bool Outfits::loadFromXml() { pugi::xml_document doc; auto folder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__) + "/XML/outfits.xml"; @@ -68,10 +75,12 @@ bool Outfits::loadFromXml() { } std::shared_ptr Outfits::getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const { - for (const auto &outfit : outfits[sex]) { - if (outfit->lookType == lookType) { - return outfit; - } + auto it = std::ranges::find_if(outfits[sex], [&lookType](const auto &outfit) { + return outfit->lookType == lookType; + }); + + if (it != outfits[sex].end()) { + return *it; } return nullptr; } @@ -83,17 +92,7 @@ std::shared_ptr Outfits::getOutfitByLookType(PlayerSex_t sex, uint16_t l * @return const pointer to the outfit or nullptr if it could not be found. */ -std::shared_ptr Outfits::getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType) { +std::shared_ptr Outfits::getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const { PlayerSex_t searchSex = (sex == PLAYERSEX_MALE) ? PLAYERSEX_FEMALE : PLAYERSEX_MALE; - - for (uint16_t i = 0; i < outfits[sex].size(); i++) { - if (outfits[sex].at(i)->lookType == lookType) { - if (outfits[searchSex].size() > i) { - return outfits[searchSex].at(i); - } else { // looktype found but the oposite sex array doesn't have this index. - return nullptr; - } - } - } - return nullptr; + return getOutfitByLookType(searchSex, lookType); } diff --git a/src/creatures/appearance/outfit/outfit.hpp b/src/creatures/appearance/outfit/outfit.hpp index e1a5143c673..30b84d1aca2 100644 --- a/src/creatures/appearance/outfit/outfit.hpp +++ b/src/creatures/appearance/outfit/outfit.hpp @@ -12,9 +12,17 @@ #include "declarations.hpp" #include "lib/di/container.hpp" +struct OutfitEntry { + constexpr OutfitEntry(uint16_t initLookType, uint8_t initAddons) : + lookType(initLookType), addons(initAddons) { } + + uint16_t lookType; + uint8_t addons; +}; + struct Outfit { Outfit(std::string initName, uint16_t initLookType, bool initPremium, bool initUnlocked, std::string initFrom) : - name(initName), lookType(initLookType), premium(initPremium), unlocked(initUnlocked), from(initFrom) { } + name(std::move(initName)), lookType(initLookType), premium(initPremium), unlocked(initUnlocked), from(std::move(initFrom)) { } std::string name; uint16_t lookType; @@ -38,9 +46,10 @@ class Outfits { return inject(); } - std::shared_ptr getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType); + std::shared_ptr getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const; bool loadFromXml(); + bool reload(); [[nodiscard]] std::shared_ptr getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const; [[nodiscard]] const std::vector> &getOutfits(PlayerSex_t sex) const { diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 06812095cbf..2aaadac4d61 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -287,7 +287,7 @@ bool Combat::isProtected(std::shared_ptr attacker, std::shared_ptrgetVocation()->canCombat() || !target->getVocation()->canCombat() && (attacker->getVocationId() == VOCATION_NONE || target->getVocationId() == VOCATION_NONE)) { + if ((!attacker->getVocation()->canCombat() || !target->getVocation()->canCombat()) && (attacker->getVocationId() == VOCATION_NONE || target->getVocationId() == VOCATION_NONE)) { return true; } @@ -707,7 +707,7 @@ bool Combat::checkFearConditionAffected(std::shared_ptr player) { auto affectedCount = (party->getMemberCount() + 5) / 5; g_logger().debug("[{}] Player is member of a party, {} members can be feared", __FUNCTION__, affectedCount); - for (const auto member : party->getMembers()) { + for (const auto &member : party->getMembers()) { if (member->hasCondition(CONDITION_FEARED)) { affectedCount -= 1; } @@ -759,7 +759,7 @@ void Combat::CombatConditionFunc(std::shared_ptr caster, std::shared_p } } - if (caster == target || target && !target->isImmune(condition->getType())) { + if (caster == target || (target && !target->isImmune(condition->getType()))) { auto conditionCopy = condition->clone(); if (caster) { conditionCopy->setParam(CONDITION_PARAM_OWNER, caster->getID()); @@ -1030,10 +1030,10 @@ bool Combat::doCombatChain(std::shared_ptr caster, std::shared_ptrgetChainValues(caster, maxTargets, chainDistance, backtracking); - auto targets = pickChainTargets(caster, params, chainDistance, maxTargets, backtracking, aggressive, target); + auto targets = pickChainTargets(caster, params, chainDistance, maxTargets, aggressive, backtracking, std::move(target)); g_logger().debug("[{}] Chain targets: {}", __FUNCTION__, targets.size()); - if (targets.empty() || targets.size() == 1 && targets.begin()->second.empty()) { + if (targets.empty() || (targets.size() == 1 && targets.begin()->second.empty())) { return false; } @@ -1122,7 +1122,7 @@ void Combat::CombatFunc(std::shared_ptr caster, const Position &origin uint32_t maxY = 0; // calculate the max viewable range - for (std::shared_ptr tile : tileList) { + for (const std::shared_ptr &tile : tileList) { const Position &tilePos = tile->getPosition(); uint32_t diff = Position::getDistanceX(tilePos, pos); @@ -1140,7 +1140,7 @@ void Combat::CombatFunc(std::shared_ptr caster, const Position &origin const int32_t rangeY = maxY + MAP_MAX_VIEW_PORT_Y; int affected = 0; - for (std::shared_ptr tile : tileList) { + for (const std::shared_ptr &tile : tileList) { if (canDoCombat(caster, tile, params.aggressive) != RETURNVALUE_NOERROR) { continue; } @@ -1195,7 +1195,7 @@ void Combat::CombatFunc(std::shared_ptr caster, const Position &origin uint8_t beamAffectedCurrent = 0; tmpDamage.affected = affected; - for (std::shared_ptr tile : tileList) { + for (const std::shared_ptr &tile : tileList) { if (canDoCombat(caster, tile, params.aggressive) != RETURNVALUE_NOERROR) { continue; } @@ -1241,7 +1241,7 @@ void Combat::CombatFunc(std::shared_ptr caster, const Position &origin } void Combat::doCombatHealth(std::shared_ptr caster, std::shared_ptr target, CombatDamage &damage, const CombatParams ¶ms) { - doCombatHealth(caster, target, caster ? caster->getPosition() : Position(), damage, params); + doCombatHealth(caster, std::move(target), caster ? caster->getPosition() : Position(), damage, params); } void Combat::doCombatHealth(std::shared_ptr caster, std::shared_ptr target, const Position &origin, CombatDamage &damage, const CombatParams ¶ms) { @@ -1382,7 +1382,7 @@ void Combat::doCombatDispel(std::shared_ptr caster, std::shared_ptr caster, std::shared_ptr target, const CombatParams ¶ms) { +[[maybe_unused]] void Combat::doCombatDefault(std::shared_ptr caster, std::shared_ptr target, const CombatParams ¶ms) { doCombatDefault(caster, target, caster ? caster->getPosition() : Position(), params); } @@ -2076,7 +2076,7 @@ void AreaCombat::setupExtArea(const std::list &list, uint32_t rows) { void MagicField::onStepInField(const std::shared_ptr &creature) { // remove magic walls/wild growth - if (!isBlocking() && g_game().getWorldType() == WORLD_TYPE_NO_PVP && id == ITEM_MAGICWALL_SAFE || id == ITEM_WILDGROWTH_SAFE) { + if ((!isBlocking() && g_game().getWorldType() == WORLD_TYPE_NO_PVP && id == ITEM_MAGICWALL_SAFE) || id == ITEM_WILDGROWTH_SAFE) { if (!creature->isInGhostMode()) { g_game().internalRemoveItem(static_self_cast(), 1); } @@ -2091,7 +2091,7 @@ void MagicField::onStepInField(const std::shared_ptr &creature) { if (ownerId) { bool harmfulField = true; auto itemTile = getTile(); - if (g_game().getWorldType() == WORLD_TYPE_NO_PVP || itemTile && itemTile->hasFlag(TILESTATE_NOPVPZONE)) { + if (g_game().getWorldType() == WORLD_TYPE_NO_PVP || (itemTile && itemTile->hasFlag(TILESTATE_NOPVPZONE))) { auto ownerPlayer = g_game().getPlayerByGUID(ownerId); if (ownerPlayer) { harmfulField = false; diff --git a/src/creatures/combat/combat.hpp b/src/creatures/combat/combat.hpp index 6a79455c7c4..93b02502f25 100644 --- a/src/creatures/combat/combat.hpp +++ b/src/creatures/combat/combat.hpp @@ -72,8 +72,8 @@ class ChainCallback final : public CallBack { private: void onChainCombat(std::shared_ptr creature, uint8_t &chainTargets, uint8_t &chainDistance, bool &backtracking); - uint8_t m_chainTargets = 0; uint8_t m_chainDistance = 0; + uint8_t m_chainTargets = 0; bool m_backtracking = false; bool m_fromLua = false; }; @@ -125,7 +125,7 @@ class MatrixArea { data_[row] = new bool[cols]; for (uint32_t col = 0; col < cols; ++col) { - data_[row][col] = 0; + data_[row][col] = false; } } } @@ -324,7 +324,7 @@ class Combat { } void setPlayerCombatValues(formulaType_t formulaType, double mina, double minb, double maxa, double maxb); void postCombatEffects(std::shared_ptr caster, const Position &origin, const Position &pos) const { - postCombatEffects(caster, origin, pos, params); + postCombatEffects(std::move(caster), origin, pos, params); } void setOrigin(CombatOrigin origin) { @@ -393,7 +393,7 @@ class Combat { * @param damage The combat damage. * @return The calculated level formula. */ - int32_t getLevelFormula(std::shared_ptr player, const std::shared_ptr wheelSpell, const CombatDamage &damage) const; + int32_t getLevelFormula(std::shared_ptr player, std::shared_ptr wheelSpell, const CombatDamage &damage) const; CombatDamage getCombatDamage(std::shared_ptr creature, std::shared_ptr target) const; // configureable diff --git a/src/creatures/combat/condition.cpp b/src/creatures/combat/condition.cpp index 56c67700d13..7f477f1d859 100644 --- a/src/creatures/combat/condition.cpp +++ b/src/creatures/combat/condition.cpp @@ -1472,7 +1472,7 @@ bool ConditionDamage::unserializeProp(ConditionAttr_t attr, PropStream &propStre } else if (attr == CONDITIONATTR_OWNER) { return propStream.skip(4); } else if (attr == CONDITIONATTR_INTERVALDATA) { - IntervalInfo damageInfo; + IntervalInfo damageInfo {}; if (!propStream.read(damageInfo)) { return false; } @@ -1530,7 +1530,7 @@ bool ConditionDamage::addDamage(int32_t rounds, int32_t time, int32_t value) { // rounds, time, damage for (int32_t i = 0; i < rounds; ++i) { - IntervalInfo damageInfo; + IntervalInfo damageInfo {}; damageInfo.interval = time; damageInfo.timeLeft = time; damageInfo.value = value; @@ -1803,13 +1803,9 @@ void ConditionDamage::generateDamageList(int32_t amount, int32_t start, std::lis * ConditionFeared */ bool ConditionFeared::isStuck(std::shared_ptr creature, Position pos) const { - for (Direction dir : m_directionsVector) { - if (canWalkTo(creature, pos, dir)) { - return false; - } - } - - return true; + return std::ranges::all_of(m_directionsVector, [&](Direction dir) { + return !canWalkTo(creature, pos, dir); + }); } bool ConditionFeared::getRandomDirection(std::shared_ptr creature, Position pos) { @@ -1995,6 +1991,8 @@ bool ConditionFeared::getFleePath(std::shared_ptr creature, const Posi futurePos.y -= wsize; g_logger().debug("[{}] Trying to flee to NORTHWEST to {} [{}]", __FUNCTION__, futurePos.toString(), wsize); break; + case DIRECTION_NONE: + break; } found = creature->getPathTo(futurePos, dirList, 0, 30); diff --git a/src/creatures/combat/condition.hpp b/src/creatures/combat/condition.hpp index 539a8711723..07b31b42d15 100644 --- a/src/creatures/combat/condition.hpp +++ b/src/creatures/combat/condition.hpp @@ -27,7 +27,7 @@ class Condition : public SharedObject { virtual bool startCondition(std::shared_ptr creature); virtual bool executeCondition(std::shared_ptr creature, int32_t interval); virtual void endCondition(std::shared_ptr creature) = 0; - virtual void addCondition(std::shared_ptr creature, const std::shared_ptr condition) = 0; + virtual void addCondition(std::shared_ptr creature, std::shared_ptr condition) = 0; virtual uint32_t getIcons() const; ConditionId_t getId() const { return id; @@ -65,14 +65,14 @@ class Condition : public SharedObject { protected: uint8_t drainBodyStage = 0; - int64_t endTime; - uint32_t subId; - int32_t ticks; - ConditionType_t conditionType; - ConditionId_t id; - bool isBuff; + int64_t endTime {}; + uint32_t subId {}; + int32_t ticks {}; + ConditionType_t conditionType {}; + ConditionId_t id {}; + bool isBuff {}; - virtual bool updateCondition(const std::shared_ptr addCondition); + virtual bool updateCondition(std::shared_ptr addCondition); private: SoundEffect_t tickSound = SoundEffect_t::SILENCE; @@ -90,7 +90,7 @@ class ConditionGeneric : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; uint32_t getIcons() const override; std::shared_ptr clone() const override { @@ -106,7 +106,7 @@ class ConditionAttributes final : public ConditionGeneric { bool startCondition(std::shared_ptr creature) final; bool executeCondition(std::shared_ptr creature, int32_t interval) final; void endCondition(std::shared_ptr creature) final; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) final; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) final; bool setParam(ConditionParam_t param, int32_t value) final; @@ -172,7 +172,7 @@ class ConditionRegeneration final : public ConditionGeneric { bool startCondition(std::shared_ptr creature) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr addCondition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr addCondition) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; bool setParam(ConditionParam_t param, int32_t value) override; @@ -205,7 +205,7 @@ class ConditionManaShield final : public Condition { bool startCondition(std::shared_ptr creature) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr addCondition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr addCondition) override; uint32_t getIcons() const override; bool setParam(ConditionParam_t param, int32_t value) override; @@ -227,7 +227,7 @@ class ConditionSoul final : public ConditionGeneric { ConditionSoul(ConditionId_t initId, ConditionType_t initType, int32_t iniTicks, bool initBuff = false, uint32_t initSubId = 0) : ConditionGeneric(initId, initType, iniTicks, initBuff, initSubId) { } - void addCondition(std::shared_ptr creature, const std::shared_ptr addCondition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr addCondition) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; bool setParam(ConditionParam_t param, int32_t value) override; @@ -270,7 +270,7 @@ class ConditionDamage final : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; uint32_t getIcons() const override; std::shared_ptr clone() const override { @@ -309,7 +309,7 @@ class ConditionDamage final : public Condition { bool getNextDamage(int32_t &damage); bool doDamage(std::shared_ptr creature, int32_t healthChange); - bool updateCondition(const std::shared_ptr addCondition) override; + bool updateCondition(std::shared_ptr addCondition) override; }; class ConditionFeared final : public Condition { @@ -321,7 +321,7 @@ class ConditionFeared final : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; uint32_t getIcons() const override; std::shared_ptr clone() const override { @@ -360,7 +360,7 @@ class ConditionSpeed final : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; uint32_t getIcons() const override; std::shared_ptr clone() const override { @@ -395,7 +395,7 @@ class ConditionOutfit final : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; std::shared_ptr clone() const override { return std::make_shared(*this); @@ -421,7 +421,7 @@ class ConditionLight final : public Condition { bool startCondition(std::shared_ptr creature) override; bool executeCondition(std::shared_ptr creature, int32_t interval) override; void endCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr addCondition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr addCondition) override; std::shared_ptr clone() const override { return std::make_shared(*this); @@ -445,7 +445,7 @@ class ConditionSpellCooldown final : public ConditionGeneric { ConditionGeneric(initId, initType, initTicks, initBuff, initSubId) { } bool startCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; std::shared_ptr clone() const override { return std::make_shared(*this); @@ -458,7 +458,7 @@ class ConditionSpellGroupCooldown final : public ConditionGeneric { ConditionGeneric(initId, initType, initTicks, initBuff, initSubId) { } bool startCondition(std::shared_ptr creature) override; - void addCondition(std::shared_ptr creature, const std::shared_ptr condition) override; + void addCondition(std::shared_ptr creature, std::shared_ptr condition) override; std::shared_ptr clone() const override { return std::make_shared(*this); diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index 3aa445b34aa..dd4305de14e 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -766,7 +766,6 @@ uint32_t Spell::getManaCost(std::shared_ptr player) const { if (manaPercent != 0) { uint32_t maxMana = player->getMaxMana(); uint32_t manaCost = (maxMana * manaPercent) / 100; - WheelSpellGrade_t spellGrade = player->wheel()->getSpellUpgrade(getName()); if (manaRedution > manaCost) { return 0; } @@ -789,7 +788,7 @@ bool InstantSpell::playerCastInstant(std::shared_ptr player, std::string var.type = VARIANT_NUMBER; var.number = player->getID(); } else if (needTarget || casterTargetOrDirection) { - std::shared_ptr target = nullptr; + std::shared_ptr target; bool useDirection = false; if (hasParam) { @@ -1085,7 +1084,7 @@ bool RuneSpell::castSpell(std::shared_ptr creature, std::shared_ptr creature, const LuaVariant &var, bool isHotkey) { bool result; if (isLoadedCallback()) { - result = executeCastSpell(creature, var, isHotkey); + result = executeCastSpell(std::move(creature), var, isHotkey); } else { result = false; } diff --git a/src/creatures/combat/spells.hpp b/src/creatures/combat/spells.hpp index dce7b3caba4..fc23bbf9030 100644 --- a/src/creatures/combat/spells.hpp +++ b/src/creatures/combat/spells.hpp @@ -63,8 +63,8 @@ class Spells final : public Scripts { } void clear(); - bool registerInstantLuaEvent(const std::shared_ptr instant); - bool registerRuneLuaEvent(const std::shared_ptr rune); + bool registerInstantLuaEvent(std::shared_ptr instant); + bool registerRuneLuaEvent(std::shared_ptr rune); private: std::map> runes; @@ -92,7 +92,7 @@ class BaseSpell { class CombatSpell final : public Script, public BaseSpell, public std::enable_shared_from_this { public: // Constructor - CombatSpell(const std::shared_ptr newCombat, bool newNeedTarget, bool newNeedDirection); + CombatSpell(std::shared_ptr newCombat, bool newNeedTarget, bool newNeedDirection); // The copy constructor and the assignment operator have been deleted to prevent accidental copying. CombatSpell(const CombatSpell &) = delete; diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index fd78e33ecf4..43e7ab89ccf 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -125,7 +125,7 @@ void Creature::onThink(uint32_t interval) { auto onThink = [self = getCreature(), interval] { // scripting event - onThink const auto &thinkEvents = self->getCreatureEvents(CREATURE_EVENT_THINK); - for (const auto creatureEventPtr : thinkEvents) { + for (const auto &creatureEventPtr : thinkEvents) { creatureEventPtr->executeOnThink(self->static_self_cast(), interval); } }; @@ -299,7 +299,7 @@ void Creature::updateTileCache(std::shared_ptr upTile, const Position &pos if (pos.z == myPos.z) { int32_t dx = Position::getOffsetX(pos, myPos); int32_t dy = Position::getOffsetY(pos, myPos); - updateTileCache(upTile, dx, dy); + updateTileCache(std::move(upTile), dx, dy); } } @@ -332,7 +332,7 @@ int32_t Creature::getWalkCache(const Position &pos) { void Creature::onAddTileItem(std::shared_ptr tileItem, const Position &pos) { if (isMapLoaded && pos.z == getPosition().z) { - updateTileCache(tileItem, pos); + updateTileCache(std::move(tileItem), pos); } } @@ -343,7 +343,7 @@ void Creature::onUpdateTileItem(std::shared_ptr updateTile, const Position if (oldType.blockSolid || oldType.blockPathFind || newType.blockPathFind || newType.blockSolid) { if (pos.z == getPosition().z) { - updateTileCache(updateTile, pos); + updateTileCache(std::move(updateTile), pos); } } } @@ -355,7 +355,7 @@ void Creature::onRemoveTileItem(std::shared_ptr updateTile, const Position if (iType.blockSolid || iType.blockPathFind || iType.isGroundTile()) { if (pos.z == getPosition().z) { - updateTileCache(updateTile, pos); + updateTileCache(std::move(updateTile), pos); } } } @@ -439,7 +439,7 @@ void Creature::checkSummonMove(const Position &newPos, bool teleportSummon) { // Check if any of our summons is out of range (+/- 2 floors or 30 tiles away) bool checkRemoveDist = Position::getDistanceZ(newPos, pos) > 2 || (std::max(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) > 30); - if (monster && monster->isFamiliar() && checkSummonDist || teleportSummon && !protectionZoneCheck && checkSummonDist) { + if ((monster && monster->isFamiliar() && checkSummonDist) || (teleportSummon && !protectionZoneCheck && checkSummonDist)) { const auto &creatureMaster = summon->getMaster(); if (!creatureMaster) { continue; @@ -709,7 +709,7 @@ void Creature::onDeath() { } } - bool killedByPlayer = mostDamageCreature && mostDamageCreature->getPlayer() || mostDamageCreatureMaster && mostDamageCreatureMaster->getPlayer(); + bool killedByPlayer = (mostDamageCreature && mostDamageCreature->getPlayer()) || (mostDamageCreatureMaster && mostDamageCreatureMaster->getPlayer()); if (getPlayer()) { g_metrics().addCounter( "player_death", @@ -761,7 +761,7 @@ bool Creature::dropCorpse(std::shared_ptr lastHitCreature, std::shared if (getMaster()) { // Scripting event onDeath const CreatureEventList &deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH); - for (const auto deathEventPtr : deathEvents) { + for (const auto &deathEventPtr : deathEvents) { deathEventPtr->executeOnDeath(static_self_cast(), nullptr, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } } @@ -834,7 +834,7 @@ bool Creature::dropCorpse(std::shared_ptr lastHitCreature, std::shared } // Scripting event onDeath - for (const auto deathEventPtr : getCreatureEvents(CREATURE_EVENT_DEATH)) { + for (const auto &deathEventPtr : getCreatureEvents(CREATURE_EVENT_DEATH)) { if (deathEventPtr) { deathEventPtr->executeOnDeath(static_self_cast(), corpse, lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified); } @@ -1169,7 +1169,7 @@ double Creature::getDamageRatio(std::shared_ptr attacker) const { } uint64_t Creature::getGainedExperience(std::shared_ptr attacker) const { - return std::floor(getDamageRatio(attacker) * getLostExperience()); + return std::floor(getDamageRatio(std::move(attacker)) * getLostExperience()); } void Creature::addDamagePoints(std::shared_ptr attacker, int32_t damagePoints) { @@ -1181,7 +1181,7 @@ void Creature::addDamagePoints(std::shared_ptr attacker, int32_t damag auto it = damageMap.find(attackerId); if (it == damageMap.end()) { - CountBlock_t cb; + CountBlock_t cb {}; cb.ticks = OTSYS_TIME(); cb.total = damagePoints; damageMap[attackerId] = cb; @@ -1247,7 +1247,7 @@ void Creature::onTickCondition(ConditionType_t type, bool &bRemove) { } void Creature::onCombatRemoveCondition(std::shared_ptr condition) { - removeCondition(condition); + removeCondition(std::move(condition)); } void Creature::onAttacked() { @@ -1275,7 +1275,7 @@ bool Creature::deprecatedOnKilledCreature(std::shared_ptr target, bool // scripting event - onKill const CreatureEventList &killEvents = getCreatureEvents(CREATURE_EVENT_KILL); - for (const auto killEventPtr : killEvents) { + for (const auto &killEventPtr : killEvents) { killEventPtr->executeOnKill(static_self_cast(), target, lastHit); } return false; @@ -1293,7 +1293,7 @@ void Creature::onGainExperience(uint64_t gainExp, std::shared_ptr targ gainExp /= 2; } - master->onGainExperience(gainExp, target); + master->onGainExperience(gainExp, std::move(target)); if (!m->isFamiliar()) { auto spectators = Spectators().find(position); @@ -1574,7 +1574,7 @@ void Creature::setSpeed(int32_t varSpeedDelta) { } void Creature::setCreatureLight(LightInfo lightInfo) { - internalLight = std::move(lightInfo); + internalLight = lightInfo; } void Creature::setNormalCreatureLight() { @@ -1589,7 +1589,7 @@ bool Creature::registerCreatureEvent(const std::string &name) { CreatureEventType_t type = event->getEventType(); if (hasEventRegistered(type)) { - for (const auto creatureEventPtr : eventsList) { + for (const auto &creatureEventPtr : eventsList) { if (creatureEventPtr == event) { return false; } @@ -1642,7 +1642,7 @@ CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type) { return tmpEventList; } - for (const auto creatureEventPtr : eventsList) { + for (const auto &creatureEventPtr : eventsList) { if (creatureEventPtr->getEventType() == type) { tmpEventList.push_back(creatureEventPtr); } @@ -1727,7 +1727,7 @@ bool FrozenPathingConditionCall::operator()(const Position &startPos, const Posi } bool Creature::isInvisible() const { - return std::find_if(conditions.begin(), conditions.end(), [](const std::shared_ptr condition) { + return std::find_if(conditions.begin(), conditions.end(), [](const std::shared_ptr &condition) { return condition->getType() == CONDITION_INVISIBLE; }) != conditions.end(); diff --git a/src/creatures/creature.hpp b/src/creatures/creature.hpp index 2c92032bd65..670d5f3d688 100644 --- a/src/creatures/creature.hpp +++ b/src/creatures/creature.hpp @@ -400,13 +400,13 @@ class Creature : virtual public Thing, public SharedObject { void executeConditions(uint32_t interval); bool hasCondition(ConditionType_t type, uint32_t subId = 0) const; - virtual bool isImmune(CombatType_t type) const { + virtual bool isImmune([[maybe_unused]] CombatType_t type) const { return false; } - virtual bool isImmune(ConditionType_t type) const { + virtual bool isImmune([[maybe_unused]] ConditionType_t type) const { return false; } - virtual bool isSuppress(ConditionType_t type, bool attackerPlayer) const { + virtual bool isSuppress([[maybe_unused]] ConditionType_t type, [[maybe_unused]] bool attackerPlayer) const { return false; }; @@ -424,7 +424,7 @@ class Creature : virtual public Thing, public SharedObject { virtual void drainHealth(std::shared_ptr attacker, int32_t damage); virtual void drainMana(std::shared_ptr attacker, int32_t manaLoss); - virtual bool challengeCreature(std::shared_ptr, int targetChangeCooldown) { + virtual bool challengeCreature(std::shared_ptr, [[maybe_unused]] int targetChangeCooldown) { return false; } @@ -448,10 +448,10 @@ class Creature : virtual public Thing, public SharedObject { * @deprecated -- This is here to trigger the deprecated onKill events in lua */ bool deprecatedOnKilledCreature(std::shared_ptr target, bool lastHit); - virtual bool onKilledPlayer(const std::shared_ptr &target, bool lastHit) { + virtual bool onKilledPlayer([[maybe_unused]] const std::shared_ptr &target, [[maybe_unused]] bool lastHit) { return false; }; - virtual bool onKilledMonster(const std::shared_ptr &target) { + virtual bool onKilledMonster([[maybe_unused]] const std::shared_ptr &target) { return false; }; virtual void onGainExperience(uint64_t gainExp, std::shared_ptr target); diff --git a/src/creatures/creatures_definitions.hpp b/src/creatures/creatures_definitions.hpp index 46fb5fe5979..136f587a64a 100644 --- a/src/creatures/creatures_definitions.hpp +++ b/src/creatures/creatures_definitions.hpp @@ -124,7 +124,7 @@ enum ConditionType_t : uint8_t { // constexpr definiting suppressible conditions constexpr bool IsConditionSuppressible(ConditionType_t condition) { - constexpr ConditionType_t suppressibleConditions[] = { + constexpr std::array suppressibleConditions = { CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, @@ -135,13 +135,9 @@ constexpr bool IsConditionSuppressible(ConditionType_t condition) { CONDITION_CURSED, }; - for (const auto &suppressibleCondition : suppressibleConditions) { - if (condition == suppressibleCondition) { - return true; - } - } - - return false; + return std::ranges::any_of(suppressibleConditions, [condition](const auto &suppressibleCondition) { + return condition == suppressibleCondition; + }); } enum ConditionParam_t { @@ -1415,20 +1411,6 @@ struct VIPEntry { bool notify; }; -struct OutfitEntry { - constexpr OutfitEntry(uint16_t initLookType, uint8_t initAddons) : - lookType(initLookType), addons(initAddons) { } - - uint16_t lookType; - uint8_t addons; -}; - -struct FamiliarEntry { - constexpr explicit FamiliarEntry(uint16_t initLookType) : - lookType(initLookType) { } - uint16_t lookType; -}; - struct Skill { uint64_t tries = 0; uint16_t level = 10; @@ -1539,19 +1521,6 @@ using ItemsTierCountList = std::map>; | ... */ -struct Familiar { - Familiar(std::string initName, uint16_t initLookType, bool initPremium, bool initUnlocked, std::string initType) : - name(initName), lookType(initLookType), - premium(initPremium), unlocked(initUnlocked), - type(initType) { } - - std::string name; - uint16_t lookType; - bool premium; - bool unlocked; - std::string type; -}; - struct ProtocolFamiliars { ProtocolFamiliars(const std::string &initName, uint16_t initLookType) : name(initName), lookType(initLookType) { } @@ -1654,18 +1623,11 @@ struct ShopBlock { int32_t itemStorageValue; std::vector childShop; - ShopBlock() { - itemId = 0; - itemName = ""; - itemSubType = 0; - itemBuyPrice = 0; - itemSellPrice = 0; - itemStorageKey = 0; - itemStorageValue = 0; - } + ShopBlock() : + itemId(0), itemName(""), itemSubType(0), itemBuyPrice(0), itemSellPrice(0), itemStorageKey(0), itemStorageValue(0) { } - explicit ShopBlock(uint16_t newItemId, int32_t newSubType = 0, uint32_t newBuyPrice = 0, uint32_t newSellPrice = 0, int32_t newStorageKey = 0, int32_t newStorageValue = 0, std::string newName = "") : - itemId(newItemId), itemSubType(newSubType), itemBuyPrice(newBuyPrice), itemSellPrice(newSellPrice), itemStorageKey(newStorageKey), itemStorageValue(newStorageValue), itemName(std::move(newName)) { } + explicit ShopBlock(uint16_t newItemId, std::string newName = "", int32_t newSubType = 0, uint32_t newBuyPrice = 0, uint32_t newSellPrice = 0, int32_t newStorageKey = 0, int32_t newStorageValue = 0) : + itemId(newItemId), itemName(std::move(newName)), itemSubType(newSubType), itemBuyPrice(newBuyPrice), itemSellPrice(newSellPrice), itemStorageKey(newStorageKey), itemStorageValue(newStorageValue) { } bool operator==(const ShopBlock &other) const { return itemId == other.itemId && itemName == other.itemName && itemSubType == other.itemSubType && itemBuyPrice == other.itemBuyPrice && itemSellPrice == other.itemSellPrice && itemStorageKey == other.itemStorageKey && itemStorageValue == other.itemStorageValue && childShop == other.childShop; diff --git a/src/creatures/interactions/chat.hpp b/src/creatures/interactions/chat.hpp index 022b3f540a1..3643086184c 100644 --- a/src/creatures/interactions/chat.hpp +++ b/src/creatures/interactions/chat.hpp @@ -71,7 +71,7 @@ class ChatChannel { int32_t onLeaveEvent = -1; int32_t onSpeakEvent = -1; - uint16_t id; + uint16_t id {}; bool publicChannel = false; friend class Chat; @@ -79,8 +79,8 @@ class ChatChannel { class PrivateChatChannel final : public ChatChannel { public: - PrivateChatChannel(uint16_t channelId, std::string channelName) : - ChatChannel(channelId, channelName) { } + PrivateChatChannel(uint16_t channelId, [[maybe_unused]] std::string channelName) : + ChatChannel(channelId, std::move(channelName)) { } uint32_t getOwner() const override { return owner; diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index f15616d6af5..fccc19b05e5 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -385,7 +385,7 @@ void Monster::onCreatureFound(std::shared_ptr creature, bool pushFront } void Monster::onCreatureEnter(std::shared_ptr creature) { - onCreatureFound(creature, true); + onCreatureFound(std::move(creature), true); } bool Monster::isFriend(const std::shared_ptr &creature) const { @@ -701,7 +701,7 @@ void Monster::updateIdleStatus() { isWalkingBack = true; } } else if (const auto &master = getMaster()) { - if ((!isSummon() && totalPlayersOnScreen == 0 || isSummon() && master->getMonster() && master->getMonster()->totalPlayersOnScreen == 0) && getFaction() != FACTION_DEFAULT) { + if (((!isSummon() && totalPlayersOnScreen == 0) || (isSummon() && master->getMonster() && master->getMonster()->totalPlayersOnScreen == 0)) && getFaction() != FACTION_DEFAULT) { idle = true; } } @@ -838,7 +838,7 @@ void Monster::doAttacking(uint32_t interval) { for (const spellBlock_t &spellBlock : mType->info.attackSpells) { bool inRange = false; - if (spellBlock.spell == nullptr || spellBlock.isMelee && isFleeing()) { + if (spellBlock.spell == nullptr || (spellBlock.isMelee && isFleeing())) { continue; } diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index edf3874161d..bf9a39e4133 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -15,7 +15,6 @@ class Creature; class Game; -class Spawn; class Monster final : public Creature { public: @@ -23,7 +22,7 @@ class Monster final : public Creature { static int32_t despawnRange; static int32_t despawnRadius; - explicit Monster(const std::shared_ptr mType); + explicit Monster(std::shared_ptr mType); // non-copyable Monster(const Monster &) = delete; @@ -160,7 +159,7 @@ class Monster final : public Creature { } std::vector getIcons() const override { - const auto creatureIcons = Creature::getIcons(); + auto creatureIcons = Creature::getIcons(); if (!creatureIcons.empty()) { return creatureIcons; } @@ -324,7 +323,7 @@ class Monster final : public Creature { return timeToChangeFiendish; } - const std::shared_ptr getMonsterType() const { + std::shared_ptr getMonsterType() const { return mType; } diff --git a/src/creatures/monsters/monsters.cpp b/src/creatures/monsters/monsters.cpp index 190c14c76e5..3d457aa4d47 100644 --- a/src/creatures/monsters/monsters.cpp +++ b/src/creatures/monsters/monsters.cpp @@ -20,7 +20,7 @@ void MonsterType::loadLoot(const std::shared_ptr monsterType, LootB if (lootBlock.childLoot.empty()) { bool isContainer = Item::items[lootBlock.id].isContainer(); if (isContainer) { - for (LootBlock child : lootBlock.childLoot) { + for (const LootBlock &child : lootBlock.childLoot) { lootBlock.childLoot.push_back(child); } } @@ -74,7 +74,7 @@ bool Monsters::deserializeSpell(const std::shared_ptr spell, spell return true; } - std::shared_ptr combatSpell = nullptr; + std::shared_ptr combatSpell; auto combatPtr = std::make_shared(); @@ -156,7 +156,7 @@ bool Monsters::deserializeSpell(const std::shared_ptr spell, spell std::shared_ptr condition = Condition::createCondition(CONDITIONID_COMBAT, CONDITION_OUTFIT, duration, 0)->static_self_cast(); - if (spell->outfitMonster != "") { + if (!spell->outfitMonster.empty()) { condition->setLazyMonsterOutfit(spell->outfitMonster); } else if (spell->outfitItem > 0) { Outfit_t outfit; @@ -307,7 +307,7 @@ std::shared_ptr Monsters::getMonsterType(const std::string &name, b } std::shared_ptr Monsters::getMonsterTypeByRaceId(uint16_t raceId, bool isBoss /* = false*/) const { - const auto bossType = g_ioBosstiary().getMonsterTypeByBossRaceId(raceId); + auto bossType = g_ioBosstiary().getMonsterTypeByBossRaceId(raceId); if (isBoss && bossType) { return bossType; } diff --git a/src/creatures/monsters/monsters.hpp b/src/creatures/monsters/monsters.hpp index 0fa2a3d88db..518befd8a70 100644 --- a/src/creatures/monsters/monsters.hpp +++ b/src/creatures/monsters/monsters.hpp @@ -30,7 +30,7 @@ struct spellBlock_t { ~spellBlock_t() = default; spellBlock_t(const spellBlock_t &other) = delete; spellBlock_t &operator=(const spellBlock_t &other) = delete; - spellBlock_t(spellBlock_t &&other) : + spellBlock_t(spellBlock_t &&other) noexcept : spell(other.spell), chance(other.chance), speed(other.speed), @@ -57,7 +57,7 @@ struct spellBlock_t { class MonsterType { struct MonsterInfo { - LuaScriptInterface* scriptInterface; + LuaScriptInterface* scriptInterface {}; std::map elementMap; std::map reflectMap; @@ -201,7 +201,7 @@ class MonsterType { return !info.bosstiaryClass.empty(); } - void loadLoot(const std::shared_ptr monsterType, LootBlock lootblock); + void loadLoot(std::shared_ptr monsterType, LootBlock lootblock); bool canSpawn(const Position &pos); }; @@ -271,8 +271,8 @@ class Monsters { std::shared_ptr getMonsterType(const std::string &name, bool silent = false) const; std::shared_ptr getMonsterTypeByRaceId(uint16_t raceId, bool isBoss = false) const; - bool tryAddMonsterType(const std::string &name, const std::shared_ptr mType); - bool deserializeSpell(const std::shared_ptr spell, spellBlock_t &sb, const std::string &description = ""); + bool tryAddMonsterType(const std::string &name, std::shared_ptr mType); + bool deserializeSpell(std::shared_ptr spell, spellBlock_t &sb, const std::string &description = ""); std::unique_ptr scriptInterface; std::map> monsters; diff --git a/src/creatures/monsters/spawns/spawn_monster.cpp b/src/creatures/monsters/spawns/spawn_monster.cpp index 21eab1a7c0b..ef5912c8052 100644 --- a/src/creatures/monsters/spawns/spawn_monster.cpp +++ b/src/creatures/monsters/spawns/spawn_monster.cpp @@ -39,7 +39,6 @@ bool SpawnsMonster::loadFromXML(const std::string &filemonstername) { this->filemonstername = filemonstername; loaded = true; - uint32_t eventschedule = g_eventsScheduler().getSpawnMonsterSchedule(); std::string boostedNameGet = g_game().getBoostedMonsterName(); for (auto spawnMonsterNode : doc.child("monsters").children()) { @@ -89,12 +88,6 @@ bool SpawnsMonster::loadFromXML(const std::string &filemonstername) { centerPos.z ); - int32_t boostedrate = 1; - - if (nameAttribute.value() == boostedNameGet) { - boostedrate = 2; - } - pugi::xml_attribute weightAttribute = childMonsterNode.attribute("weight"); uint32_t weight = 1; if (weightAttribute) { @@ -157,12 +150,9 @@ SpawnMonster::~SpawnMonster() { bool SpawnMonster::findPlayer(const Position &pos) { auto spectators = Spectators().find(pos); - for (const auto &spectator : spectators) { - if (!spectator->getPlayer()->hasFlag(PlayerFlags_t::IgnoredByMonsters)) { - return true; - } - } - return false; + return std::ranges::any_of(spectators, [](const auto &spectator) { + return !spectator->getPlayer()->hasFlag(PlayerFlags_t::IgnoredByMonsters); + }); } bool SpawnMonster::isInSpawnMonsterZone(const Position &pos) { @@ -299,7 +289,7 @@ void SpawnMonster::cleanup() { } bool SpawnMonster::addMonster(const std::string &name, const Position &pos, Direction dir, uint32_t scheduleInterval, uint32_t weight /*= 1*/) { - std::string variant = ""; + std::string variant; for (const auto &zone : Zone::getZones(pos)) { if (!zone->getMonsterVariant().empty()) { variant = zone->getMonsterVariant() + "|"; @@ -343,7 +333,7 @@ bool SpawnMonster::addMonster(const std::string &name, const Position &pos, Dire g_logger().error("[SpawnMonster] Monster {} already exists in spawn block at {}", name, pos.toString()); return false; } - if (monsterType->isBoss() && sb->monsterTypes.size() > 0) { + if (monsterType->isBoss() && !sb->monsterTypes.empty()) { g_logger().error("[SpawnMonster] Boss monster {} has been added to spawn block with other monsters. This is not allowed.", name); return false; } @@ -436,10 +426,8 @@ std::shared_ptr spawnBlock_t::getMonsterType() const { } bool spawnBlock_t::hasBoss() const { - for (const auto &[monsterType, weight] : monsterTypes) { - if (monsterType->isBoss()) { - return true; - } - } - return false; + return std::ranges::any_of(monsterTypes, [](const auto &pair) { + const auto &[monsterType, weight] = pair; + return monsterType->isBoss(); + }); } diff --git a/src/creatures/monsters/spawns/spawn_monster.hpp b/src/creatures/monsters/spawns/spawn_monster.hpp index 800b36fda5a..35b856d23d4 100644 --- a/src/creatures/monsters/spawns/spawn_monster.hpp +++ b/src/creatures/monsters/spawns/spawn_monster.hpp @@ -29,7 +29,7 @@ struct spawnBlock_t { class SpawnMonster { public: SpawnMonster(Position initPos, int32_t initRadius) : - centerPos(std::move(initPos)), radius(initRadius) { } + centerPos(initPos), radius(initRadius) { } ~SpawnMonster(); // non-copyable @@ -71,9 +71,9 @@ class SpawnMonster { uint32_t checkSpawnMonsterEvent = 0; static bool findPlayer(const Position &pos); - bool spawnMonster(uint32_t spawnMonsterId, spawnBlock_t &sb, const std::shared_ptr monsterType, bool startup = false); + bool spawnMonster(uint32_t spawnMonsterId, spawnBlock_t &sb, std::shared_ptr monsterType, bool startup = false); void checkSpawnMonster(); - void scheduleSpawn(uint32_t spawnMonsterId, spawnBlock_t &sb, const std::shared_ptr monsterType, uint16_t interval, bool startup = false); + void scheduleSpawn(uint32_t spawnMonsterId, spawnBlock_t &sb, std::shared_ptr monsterType, uint16_t interval, bool startup = false); }; class SpawnsMonster { diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index d347ec6b66c..e445a58fcca 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -52,9 +52,6 @@ Npc::Npc(const std::shared_ptr &npcType) : } } -Npc::~Npc() { -} - void Npc::addList() { g_game().addNpc(static_self_cast()); } @@ -248,7 +245,7 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 uint32_t shoppingBagSlots = 20; const ItemType &itemType = Item::items[itemId]; if (std::shared_ptr tile = ignore ? player->getTile() : nullptr; tile) { - double slotsNedeed = 0; + double slotsNedeed; if (itemType.stackable) { slotsNedeed = inBackpacks ? std::ceil(std::ceil(static_cast(amount) / itemType.stackSize) / shoppingBagSlots) : std::ceil(static_cast(amount) / itemType.stackSize); } else { @@ -263,7 +260,7 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 uint32_t buyPrice = 0; const std::vector &shopVector = getShopItemVector(player->getGUID()); - for (ShopBlock shopBlock : shopVector) { + for (const ShopBlock &shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemBuyPrice != 0) { buyPrice = shopBlock.itemBuyPrice; } @@ -308,7 +305,7 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 void Npc::onPlayerSellItem(std::shared_ptr player, uint16_t itemId, uint8_t subType, uint16_t amount, bool ignore) { uint64_t totalPrice = 0; - onPlayerSellItem(player, itemId, subType, amount, ignore, totalPrice); + onPlayerSellItem(std::move(player), itemId, subType, amount, ignore, totalPrice); } void Npc::onPlayerSellAllLoot(uint32_t playerId, uint16_t itemId, bool ignore, uint64_t totalPrice) { @@ -324,7 +321,6 @@ void Npc::onPlayerSellAllLoot(uint32_t playerId, uint16_t itemId, bool ignore, u bool hasMore = false; uint64_t toSellCount = 0; phmap::flat_hash_map toSell; - int64_t start = OTSYS_TIME(); for (ContainerIterator it = container->iterator(); it.hasNext(); it.advance()) { if (toSellCount >= 500) { hasMore = true; @@ -341,8 +337,8 @@ void Npc::onPlayerSellAllLoot(uint32_t playerId, uint16_t itemId, bool ignore, u toSellCount += item->getItemAmount(); } } - for (auto &[itemId, amount] : toSell) { - onPlayerSellItem(player, itemId, 0, amount, ignore, totalPrice, container); + for (auto &[m_itemId, amount] : toSell) { + onPlayerSellItem(player, m_itemId, 0, amount, ignore, totalPrice, container); } auto ss = std::stringstream(); if (totalPrice == 0) { @@ -377,7 +373,7 @@ void Npc::onPlayerSellItem(std::shared_ptr player, uint16_t itemId, uint uint32_t sellPrice = 0; const ItemType &itemType = Item::items[itemId]; const std::vector &shopVector = getShopItemVector(player->getGUID()); - for (ShopBlock shopBlock : shopVector) { + for (const ShopBlock &shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemSellPrice != 0) { sellPrice = shopBlock.itemSellPrice; } @@ -387,7 +383,7 @@ void Npc::onPlayerSellItem(std::shared_ptr player, uint16_t itemId, uint } auto toRemove = amount; - for (auto item : player->getInventoryItemsFromId(itemId, ignore)) { + for (const auto &item : player->getInventoryItemsFromId(itemId, ignore)) { if (!item || item->getTier() > 0 || item->hasImbuements()) { continue; } @@ -452,7 +448,6 @@ void Npc::onPlayerCheckItem(std::shared_ptr player, uint16_t itemId, uin return; } - const ItemType &itemType = Item::items[itemId]; // onPlayerCheckItem(self, player, itemId, subType) CreatureCallback callback = CreatureCallback(npcType->info.scriptInterface, getNpc()); if (callback.startScriptInterface(npcType->info.playerLookEvent)) { @@ -515,7 +510,7 @@ void Npc::onThinkWalk(uint32_t interval) { } // If talking, no walking - if (playerInteractions.size() > 0) { + if (!playerInteractions.empty()) { walkTicks = 0; eventWalk = 0; return; diff --git a/src/creatures/npcs/npc.hpp b/src/creatures/npcs/npc.hpp index 2d4e87ac7b8..7e8be84c7f1 100644 --- a/src/creatures/npcs/npc.hpp +++ b/src/creatures/npcs/npc.hpp @@ -27,7 +27,6 @@ class Npc final : public Creature { explicit Npc(const std::shared_ptr &npcType); Npc() = default; - ~Npc(); // Singleton - ensures we don't accidentally copy it Npc(const Npc &) = delete; @@ -68,7 +67,7 @@ class Npc final : public Creature { } void setName(std::string newName) { - npcType->name = newName; + npcType->name = std::move(newName); } CreatureType_t getType() const override { @@ -190,13 +189,13 @@ class Npc final : public Creature { std::shared_ptr npcType; std::shared_ptr spawnNpc; - uint8_t speechBubble; + uint8_t speechBubble {}; uint32_t yellTicks = 0; uint32_t walkTicks = 0; uint32_t soundTicks = 0; - bool ignoreHeight; + bool ignoreHeight {}; phmap::flat_hash_set> playerSpectators; Position masterPos; diff --git a/src/creatures/npcs/npcs.cpp b/src/creatures/npcs/npcs.cpp index ecfd2750a94..6fe7f0b8320 100644 --- a/src/creatures/npcs/npcs.cpp +++ b/src/creatures/npcs/npcs.cpp @@ -84,16 +84,16 @@ void NpcType::loadShop(const std::shared_ptr &npcType, ShopBlock shopBl } // Check if the item already exists in the shop vector and ignore it - for (auto shopIterator = npcType->info.shopItemVector.begin(); shopIterator != npcType->info.shopItemVector.end(); ++shopIterator) { - if (*shopIterator == shopBlock) { - return; - } + if (std::any_of(npcType->info.shopItemVector.begin(), npcType->info.shopItemVector.end(), [&shopBlock](const auto &shopIterator) { + return shopIterator == shopBlock; + })) { + return; } if (shopBlock.childShop.empty()) { bool isContainer = iType.isContainer(); if (isContainer) { - for (ShopBlock child : shopBlock.childShop) { + for (const ShopBlock &child : shopBlock.childShop) { shopBlock.childShop.push_back(child); } } diff --git a/src/creatures/npcs/npcs.hpp b/src/creatures/npcs/npcs.hpp index 1a984abf2e8..ab5e700caea 100644 --- a/src/creatures/npcs/npcs.hpp +++ b/src/creatures/npcs/npcs.hpp @@ -25,7 +25,7 @@ class Shop { class NpcType : public SharedObject { struct NpcInfo { - LuaScriptInterface* scriptInterface; + LuaScriptInterface* scriptInterface {}; Outfit_t outfit = {}; RespawnType respawnType = {}; diff --git a/src/creatures/npcs/spawns/spawn_npc.cpp b/src/creatures/npcs/spawns/spawn_npc.cpp index 968deca5331..a8be411dc6c 100644 --- a/src/creatures/npcs/spawns/spawn_npc.cpp +++ b/src/creatures/npcs/spawns/spawn_npc.cpp @@ -146,12 +146,9 @@ SpawnNpc::~SpawnNpc() { bool SpawnNpc::findPlayer(const Position &pos) { auto spectators = Spectators().find(pos); - for (const auto &spectator : spectators) { - if (!spectator->getPlayer()->hasFlag(PlayerFlags_t::IgnoredByNpcs)) { - return true; - } - } - return false; + return std::ranges::any_of(spectators, [](const auto &spectator) { + return !spectator->getPlayer()->hasFlag(PlayerFlags_t::IgnoredByNpcs); + }); } bool SpawnNpc::isInSpawnNpcZone(const Position &pos) { diff --git a/src/creatures/npcs/spawns/spawn_npc.hpp b/src/creatures/npcs/spawns/spawn_npc.hpp index d02a83e80c5..49eb3bc6f2b 100644 --- a/src/creatures/npcs/spawns/spawn_npc.hpp +++ b/src/creatures/npcs/spawns/spawn_npc.hpp @@ -26,7 +26,7 @@ struct spawnBlockNpc_t { class SpawnNpc : public SharedObject { public: SpawnNpc(Position initPos, int32_t initRadius) : - centerPos(std::move(initPos)), radius(initRadius) { } + centerPos(initPos), radius(initRadius) { } ~SpawnNpc(); // non-copyable @@ -91,7 +91,7 @@ class SpawnsNpc { } std::string setFileName(std::string setName) { - return fileName = setName; + return fileName = std::move(setName); } std::forward_list> &getSpawnNpcList() { diff --git a/src/creatures/players/achievement/player_achievement.hpp b/src/creatures/players/achievement/player_achievement.hpp index 7d141c96a16..d1073a9bf1e 100644 --- a/src/creatures/players/achievement/player_achievement.hpp +++ b/src/creatures/players/achievement/player_achievement.hpp @@ -13,7 +13,7 @@ class Player; class KV; struct Achievement { - Achievement() { } + Achievement() = default; std::string name; std::string description; diff --git a/src/creatures/players/grouping/familiars.cpp b/src/creatures/players/grouping/familiars.cpp index 538519685c3..a922013f19b 100644 --- a/src/creatures/players/grouping/familiars.cpp +++ b/src/creatures/players/grouping/familiars.cpp @@ -14,6 +14,13 @@ #include "utils/pugicast.hpp" #include "utils/tools.hpp" +bool Familiars::reload() { + for (auto &familiarsVector : familiars) { + familiarsVector.clear(); + } + return loadFromXml(); +} + bool Familiars::loadFromXml() { pugi::xml_document doc; auto folder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__) + "/XML/familiars.xml"; @@ -47,13 +54,13 @@ bool Familiars::loadFromXml() { continue; } - familiars[vocation].emplace_back( + familiars[vocation].emplace_back(std::make_shared( familiarsNode.attribute("name").as_string(), pugi::cast(lookTypeAttribute.value()), familiarsNode.attribute("premium").as_bool(), familiarsNode.attribute("unlocked").as_bool(true), familiarsNode.attribute("type").as_string() - ); + )); } for (uint16_t vocation = VOCATION_NONE; vocation <= VOCATION_LAST; ++vocation) { familiars[vocation].shrink_to_fit(); @@ -61,11 +68,12 @@ bool Familiars::loadFromXml() { return true; } -const Familiar* Familiars::getFamiliarByLookType(uint16_t vocation, uint16_t lookType) const { - for (const Familiar &familiar : familiars[vocation]) { - if (familiar.lookType == lookType) { - return &familiar; - } +std::shared_ptr Familiars::getFamiliarByLookType(uint16_t vocation, uint16_t lookType) const { + if (auto it = std::find_if(familiars[vocation].begin(), familiars[vocation].end(), [lookType](auto familiar_it) { + return familiar_it->lookType == lookType; + }); + it != familiars[vocation].end()) { + return *it; } return nullptr; } diff --git a/src/creatures/players/grouping/familiars.hpp b/src/creatures/players/grouping/familiars.hpp index aae9b34e227..8f553af9fbe 100644 --- a/src/creatures/players/grouping/familiars.hpp +++ b/src/creatures/players/grouping/familiars.hpp @@ -9,20 +9,42 @@ #pragma once -#include "declarations.hpp" #include "lib/di/container.hpp" +struct FamiliarEntry { + constexpr explicit FamiliarEntry(uint16_t initLookType) : + lookType(initLookType) { } + uint16_t lookType; +}; + +struct Familiar { + Familiar(std::string initName, uint16_t initLookType, bool initPremium, bool initUnlocked, std::string initType) : + name(std::move(initName)), lookType(initLookType), + premium(initPremium), unlocked(initUnlocked), + type(std::move(initType)) { } + + std::string name; + uint16_t lookType; + bool premium; + bool unlocked; + std::string type; +}; + class Familiars { public: static Familiars &getInstance() { return inject(); } + bool loadFromXml(); - const std::vector &getFamiliars(uint16_t vocation) const { + bool reload(); + + std::vector> &getFamiliars(uint16_t vocation) { return familiars[vocation]; } - const Familiar* getFamiliarByLookType(uint16_t vocation, uint16_t lookType) const; + + [[nodiscard]] std::shared_ptr getFamiliarByLookType(uint16_t vocation, uint16_t lookType) const; private: - std::vector familiars[VOCATION_LAST + 1]; + std::vector> familiars[VOCATION_LAST + 1]; }; diff --git a/src/creatures/players/grouping/groups.cpp b/src/creatures/players/grouping/groups.cpp index 40dd13bc385..27ae68d9fd4 100644 --- a/src/creatures/players/grouping/groups.cpp +++ b/src/creatures/players/grouping/groups.cpp @@ -93,17 +93,18 @@ bool Groups::load() { // Parsing group flags parseGroupFlags(group, groupNode); - groups_vector.push_back(group); + groups_vector.emplace_back(std::make_shared(group)); } groups_vector.shrink_to_fit(); return true; } -Group* Groups::getGroup(uint16_t id) { - for (Group &group : groups_vector) { - if (group.id == id) { - return &group; - } +std::shared_ptr Groups::getGroup(uint16_t id) { + if (auto it = std::find_if(groups_vector.begin(), groups_vector.end(), [id](auto group_it) { + return group_it->id == id; + }); + it != groups_vector.end()) { + return *it; } return nullptr; } diff --git a/src/creatures/players/grouping/groups.hpp b/src/creatures/players/grouping/groups.hpp index 3d74564173d..d76914e2632 100644 --- a/src/creatures/players/grouping/groups.hpp +++ b/src/creatures/players/grouping/groups.hpp @@ -26,11 +26,11 @@ class Groups { static PlayerFlags_t getFlagFromNumber(uint8_t value); bool reload() const; bool load(); - Group* getGroup(uint16_t id); - std::vector &getGroups() { + std::shared_ptr getGroup(uint16_t id); + std::vector> &getGroups() { return groups_vector; } private: - std::vector groups_vector; + std::vector> groups_vector; }; diff --git a/src/creatures/players/grouping/guild.cpp b/src/creatures/players/grouping/guild.cpp index aca512f28e3..bbd662d1a1d 100644 --- a/src/creatures/players/grouping/guild.cpp +++ b/src/creatures/players/grouping/guild.cpp @@ -14,7 +14,7 @@ void Guild::addMember(const std::shared_ptr &player) { membersOnline.push_back(player); - for (auto member : getMembersOnline()) { + for (const auto &member : getMembersOnline()) { g_game().updatePlayerHelpers(member); } } diff --git a/src/creatures/players/grouping/guild.hpp b/src/creatures/players/grouping/guild.hpp index 834eb03252c..82b0a7367ea 100644 --- a/src/creatures/players/grouping/guild.hpp +++ b/src/creatures/players/grouping/guild.hpp @@ -32,9 +32,10 @@ class Guild : public Bankable { void addMember(const std::shared_ptr &player); void removeMember(const std::shared_ptr &player); - bool isGuild() { + bool isGuild() override { return true; } + void setOnline(bool value) override { online = value; } diff --git a/src/creatures/players/grouping/party.cpp b/src/creatures/players/grouping/party.cpp index c7d6fd48363..76f1d955f10 100644 --- a/src/creatures/players/grouping/party.cpp +++ b/src/creatures/players/grouping/party.cpp @@ -7,6 +7,8 @@ * Website: https://docs.opentibiabr.com/ */ +#include + #include "pch.hpp" #include "creatures/players/grouping/party.hpp" @@ -47,23 +49,23 @@ void Party::disband() { currentLeader->sendCreatureSkull(currentLeader); currentLeader->sendTextMessage(MESSAGE_PARTY_MANAGEMENT, "Your party has been disbanded."); - for (auto invitee : getInvitees()) { + for (const auto &invitee : getInvitees()) { invitee->removePartyInvitation(getParty()); currentLeader->sendCreatureShield(invitee); } inviteList.clear(); auto members = getMembers(); - for (auto member : members) { + for (const auto &member : members) { member->setParty(nullptr); member->sendClosePrivate(CHANNEL_PARTY); member->sendTextMessage(MESSAGE_PARTY_MANAGEMENT, "Your party has been disbanded."); } - for (auto member : members) { + for (const auto &member : members) { g_game().updatePlayerShield(member); - for (auto otherMember : members) { + for (const auto &otherMember : members) { otherMember->sendCreatureSkull(member); } @@ -132,7 +134,7 @@ bool Party::leaveParty(std::shared_ptr player) { g_game().updatePlayerShield(player); g_game().updatePlayerHelpers(player); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->sendCreatureSkull(player); player->sendPlayerPartyIcons(member); member->sendPartyCreatureUpdate(player); @@ -185,12 +187,12 @@ bool Party::passPartyLeadership(std::shared_ptr player) { updateSharedExperience(); updateTrackerAnalyzer(); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->sendPartyCreatureShield(oldLeader); member->sendPartyCreatureShield(player); } - for (auto invitee : getInvitees()) { + for (const auto &invitee : getInvitees()) { invitee->sendCreatureShield(oldLeader); invitee->sendCreatureShield(player); } @@ -231,7 +233,7 @@ bool Party::joinParty(const std::shared_ptr &player) { g_game().updatePlayerShield(player); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->sendCreatureSkull(player); member->sendPlayerPartyIcons(player); player->sendPlayerPartyIcons(member); @@ -282,7 +284,7 @@ bool Party::removeInvite(const std::shared_ptr &player, bool removeFromP if (empty()) { disband(); } else { - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { g_game().updatePlayerHelpers(member); } @@ -332,7 +334,7 @@ bool Party::invitePlayer(const std::shared_ptr &player) { inviteList.push_back(player); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { g_game().updatePlayerHelpers(member); } @@ -359,8 +361,8 @@ void Party::updateAllPartyIcons() { return; } auto members = getMembers(); - for (auto member : members) { - for (auto otherMember : members) { + for (const auto &member : members) { + for (const auto &otherMember : members) { member->sendPartyCreatureShield(otherMember); } @@ -376,14 +378,14 @@ void Party::broadcastPartyMessage(MessageClasses msgClass, const std::string &ms if (!leader) { return; } - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->sendTextMessage(msgClass, msg); } leader->sendTextMessage(msgClass, msg); if (sendToInvitations) { - for (auto invitee : getInvitees()) { + for (const auto &invitee : getInvitees()) { invitee->sendTextMessage(msgClass, msg); } } @@ -454,14 +456,14 @@ void Party::shareExperience(uint64_t experience, std::shared_ptr targe g_events().eventPartyOnShareExperience(getParty(), shareExperience); g_callbacks().executeCallback(EventCallback_t::partyOnShareExperience, &EventCallback::partyOnShareExperience, getParty(), shareExperience); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->onGainSharedExperience(shareExperience, target); } leader->onGainSharedExperience(shareExperience, target); } bool Party::canUseSharedExperience(std::shared_ptr player) { - return getMemberSharedExperienceStatus(player) == SHAREDEXP_OK; + return getMemberSharedExperienceStatus(std::move(player)) == SHAREDEXP_OK; } SharedExpStatus_t Party::getMemberSharedExperienceStatus(std::shared_ptr player) { @@ -473,7 +475,6 @@ SharedExpStatus_t Party::getMemberSharedExperienceStatus(std::shared_ptr return SHAREDEXP_EMPTYPARTY; } - uint32_t highestLevel = getHighestLevel(); uint32_t minLevel = getMinLevel(); if (player->getLevel() < minLevel) { return SHAREDEXP_LEVELDIFFTOOLARGE; @@ -502,7 +503,7 @@ uint32_t Party::getHighestLevel() { } uint32_t highestLevel = leader->getLevel(); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { if (member->getLevel() > highestLevel) { highestLevel = member->getLevel(); } @@ -520,7 +521,7 @@ uint32_t Party::getLowestLevel() { return 0; } uint32_t lowestLevel = leader->getLevel(); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { if (member->getLevel() < lowestLevel) { lowestLevel = member->getLevel(); } @@ -551,7 +552,7 @@ SharedExpStatus_t Party::getSharedExperienceStatus() { return leaderStatus; } - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { SharedExpStatus_t memberStatus = getMemberSharedExperienceStatus(member); if (memberStatus != SHAREDEXP_OK) { return memberStatus; @@ -620,7 +621,7 @@ void Party::updatePlayerStatus(std::shared_ptr player) { } int32_t maxDistance = g_configManager().getNumber(PARTY_LIST_MAX_DISTANCE, __FUNCTION__); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { bool condition = (maxDistance == 0 || (Position::getDistanceX(player->getPosition(), member->getPosition()) <= maxDistance && Position::getDistanceY(player->getPosition(), member->getPosition()) <= maxDistance)); if (condition) { showPlayerStatus(player, member, true); @@ -644,7 +645,7 @@ void Party::updatePlayerStatus(std::shared_ptr player, const Position &o int32_t maxDistance = g_configManager().getNumber(PARTY_LIST_MAX_DISTANCE, __FUNCTION__); if (maxDistance != 0) { - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { bool condition1 = (Position::getDistanceX(oldPos, member->getPosition()) <= maxDistance && Position::getDistanceY(oldPos, member->getPosition()) <= maxDistance); bool condition2 = (Position::getDistanceX(newPos, member->getPosition()) <= maxDistance && Position::getDistanceY(newPos, member->getPosition()) <= maxDistance); if (condition1 && !condition2) { @@ -673,7 +674,7 @@ void Party::updatePlayerHealth(std::shared_ptr player, std::shared_ptrgetPosition(); auto leaderPosition = leader->getPosition(); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { auto memberPosition = member->getPosition(); bool condition = (maxDistance == 0 || (Position::getDistanceX(playerPosition, memberPosition) <= maxDistance && Position::getDistanceY(playerPosition, memberPosition) <= maxDistance)); if (condition) { @@ -693,7 +694,7 @@ void Party::updatePlayerMana(std::shared_ptr player, uint8_t manaPercent } int32_t maxDistance = g_configManager().getNumber(PARTY_LIST_MAX_DISTANCE, __FUNCTION__); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { bool condition = (maxDistance == 0 || (Position::getDistanceX(player->getPosition(), member->getPosition()) <= maxDistance && Position::getDistanceY(player->getPosition(), member->getPosition()) <= maxDistance)); if (condition) { member->sendPartyPlayerMana(player, manaPercent); @@ -712,7 +713,7 @@ void Party::updatePlayerVocation(std::shared_ptr player) { } int32_t maxDistance = g_configManager().getNumber(PARTY_LIST_MAX_DISTANCE, __FUNCTION__); - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { bool condition = (maxDistance == 0 || (Position::getDistanceX(player->getPosition(), member->getPosition()) <= maxDistance && Position::getDistanceY(player->getPosition(), member->getPosition()) <= maxDistance)); if (condition) { member->sendPartyPlayerVocation(player); @@ -730,7 +731,7 @@ void Party::updateTrackerAnalyzer() { return; } - for (auto member : getMembers()) { + for (const auto &member : getMembers()) { member->updatePartyTrackerAnalyzer(); } diff --git a/src/creatures/players/grouping/party.hpp b/src/creatures/players/grouping/party.hpp index 5da0f4e0647..10663a278bf 100644 --- a/src/creatures/players/grouping/party.hpp +++ b/src/creatures/players/grouping/party.hpp @@ -105,7 +105,7 @@ class Party : public SharedObject { void reloadPrices(); std::shared_ptr getPlayerPartyAnalyzerStruct(uint32_t playerId) const { - if (auto it = std::find_if(membersData.begin(), membersData.end(), [playerId](const std::shared_ptr preyIt) { + if (auto it = std::find_if(membersData.begin(), membersData.end(), [playerId](const std::shared_ptr &preyIt) { return preyIt->id == playerId; }); it != membersData.end()) { diff --git a/src/creatures/players/grouping/team_finder.hpp b/src/creatures/players/grouping/team_finder.hpp index 123ce7c07d8..9fafbd03227 100644 --- a/src/creatures/players/grouping/team_finder.hpp +++ b/src/creatures/players/grouping/team_finder.hpp @@ -1,3 +1,5 @@ +#include + /** * Canary - A free and open-source MMORPG server emulator * Copyright (©) 2019-2024 OpenTibiaBR @@ -31,7 +33,7 @@ class TeamFinder { hunt_area(initHunt_area), questID(initQuestID), leaderGuid(initLeaderGuid), - membersMap(initMembersMap) { } + membersMap(std::move(initMembersMap)) { } virtual ~TeamFinder() = default; uint16_t minLevel = 0; diff --git a/src/creatures/players/highscore_category.hpp b/src/creatures/players/highscore_category.hpp index b387199f315..71da6b76ec6 100644 --- a/src/creatures/players/highscore_category.hpp +++ b/src/creatures/players/highscore_category.hpp @@ -10,8 +10,8 @@ #pragma once struct HighscoreCategory { - HighscoreCategory(const std::string &name, uint8_t id) : - m_name(name), + HighscoreCategory(std::string name, uint8_t id) : + m_name(std::move(name)), m_id(id) { } std::string m_name; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 78478953ade..3182607ecba 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -56,7 +56,7 @@ Player::Player(ProtocolGame_ptr p) : } Player::~Player() { - for (std::shared_ptr item : inventory) { + for (const std::shared_ptr &item : inventory) { if (item) { item->resetParent(); item->stopDecaying(); @@ -1335,7 +1335,7 @@ void Player::getRewardList(std::vector &rewards) const { std::vector> Player::getRewardsFromContainer(std::shared_ptr container) const { std::vector> rewardItemsVector; if (container) { - for (auto item : container->getItems(false)) { + for (const auto &item : container->getItems(false)) { if (item->getID() == ITEM_REWARD_CONTAINER) { auto items = getRewardsFromContainer(item->getContainer()); rewardItemsVector.insert(rewardItemsVector.end(), items.begin(), items.end()); @@ -1754,7 +1754,7 @@ void Player::onCreatureAppear(std::shared_ptr creature, bool isLogin) offlineTime = 0; } - for (std::shared_ptr condition : getMuteConditions()) { + for (const std::shared_ptr &condition : getMuteConditions()) { condition->setTicks(condition->getTicks() - (offlineTime * 1000)); if (condition->getTicks() <= 0) { removeCondition(condition); @@ -2232,7 +2232,7 @@ uint32_t Player::isMuted() const { } int32_t muteTicks = 0; - for (std::shared_ptr condition : conditions) { + for (const std::shared_ptr &condition : conditions) { if (condition->getType() == CONDITION_MUTED && condition->getTicks() > muteTicks) { muteTicks = condition->getTicks(); } @@ -2401,7 +2401,7 @@ void Player::addExperience(std::shared_ptr target, uint64_t exp, bool if (!spectators.empty()) { message.type = MESSAGE_EXPERIENCE_OTHERS; message.text = getName() + " gained " + expString; - for (std::shared_ptr spectator : spectators) { + for (const std::shared_ptr &spectator : spectators) { spectator->getPlayer()->sendTextMessage(message); } } @@ -2494,7 +2494,7 @@ void Player::removeExperience(uint64_t exp, bool sendText /* = false*/) { if (!spectators.empty()) { message.type = MESSAGE_EXPERIENCE_OTHERS; message.text = getName() + " lost " + expString; - for (std::shared_ptr spectator : spectators) { + for (const std::shared_ptr &spectator : spectators) { spectator->getPlayer()->sendTextMessage(message); } } @@ -3553,7 +3553,7 @@ std::shared_ptr Player::queryDestination(int32_t &index, const std::sh n--; } - for (std::shared_ptr tmpContainerItem : tmpContainer->getItemList()) { + for (const std::shared_ptr &tmpContainerItem : tmpContainer->getItemList()) { if (std::shared_ptr subContainer = tmpContainerItem->getContainer()) { containers.push_back(subContainer); } @@ -3564,7 +3564,7 @@ std::shared_ptr Player::queryDestination(int32_t &index, const std::sh uint32_t n = 0; - for (std::shared_ptr tmpItem : tmpContainer->getItemList()) { + for (const std::shared_ptr &tmpItem : tmpContainer->getItemList()) { if (tmpItem == tradeItem) { continue; } @@ -3772,7 +3772,7 @@ uint32_t Player::getItemTypeCount(uint16_t itemId, int32_t subType /*= -1*/) con void Player::stashContainer(StashContainerList itemDict) { StashItemList stashItemDict; // ItemID - Count - for (auto it_dict : itemDict) { + for (const auto &it_dict : itemDict) { stashItemDict[(it_dict.first)->getID()] = it_dict.second; } @@ -3792,7 +3792,7 @@ void Player::stashContainer(StashContainerList itemDict) { uint32_t totalStowed = 0; std::ostringstream retString; uint16_t refreshDepotSearchOnItem = 0; - for (auto stashIterator : itemDict) { + for (const auto &stashIterator : itemDict) { uint16_t iteratorCID = (stashIterator.first)->getID(); if (g_game().internalRemoveItem(stashIterator.first, stashIterator.second) == RETURNVALUE_NOERROR) { addItemOnStash(iteratorCID, stashIterator.second); @@ -3878,7 +3878,7 @@ bool Player::removeItemOfType(uint16_t itemId, uint32_t amount, int32_t subType, bool Player::hasItemCountById(uint16_t itemId, uint32_t itemAmount, bool checkStash) const { uint32_t newCount = 0; // Check items from inventory - for (const auto item : getAllInventoryItems()) { + for (const auto &item : getAllInventoryItems()) { if (!item || item->getID() != itemId) { continue; } @@ -3909,7 +3909,7 @@ bool Player::removeItemCountById(uint16_t itemId, uint32_t itemAmount, bool remo uint32_t amountToRemove = itemAmount; // Check items from inventory - for (auto item : getAllInventoryItems()) { + for (const auto &item : getAllInventoryItems()) { if (!item || item->getID() != itemId) { continue; } @@ -4171,14 +4171,14 @@ std::vector> Player::getEquippedItems() const { } std::map &Player::getAllItemTypeCount(std::map &countMap) const { - for (const auto item : getAllInventoryItems()) { + for (const auto &item : getAllInventoryItems()) { countMap[static_cast(item->getID())] += Item::countByType(item, -1); } return countMap; } std::map &Player::getAllSaleItemIdAndCount(std::map &countMap) const { - for (const auto item : getAllInventoryItems(false, true)) { + for (const auto &item : getAllInventoryItems(false, true)) { countMap[item->getID()] += item->getItemCount(); } @@ -4186,7 +4186,7 @@ std::map &Player::getAllSaleItemIdAndCount(std::map &countMap) const { - for (const auto item : getAllInventoryItems()) { + for (const auto &item : getAllInventoryItems()) { uint16_t itemId = item->getID(); if (Item::items[itemId].isFluidContainer()) { countMap[static_cast(itemId) | (item->getAttribute(ItemAttribute_t::FLUIDTYPE)) << 16] += item->getItemCount(); @@ -4263,7 +4263,7 @@ void Player::postAddNotification(std::shared_ptr thing, std::shared_ptr container : containers) { + for (const std::shared_ptr &container : containers) { autoCloseContainers(container); } } @@ -4570,7 +4570,7 @@ void Player::updateItemsLight(bool internal /*=false*/) { LightInfo curLight = item->getLightInfo(); if (curLight.level > maxLight.level) { - maxLight = std::move(curLight); + maxLight = curLight; } } } @@ -5101,7 +5101,7 @@ bool Player::canFamiliar(uint16_t lookType) const { return true; } - const Familiar* familiar = Familiars::getInstance().getFamiliarByLookType(getVocationId(), lookType); + const auto &familiar = Familiars::getInstance().getFamiliarByLookType(getVocationId(), lookType); if (!familiar) { return false; } @@ -5142,24 +5142,24 @@ bool Player::removeFamiliar(uint16_t lookType) { return false; } -bool Player::getFamiliar(const Familiar &familiar) const { +bool Player::getFamiliar(const std::shared_ptr &familiar) const { if (group->access) { return true; } - if (familiar.premium && !isPremium()) { + if (familiar->premium && !isPremium()) { return false; } for (const FamiliarEntry &familiarEntry : familiars) { - if (familiarEntry.lookType != familiar.lookType) { + if (familiarEntry.lookType != familiar->lookType) { continue; } return true; } - if (!familiar.unlocked) { + if (!familiar->unlocked) { return false; } @@ -5514,7 +5514,7 @@ void Player::setTibiaCoins(int32_t v) { int32_t Player::getCleavePercent(bool useCharges) const { int32_t result = cleavePercent; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &it = Item::items[item->getID()]; if (!it.abilities) { continue; @@ -5540,7 +5540,7 @@ int32_t Player::getPerfectShotDamage(uint8_t range, bool useCharges) const { result = it->second; } - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5564,7 +5564,7 @@ int32_t Player::getPerfectShotDamage(uint8_t range, bool useCharges) const { int32_t Player::getSpecializedMagicLevel(CombatType_t combat, bool useCharges) const { int32_t result = specializedMagicLevel[combatTypeToIndex(combat)]; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5585,7 +5585,7 @@ int32_t Player::getSpecializedMagicLevel(CombatType_t combat, bool useCharges) c int32_t Player::getMagicShieldCapacityFlat(bool useCharges) const { int32_t result = magicShieldCapacityFlat; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5606,7 +5606,7 @@ int32_t Player::getMagicShieldCapacityFlat(bool useCharges) const { int32_t Player::getMagicShieldCapacityPercent(bool useCharges) const { int32_t result = magicShieldCapacityPercent; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5627,7 +5627,7 @@ int32_t Player::getMagicShieldCapacityPercent(bool useCharges) const { int32_t Player::getReflectPercent(CombatType_t combat, bool useCharges) const { int32_t result = reflectPercent[combatTypeToIndex(combat)]; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5648,7 +5648,7 @@ int32_t Player::getReflectPercent(CombatType_t combat, bool useCharges) const { int32_t Player::getReflectFlat(CombatType_t combat, bool useCharges) const { int32_t result = reflectFlat[combatTypeToIndex(combat)]; - for (const auto item : getEquippedItems()) { + for (const auto &item : getEquippedItems()) { const ItemType &itemType = Item::items[item->getID()]; if (!itemType.abilities) { continue; @@ -5855,7 +5855,7 @@ void Player::setCurrentMount(uint8_t mount) { bool Player::hasAnyMount() const { const auto mounts = g_game().mounts.getMounts(); - for (const auto mount : mounts) { + for (const auto &mount : mounts) { if (hasMount(mount)) { return true; } @@ -5866,7 +5866,7 @@ bool Player::hasAnyMount() const { uint8_t Player::getRandomMountId() const { std::vector playerMounts; const auto mounts = g_game().mounts.getMounts(); - for (const auto mount : mounts) { + for (const auto &mount : mounts) { if (hasMount(mount)) { playerMounts.push_back(mount->id); } @@ -6253,7 +6253,7 @@ uint64_t Player::getMoney() const { size_t i = 0; while (i < containers.size()) { std::shared_ptr container = containers[i++]; - for (std::shared_ptr item : container->getItemList()) { + for (const std::shared_ptr &item : container->getItemList()) { std::shared_ptr tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); @@ -6270,7 +6270,7 @@ std::pair Player::getForgeSliversAndCores() const { uint64_t coreCount = 0; // Check items from inventory - for (const auto item : getAllInventoryItems()) { + for (const auto &item : getAllInventoryItems()) { if (!item) { continue; } @@ -6313,7 +6313,7 @@ size_t Player::getMaxDepotItems() const { std::forward_list> Player::getMuteConditions() const { std::forward_list> muteConditions; - for (std::shared_ptr condition : conditions) { + for (const std::shared_ptr &condition : conditions) { if (condition->getTicks() <= 0) { continue; } @@ -6519,7 +6519,7 @@ void sendStowItems(const std::shared_ptr &item, const std::shared_ptrgetContainer()) { - for (auto stowable_it : container->getStowableItems()) { + for (const auto &stowable_it : container->getStowableItems()) { if ((stowable_it.first)->getID() == item->getID()) { itemDict.push_back(stowable_it); } @@ -6597,14 +6597,14 @@ void Player::openPlayerContainers() { if (itemContainer) { auto cid = item->getAttribute(ItemAttribute_t::OPENCONTAINER); if (cid > 0) { - openContainersList.emplace_back(std::make_pair(cid, itemContainer)); + openContainersList.emplace_back(cid, itemContainer); } for (ContainerIterator it = itemContainer->iterator(); it.hasNext(); it.advance()) { std::shared_ptr subContainer = (*it)->getContainer(); if (subContainer) { auto subcid = (*it)->getAttribute(ItemAttribute_t::OPENCONTAINER); if (subcid > 0) { - openContainersList.emplace_back(std::make_pair(subcid, subContainer)); + openContainersList.emplace_back(subcid, subContainer); } } } @@ -6822,7 +6822,7 @@ void Player::requestDepotItems() { return; } - for (std::shared_ptr locker : depotLocker->getItemList()) { + for (const std::shared_ptr &locker : depotLocker->getItemList()) { std::shared_ptr c = locker->getContainer(); if (!c || c->empty()) { continue; @@ -6888,7 +6888,7 @@ void Player::requestDepotSearchItem(uint16_t itemId, uint8_t tier) { return; } - for (std::shared_ptr locker : depotLocker->getItemList()) { + for (const std::shared_ptr &locker : depotLocker->getItemList()) { std::shared_ptr c = locker->getContainer(); if (!c || c->empty()) { continue; @@ -6925,7 +6925,7 @@ void Player::retrieveAllItemsFromDepotSearch(uint16_t itemId, uint8_t tier, bool } std::vector> itemsVector; - for (std::shared_ptr locker : depotLocker->getItemList()) { + for (const std::shared_ptr &locker : depotLocker->getItemList()) { std::shared_ptr c = locker->getContainer(); if (!c || c->empty() || // Retrieve from inbox. @@ -6948,7 +6948,7 @@ void Player::retrieveAllItemsFromDepotSearch(uint16_t itemId, uint8_t tier, bool } ReturnValue ret = RETURNVALUE_NOERROR; - for (std::shared_ptr item : itemsVector) { + for (const std::shared_ptr &item : itemsVector) { // First lets try to retrieve the item to the stash retrieve container. if (g_game().tryRetrieveStashItems(static_self_cast(), item)) { continue; @@ -6994,7 +6994,7 @@ std::shared_ptr Player::getItemFromDepotSearch(uint16_t itemId, const Posi } uint8_t index = 0; - for (std::shared_ptr locker : depotLocker->getItemList()) { + for (const std::shared_ptr &locker : depotLocker->getItemList()) { std::shared_ptr c = locker->getContainer(); if (!c || c->empty() || (c->isInbox() && pos.y != 0x21) || // From inbox. (!c->isInbox() && pos.y != 0x20)) { // From depot. @@ -7071,7 +7071,7 @@ std::pair>, uint16_t> Player::getLockerItemsAn std::vector> lockerItems; auto [itemVector, itemMap] = requestLockerItems(depotLocker, false, tier); uint16_t totalCount = 0; - for (auto item : itemVector) { + for (const auto &item : itemVector) { if (!item || item->getID() != itemId) { continue; } @@ -7117,7 +7117,7 @@ bool Player::saySpell( int32_t valueEmote = 0; // Send to client - for (std::shared_ptr spectator : spectators) { + for (const std::shared_ptr &spectator : spectators) { if (std::shared_ptr tmpPlayer = spectator->getPlayer()) { if (g_configManager().getBoolean(EMOTE_SPELLS, __FUNCTION__)) { valueEmote = tmpPlayer->getStorageValue(STORAGEVALUE_EMOTE); @@ -7133,7 +7133,7 @@ bool Player::saySpell( } // Execute lua event method - for (std::shared_ptr spectator : spectators) { + for (const std::shared_ptr &spectator : spectators) { auto tmpPlayer = spectator->getPlayer(); if (!tmpPlayer) { continue; @@ -7777,7 +7777,7 @@ void Player::closeAllExternalContainers() { } } - for (std::shared_ptr container : containerToClose) { + for (const std::shared_ptr &container : containerToClose) { autoCloseContainers(container); } } @@ -7898,7 +7898,7 @@ bool Player::setAccount(uint32_t accountId) { } uint8_t Player::getAccountType() const { - return account ? account->getAccountType() : AccountType::ACCOUNT_TYPE_NORMAL; + return static_cast(account ? account->getAccountType() : static_cast(AccountType::ACCOUNT_TYPE_NORMAL)); } uint32_t Player::getAccountId() const { @@ -7941,7 +7941,7 @@ void Player::parseAttackRecvHazardSystem(CombatDamage &damage, std::shared_ptrgetMembers()) { + for (const auto &partyMember : m_party->getMembers()) { if (partyMember && partyMember->getHazardSystemPoints() < points) { points = partyMember->getHazardSystemPoints(); } @@ -8000,7 +8000,7 @@ void Player::parseAttackDealtHazardSystem(CombatDamage &damage, std::shared_ptr< auto points = getHazardSystemPoints(); if (m_party) { - for (const auto partyMember : m_party->getMembers()) { + for (const auto &partyMember : m_party->getMembers()) { if (partyMember && partyMember->getHazardSystemPoints() < points) { points = partyMember->getHazardSystemPoints(); } @@ -8089,7 +8089,7 @@ void Player::sendLootMessage(const std::string &message) const { if (auto partyLeader = party->getLeader()) { partyLeader->sendTextMessage(MESSAGE_LOOT, message); } - for (const auto partyMember : party->getMembers()) { + for (const auto &partyMember : party->getMembers()) { if (partyMember) { partyMember->sendTextMessage(MESSAGE_LOOT, message); } diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index b3bdd875b20..f61e33a37ef 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -517,10 +517,10 @@ class Player final : public Creature, public Cylinder, public Bankable { void genReservedStorageRange(); - void setGroup(Group* newGroup) { + void setGroup(std::shared_ptr newGroup) { group = newGroup; } - Group* getGroup() const { + std::shared_ptr getGroup() const { return group; } @@ -1041,7 +1041,7 @@ class Player final : public Creature, public Cylinder, public Bankable { bool canFamiliar(uint16_t lookType) const; void addFamiliar(uint16_t lookType); bool removeFamiliar(uint16_t lookType); - bool getFamiliar(const Familiar &familiar) const; + bool getFamiliar(const std::shared_ptr &familiar) const; void setFamiliarLooktype(uint16_t familiarLooktype) { this->defaultOutfit.lookFamiliarsType = familiarLooktype; } @@ -2800,7 +2800,7 @@ class Player final : public Creature, public Cylinder, public Bankable { std::shared_ptr bedItem = nullptr; std::shared_ptr guild = nullptr; GuildRank_ptr guildRank; - Group* group = nullptr; + std::shared_ptr group = nullptr; std::shared_ptr inbox; std::shared_ptr imbuingItem = nullptr; std::shared_ptr tradeItem = nullptr; diff --git a/src/creatures/players/wheel/player_wheel.cpp b/src/creatures/players/wheel/player_wheel.cpp index 8101f51ae42..c4fdbf5e169 100644 --- a/src/creatures/players/wheel/player_wheel.cpp +++ b/src/creatures/players/wheel/player_wheel.cpp @@ -283,7 +283,7 @@ bool PlayerWheel::canPlayerSelectPointOnSlot(WheelSlots_t slot, bool recursive) return true; } } else if (slot == WheelSlots_t::SLOT_GREEN_50) { - return recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot)) || true; + return (recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot))) || true; } // Red quadrant @@ -410,7 +410,7 @@ bool PlayerWheel::canPlayerSelectPointOnSlot(WheelSlots_t slot, bool recursive) return true; } } else if (slot == WheelSlots_t::SLOT_RED_50) { - return recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot)) || true; + return (recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot))) || true; } // Purple quadrant @@ -537,7 +537,7 @@ bool PlayerWheel::canPlayerSelectPointOnSlot(WheelSlots_t slot, bool recursive) return true; } } else if (slot == WheelSlots_t::SLOT_PURPLE_50) { - return recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot)) || true; + return (recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot))) || true; } // Blue quadrant @@ -664,7 +664,7 @@ bool PlayerWheel::canPlayerSelectPointOnSlot(WheelSlots_t slot, bool recursive) return true; } } else if (slot == WheelSlots_t::SLOT_BLUE_50) { - return recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot)) || true; + return (recursive && (getPointsBySlotType(slot) == getMaxPointsPerSlot(slot))) || true; } return false; @@ -1603,7 +1603,7 @@ void PlayerWheel::registerPlayerBonusData() { setSpellInstant("Avatar of Storm", false); } - for (const auto spell : m_playerBonusData.spells) { + for (const auto &spell : m_playerBonusData.spells) { upgradeSpell(spell); } @@ -1759,7 +1759,7 @@ void PlayerWheel::printPlayerWheelMethodsBonusData(const PlayerWheelMethodsBonus auto &spellsVector = bonusData.spells; if (!spellsVector.empty()) { g_logger().debug("Spells:"); - for (const auto spell : bonusData.spells) { + for (const auto &spell : bonusData.spells) { g_logger().debug(" {}", spell); } } @@ -2523,7 +2523,7 @@ void PlayerWheel::reduceAllSpellsCooldownTimer(int32_t value) { } void PlayerWheel::resetUpgradedSpells() { - for (const auto spell : m_learnedSpellsSelected) { + for (const auto &spell : m_learnedSpellsSelected) { if (m_player.hasLearnedInstantSpell(spell)) { m_player.forgetInstantSpell(spell); } diff --git a/src/creatures/players/wheel/wheel_gems.hpp b/src/creatures/players/wheel/wheel_gems.hpp index 762684cb383..668d8fe05db 100644 --- a/src/creatures/players/wheel/wheel_gems.hpp +++ b/src/creatures/players/wheel/wheel_gems.hpp @@ -174,7 +174,7 @@ class GemModifierStrategy { public: explicit GemModifierStrategy(PlayerWheel &wheel) : m_wheel(wheel) { } - virtual ~GemModifierStrategy() { } + virtual ~GemModifierStrategy() = default; virtual void execute() = 0; protected: @@ -211,7 +211,7 @@ class GemModifierStatStrategy : public GemModifierStrategy { class GemModifierRevelationStrategy : public GemModifierStrategy { public: - explicit GemModifierRevelationStrategy(PlayerWheel &wheel, WheelGemAffinity_t affinity, uint16_t value) : + explicit GemModifierRevelationStrategy(PlayerWheel &wheel, WheelGemAffinity_t affinity, [[maybe_unused]] uint16_t value) : GemModifierStrategy(wheel), m_affinity(affinity) { } @@ -224,9 +224,9 @@ class GemModifierRevelationStrategy : public GemModifierStrategy { class GemModifierSpellBonusStrategy : public GemModifierStrategy { public: - explicit GemModifierSpellBonusStrategy(PlayerWheel &wheel, const std::string &spellName, WheelSpells::Bonus bonus) : + explicit GemModifierSpellBonusStrategy(PlayerWheel &wheel, std::string spellName, WheelSpells::Bonus bonus) : GemModifierStrategy(wheel), - m_spellName(spellName), + m_spellName(std::move(spellName)), m_bonus(bonus) { } void execute() override; @@ -256,7 +256,7 @@ class WheelModifierContext { Vocation_t m_vocation; }; -static int32_t getHealthValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { +[[maybe_unused]] static int32_t getHealthValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { static const std::unordered_map> stats = { { WheelGemBasicModifier_t::Vocation_Health, @@ -333,7 +333,7 @@ static int32_t getHealthValue(Vocation_t vocation, WheelGemBasicModifier_t modif return 0; } -static int32_t getManaValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { +[[maybe_unused]] static int32_t getManaValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { static const std::unordered_map> stats = { { WheelGemBasicModifier_t::Vocation_Mana_FireResistance, @@ -409,7 +409,7 @@ static int32_t getManaValue(Vocation_t vocation, WheelGemBasicModifier_t modifie return 0; } -static int32_t getCapacityValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { +[[maybe_unused]] static int32_t getCapacityValue(Vocation_t vocation, WheelGemBasicModifier_t modifier) { static const std::unordered_map> stats = { { WheelGemBasicModifier_t::Vocation_Capacity_FireResistance, diff --git a/src/game/functions/game_reload.cpp b/src/game/functions/game_reload.cpp index 9a7246a86ec..0fc74bcee71 100644 --- a/src/game/functions/game_reload.cpp +++ b/src/game/functions/game_reload.cpp @@ -116,7 +116,6 @@ bool GameReload::reloadCore() const { const bool coreLoaded = g_luaEnvironment().loadFile(coreFolder + "/core.lua", "core.lua") == 0; if (coreLoaded) { - const auto &datapackFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__); const bool scriptsLoaded = g_scripts().loadScripts(coreFolder + "/scripts/lib", true, false); if (scriptsLoaded) { return true; diff --git a/src/game/game.cpp b/src/game/game.cpp index d731bd766b6..1743edb2f32 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -94,7 +94,7 @@ namespace InternalGame { } if (blockType != BLOCK_NONE) { - g_game().sendSingleSoundEffect(targetPos, SoundEffect_t::NO_DAMAGE, source); + g_game().sendSingleSoundEffect(targetPos, SoundEffect_t::NO_DAMAGE, std::move(source)); } } @@ -405,15 +405,15 @@ void Game::loadBoostedCreature() { MonsterRace selectedMonster; if (!monsterlist.empty()) { - std::vector monsters; + std::vector m_monsters; for (const auto &[raceId, _name] : BestiaryList) { if (raceId != oldRace) { - monsters.emplace_back(raceId, _name); + m_monsters.emplace_back(raceId, _name); } } - if (!monsters.empty()) { - selectedMonster = monsters[normal_random(0, monsters.size() - 1)]; + if (!m_monsters.empty()) { + selectedMonster = m_monsters[normal_random(0, m_monsters.size() - 1)]; } } @@ -626,7 +626,7 @@ void Game::loadCustomMaps(const std::filesystem::path &customMapPath) { int customMapIndex = 0; for (const auto &entry : fs::directory_iterator(customMapPath)) { - const auto realPath = entry.path(); + const auto &realPath = entry.path(); if (realPath.extension() != ".otbm") { continue; @@ -1133,7 +1133,7 @@ bool Game::removeCreature(std::shared_ptr creature, bool isLogout /* = } // event method - for (auto spectator : spectators) { + for (const auto &spectator : spectators) { spectator->onRemoveCreature(creature, isLogout); } } @@ -1150,7 +1150,7 @@ bool Game::removeCreature(std::shared_ptr creature, bool isLogout /* = removeCreatureCheck(creature); - for (auto summon : creature->getSummons()) { + for (const auto &summon : creature->getSummons()) { summon->setSkillLoss(false); removeCreature(summon); } @@ -1772,12 +1772,10 @@ void Game::playerMoveItem(std::shared_ptr player, const Position &fromPo player->stowItem(item, count, false); return; } - if (!item->isPushable() || item->hasAttribute(ItemAttribute_t::UNIQUEID)) { player->sendCancelMessage(RETURNVALUE_NOTMOVABLE); return; } - ReturnValue ret = internalMoveItem(fromCylinder, toCylinder, toIndex, item, count, nullptr, 0, player); if (ret != RETURNVALUE_NOERROR) { player->sendCancelMessage(ret); @@ -1868,7 +1866,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s } if (item->getContainer() && !item->isStoreItem()) { - for (std::shared_ptr containerItem : item->getContainer()->getItems(true)) { + for (const std::shared_ptr &containerItem : item->getContainer()->getItems(true)) { if (containerItem->isStoreItem() && ((containerID != ITEM_GOLD_POUCH && containerID != ITEM_DEPOT && containerID != ITEM_STORE_INBOX) || (topParentContainer->getParent() && topParentContainer->getParent()->getContainer() && (!topParentContainer->getParent()->getContainer()->isDepotChest() || topParentContainer->getParent()->getContainer()->getID() != ITEM_STORE_INBOX)))) { return RETURNVALUE_NOTPOSSIBLE; } @@ -1884,7 +1882,7 @@ ReturnValue Game::checkMoveItemToCylinder(std::shared_ptr player, std::s } } if (item->getContainer() && !item->isStoreItem()) { - for (std::shared_ptr containerItem : item->getContainer()->getItems(true)) { + for (const std::shared_ptr &containerItem : item->getContainer()->getItems(true)) { if (containerItem->isStoreItem()) { return RETURNVALUE_NOTPOSSIBLE; } @@ -2155,7 +2153,7 @@ ReturnValue Game::internalMoveItem(std::shared_ptr fromCylinder, std:: ReturnValue Game::internalAddItem(std::shared_ptr toCylinder, std::shared_ptr item, int32_t index /*= INDEX_WHEREEVER*/, uint32_t flags /* = 0*/, bool test /* = false*/) { uint32_t remainderCount = 0; - return internalAddItem(toCylinder, item, index, flags, test, remainderCount); + return internalAddItem(std::move(toCylinder), std::move(item), index, flags, test, remainderCount); } ReturnValue Game::internalAddItem(std::shared_ptr toCylinder, std::shared_ptr item, int32_t index, uint32_t flags, bool test, uint32_t &remainderCount) { @@ -2553,7 +2551,7 @@ bool Game::removeMoney(std::shared_ptr cylinder, uint64_t money, uint3 size_t i = 0; while (i < containers.size()) { std::shared_ptr container = containers[i++]; - for (std::shared_ptr item : container->getItemList()) { + for (const std::shared_ptr &item : container->getItemList()) { std::shared_ptr tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); @@ -2848,7 +2846,7 @@ void Game::playerQuickLootCorpse(std::shared_ptr player, std::shared_ptr uint32_t totalLootedGold = 0; uint32_t totalLootedItems = 0; - for (std::shared_ptr item : itemList) { + for (const std::shared_ptr &item : itemList) { uint32_t worth = item->getWorth(); uint16_t baseCount = item->getItemCount(); ObjectCategory_t category = getObjectCategory(item); @@ -3099,7 +3097,7 @@ ReturnValue Game::collectRewardChestItems(std::shared_ptr player, uint32 auto rewardCount = rewardItemsVector.size(); uint32_t movedRewardItems = 0; std::string lootedItemsMessage; - for (auto item : rewardItemsVector) { + for (const auto &item : rewardItemsVector) { // Stop if player not have free capacity if (item && player->getCapacity() < item->getWeight()) { player->sendCancelMessage(RETURNVALUE_NOTENOUGHCAPACITY); @@ -4471,7 +4469,7 @@ void Game::playerWriteItem(uint32_t playerId, uint32_t windowTextId, const std:: return; } - for (auto creatureEvent : player->getCreatureEvents(CREATURE_EVENT_TEXTEDIT)) { + for (const auto &creatureEvent : player->getCreatureEvents(CREATURE_EVENT_TEXTEDIT)) { if (!creatureEvent->executeTextEdit(player, writeItem, text)) { player->setWriteItem(nullptr); return; @@ -4836,7 +4834,7 @@ void Game::playerRequestTrade(uint32_t playerId, const Position &pos, uint8_t st } if (tradeItemContainer) { - for (std::shared_ptr containerItem : tradeItemContainer->getItems(true)) { + for (const std::shared_ptr &containerItem : tradeItemContainer->getItems(true)) { if (containerItem->isStoreItem()) { player->sendTextMessage(MESSAGE_TRADE, "This item cannot be trade."); return; @@ -5067,7 +5065,7 @@ void Game::playerLookInTrade(uint32_t playerId, bool lookAtCounterOffer, uint8_t size_t i = 0; while (i < containers.size()) { std::shared_ptr container = containers[i++]; - for (std::shared_ptr item : container->getItemList()) { + for (const std::shared_ptr &item : container->getItemList()) { std::shared_ptr tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); @@ -5519,7 +5517,7 @@ void Game::playerSetManagedContainer(uint32_t playerId, ObjectCategory_t categor std::shared_ptr container = thing->getContainer(); auto allowConfig = g_configManager().getBoolean(TOGGLE_GOLD_POUCH_ALLOW_ANYTHING, __FUNCTION__) || g_configManager().getBoolean(TOGGLE_GOLD_POUCH_QUICKLOOT_ONLY, __FUNCTION__); - if (!container || (container->getID() == ITEM_GOLD_POUCH && category != OBJECTCATEGORY_GOLD) && !allowConfig) { + if (!container || ((container->getID() == ITEM_GOLD_POUCH && category != OBJECTCATEGORY_GOLD) && !allowConfig)) { player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE); return; } @@ -5849,7 +5847,6 @@ void Game::playerCloseImbuementWindow(uint32_t playerid) { } player->setImbuingItem(nullptr); - return; } void Game::playerTurn(uint32_t playerId, Direction dir) { @@ -6157,7 +6154,7 @@ void Game::playerSpeakToNpc(std::shared_ptr player, const std::string &t } std::shared_ptr Game::createPlayerTask(uint32_t delay, std::function f, std::string context) const { - return Player::createPlayerTask(delay, f, context); + return Player::createPlayerTask(delay, std::move(f), std::move(context)); } //-- @@ -6742,7 +6739,7 @@ void Game::handleHazardSystemAttack(CombatDamage &damage, std::shared_ptr attackerPlayer, std::shared_ptr targetMonster) { if (!spectators.empty()) { - for (auto spectator : spectators) { + for (const auto &spectator : spectators) { if (!spectator) { continue; } @@ -6912,7 +6909,7 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt if (damage.origin != ORIGIN_NONE) { const auto events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE); if (!events.empty()) { - for (const auto creatureEvent : events) { + for (const auto &creatureEvent : events) { creatureEvent->executeHealthChange(target, attacker, damage); } damage.origin = ORIGIN_NONE; @@ -7131,7 +7128,7 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt if (damage.origin != ORIGIN_NONE) { const auto events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE); if (!events.empty()) { - for (const auto creatureEvent : events) { + for (const auto &creatureEvent : events) { creatureEvent->executeManaChange(target, attacker, damage); } healthChange = damage.primary.value + damage.secondary.value; @@ -7235,7 +7232,7 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt if (damage.origin != ORIGIN_NONE) { const auto events = target->getCreatureEvents(CREATURE_EVENT_HEALTHCHANGE); if (!events.empty()) { - for (const auto creatureEvent : events) { + for (const auto &creatureEvent : events) { creatureEvent->executeHealthChange(target, attacker, damage); } damage.origin = ORIGIN_NONE; @@ -7260,7 +7257,7 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt if (realDamage == 0) { return true; } else if (realDamage >= targetHealth) { - for (const auto creatureEvent : target->getCreatureEvents(CREATURE_EVENT_PREPAREDEATH)) { + for (const auto &creatureEvent : target->getCreatureEvents(CREATURE_EVENT_PREPAREDEATH)) { if (!creatureEvent->executeOnPrepareDeath(target, attacker)) { return false; } @@ -7336,7 +7333,7 @@ void Game::sendDamageMessageAndEffects( sendEffects(target, damage, targetPos, message, spectators); if (shouldSendMessage(message)) { - sendMessages(attacker, target, damage, targetPos, attackerPlayer, targetPlayer, message, spectators, realDamage); + sendMessages(std::move(attacker), target, damage, targetPos, std::move(attackerPlayer), std::move(targetPlayer), message, spectators, realDamage); } } @@ -7375,7 +7372,7 @@ void Game::sendMessages( std::string spectatorMessage; - for (std::shared_ptr spectator : spectators) { + for (const std::shared_ptr &spectator : spectators) { std::shared_ptr tmpPlayer = spectator->getPlayer(); if (!tmpPlayer || tmpPlayer->getPosition().z != targetPos.z) { continue; @@ -7496,7 +7493,7 @@ void Game::applyCharmRune( int8_t chance = charm->id == CHARM_CRIPPLE ? charm->chance : charm->chance + attackerPlayer->getCharmChanceModifier(); g_logger().debug("charm chance: {}, base: {}, bonus: {}", chance, charm->chance, attackerPlayer->getCharmChanceModifier()); if (charm->type == CHARM_OFFENSIVE && (chance >= normal_random(0, 100))) { - g_iobestiary().parseCharmCombat(charm, attackerPlayer, target, realDamage); + g_iobestiary().parseCharmCombat(charm, attackerPlayer, std::move(target), realDamage); } } } @@ -7589,7 +7586,7 @@ bool Game::combatChangeMana(std::shared_ptr attacker, std::shared_ptr< if (damage.origin != ORIGIN_NONE) { const auto events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE); if (!events.empty()) { - for (const auto creatureEvent : events) { + for (const auto &creatureEvent : events) { creatureEvent->executeManaChange(target, attacker, damage); } damage.origin = ORIGIN_NONE; @@ -7683,7 +7680,7 @@ bool Game::combatChangeMana(std::shared_ptr attacker, std::shared_ptr< if (damage.origin != ORIGIN_NONE) { const auto events = target->getCreatureEvents(CREATURE_EVENT_MANACHANGE); if (!events.empty()) { - for (const auto creatureEvent : events) { + for (const auto &creatureEvent : events) { creatureEvent->executeManaChange(target, attacker, damage); } damage.origin = ORIGIN_NONE; @@ -7991,7 +7988,7 @@ void Game::broadcastMessage(const std::string &text, MessageClasses type) const void Game::updateCreatureWalkthrough(std::shared_ptr creature) { // Send to clients - for (const auto spectator : Spectators().find(creature->getPosition(), true)) { + for (const auto &spectator : Spectators().find(creature->getPosition(), true)) { const auto &tmpPlayer = spectator->getPlayer(); tmpPlayer->sendCreatureWalkthrough(creature, tmpPlayer->canWalkthroughEx(creature)); } @@ -8224,7 +8221,7 @@ void Game::playerLeaveParty(uint32_t playerId) { } std::shared_ptr party = player->getParty(); - if (!party || player->hasCondition(CONDITION_INFIGHT) && !player->getZoneType() == ZONE_PROTECTION) { + if (!party || (player->hasCondition(CONDITION_INFIGHT) && !player->getZoneType() == ZONE_PROTECTION)) { player->sendTextMessage(TextMessage(MESSAGE_FAILURE, "You cannot leave party, contact the administrator.")); return; } @@ -8302,7 +8299,7 @@ void Game::playerCyclopediaCharacterInfo(std::shared_ptr player, uint32_ query << "SELECT `time`, `level`, `killed_by`, `mostdamage_by`, (select count(*) FROM `player_deaths` WHERE `player_id` = " << playerGUID << ") as `entries` FROM `player_deaths` WHERE `player_id` = " << playerGUID << " ORDER BY `time` DESC LIMIT " << offset << ", " << entriesPerPage; uint32_t playerID = player->getID(); - std::function callback = [playerID, page, entriesPerPage](DBResult_ptr result, bool) { + std::function callback = [playerID, page, entriesPerPage](const DBResult_ptr &result, bool) { std::shared_ptr player = g_game().getPlayerByID(playerID); if (!player) { return; @@ -8367,7 +8364,7 @@ void Game::playerCyclopediaCharacterInfo(std::shared_ptr player, uint32_ query << "SELECT `d`.`time`, `d`.`killed_by`, `d`.`mostdamage_by`, `d`.`unjustified`, `d`.`mostdamage_unjustified`, `p`.`name`, (select count(*) FROM `player_deaths` WHERE ((`killed_by` = " << escapedName << " AND `is_player` = 1) OR (`mostdamage_by` = " << escapedName << " AND `mostdamage_is_player` = 1))) as `entries` FROM `player_deaths` AS `d` INNER JOIN `players` AS `p` ON `d`.`player_id` = `p`.`id` WHERE ((`d`.`killed_by` = " << escapedName << " AND `d`.`is_player` = 1) OR (`d`.`mostdamage_by` = " << escapedName << " AND `d`.`mostdamage_is_player` = 1)) ORDER BY `time` DESC LIMIT " << offset << ", " << entriesPerPage; uint32_t playerID = player->getID(); - std::function callback = [playerID, page, entriesPerPage](DBResult_ptr result, bool) { + std::function callback = [playerID, page, entriesPerPage](const DBResult_ptr &result, bool) { std::shared_ptr player = g_game().getPlayerByID(playerID); if (!player) { return; @@ -8812,13 +8809,13 @@ namespace { auto [itemVector, totalCount] = player->getLockerItemsAndCountById(depotLocker, tier, itemType.id); if (removeAmount > 0) { - if (totalCount == 0 || itemVector.size() == 0) { + if (totalCount == 0 || itemVector.empty()) { offerStatus << "Player " << player->getName() << " not have item for create offer"; return false; } uint32_t count = 0; - for (auto item : itemVector) { + for (const auto &item : itemVector) { if (!item) { continue; } @@ -8904,7 +8901,7 @@ bool checkCanInitCreateMarketOffer(std::shared_ptr player, uint8_t type, return false; } - if (amount == 0 || !it.stackable && amount > 2000 || it.stackable && amount > 64000) { + if (amount == 0 || (!it.stackable && amount > 2000) || (it.stackable && amount > 64000)) { offerStatus << "Failed to load amount " << amount << " for player " << player->getName(); return false; } @@ -9123,7 +9120,7 @@ void Game::playerAcceptMarketOffer(uint32_t playerId, uint32_t timestamp, uint16 return; } - if (amount == 0 || !it.stackable && amount > 2000 || it.stackable && amount > 64000 || amount > offer.amount) { + if (amount == 0 || (!it.stackable && amount > 2000) || (it.stackable && amount > 64000) || amount > offer.amount) { offerStatus << "Invalid offer amount " << amount << " for player " << player->getName(); return; } @@ -9372,7 +9369,7 @@ void Game::parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const st return; } - for (const auto creatureEvent : player->getCreatureEvents(CREATURE_EVENT_EXTENDED_OPCODE)) { + for (const auto &creatureEvent : player->getCreatureEvents(CREATURE_EVENT_EXTENDED_OPCODE)) { creatureEvent->executeExtendedOpcode(player, opcode, buffer); } } @@ -9424,7 +9421,7 @@ void Game::playerAnswerModalWindow(uint32_t playerId, uint32_t modalWindowId, ui player->setBedItem(nullptr); } else { - for (const auto creatureEvent : player->getCreatureEvents(CREATURE_EVENT_MODALWINDOW)) { + for (const auto &creatureEvent : player->getCreatureEvents(CREATURE_EVENT_MODALWINDOW)) { creatureEvent->executeModalWindow(player, modalWindowId, button, choice); } } @@ -9694,7 +9691,7 @@ void Game::playerRotatePodium(uint32_t playerId, const Position &pos, uint8_t st bool isPodiumOfRenown = itemId == ITEM_PODIUM_OF_RENOWN1 || itemId == ITEM_PODIUM_OF_RENOWN2; if (!isPodiumOfRenown) { auto lookTypeExAttribute = item->getCustomAttribute("LookTypeEx"); - if (!isMonsterVisible || podiumRaceId == 0 || lookTypeExAttribute && lookTypeExAttribute->getInteger() == 39003) { + if (!isMonsterVisible || podiumRaceId == 0 || (lookTypeExAttribute && lookTypeExAttribute->getInteger() == 39003)) { player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE); return; } @@ -9910,7 +9907,7 @@ void Game::removeGuild(uint32_t guildId) { void Game::internalRemoveItems(const std::vector> &itemVector, uint32_t amount, bool stackable) { if (stackable) { - for (std::shared_ptr item : itemVector) { + for (const std::shared_ptr &item : itemVector) { if (item->getItemCount() > amount) { internalRemoveItem(item, amount); break; @@ -9920,7 +9917,7 @@ void Game::internalRemoveItems(const std::vector> &itemVec } } } else { - for (std::shared_ptr item : itemVector) { + for (const std::shared_ptr &item : itemVector) { internalRemoveItem(item); } } @@ -9935,7 +9932,7 @@ std::shared_ptr Game::getBedBySleeper(uint32_t guid) const { } void Game::setBedSleeper(std::shared_ptr bed, uint32_t guid) { - bedSleepersMap[guid] = bed; + bedSleepersMap[guid] = std::move(bed); } void Game::removeBedSleeper(uint32_t guid) { @@ -10489,7 +10486,7 @@ void Game::playerRewardChestCollect(uint32_t playerId, const Position &pos, uint bool Game::tryRetrieveStashItems(std::shared_ptr player, std::shared_ptr item) { ObjectCategory_t category = getObjectCategory(item); - return internalCollectManagedItems(player, item, category, false) == RETURNVALUE_NOERROR; + return internalCollectManagedItems(std::move(player), item, category, false) == RETURNVALUE_NOERROR; } std::unique_ptr &Game::getIOWheel() { @@ -10621,7 +10618,7 @@ void Game::registerAchievement(uint16_t id, std::string name, std::string descri m_achievements[id] = Achievement(); m_achievements[id].id = id; m_achievements[id].name = name; - m_achievements[id].description = description; + m_achievements[id].description = std::move(description); m_achievements[id].secret = secret; m_achievements[id].grade = grade; m_achievements[id].points = points; diff --git a/src/game/scheduling/events_scheduler.cpp b/src/game/scheduling/events_scheduler.cpp index c57f84b667c..a86254fa35c 100644 --- a/src/game/scheduling/events_scheduler.cpp +++ b/src/game/scheduling/events_scheduler.cpp @@ -27,7 +27,6 @@ bool EventsScheduler::loadScheduleEventFromXml() { int daysMath = ((timePtr->tm_year + 1900) * 365) + ((timePtr->tm_mon + 1) * 30) + (timePtr->tm_mday); // Keep track of loaded scripts to check for duplicates - int count = 0; phmap::flat_hash_set loadedScripts; std::map eventsOnSameDay; for (const auto &eventNode : doc.child("events").children()) { diff --git a/src/io/functions/iologindata_load_player.cpp b/src/io/functions/iologindata_load_player.cpp index 0498b40e29f..bcbfc531468 100644 --- a/src/io/functions/iologindata_load_player.cpp +++ b/src/io/functions/iologindata_load_player.cpp @@ -66,7 +66,7 @@ bool IOLoginDataLoad::preLoadPlayer(std::shared_ptr player, const std::s } player->setGUID(result->getNumber("id")); - Group* group = g_game().groups.getGroup(result->getNumber("group_id")); + std::shared_ptr group = g_game().groups.getGroup(result->getNumber("group_id")); if (!group) { g_logger().error("Player {} has group id {} which doesn't exist", player->name, result->getNumber("group_id")); return false; @@ -118,7 +118,7 @@ bool IOLoginDataLoad::loadPlayerFirst(std::shared_ptr player, DBResult_p player->setAccount(result->getNumber("account_id")); } - Group* group = g_game().groups.getGroup(result->getNumber("group_id")); + std::shared_ptr group = g_game().groups.getGroup(result->getNumber("group_id")); if (!group) { g_logger().error("Player {} has group id {} which doesn't exist", player->name, result->getNumber("group_id")); return false; diff --git a/src/io/functions/iologindata_save_player.cpp b/src/io/functions/iologindata_save_player.cpp index 82ba286d622..eccb88c8229 100644 --- a/src/io/functions/iologindata_save_player.cpp +++ b/src/io/functions/iologindata_save_player.cpp @@ -436,7 +436,7 @@ bool IOLoginDataSave::savePlayerBestiarySystem(std::shared_ptr player) { query << "`UnlockedRunesBit` = " << player->UnlockedRunesBit << ","; PropWriteStream propBestiaryStream; - for (const auto trackedType : player->getCyclopediaMonsterTrackerSet(false)) { + for (const auto &trackedType : player->getCyclopediaMonsterTrackerSet(false)) { propBestiaryStream.write(trackedType->info.raceid); } size_t trackerSize; @@ -737,7 +737,7 @@ bool IOLoginDataSave::savePlayerBosstiary(std::shared_ptr player) { // Bosstiary tracker PropWriteStream stream; - for (const auto monsterType : player->getCyclopediaMonsterTrackerSet(true)) { + for (const auto &monsterType : player->getCyclopediaMonsterTrackerSet(true)) { if (!monsterType) { continue; } diff --git a/src/io/iobestiary.cpp b/src/io/iobestiary.cpp index f7305d8503c..c544021367e 100644 --- a/src/io/iobestiary.cpp +++ b/src/io/iobestiary.cpp @@ -97,7 +97,7 @@ bool IOBestiary::parseCharmCombat(const std::shared_ptr charm, std::share std::shared_ptr IOBestiary::getBestiaryCharm(charmRune_t activeCharm, bool force /*= false*/) const { const auto charmInternal = g_game().getCharmList(); - for (const auto tmpCharm : charmInternal) { + for (const auto &tmpCharm : charmInternal) { if (tmpCharm->id == activeCharm) { return tmpCharm; } @@ -169,7 +169,7 @@ void IOBestiary::setCharmRuneCreature(std::shared_ptr player, const std: std::list IOBestiary::getCharmUsedRuneBitAll(std::shared_ptr player) { int32_t input = player->getUsedRunesBit(); - ; + int8_t i = 0; std::list rtn; while (input != 0) { @@ -191,7 +191,7 @@ uint16_t IOBestiary::getBestiaryRaceUnlocked(std::shared_ptr player, Bes uint16_t count = 0; std::map besty_l = g_game().getBestiaryList(); - for (auto it : besty_l) { + for (const auto &it : besty_l) { const auto mtype = g_monsters().getMonsterType(it.second); if (mtype && mtype->info.bestiaryRace == race && player->getBestiaryKillCount(mtype->info.raceid) > 0) { count++; @@ -271,7 +271,7 @@ int32_t IOBestiary::bitToggle(int32_t input, const std::shared_ptr charm, return CHARM_NONE; } - int32_t returnToggle = 0; + int32_t returnToggle; int32_t binary = charm->binary; if (on) { returnToggle = input | binary; @@ -307,7 +307,7 @@ void IOBestiary::sendBuyCharmRune(std::shared_ptr player, charmRune_t ru player->setUnlockedRunesBit(value); } else if (action == 1) { std::list usedRunes = getCharmUsedRuneBitAll(player); - uint16_t limitRunes = 0; + uint16_t limitRunes; if (player->isPremium()) { if (player->hasCharmExpansion()) { @@ -343,7 +343,6 @@ void IOBestiary::sendBuyCharmRune(std::shared_ptr player, charmRune_t ru player->sendFYIBox("You don't have enough gold."); } player->BestiarysendCharms(); - return; } std::map IOBestiary::getMonsterElements(const std::shared_ptr mtype) const { diff --git a/src/io/iobestiary.hpp b/src/io/iobestiary.hpp index 9cb2ef2fe55..a521ce68852 100644 --- a/src/io/iobestiary.hpp +++ b/src/io/iobestiary.hpp @@ -20,16 +20,18 @@ class Charm { public: Charm() = default; Charm(std::string initname, charmRune_t initcharmRune_t, std::string initdescription, charm_t inittype, uint16_t initpoints, int32_t initbinary) : - name(initname), id(initcharmRune_t), description(initdescription), type(inittype), points(initpoints), binary(initbinary) { } + name(std::move(initname)), id(initcharmRune_t), description(std::move(initdescription)), type(inittype), points(initpoints), binary(initbinary) { } virtual ~Charm() = default; std::string name; + charmRune_t id = CHARM_NONE; + std::string description; + charm_t type; + uint16_t points = 0; + int32_t binary = 0; std::string cancelMsg; std::string logMsg; - std::string description; - charm_t type; - charmRune_t id = CHARM_NONE; CombatType_t dmgtype = COMBAT_NONE; uint16_t effect = CONST_ME_NONE; @@ -38,8 +40,6 @@ class Charm { uint16_t percent = 0; int8_t chance = 0; - uint16_t points = 0; - int32_t binary = 0; }; class IOBestiary { diff --git a/src/io/iologindata.cpp b/src/io/iologindata.cpp index 4c6b95dc32e..46426451ddc 100644 --- a/src/io/iologindata.cpp +++ b/src/io/iologindata.cpp @@ -72,7 +72,7 @@ uint8_t IOLoginData::getAccountType(uint32_t accountId) { void IOLoginData::updateOnlineStatus(uint32_t guid, bool login) { static phmap::flat_hash_map updateOnline; - if (login && updateOnline.find(guid) != updateOnline.end() || guid <= 0) { + if ((login && updateOnline.find(guid) != updateOnline.end()) || guid <= 0) { return; } diff --git a/src/io/iomap.cpp b/src/io/iomap.cpp index 4edfefa66d1..d50d9b2804f 100644 --- a/src/io/iomap.cpp +++ b/src/io/iomap.cpp @@ -122,8 +122,6 @@ void IOMap::parseTileArea(FileStream &stream, Map &map, const Position &pos) { const uint16_t base_y = stream.getU16(); const uint8_t base_z = stream.getU8(); - bool tileIsStatic = false; - while (stream.startNode()) { const uint8_t tileType = stream.getU8(); if (tileType != OTBM_HOUSETILE && tileType != OTBM_TILE) { @@ -166,9 +164,6 @@ void IOMap::parseTileArea(FileStream &stream, Map &map, const Position &pos) { const auto &iType = Item::items[id]; if (!tile->isHouse() || (!iType.isBed() && !iType.isTrashHolder())) { - if (iType.blockSolid) { - tileIsStatic = true; - } const auto item = std::make_shared(); item->id = id; @@ -194,10 +189,6 @@ void IOMap::parseTileArea(FileStream &stream, Map &map, const Position &pos) { const auto &iType = Item::items[id]; - if (iType.blockSolid) { - tileIsStatic = true; - } - const auto item = std::make_shared(); item->id = id; diff --git a/src/items/containers/container.cpp b/src/items/containers/container.cpp index 5d2ffd98769..63ce657741a 100644 --- a/src/items/containers/container.cpp +++ b/src/items/containers/container.cpp @@ -383,7 +383,7 @@ bool Container::isInsideContainerWithId(const uint16_t id) { } bool Container::isAnyKindOfRewardChest() { - return getID() == ITEM_REWARD_CHEST || getID() == ITEM_REWARD_CONTAINER && getParent() && getParent()->getContainer() && getParent()->getContainer()->getID() == ITEM_REWARD_CHEST || isBrowseFieldAndHoldsRewardChest(); + return getID() == ITEM_REWARD_CHEST || (getID() == ITEM_REWARD_CONTAINER && getParent() && getParent()->getContainer() && getParent()->getContainer()->getID() == ITEM_REWARD_CHEST) || isBrowseFieldAndHoldsRewardChest(); } bool Container::isAnyKindOfRewardContainer() { diff --git a/src/items/item.cpp b/src/items/item.cpp index 104efc7f925..823eb13b393 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -3237,7 +3237,7 @@ std::shared_ptr Item::transform(uint16_t itemId, uint16_t itemCount /*= -1 } std::shared_ptr newItem; - if (itemCount == -1) { + if (itemCount == 0) { newItem = Item::CreateItem(itemId, 1); } else { newItem = Item::CreateItem(itemId, itemCount); diff --git a/src/items/tile.cpp b/src/items/tile.cpp index ca354700f22..11e3fafd6fd 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -791,7 +791,7 @@ ReturnValue Tile::queryAdd(int32_t, const std::shared_ptr &thing, uint32_ if (ground) { const ItemType &iiType = Item::items[ground->getID()]; if (iiType.blockSolid) { - if (!iiType.pickupable && iiType.type != ITEM_TYPE_TRASHHOLDER || item->isMagicField() || item->isBlocking()) { + if ((!iiType.pickupable && iiType.type != ITEM_TYPE_TRASHHOLDER) || item->isMagicField() || item->isBlocking()) { if (!item->isPickupable() && !item->isCarpet()) { return RETURNVALUE_NOTENOUGHROOM; } @@ -1575,7 +1575,7 @@ void Tile::internalAddThing(uint32_t, std::shared_ptr thing) { if (!thing) { return; } - for (const auto zone : getZones()) { + for (const auto &zone : getZones()) { zone->thingAdded(thing); } diff --git a/src/items/weapons/weapons.hpp b/src/items/weapons/weapons.hpp index 5b2b260e2ee..59cc23636e2 100644 --- a/src/items/weapons/weapons.hpp +++ b/src/items/weapons/weapons.hpp @@ -200,11 +200,11 @@ class Weapon : public Script { return m_isDisabledChain; } - const WeaponType_t getWeaponType() const { + WeaponType_t getWeaponType() const { return weaponType; } - const std::shared_ptr getCombat() const { + std::shared_ptr getCombat() const { if (!m_combat) { g_logger().error("Weapon::getCombat() - m_combat is nullptr"); return nullptr; diff --git a/src/lib/metrics/metrics.cpp b/src/lib/metrics/metrics.cpp index cf11060125a..f005c79c966 100644 --- a/src/lib/metrics/metrics.cpp +++ b/src/lib/metrics/metrics.cpp @@ -87,7 +87,7 @@ void Metrics::shutdown() { metrics_api::Provider::SetMeterProvider(none); } -ScopedLatency::ScopedLatency(std::string_view name, const std::string &histogramName, const std::string &scopeKey) : +ScopedLatency::ScopedLatency(const std::string_view &name, const std::string &histogramName, const std::string &scopeKey) : ScopedLatency(name, g_metrics().latencyHistograms[histogramName], { { scopeKey, std::string(name) } }, g_metrics().defaultContext) { if (histogram == nullptr) { stopped = true; diff --git a/src/lib/metrics/metrics.hpp b/src/lib/metrics/metrics.hpp index 279ea5f91c5..1e3dbe31086 100644 --- a/src/lib/metrics/metrics.hpp +++ b/src/lib/metrics/metrics.hpp @@ -54,9 +54,9 @@ namespace metrics { class ScopedLatency { public: - explicit ScopedLatency(std::string_view name, const std::string &histogramName, const std::string &scopeKey); - explicit ScopedLatency(std::string_view name, Histogram &histogram, std::map attrs = {}, opentelemetry::context::Context context = opentelemetry::context::Context()) : - begin(std::chrono::steady_clock::now()), histogram(histogram), attrs(attrs), context(context) { + explicit ScopedLatency(const std::string_view &name, const std::string &histogramName, const std::string &scopeKey); + explicit ScopedLatency([[maybe_unused]] const std::string_view &name, Histogram &histogram, std::map attrs = {}, opentelemetry::context::Context context = opentelemetry::context::Context()) : + begin(std::chrono::steady_clock::now()), histogram(histogram), attrs(std::move(attrs)), context(std::move(context)) { } void stop(); @@ -64,10 +64,10 @@ namespace metrics { ~ScopedLatency(); private: - opentelemetry::context::Context context; - Histogram &histogram; std::chrono::steady_clock::time_point begin; + Histogram &histogram; std::map attrs; + opentelemetry::context::Context context; bool stopped { false }; }; @@ -94,7 +94,7 @@ namespace metrics { class Metrics final { public: - Metrics() { } + Metrics() = default; ~Metrics() = default; void init(Options opts); diff --git a/src/lua/creature/movement.cpp b/src/lua/creature/movement.cpp index 0af09476ed8..b302877b3d3 100644 --- a/src/lua/creature/movement.cpp +++ b/src/lua/creature/movement.cpp @@ -24,8 +24,6 @@ void MoveEvents::clear(bool isFromXML /*= false*/) { for (int moveEventType = 0; moveEventType < MOVE_EVENT_LAST; ++moveEventType) { auto &eventList = moveEventList.moveEvent[moveEventType]; - int originalSize = eventList.size(); - eventList.remove_if([&](const std::shared_ptr &moveEvent) { bool removed = moveEvent && moveEvent->isFromXML(); if (removed) { diff --git a/src/lua/creature/movement.hpp b/src/lua/creature/movement.hpp index 485454a0564..4ce4297b0f5 100644 --- a/src/lua/creature/movement.hpp +++ b/src/lua/creature/movement.hpp @@ -180,7 +180,7 @@ class MoveEvent final : public Script, public SharedObject { } void addVocEquipMap(std::string vocName) { uint16_t vocationId = g_vocations().getVocationId(vocName); - if (vocationId != -1) { + if (vocationId != 65535) { vocEquipMap[vocationId] = true; } } diff --git a/src/lua/functions/core/game/config_functions.cpp b/src/lua/functions/core/game/config_functions.cpp index a84c500b985..d0e77a69352 100644 --- a/src/lua/functions/core/game/config_functions.cpp +++ b/src/lua/functions/core/game/config_functions.cpp @@ -22,7 +22,6 @@ void ConfigFunctions::init(lua_State* L) { #define registerMagicEnumIn(L, tableName, enumValue) \ do { \ - auto number = magic_enum::enum_integer(enumValue); \ auto name = magic_enum::enum_name(enumValue).data(); \ registerVariable(L, tableName, name, value); \ } while (0) diff --git a/src/lua/functions/core/game/game_functions.cpp b/src/lua/functions/core/game/game_functions.cpp index a91889e43bc..0fdbc96f4d6 100644 --- a/src/lua/functions/core/game/game_functions.cpp +++ b/src/lua/functions/core/game/game_functions.cpp @@ -214,7 +214,7 @@ int GameFunctions::luaGameGetMonsterTypes(lua_State* L) { const auto type = g_monsters().monsters; lua_createtable(L, type.size(), 0); - for (const auto [typeName, mType] : type) { + for (const auto &[typeName, mType] : type) { pushUserdata(L, mType); setMetatable(L, -1, "MonsterType"); lua_setfield(L, -2, typeName.c_str()); @@ -517,7 +517,7 @@ int GameFunctions::luaGameGetBestiaryCharm(lua_State* L) { lua_createtable(L, c_list.size(), 0); int index = 0; - for (const auto charmPtr : c_list) { + for (const auto &charmPtr : c_list) { pushUserdata(L, charmPtr); setMetatable(L, -1, "Charm"); lua_rawseti(L, -2, ++index); @@ -699,7 +699,7 @@ int GameFunctions::luaGameGetInfluencedMonsters(lua_State* L) { int GameFunctions::luaGameGetLadderIds(lua_State* L) { // Game.getLadderIds() - const auto ladders = Item::items.getLadders(); + const auto &ladders = Item::items.getLadders(); lua_createtable(L, static_cast(ladders.size()), 0); int index = 0; for (const auto ladderId : ladders) { @@ -721,7 +721,7 @@ int GameFunctions::luaGameGetDummies(lua_State* L) { local rate = dummies[1] -- Retrieve dummy rate */ - const auto dummies = Item::items.getDummys(); + const auto &dummies = Item::items.getDummys(); lua_createtable(L, dummies.size(), 0); for (const auto &[dummyId, rate] : dummies) { lua_pushnumber(L, static_cast(rate)); diff --git a/src/lua/functions/creatures/creature_functions.cpp b/src/lua/functions/creatures/creature_functions.cpp index a633afe9749..7a40cc426f1 100644 --- a/src/lua/functions/creatures/creature_functions.cpp +++ b/src/lua/functions/creatures/creature_functions.cpp @@ -54,7 +54,7 @@ int CreatureFunctions::luaCreatureGetEvents(lua_State* L) { lua_createtable(L, static_cast(eventList.size()), 0); int index = 0; - for (const auto eventPtr : eventList) { + for (const auto &eventPtr : eventList) { pushString(L, eventPtr->getName()); lua_rawseti(L, -2, ++index); } diff --git a/src/lua/functions/creatures/monster/charm_functions.cpp b/src/lua/functions/creatures/monster/charm_functions.cpp index 48f7ff5aec9..d456f1c96a8 100644 --- a/src/lua/functions/creatures/monster/charm_functions.cpp +++ b/src/lua/functions/creatures/monster/charm_functions.cpp @@ -18,7 +18,7 @@ int CharmFunctions::luaCharmCreate(lua_State* L) { if (isNumber(L, 2)) { charmRune_t charmid = getNumber(L, 2); const auto charmList = g_game().getCharmList(); - for (const auto charm : charmList) { + for (const auto &charm : charmList) { if (charm->id == charmid) { pushUserdata(L, charm); setMetatable(L, -1, "Charm"); diff --git a/src/lua/functions/creatures/monster/monster_spell_functions.cpp b/src/lua/functions/creatures/monster/monster_spell_functions.cpp index ee00fd43af7..a20d57008d2 100644 --- a/src/lua/functions/creatures/monster/monster_spell_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_spell_functions.cpp @@ -170,7 +170,7 @@ int MonsterSpellFunctions::luaMonsterSpellSetConditionType(lua_State* L) { const auto spell = getUserdataShared(L, 1); if (spell) { auto conditionType = getNumber(L, 2); - if (conditionType == -1) { + if (conditionType == 254) { g_logger().error("[{}] trying to register condition type none for monster: {}", __FUNCTION__, spell->name); reportErrorFunc(fmt::format("trying to register condition type none for monster: {}", spell->name)); pushBoolean(L, false); diff --git a/src/lua/functions/creatures/npc/npc_functions.cpp b/src/lua/functions/creatures/npc/npc_functions.cpp index 43c2950a802..8c19a4ede0a 100644 --- a/src/lua/functions/creatures/npc/npc_functions.cpp +++ b/src/lua/functions/creatures/npc/npc_functions.cpp @@ -400,7 +400,7 @@ int NpcFunctions::luaNpcOpenShopWindowTable(lua_State* L) { if (itemName.empty()) { itemName = Item::items[itemId].name; } - items.emplace_back(itemId, subType, buyPrice, sellPrice, storageKey, storageValue, itemName); + items.emplace_back(itemId, itemName, subType, buyPrice, sellPrice, storageKey, storageValue); lua_pop(L, 8); } lua_pop(L, 3); diff --git a/src/lua/functions/creatures/player/group_functions.cpp b/src/lua/functions/creatures/player/group_functions.cpp index 0ea195fe745..5acc16d72a9 100644 --- a/src/lua/functions/creatures/player/group_functions.cpp +++ b/src/lua/functions/creatures/player/group_functions.cpp @@ -17,7 +17,7 @@ int GroupFunctions::luaGroupCreate(lua_State* L) { // Group(id) uint32_t id = getNumber(L, 2); - Group* group = g_game().groups.getGroup(id); + std::shared_ptr group = g_game().groups.getGroup(id); if (group) { pushUserdata(L, group); setMetatable(L, -1, "Group"); @@ -29,7 +29,7 @@ int GroupFunctions::luaGroupCreate(lua_State* L) { int GroupFunctions::luaGroupGetId(lua_State* L) { // group:getId() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->id); } else { @@ -40,7 +40,7 @@ int GroupFunctions::luaGroupGetId(lua_State* L) { int GroupFunctions::luaGroupGetName(lua_State* L) { // group:getName() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { pushString(L, group->name); } else { @@ -51,7 +51,7 @@ int GroupFunctions::luaGroupGetName(lua_State* L) { int GroupFunctions::luaGroupGetFlags(lua_State* L) { // group:getFlags() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { std::bitset flags; for (uint8_t i = 0; i < magic_enum::enum_integer(PlayerFlags_t::FlagLast); ++i) { @@ -68,7 +68,7 @@ int GroupFunctions::luaGroupGetFlags(lua_State* L) { int GroupFunctions::luaGroupGetAccess(lua_State* L) { // group:getAccess() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { pushBoolean(L, group->access); } else { @@ -79,7 +79,7 @@ int GroupFunctions::luaGroupGetAccess(lua_State* L) { int GroupFunctions::luaGroupGetMaxDepotItems(lua_State* L) { // group:getMaxDepotItems() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->maxDepotItems); } else { @@ -90,7 +90,7 @@ int GroupFunctions::luaGroupGetMaxDepotItems(lua_State* L) { int GroupFunctions::luaGroupGetMaxVipEntries(lua_State* L) { // group:getMaxVipEntries() - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->maxVipEntries); } else { @@ -101,7 +101,7 @@ int GroupFunctions::luaGroupGetMaxVipEntries(lua_State* L) { int GroupFunctions::luaGroupHasFlag(lua_State* L) { // group:hasFlag(flag) - Group* group = getUserdata(L, 1); + std::shared_ptr group = getUserdataShared(L, 1); if (group) { auto flag = static_cast(getNumber(L, 2)); pushBoolean(L, group->flags[Groups::getFlagNumber(flag)]); diff --git a/src/lua/functions/creatures/player/group_functions.hpp b/src/lua/functions/creatures/player/group_functions.hpp index ecc3ac07280..4a33d1b988e 100644 --- a/src/lua/functions/creatures/player/group_functions.hpp +++ b/src/lua/functions/creatures/player/group_functions.hpp @@ -14,7 +14,7 @@ class GroupFunctions final : LuaScriptInterface { public: static void init(lua_State* L) { - registerClass(L, "Group", "", GroupFunctions::luaGroupCreate); + registerSharedClass(L, "Group", "", GroupFunctions::luaGroupCreate); registerMetaMethod(L, "Group", "__eq", GroupFunctions::luaUserdataCompare); registerMethod(L, "Group", "getId", GroupFunctions::luaGroupGetId); diff --git a/src/lua/functions/creatures/player/player_functions.cpp b/src/lua/functions/creatures/player/player_functions.cpp index 51dd79638ab..7f4d96f3773 100644 --- a/src/lua/functions/creatures/player/player_functions.cpp +++ b/src/lua/functions/creatures/player/player_functions.cpp @@ -1604,7 +1604,7 @@ int PlayerFunctions::luaPlayerGetGroup(lua_State* L) { int PlayerFunctions::luaPlayerSetGroup(lua_State* L) { // player:setGroup(group) - Group* group = getUserdata(L, 2); + std::shared_ptr group = getUserdataShared(L, 2); if (!group) { pushBoolean(L, false); return 1; diff --git a/src/map/house/house.cpp b/src/map/house/house.cpp index 7967e21c3cc..842622b2af5 100644 --- a/src/map/house/house.cpp +++ b/src/map/house/house.cpp @@ -45,7 +45,7 @@ void House::setNewOwnerGuid(int32_t newOwnerGuid, bool serverStartup) { void House::clearHouseInfo(bool preventOwnerDeletion) { // Remove players from beds - for (auto bed : bedsList) { + for (const auto &bed : bedsList) { if (bed->getSleeper() != 0) { bed->wakeUp(nullptr); } @@ -60,7 +60,7 @@ void House::clearHouseInfo(bool preventOwnerDeletion) { setAccessList(SUBOWNER_LIST, ""); setAccessList(GUEST_LIST, ""); - for (auto door : doorList) { + for (const auto &door : doorList) { door->setAccessList(""); } } @@ -73,7 +73,7 @@ bool House::tryTransferOwnership(std::shared_ptr player, bool serverStar transferSuccess = transferToDepot(); } - for (auto tile : houseTiles) { + for (const auto &tile : houseTiles) { if (const CreatureVector* creatures = tile->getCreatures()) { for (int32_t i = creatures->size(); --i >= 0;) { const auto creature = (*creatures)[i]; @@ -103,7 +103,7 @@ void House::setOwner(uint32_t guid, bool updateDatabase /* = true*/, std::shared isLoaded = true; if (owner != 0) { - tryTransferOwnership(player, false); + tryTransferOwnership(std::move(player), false); } else { std::string strRentPeriod = asLowerCaseString(g_configManager().getString(HOUSE_RENT_PERIOD, __FUNCTION__)); time_t currentTime = time(nullptr); @@ -237,7 +237,7 @@ void House::setAccessList(uint32_t listId, const std::string &textlist) { } // kick uninvited players - for (std::shared_ptr tile : houseTiles) { + for (const std::shared_ptr &tile : houseTiles) { if (CreatureVector* creatures = tile->getCreatures()) { for (int32_t i = creatures->size(); --i >= 0;) { std::shared_ptr player = (*creatures)[i]->getPlayer(); @@ -272,7 +272,7 @@ bool House::transferToDepot(std::shared_ptr player) const { if (townId == 0 || !player) { return false; } - for (std::shared_ptr tile : houseTiles) { + for (const std::shared_ptr &tile : houseTiles) { if (!transferToDepot(player, tile)) { return false; } @@ -304,7 +304,7 @@ bool House::transferToDepot(std::shared_ptr player, std::shared_ptr> playersToSave = { player }; - for (std::shared_ptr item : moveItemList) { + for (const std::shared_ptr &item : moveItemList) { g_logger().debug("[{}] moving item '{}' to depot", __FUNCTION__, item->getName()); auto targetPlayer = player; if (item->hasOwner() && !item->isOwner(targetPlayer)) { @@ -317,7 +317,7 @@ bool House::transferToDepot(std::shared_ptr player, std::shared_ptrgetParent(), targetPlayer->getInbox(), INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT); } - for (auto playerToSave : playersToSave) { + for (const auto &playerToSave : playersToSave) { g_saveManager().savePlayer(playerToSave); } return true; @@ -379,7 +379,7 @@ void House::handleWrapableItem(ItemList &moveItemList, std::shared_ptr ite void House::handleContainer(ItemList &moveItemList, std::shared_ptr item) const { if (const auto container = item->getContainer()) { - for (std::shared_ptr containerItem : container->getItemList()) { + for (const std::shared_ptr &containerItem : container->getItemList()) { moveItemList.push_back(containerItem); } } @@ -554,32 +554,32 @@ void AccessList::parseList(const std::string &list) { } auto lines = explodeString(validList, "\n", 100); - for (auto &line : lines) { - trimString(line); - trim_left(line, '\t'); - trim_right(line, '\t'); - trimString(line); + for (auto &m_line : lines) { + trimString(m_line); + trim_left(m_line, '\t'); + trim_right(m_line, '\t'); + trimString(m_line); - if (line.empty() || line.front() == '#' || line.length() > 100) { + if (m_line.empty() || m_line.front() == '#' || m_line.length() > 100) { continue; } - toLowerCaseString(line); + toLowerCaseString(m_line); - std::string::size_type at_pos = line.find("@"); + std::string::size_type at_pos = m_line.find('@'); if (at_pos != std::string::npos) { if (at_pos == 0) { - addGuild(line.substr(1)); + addGuild(m_line.substr(1)); } else { - addGuildRank(line.substr(0, at_pos - 1), line.substr(at_pos + 1)); + addGuildRank(m_line.substr(0, at_pos - 1), m_line.substr(at_pos + 1)); } - } else if (line == "*") { + } else if (m_line == "*") { allowEveryone = true; - } else if (line.find_first_of("!*?") != std::string::npos) { + } else if (m_line.find_first_of("!*?") != std::string::npos) { // Remove regular expressions since they don't make much sense in houses continue; - } else if (line.length() <= NETWORKMESSAGE_PLAYERNAME_MAXLENGTH) { - addPlayer(line); + } else if (m_line.length() <= NETWORKMESSAGE_PLAYERNAME_MAXLENGTH) { + addPlayer(m_line); } } } @@ -603,7 +603,7 @@ namespace { return nullptr; } - const auto guild = g_game().getGuild(guildId); + auto guild = g_game().getGuild(guildId); if (guild) { return guild; } @@ -615,7 +615,7 @@ namespace { void AccessList::addGuild(const std::string &name) { const auto guild = getGuildByName(name); if (guild) { - for (const auto rank : guild->getRanks()) { + for (const auto &rank : guild->getRanks()) { guildRankList.insert(rank->id); } } @@ -669,7 +669,7 @@ void Door::setHouse(std::shared_ptr newHouse) { return; } - this->house = newHouse; + this->house = std::move(newHouse); if (!accessList) { accessList = std::make_unique(); diff --git a/src/map/map.cpp b/src/map/map.cpp index 395e6d7d2be..fcf14262c30 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -611,7 +611,7 @@ bool Map::getPathMatching(const std::shared_ptr &creature, const Posit const bool withoutCreature = creature == nullptr; const auto &tile = neighborNode || withoutCreature ? getTile(pos.x, pos.y, pos.z) : canWalkTo(creature, pos); - if (!tile || !neighborNode && withoutCreature && tile->hasFlag(TILESTATE_BLOCKSOLID)) { + if (!tile || (!neighborNode && withoutCreature && tile->hasFlag(TILESTATE_BLOCKSOLID))) { continue; } diff --git a/src/map/spectators.cpp b/src/map/spectators.cpp index 18ce13871fe..7c0e80a0412 100644 --- a/src/map/spectators.cpp +++ b/src/map/spectators.cpp @@ -79,7 +79,7 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl if (checkDistance) { SpectatorList spectators; spectators.reserve(creatures.size()); - for (const auto creature : *list) { + for (const auto &creature : *list) { const auto &specPos = creature->getPosition(); if (centerPos.x - specPos.x >= minRangeX && centerPos.y - specPos.y >= minRangeY @@ -184,7 +184,7 @@ Spectators Spectators::find(const Position ¢erPos, bool multifloor, bool onl for (uint_fast16_t nx = startx1; nx <= endx2; nx += FLOOR_SIZE) { if (leafE) { const auto &node_list = (onlyPlayers ? leafE->player_list : leafE->creature_list); - for (const auto creature : node_list) { + for (const auto &creature : node_list) { const auto &cpos = creature->getPosition(); if (minRangeZ > cpos.z || maxRangeZ < cpos.z) { continue; @@ -211,7 +211,7 @@ Spectators Spectators::find(const Position ¢erPos, bool multifloor, bool onl } // It is necessary to create the cache even if no spectators is found, so that there is no future query. - auto &cache = cacheFound ? it->second : spectatorsCache.emplace(centerPos, SpectatorsCache { .minRangeX = minRangeX, .maxRangeX = maxRangeX, .minRangeY = minRangeY, .maxRangeY = maxRangeY }).first->second; + auto &cache = cacheFound ? it->second : spectatorsCache.emplace(centerPos, SpectatorsCache { .minRangeX = minRangeX, .maxRangeX = maxRangeX, .minRangeY = minRangeY, .maxRangeY = maxRangeY, .creatures = {}, .players = {} }).first->second; auto &creaturesCache = onlyPlayers ? cache.players : cache.creatures; auto &creatureList = (multifloor ? creaturesCache.multiFloor : creaturesCache.floor); if (creatureList) { diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index ab111fd3c8f..ada1340a7c6 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -2247,7 +2247,7 @@ void ProtocolGame::parseBestiarysendRaces() { for (uint8_t i = BESTY_RACE_FIRST; i <= BESTY_RACE_LAST; i++) { std::string BestClass = ""; uint16_t count = 0; - for (auto rit : mtype_list) { + for (const auto &rit : mtype_list) { const auto mtype = g_monsters().getMonsterType(rit.second); if (!mtype) { return; @@ -2323,7 +2323,7 @@ void ProtocolGame::parseBestiarysendMonsterData(NetworkMessage &msg) { std::vector lootList = mtype->info.lootItems; newmsg.addByte(lootList.size()); - for (LootBlock loot : lootList) { + for (const LootBlock &loot : lootList) { int8_t difficult = g_iobestiary().calculateDifficult(loot.chance); bool shouldAddItem = false; @@ -2635,7 +2635,7 @@ void ProtocolGame::createLeaderTeamFinder(NetworkMessage &msg) { auto party = player->getParty(); if (teamAssemble->partyBool && party) { - for (std::shared_ptr member : party->getMembers()) { + for (const std::shared_ptr &member : party->getMembers()) { if (member && member->getGUID() != player->getGUID()) { teamAssemble->membersMap.insert({ member->getGUID(), 3 }); } @@ -2907,7 +2907,7 @@ void ProtocolGame::parseBestiarysendCreatures(NetworkMessage &msg) { std::string raceName = msg.getString(); race = g_iobestiary().findRaceByName(raceName); - if (race.size() == 0) { + if (race.empty()) { g_logger().warn("[ProtocolGame::parseBestiarysendCreature] - " "Race was not found: {}, search: {}", raceName, search); @@ -2921,7 +2921,7 @@ void ProtocolGame::parseBestiarysendCreatures(NetworkMessage &msg) { newmsg.add(race.size()); std::map creaturesKilled = g_iobestiary().getBestiaryKillCountByMonsterIDs(player, race); - for (auto it_ : race) { + for (const auto &it_ : race) { uint16_t raceid_ = it_.first; newmsg.add(raceid_); @@ -3889,14 +3889,14 @@ void ProtocolGame::sendCyclopediaCharacterOutfitsMounts() { auto startFamiliars = msg.getBufferPosition(); msg.skipBytes(2); const auto familiars = Familiars::getInstance().getFamiliars(player->getVocationId()); - for (const Familiar &familiar : familiars) { - const std::string type = familiar.type; + for (const auto &familiar : familiars) { + const std::string type = familiar->type; if (!player->getFamiliar(familiar)) { continue; } ++familiarsSize; - msg.add(familiar.lookType); - msg.addString(familiar.name, "ProtocolGame::sendCyclopediaCharacterOutfitsMounts - familiar.name"); + msg.add(familiar->lookType); + msg.addString(familiar->name, "ProtocolGame::sendCyclopediaCharacterOutfitsMounts - familiar.name"); if (type == "quest") { msg.addByte(CYCLOPEDIA_CHARACTERINFO_OUTFITTYPE_QUEST); } else { @@ -4151,7 +4151,7 @@ void ProtocolGame::sendBasicData() { // Send total size of spells msg.add(validSpells.size()); // Send each spell valid ids - for (auto spell : validSpells) { + for (const auto &spell : validSpells) { if (!spell) { continue; } @@ -4488,7 +4488,7 @@ void ProtocolGame::sendContainer(uint8_t cid, std::shared_ptr contain msg.addByte(0x00); } else if (container->getID() == ITEM_STORE_INBOX && !itemsStoreInboxToSend.empty()) { msg.addByte(std::min(maxItemsToSend, containerSize)); - for (const auto item : itemsStoreInboxToSend) { + for (const auto &item : itemsStoreInboxToSend) { AddItem(msg, item); } } else { @@ -4616,7 +4616,7 @@ void ProtocolGame::sendShop(std::shared_ptr npc) { msg.add(itemsToSend); uint16_t i = 0; - for (ShopBlock shopBlock : shoplist) { + for (const ShopBlock &shopBlock : shoplist) { if (++i > itemsToSend) { break; } @@ -4699,7 +4699,7 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co msg.addByte(0xEE); msg.addByte(0x00); msg.add(player->getBankBalance()); - uint16_t currency = player->getShopOwner() ? player->getShopOwner()->getCurrency() : ITEM_GOLD_COIN; + uint16_t currency = player->getShopOwner() ? player->getShopOwner()->getCurrency() : static_cast(ITEM_GOLD_COIN); msg.addByte(0xEE); if (currency == ITEM_GOLD_COIN) { msg.addByte(0x01); @@ -4724,7 +4724,7 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co auto msgPosition = msg.getBufferPosition(); msg.skipBytes(1); - for (ShopBlock shopBlock : shopVector) { + for (const ShopBlock &shopBlock : shopVector) { if (shopBlock.itemSellPrice == 0) { continue; } @@ -5859,7 +5859,7 @@ void ProtocolGame::sendTradeItemRequest(const std::string &traderName, std::shar std::shared_ptr container = listContainer.front(); listContainer.pop_front(); - for (std::shared_ptr containerItem : container->getItemList()) { + for (const std::shared_ptr &containerItem : container->getItemList()) { std::shared_ptr tmpContainer = containerItem->getContainer(); if (tmpContainer) { listContainer.push_back(tmpContainer); @@ -5869,7 +5869,7 @@ void ProtocolGame::sendTradeItemRequest(const std::string &traderName, std::shar } msg.addByte(itemList.size()); - for (std::shared_ptr listItem : itemList) { + for (const std::shared_ptr &listItem : itemList) { AddItem(msg, listItem); } } else { @@ -6810,14 +6810,14 @@ void ProtocolGame::sendOutfitWindow() { } std::vector> mounts; - for (const auto mount : g_game().mounts.getMounts()) { + for (const auto &mount : g_game().mounts.getMounts()) { if (player->hasMount(mount)) { mounts.push_back(mount); } } msg.addByte(mounts.size()); - for (const auto mount : mounts) { + for (const auto &mount : mounts) { msg.add(mount->clientId); msg.addString(mount->name, "ProtocolGame::sendOutfitWindow - mount->name"); } @@ -6919,7 +6919,7 @@ void ProtocolGame::sendOutfitWindow() { msg.skipBytes(2); const auto mounts = g_game().mounts.getMounts(); - for (const auto mount : mounts) { + for (const auto &mount : mounts) { if (player->hasMount(mount)) { msg.add(mount->clientId); msg.addString(mount->name, "ProtocolGame::sendOutfitWindow - mount->name"); @@ -6950,13 +6950,13 @@ void ProtocolGame::sendOutfitWindow() { const auto familiars = Familiars::getInstance().getFamiliars(player->getVocationId()); - for (const Familiar &familiar : familiars) { + for (const auto &familiar : familiars) { if (!player->getFamiliar(familiar)) { continue; } - msg.add(familiar.lookType); - msg.addString(familiar.name, "ProtocolGame::sendOutfitWindow - familiar.name"); + msg.add(familiar->lookType); + msg.addString(familiar->name, "ProtocolGame::sendOutfitWindow - familiar.name"); msg.addByte(0x00); if (++familiarSize == limitFamiliars) { break; @@ -7039,7 +7039,7 @@ void ProtocolGame::sendPodiumWindow(std::shared_ptr podium, const Position msg.skipBytes(2); const auto mounts = g_game().mounts.getMounts(); - for (const auto mount : mounts) { + for (const auto &mount : mounts) { if (player->hasMount(mount)) { msg.add(mount->clientId); msg.addString(mount->name, "ProtocolGame::sendPodiumWindow - mount->name"); @@ -7432,7 +7432,7 @@ void ProtocolGame::AddCreature(NetworkMessage &msg, std::shared_ptr cr } auto bubble = creature->getSpeechBubble(); - msg.addByte(oldProtocol && bubble == SPEECHBUBBLE_HIRELING ? SPEECHBUBBLE_NONE : bubble); + msg.addByte(oldProtocol && bubble == SPEECHBUBBLE_HIRELING ? static_cast(SPEECHBUBBLE_NONE) : bubble); msg.addByte(0xFF); // MARK_UNMARKED if (!oldProtocol) { msg.addByte(0x00); // inspection type @@ -7715,7 +7715,7 @@ void ProtocolGame::updatePartyTrackerAnalyzer(const std::shared_ptr party msg.addByte(static_cast(party->priceType)); msg.addByte(static_cast(party->membersData.size())); - for (const std::shared_ptr analyzer : party->membersData) { + for (const std::shared_ptr &analyzer : party->membersData) { msg.add(analyzer->id); if (std::shared_ptr member = g_game().getPlayerByID(analyzer->id); !member || !member->getParty() || member->getParty() != party) { @@ -7734,7 +7734,7 @@ void ProtocolGame::updatePartyTrackerAnalyzer(const std::shared_ptr party msg.addByte(showNames ? 0x01 : 0x00); if (showNames) { msg.addByte(static_cast(party->membersData.size())); - for (const std::shared_ptr analyzer : party->membersData) { + for (const std::shared_ptr &analyzer : party->membersData) { msg.add(analyzer->id); msg.addString(analyzer->name, "ProtocolGame::updatePartyTrackerAnalyzer - analyzer->name"); } @@ -8573,7 +8573,7 @@ void ProtocolGame::parseSendBosstiarySlots() { std::string boostedBossName = g_ioBosstiary().getBoostedBossName(); const auto mTypeBoosted = g_monsters().getMonsterType(boostedBossName); auto boostedBossRace = mTypeBoosted ? mTypeBoosted->info.bosstiaryRace : BosstiaryRarity_t::BOSS_INVALID; - auto isValidBoostedBoss = boostedBossId == 0 || boostedBossRace >= BosstiaryRarity_t::RARITY_BANE && boostedBossRace <= BosstiaryRarity_t::RARITY_NEMESIS; + auto isValidBoostedBoss = boostedBossId == 0 || (boostedBossRace >= BosstiaryRarity_t::RARITY_BANE && boostedBossRace <= BosstiaryRarity_t::RARITY_NEMESIS); if (!isValidBoostedBoss) { g_logger().error("[{}] The boosted boss '{}' has an invalid race", __FUNCTION__, boostedBossName); return; @@ -8581,7 +8581,7 @@ void ProtocolGame::parseSendBosstiarySlots() { const auto mTypeSlotOne = g_ioBosstiary().getMonsterTypeByBossRaceId((uint16_t)bossIdSlotOne); auto bossRaceSlotOne = mTypeSlotOne ? mTypeSlotOne->info.bosstiaryRace : BosstiaryRarity_t::BOSS_INVALID; - auto isValidBossSlotOne = bossIdSlotOne == 0 || bossRaceSlotOne >= BosstiaryRarity_t::RARITY_BANE && bossRaceSlotOne <= BosstiaryRarity_t::RARITY_NEMESIS; + auto isValidBossSlotOne = bossIdSlotOne == 0 || (bossRaceSlotOne >= BosstiaryRarity_t::RARITY_BANE && bossRaceSlotOne <= BosstiaryRarity_t::RARITY_NEMESIS); if (!isValidBossSlotOne) { g_logger().error("[{}] boss slot1 with race id '{}' has an invalid race", __FUNCTION__, bossIdSlotOne); return; @@ -8589,7 +8589,7 @@ void ProtocolGame::parseSendBosstiarySlots() { const auto mTypeSlotTwo = g_ioBosstiary().getMonsterTypeByBossRaceId((uint16_t)bossIdSlotTwo); auto bossRaceSlotTwo = mTypeSlotTwo ? mTypeSlotTwo->info.bosstiaryRace : BosstiaryRarity_t::BOSS_INVALID; - auto isValidBossSlotTwo = bossIdSlotTwo == 0 || bossRaceSlotTwo >= BosstiaryRarity_t::RARITY_BANE && bossRaceSlotTwo <= BosstiaryRarity_t::RARITY_NEMESIS; + auto isValidBossSlotTwo = bossIdSlotTwo == 0 || (bossRaceSlotTwo >= BosstiaryRarity_t::RARITY_BANE && bossRaceSlotTwo <= BosstiaryRarity_t::RARITY_NEMESIS); if (!isValidBossSlotTwo) { g_logger().error("[{}] boss slot1 with race id '{}' has an invalid race", __FUNCTION__, bossIdSlotTwo); return; From c9d1035379e55419e6fa8c44bfb750f8090ebc08 Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Tue, 14 May 2024 17:57:10 -0300 Subject: [PATCH 3/8] fix: missing achievements (#2590) --- data/scripts/lib/register_achievements.lua | 67 ++++++++++++++-------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/data/scripts/lib/register_achievements.lua b/data/scripts/lib/register_achievements.lua index 18a2d6e41ef..23d4bbd93ca 100644 --- a/data/scripts/lib/register_achievements.lua +++ b/data/scripts/lib/register_achievements.lua @@ -58,7 +58,7 @@ ACHIEVEMENTS = { [57] = { name = "Annihilator", grade = 2, points = 5, description = "You've daringly jumped into the infamous Annihilator and survived - taking home fame, glory and your reward." }, [58] = { name = "Master of the Nexus", grade = 2, points = 6, description = "You were able to fight your way through the countless hordes in the Demon Forge. Once more you proved that nothing is impossible." }, [59] = { name = "Talented Dancer", grade = 1, points = 1, description = "You're a lord or lady of the dance - and not afraid to use your skills to impress tribal gods. One step to the left, one jump to the right, twist and shout!" }, - [60] = { name = "Ministrel", grade = 1, points = 2, secret = true, description = "You can handle any music instrument you're given - and actually manage to produce a pleasant sound with it. You're a welcome guest and entertainer in most taverns." }, + [60] = { name = "Allow Cookies?", grade = 1, points = 2, description = "With a perfectly harmless smile, you tricked all the funny guys into eating your exploding cookies. Next time you pull this prank, consider wearing a Boy Scout outfit to make it even better." }, [61] = { name = "Ruthless", grade = 2, points = 5, description = "You've touched all thrones of the Ruthless Seven and absorbed some of their evil spirit. It may have changed you forever." }, [62] = { name = "Champion of Chazorai", grade = 2, points = 4, description = "You won the merciless 2 vs. 2 team tournament on the Isle of Strife and wiped out wave after wave of fearsome opponents. Death or victory - you certainly chose the latter." }, [63] = { name = "Wayfarer", grade = 1, points = 3, secret = true, description = "Dragon dreams are golden." }, @@ -193,7 +193,7 @@ ACHIEVEMENTS = { [192] = { name = "I Like it Fancy", grade = 1, points = 1, secret = true, description = "You definitely know how to bring out the best in your furniture and decoration pieces. Beautiful." }, [193] = { name = "Skin-Deep", grade = 2, points = 4, secret = true, description = "You always carry your obsidian knife with you and won't hesitate to use it. You've skinned countless little - and bigger - critters and yeah: they usually don't get any more beautiful on the inside. It's rather blood and gore and all that..." }, [194] = { name = "Ashes to Dust", grade = 2, points = 4, secret = true, description = "Staking vampires and demons has almost turned into your profession. You make sure to gather even the tiniest amount of evil dust particles. Beware of silicosis." }, - [195] = { name = "Silent Pet", grade = 1, points = 1, secret = true, description = "Awww. Your very own little goldfish friend - he's cute, he's shiny and he can't complain should you forget to feed him. He'll definitely brighten up your day!" }, + -- [195] = Unknown/non-existent [196] = { name = "Safely Stored Away", grade = 1, points = 2, secret = true, description = "Don't worry, no one will be able to take it from you. Probably." }, [197] = { name = "Something's in There", grade = 1, points = 1, secret = true, description = "By the gods! What was that?" }, [198] = { name = "Silent Pet", grade = 1, points = 1, secret = true, description = "Awww. Your very own little goldfish friend - he's cute, he's shiny and he can't complain should you forget to feed him. He'll definitely brighten up your day!" }, @@ -218,7 +218,7 @@ ACHIEVEMENTS = { [217] = { name = "Doctor! Doctor!", grade = 1, points = 2, secret = true, description = "Did someone call a doctor? You delivered 100 medicine bags to Ottokar of the Venore poor house in times of dire need, well done!" }, [218] = { name = "Beak Doctor", grade = 2, points = 4, description = "You significantly helped the afflicted citizens of Venore in times of dire need. Somehow you still feel close to the victims of the fever outbreak. Your clothes make you one of them, one poor soul amongst the countless afflicted." }, [219] = { name = "Mystic Fabric Magic", grade = 2, points = 4, description = "You vanquished the mad mage, you subdued the raging mage - no spellweaving self-exposer can stand in your way. Yet you are quite absorbed in magical studies yourself. This very fabric reflects this personal approval of the magic arts." }, - [220] = { name = "Breaking the Ice", grade = 1, points = 1, description = "You almost made friends with Shardhead... before he died. Poor guy only seems to attract violence with his frosty attitude." }, + -- [220] = Unknown/non-existent [221] = { name = "Arachnoise", grade = 1, points = 1, description = "You've shattered each of Bloodweb's eight frozen legs. As they say: break a leg, and then some more." }, [222] = { name = "Rootless Behaviour", grade = 1, points = 1, description = "You've descended into the swampy depths of Deathbine's lair and made quick work of it." }, [223] = { name = "Twisted Mutation", grade = 1, points = 1, description = "You've slain Esmeralda, the most hideous and aggressive of the mutated rats. No one will know that you almost lost a finger in the process." }, @@ -248,7 +248,7 @@ ACHIEVEMENTS = { [247] = { name = "Torn Treasures", grade = 1, points = 1, secret = true, description = "Wyda seems to be really, really bored. You also found out that she doesn't really need all those blood herbs that adventurers brought her. Still, she was nice enough to take one from you and gave you something quite cool in exchange." }, [248] = { name = "Loyal Subject", grade = 1, points = 1, secret = true, description = "You joined the Kingsday festivities and payed King Tibianus your respects. Now, off to party!" }, [249] = { name = "Desert Fisher", grade = 1, points = 1, description = "You managed to catch a fish in a surrounding that usually doesn't even carry water. Everything is subject to change, probably..." }, - [250] = { name = "Gem Cutter", grade = 1, points = 1, secret = true, description = 'You cut your first gem - and it bears your own name! Now that would be a nice gift! This does not make it a "true" Heart of the Sea, however...' }, + -- [250] = Unknown/non-existent [251] = { name = "Dog Sitter", grade = 1, points = 1, description = "You showed Noodles the way home. How long will it take this time until he's on the loose again? That dog must be really bored in the throne room by now." }, [252] = { name = "Ice Harvester", grade = 1, points = 1, description = "You witnessed the thawing of Svargrond and harvested rare seeds from some strange icy plants. They must be good for something." }, [253] = { name = "Preservationist", grade = 1, points = 1, secret = true, description = "You are a pretty smart thinker and managed to create everlasting flowers. They might become a big hit with all the people who aren't blessed with a green thumb or just forgetful." }, @@ -273,7 +273,7 @@ ACHIEVEMENTS = { [272] = { name = "Headache", grade = 1, points = 2, description = "Even in the deepest structures of the hive, you began to strike against the mighty foe. Your actions probably already gave the hive a headache." }, [273] = { name = "Confusion", grade = 1, points = 3, description = "The destruction you have caused by now can be felt throughout the whole hive. The mayhem that follows your step caused significant confusion in the consciousness of the hive." }, [274] = { name = "Manic", grade = 2, points = 4, description = "You have destroyed a significant amount of the hive's vital nerve centers and caused massive destruction to the hive's awareness. You are probably causing the hive horrible nightmares." }, - [275] = { name = "Suppressor", grade = 2, points = 4, description = "A war is won by those who have the best supply of troops. The hive's troops have been dealt a significant blow by your actions. You interrupted the hive's replenishment of troops lastingly and severely." }, + -- [275] = Unknown/non-existent [276] = { name = "Navigational Error", grade = 2, points = 5, secret = true, description = "You confronted the Navigator." }, [277] = { name = "Si, Ariki!", grade = 1, points = 1, description = "You've found the oriental traveller Yasir and were able to trade with him - even if you didn't really understand his language." }, [278] = { name = "Guardian Downfall", grade = 2, points = 4, description = "You ended the life of over three hundred Deepling Guards. Not quite the guardian of the Deeplings, are you?" }, @@ -282,7 +282,7 @@ ACHIEVEMENTS = { [281] = { name = "Gem Cutter", grade = 1, points = 1, secret = true, description = 'You cut your first gem - and it bears your own name! Now that would be a nice gift! This does not make it a "true" Heart of the Sea, however...' }, [282] = { name = "Spolium Profundis", grade = 2, points = 4, description = "You travelled the depths of this very world. You entered the blackness of the deep sea to conquer the realm of the Deeplings. May this suit remind you of the strange beauty below." }, [283] = { name = "Bane of the Hive", grade = 1, points = 2, description = "Countless fights and never tiring effort in the war against the hive grant you the experience to finish your outfit with the last remaining part. Your chitin outfit is a testament of your skills and dedication for the cause." }, - [284] = { name = "King of the Ring", grade = 1, points = 2, description = "Bretzecutioner's body just got slammed away. You are a true king of the ring!" }, + -- [284] = Unknown/non-existent [285] = { name = "Hive War Veteran", grade = 1, points = 1, description = "Your invaluable experience in fighting the hive allows you to add another piece of armor to your chitin outfit to prove your dedication for the cause." }, [286] = { name = "Hive Fighter", grade = 1, points = 1, description = "You have participated that much in the hive war, that you are able to create some makeshift armor from the remains of dead hive born that can be found in the major hive, to show of your skill." }, [287] = { name = "Howly Silence", grade = 1, points = 1, description = "You muted the everlasting howling of Hemming." }, @@ -294,7 +294,7 @@ ACHIEVEMENTS = { [293] = { name = "King of the Ring", grade = 1, points = 2, description = "Bretzecutioner's body just got slammed away. You are a true king of the ring!" }, [294] = { name = "Back from the Dead", grade = 1, points = 2, description = "You overcame the undead Zanakeph and sent him back into the darkness that spawned him." }, [295] = { name = "Pwned All Fur", grade = 3, points = 8, secret = true, description = "You've faced and defeated each of the mighty bosses the Paw and Fur society sent you out to kill. All by yourself. What a hunt!" }, - [296] = { name = "Diplomatic Immunity", grade = 2, points = 4, secret = true, description = "You killed the ambassador of the abyss that often that they might consider sending another one. Perhaps that will one day stop further intrusions." }, + -- [296] = Unknown/non-existent [297] = { name = "Bibby's Bloodbath", grade = 1, points = 1, secret = true, description = "You lend a helping hand in defeating invading Orcs by destroying their warcamp along with their leader. Bibby's personal bloodbath..." }, [298] = { name = "Nestling", grade = 1, points = 1, description = "You cleansed the land from an eight legged nuisance by defeating Mamma Longlegs three times. She won't be back soon... or will she?" }, [299] = { name = "Becoming a Bigfoot", grade = 1, points = 1, description = "You did it! You convinced the reclusive gnomes to accept you as one of their Bigfoots. Now you are ready to help them. With big feet big missions seen to come." }, @@ -321,14 +321,14 @@ ACHIEVEMENTS = { [320] = { name = "Funghitastic", grade = 1, points = 3, description = "Finally your dream to become a walking mushroom has come true ... No, wait a minute!" }, [321] = { name = "Crystal Clear", grade = 1, points = 3, description = "If the gnomes had told you that crystal armor is see-through you had probably changed your underwear in time." }, [322] = { name = "Gnomish Art Of War", grade = 1, points = 3, description = "You have unleashed your inner gnome and slain some of the most fearsome threats that gnomekind has ever faced. Now you can come and go to the warzones as it pleases you. The enemies of gnomekind will never be safe again." }, - [323] = { name = "Never Surrender", grade = 1, points = 3, description = "You did not show any signs of surrender to any sight of... you get the picture. Even a hundred of them did not pose a threat to you." }, + -- [323] = Unknown/non-existent [324] = { name = "True Dedication", grade = 2, points = 5, secret = true, description = "You conquered the demon challenge and prevailed... now show off your success in style!" }, [325] = { name = "Task Manager", grade = 1, points = 2, secret = true, description = "Helping a poor, stupid goblin to feed his starving children and wifes feels good ... if you'd only get rid of the strange feeling that you're missing something." }, [326] = { name = "Gravedigger", grade = 1, points = 3, description = "Assisting Omrabas' sick plan to resurrect made you dig your way through the blood-soaked halls of Drefia. Maybe better he failed!" }, [327] = { name = "Repenter", grade = 1, points = 1, secret = true, description = "You cleansed your soul in serving the Repenter enclave and purified thine self in completing all tasks in a single day of labour." }, [328] = { name = "Umbral Swordsman", grade = 2, points = 6, description = "You managed to transform, improve and sacrify your blade into a master state and have proven yourself worthy in a nightmarish world." }, - [329] = { name = "Umbral Berserker", grade = 2, points = 6, description = "You managed to transform, improve and sacrify your hammer into a master state and have proven yourself worthy in a nightmarish world." }, - [330] = { name = "Umbral Bladelord", grade = 2, points = 6, description = "You managed to transform, improve and sacrify your slayer into a master state and have proven yourself worthy in a nightmarish world." }, + -- [329] = Unknown/non-existent + -- [330] = Unknown/non-existent [331] = { name = "Cave Completionist", grade = 1, points = 2, description = "You have helped the gnomes of the spike in securing the caves and explored enough of the lightles depths to earn you a complete cave explorers outfit. Well done!" }, [332] = { name = "Umbral Bladelord", grade = 2, points = 6, description = "You managed to transform, improve and sacrify your slayer into a master state and have proven yourself worthy in a nightmarish world." }, [333] = { name = "Umbral Headsman", grade = 2, points = 6, description = "You managed to transform, improve and sacrify your axe into a master state and have proven yourself worthy in a nightmarish world." }, @@ -367,7 +367,7 @@ ACHIEVEMENTS = { [366] = { name = "Publicity", grade = 1, points = 1, description = "You are a man of the public. Or of good publicity at least. Through your efforts in advertising the airtight cloth, Zeronex might yet be redeemed - and Rathleton might yet see its first working Gloud Ship." }, [367] = { name = "Snake Charmer", grade = 1, points = 1, description = "By restoring the Everhungry Altar, you charmed the Fire-Feathered Sea Serpent back into its fitful sleep, twenty miles beneath the sea." }, [368] = { name = "Hoard of the Dragon", grade = 1, points = 1, secret = true, description = "Your adventurous way through countless dragon lairs earned you a pretty treasure - and surely the enmity of many a dragon." }, - [369] = { name = "Icy Glare", grade = 1, points = 1, description = "Here's looking at you, kid. This ancient creature seems to size you up with its brilliant eyes and barely tolerates you riding it. Maybe it thinks you're the defrosted snack, after all?" }, + -- [369] = Unknown/non-existent [370] = { name = "Little Ball of Wool", grade = 1, points = 1, description = "You found a lost sheep and thus a steady source of black wool. But careful: don't get entangled." }, [371] = { name = "Luminous Kitty", grade = 1, points = 3, description = "You made some efforts to bring a little more light into the world. And what a nice present you got in return!" }, [372] = { name = "The Right Tone", grade = 1, points = 1, description = "By setting the right tone you convinced a crystal wolf to accompany you. Remember it is made of crystal, though, so be careful in a banshee's presence." }, @@ -404,10 +404,10 @@ ACHIEVEMENTS = { [403] = { name = "Icy Glare", grade = 1, points = 1, description = "Here's looking at you, kid. This ancient creature seems to size you up with its brilliant eyes and barely tolerates you riding it. Maybe it thinks you're the defrosted snack, after all?" }, [404] = { name = "Cartography 101", grade = 1, points = 2, description = "You succeeded in finding and charting several previously unexplored landmarks and locations for the Adventurer's Guild, you probably never need to ask anyone for the way - do you?" }, [405] = { name = "Lost Palace Raider", grade = 1, points = 2, secret = true, description = "Lifting the secrets of a fabulous palace and defeating a beautiful demon princess was a thrilling experience indeed. This site's marvels nearly matched its terrors. Nearly." }, - [406] = { name = "The More the Merrier", grade = 0, points = 0, secret = true, description = "It's dangerous to go alone... Take ten friends." }, - [407] = { name = "Contender", grade = 1, points = 3, description = "You have fully unlocked 10 medium monsters in the cyclopedia." }, + [406] = { name = "The More the Merrier", grade = 1, points = 0, secret = true, description = "It's dangerous to go alone... Take ten friends." }, + -- [407] = Unknown/non-existent [408] = { name = "Rift Warrior", grade = 1, points = 3, description = "You went through hell. Seven times. You defeated the demons. Countless times. You put an end to Ferumbras claims to ascendancy. Once and for all." }, - [409] = { name = "Duked It Out", grade = 1, points = 1, description = "You defeated the Duke of the Depths and destroyed his lava pump!" }, + -- [409] = Unknown/non-existent [410] = { name = "Hat Hunter", grade = 2, points = 5, description = "You sucessfully fought against all odds to protect your world from an ascending god! – You weren't there for the hat only after all?" }, [411] = { name = "Ogre Chef", grade = 1, points = 1, description = "You didn't manage to become an ogre chief. But at least you are, beyond doubt, a worthy ogre chef." }, [412] = { name = "The Call of the Wild", grade = 1, points = 2, description = "You opposed man-eating ogres and clumsy clomps. You grappled with hungry chieftains, desperate goblins and angry spirits. So you truly overcame the wild vastness of Krailos." }, @@ -421,13 +421,13 @@ ACHIEVEMENTS = { [420] = { name = "Toothfairy Assistant", grade = 1, points = 1, description = "You assisted a very prominent fae and you fought tooth and nail to earn this title." }, [421] = { name = "Fairy Teasing", grade = 1, points = 1, secret = true, description = "Teasing fairies is fun. They leave behind such pretty clouds of glittering dust when chased. Just hope they don't get you back for it." }, [422] = { name = "Corruption Contained", grade = 2, points = 5, description = "You have managed to stall the worst incursion of corruption. Still this is just one battle won in an all out war for your world." }, - [423] = { name = "Daraman's Footsteps", grade = 1, points = 1, description = "You journeyed through Darashia and the sea of sand around it, while fighting the perils of the desert." }, - [424] = { name = "Dwarven Mines", grade = 1, points = 1, description = "Vast mines, an orc fortress and the magnificence of Kazordoon - you really know every corner of North-Eastern Mainland now." }, - [425] = { name = "Elven Woods", grade = 1, points = 1, description = "Tall trees, deep forests and and the beauty of Ab'Dendriel - you really know every corner of the elven lands now." }, - [426] = { name = "Glooth Punk", grade = 1, points = 1, description = "Glooth is the substance that powers a whole continent and all its weird inhabitants, workshops and factories. You travelled this strange smorgasbord of curiosities in its entirety - just in time for tea." }, - [427] = { name = "High and Dry", grade = 1, points = 2, description = "You asked Captain Charles to take a shortcut quite a few times. Now you are all too familiar with desert islands all over Tibia." }, - [428] = { name = "Jewel in the Swamp", grade = 1, points = 1, description = "Damp swamps, a dry desert and the opulence of Venore - you really know every corner of Eastern Mainland now." }, - [429] = { name = "King of the Jungle", grade = 1, points = 1, description = "You have searched Port Hope and the jungle that thoroughly, that you are up to adoption by a friendly ape family." }, + -- [423] = Unknown/non-existent + -- [424] = Unknown/non-existent + -- [425] = Unknown/non-existent + -- [426] = Unknown/non-existent + -- [427] = Unknown/non-existent + -- [428] = Unknown/non-existent + -- [429] = Unknown/non-existent [430] = { name = "Little Adventure", grade = 1, points = 1, description = "You have fully unlocked 10 easy monsters in the cyclopedia." }, [431] = { name = "Little Big Adventure", grade = 1, points = 2, secret = true, description = "You have fully unlocked 100 easy monsters in the cyclopedia." }, [432] = { name = "Contender", grade = 1, points = 3, description = "You have fully unlocked 10 medium monsters in the cyclopedia." }, @@ -470,7 +470,7 @@ ACHIEVEMENTS = { [469] = { name = "Battle Mage", grade = 2, points = 6, description = "Wielding dangerous knowledge as well as the sword is your expertise. You have proven yourself versatile in all manner of situations." }, [470] = { name = "Widely Travelled", grade = 3, points = 7, description = "As a true globetrotter you can now show your colours proudly with this extraordinary outfit." }, [471] = { name = "Running the Rift", grade = 1, points = 3, description = "You don't just have a permission to ride a rift runner, you literally went through hell and earned it!" }, - [472] = { name = "Nothing but Hot Air", grade = 1, points = 2, description = "You have tamed the ghostly mists to do your bidding. For now ..." }, + -- [472] = Unknown/non-existent [473] = { name = "Exalted Battle Mage", grade = 1, points = 2, description = "Not only did you master the battlefield as a mage, you were also induced to the most inner secrets of the art of magical warfare and prevailed." }, [474] = { name = "Areas of Effect", grade = 1, points = 3, secret = true, description = "Wisely contributing your resources to areas, you pushed creatures to maximum effect, allowing improved respawn for everyone! Well done!" }, [475] = { name = "Tied the Knot", grade = 1, points = 1, secret = true, description = "You figured out the right order of spells in the buried cathedral, how enchanting!" }, @@ -483,7 +483,7 @@ ACHIEVEMENTS = { [482] = { name = "Dream Catcher", grade = 1, points = 3, description = "You are the slayer of the ancient nightmare beast and prevented the nightmare to spread its madness." }, [483] = { name = "Champion of Summer", grade = 1, points = 2, secret = true, description = "You have vanquished numerous arena champions in the name of the Summer Court." }, [484] = { name = "Champion of Winter", grade = 1, points = 2, secret = true, description = "You have vanquished numerous arena champions in the name of the Winter Court." }, - [485] = { name = "Allow Cookies?", grade = 2, points = 6, description = "With a perfectly harmless smile, you tricked all the funny guys into eating your exploding cookies. Next time you pull this prank, consider wearing a Boy Scout outfit to make it even better." }, + -- [485] = Unknown/non-existent [486] = { name = "Bewitcher", grade = 2, points = 5, secret = true, description = "You literally put everything in that cauldron except lilac and gooseberries." }, [487] = { name = "Gryphon Rider", grade = 1, points = 3, description = "Unmasking spies, killing demons, discovering omens, solving puzzles and fighting ogres, manticores and feral sphinxes. - Nobody said it was easy to become a gryphon rider." }, [488] = { name = "Sculptor Apprentice", grade = 1, points = 2, secret = true, description = "Granted, you didn't carve those lifelike animal figurines yourself. But helping a medusa to find proper objects and even watching her using her petrifying gaze is almost as rewarding." }, @@ -496,6 +496,7 @@ ACHIEVEMENTS = { [495] = { name = "Inquisition's Arm", grade = 1, points = 2, description = "Your special garb, solely awarded to a dedicated Hand of the Inquisition, is now complete." }, [496] = { name = "Traditionalist", grade = 2, points = 6, description = "You proudly wear the traditional Orcsoberfest garb, same as it ever was and as it always will be." }, [497] = { name = "Do a Barrel Roll!", grade = 1, points = 3, description = "Riding a traditional beer barrel from the Orcsoberfest is a once-in-a-lifetime experience. Beer sold separately." }, + -- [498] = Unknown/non-existent [499] = { name = "Orcsoberfest Welcome", grade = 1, points = 3, secret = true, description = 'The Orcsoberfest is not only known for its traditional food, beer and customs but also fun events and excitement! You took part in all of that and can now truly say: "I survived!"' }, [500] = { name = "Prospectre", grade = 1, points = 1, secret = true, description = "You made acquaintance with the Thaian. A strange contemporary with a dark history. No man but a derivate of greed and obsession." }, [501] = { name = "Nothing but Hot Air", grade = 1, points = 3, description = "You have tamed the ghostly mists to do your bidding. For now ..." }, @@ -506,19 +507,24 @@ ACHIEVEMENTS = { [506] = { name = "Falconer", grade = 1, points = 2, description = "A true beastmaster learns the language of his animal companions. Now you as well can bolster your unique bond with nature and help preserve the balance of life as a proud falconer." }, [507] = { name = "Steppe Elegance", grade = 1, points = 3, description = "Champion of the wildlands, a swift strider among the creatures of the wild. The elegant nature of the gallop, this envoy of speed has mastered, indicates the precise understanding of its terrain and environment." }, [508] = { name = "Beyonder", grade = 1, points = 3, description = "Adventurous beyond death, you travelled the Netherworld. Although you had just the ghost of a chance you survived and even came back from the realm of the dead." }, + -- [509] = Unknown/non-existent [510] = { name = "Drama in Darama", grade = 1, points = 3, description = "If a pride of lions and a pack of hyaenas feud, it is not called a catfight but a ... whatsoever. For sure, it caused a lot of drama in the Darama Desert." }, [511] = { name = "Malefitz", grade = 1, points = 1, secret = true, description = "Made acquaintance with three brothers Fitz." }, [512] = { name = "Lionheart", grade = 1, points = 3, description = "You bested the maleficent duo Drume and Fugue and restored order to the besieged town of Bounac. You conquered the exotic stronghold of the Order of the Cobra and bested the undead knights of the Order of the Falcon. A true knight in heart and mind." }, + [513] = { name = "Soul Mender", grade = 4, points = 10, description = "Brought back to the realm of the living this magnificent creature will carry you through death and everything that lays beyond." }, [514] = { name = "You Got Horse Power", grade = 3, points = 8, description = "Brought back to the realm of the living this magnificent creature will carry you through death and everything that lays beyond." }, [515] = { name = "Unleash the Beast", grade = 3, points = 8, description = "You defeated the manifestation of Goshnar's evil traits by fighting your way through beasts you didn't even want to imagine. It transformed you and now you can also look the part." }, [516] = { name = "Well Roared, Lion!", grade = 1, points = 1, description = "You helped Domizian and thus proved yourself worthy to enter the werelion sanctum underneath Lion's Rock. You faced the mighty werelions there and one of the rare white lions even chose to accompany you." }, + -- [517] = Unknown/non-existent [518] = { name = "Honorary Rascoohan", grade = 1, points = 2, description = "When in Rascacoon, do as the Rascoohans do!" }, [519] = { name = "Release the Kraken", grade = 1, points = 3, description = "Riding around on this squishy companion gives you the feeling of flying through the air... uhm... swimming through the seven seas!" }, + -- [520] = Unknown/non-existent [521] = { name = "Pied Piper", grade = 1, points = 3, secret = true, description = "You are not exactly the Pied Piper of Hamelin but at least you managed to fend off a decent amount of pirats and helped to keep them out of the cities." }, [522] = { name = "Woodcarver", grade = 1, points = 3, secret = true, description = "You defeated Megasylvan Yselda in the wake of the sleeping carnisylvan menace deep under Bounac." }, [523] = { name = "Bounacean Chivalry", grade = 1, points = 2, secret = true, description = "Yselda forever stands watch against the carnisylvan menace. Ever awake, waiting in the dark, her heart longs to be united with her king once again. Deep empathy let a hero to bring her Kesar's tulip as a token of his love. That hero was you." }, [524] = { name = "Knowledge Raider", grade = 1, points = 3, description = "Your thirst for knowledge is insatiable. In the task of helping your gnomish friends, flawless execution is just the icing on the cake." }, [525] = { name = "Citizen of Issavi", grade = 1, points = 2, description = "It was not the first time that you helped the Sapphire Blade or the Midnight Flame with a difficult task. You may now wear the Kilmareshian robes as well as the tagralt blade and the eye-embroidered veil of the seers as a sign of Issavi's gratitude." }, + [526] = { name = "King's Council", grade = 1, points = 0, description = "Your continued efforts in keeping Bounac and the people of Kesar the Younger safe, earned you a permanent place at the royal court as an advisor to the king." }, [527] = { name = "Hot on the Trail", grade = 1, points = 3, description = "Since it is fireproof, this flaming creature feels right at home in raging infernos. But remember: just because it doesn't burn, you still do!" }, [528] = { name = "Shell We Take a Ride", grade = 1, points = 3, description = "Equipped with the shell of a tortoise and claws of a lobster this insect like companion will help you through every hardship." }, [529] = { name = "Phantastic!", grade = 1, points = 3, description = "This mighty pachyderm will march into battle as if just taking its Sunday stroll. The cost of friendship was only a few drome points!" }, @@ -526,7 +532,22 @@ ACHIEVEMENTS = { [531] = { name = "First Achievement", grade = 1, points = 1, secret = true, description = "Congratulations to your very first achievement! ... Well, not really. But imagine, it is. Because at this point during your journey into Tibia's past, achievements have been introduced." }, [532] = { name = "Sharp Dressed", grade = 1, points = 2, description = "Just everyone will be crazy about you if you are wearing this formal dress. They will come running, promise!" }, [533] = { name = "Engine Driver", grade = 1, points = 3, description = "This glooth-driven locomotive will bring you to any party in the blink of an eye." }, + [534] = { name = "Friendly Fire", grade = 1, points = 2, description = "You mastered the fire and tamed a supervulcano!" }, + [535] = { name = "Wedding Planner", grade = 1, points = 3, description = "Alas! What could be more beautiful and satisfying than bringing two loving hearts together? So romantic!" }, + [536] = { name = "Beaver Away", grade = 1, points = 1, description = "You really were as busy as a beaver in order to help the nagas. Enjoy some eager company!" }, + [537] = { name = "Snake Pit", grade = 1, points = 1, description = "Mysterious nagas, a vibrant jungle and a sinking island - you really know every corner of Marapur now." }, + [538] = { name = "Royalty of Hazard", grade = 1, points = 1, description = "For some it can't be hazardous enough." }, + [539] = { name = "Measuring the World", grade = 1, points = 2, description = "Step by step you discovered many of the secrets hidden in the world, thus gaining the right to wear the Discoverer outfit and hat. Made-to-measure for a brave traveller of the Tibian wilds." }, [540] = { name = "Ripp-Ripp Hooray!", grade = 1, points = 3, description = "Don't get carried away by your success. Get carried away by your Ripptor." }, + [541] = { name = "Warrior of the Iks", grade = 1, points = 2, description = "Combining unabating courage in combat and respect for the traditions and culture of the ancient Iks earned you the honours of true Aucar." }, + [542] = { name = "Mutagenius", grade = 1, points = 2, description = "You accomplished the impossible and created 16 mutagens of corresponding colours." }, + [543] = { name = "Strangest Thing", grade = 1, points = 3, description = "Only its rider can love this abomination of a mount." }, + [544] = { name = "Fully Decayed", grade = 1, points = 2, description = "You defeated the embodiments of decay and live to tell the tale, wear the rotting attire of the unfaltering defender proudly." }, + [545] = { name = "Like Fox and Mouse", grade = 1, points = 3, description = "Sly as a fox, quiet as a mouse - the perfect mount for a stealthy foray." }, + [546] = { name = "The Spirit of Purity", grade = 1, points = 3, description = "Withstanding both filth and desolation of the rotten darkness that corrupted the very core of this world, you embodied the weapon of purity and light to defy all that was tainted. This spirit will continue guide you on all future paths." }, + [547] = { name = "Museum Goer", grade = 1, points = 2, description = "You unveiled the secret plot of the Mitmah who stole away an entire civilisation for their own entertainment. Let the death of their outpost vanguard be an eternal lesson to them." }, + [548] = { name = "Mystic Predator", grade = 1, points = 3, description = "Proving your true worth to a mystic creature like the jaguar, king of the hunt, granted you not only respect but also its heart." }, + [549] = { name = "The Rule of Raccool", grade = 1, points = 2, description = "You almost feel as cool as a raccoon. Now, where's the trash?" }, } --[[ From 84c9658dc1c6882a38ec8f847d62f9ce29b40859 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Wed, 15 May 2024 20:27:51 -0300 Subject: [PATCH 4/8] fix: sonar bugs and gha checks (#2633) Fix to use std::cmp_greater and iteration using total ++ Co-authored-by: Elson Costa --- .github/workflows/build-ubuntu-dummy.yml | 4 +--- .github/workflows/build-ubuntu.yml | 4 +--- .../players/cyclopedia/player_title.cpp | 2 +- .../players/cyclopedia/player_title.hpp | 21 ++++++++++--------- src/game/game.cpp | 1 - src/items/items.hpp | 2 +- src/utils/tools.cpp | 13 ++++++------ 7 files changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-ubuntu-dummy.yml b/.github/workflows/build-ubuntu-dummy.yml index 00c4efdef87..f4ebb00ff27 100644 --- a/.github/workflows/build-ubuntu-dummy.yml +++ b/.github/workflows/build-ubuntu-dummy.yml @@ -17,11 +17,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-22.04] buildtype: [linux-release, linux-debug] include: - - os: ubuntu-20.04 - triplet: x64-linux - os: ubuntu-22.04 triplet: x64-linux diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index cdc54dc33f2..2b369e34875 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -36,11 +36,9 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: [ubuntu-22.04] buildtype: [linux-release, linux-debug] include: - - os: ubuntu-20.04 - triplet: x64-linux - os: ubuntu-22.04 triplet: x64-linux diff --git a/src/creatures/players/cyclopedia/player_title.cpp b/src/creatures/players/cyclopedia/player_title.cpp index 9e1c763a4ad..624b0313457 100644 --- a/src/creatures/players/cyclopedia/player_title.cpp +++ b/src/creatures/players/cyclopedia/player_title.cpp @@ -185,7 +185,7 @@ bool PlayerTitle::checkMount(uint32_t amount) { uint8_t total = 0; for (const auto &mount : g_game().mounts.getMounts()) { if (m_player.hasMount(mount)) { - total = total++; + total++; } } return total >= amount; diff --git a/src/creatures/players/cyclopedia/player_title.hpp b/src/creatures/players/cyclopedia/player_title.hpp index abf29650961..0530fcc083d 100644 --- a/src/creatures/players/cyclopedia/player_title.hpp +++ b/src/creatures/players/cyclopedia/player_title.hpp @@ -32,27 +32,28 @@ struct Title { Title() = default; Title(uint8_t id, CyclopediaTitle_t type, std::string maleName, std::string description, uint32_t amount, bool permanent) : - m_id(id), m_type(type), m_maleName(std::move(maleName)), m_description(std::move(description)), m_amount(amount), - m_permanent(permanent) { } + m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(), m_description(std::move(description)), + m_amount(amount), m_permanent(permanent), m_skill(0), m_race(0) { } Title(uint8_t id, CyclopediaTitle_t type, std::string maleName, std::string description, uint32_t amount, bool permanent, std::string femaleName) : - m_id(id), m_type(type), m_maleName(std::move(maleName)), m_description(std::move(description)), m_amount(amount), - m_permanent(permanent), m_femaleName(std::move(femaleName)) { } + m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), m_description(std::move(description)), + m_amount(amount), m_permanent(permanent), m_skill(0), m_race(0) { } Title(uint8_t id, CyclopediaTitle_t type, std::string maleName, std::string femaleName, std::string description, uint8_t skill) : m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), m_description(std::move(description)), - m_skill(skill) { } + m_amount(0), m_permanent(false), m_skill(skill), m_race(0) { } Title(uint8_t id, CyclopediaTitle_t type, uint16_t race, std::string maleName, std::string femaleName, std::string description) : - m_id(id), m_type(type), m_race(race), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), - m_description(std::move(description)) { } + m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), m_description(std::move(description)), + m_amount(0), m_permanent(false), m_skill(0), m_race(race) { } Title(uint8_t id, CyclopediaTitle_t type, uint16_t race, std::string maleName, std::string femaleName, std::string description, uint32_t amount, bool permanent) : - m_id(id), m_type(type), m_race(race), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), - m_description(std::move(description)), m_amount(amount), m_permanent(permanent) { } + m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(std::move(femaleName)), m_description(std::move(description)), + m_amount(amount), m_permanent(permanent), m_skill(0), m_race(race) { } Title(uint8_t id, CyclopediaTitle_t type, std::string maleName, std::string description, bool permanent) : - m_id(id), m_type(type), m_maleName(std::move(maleName)), m_description(std::move(description)), m_permanent(permanent) { } + m_id(id), m_type(type), m_maleName(std::move(maleName)), m_femaleName(), m_description(std::move(description)), + m_amount(0), m_permanent(permanent), m_skill(0), m_race(0) { } bool operator==(const Title &other) const { return m_id == other.m_id; diff --git a/src/game/game.cpp b/src/game/game.cpp index 1743edb2f32..67a02ea8523 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -8266,7 +8266,6 @@ void Game::kickPlayer(uint32_t playerId, bool displayEffect) { } void Game::playerFriendSystemAction(std::shared_ptr player, uint8_t type, uint8_t titleId) { - uint32_t playerGUID = player->getGUID(); if (type == 0x0E) { player->title()->setCurrentTitle(titleId); player->sendCyclopediaCharacterBaseInformation(); diff --git a/src/items/items.hpp b/src/items/items.hpp index 82af0659af4..e56678af6f3 100644 --- a/src/items/items.hpp +++ b/src/items/items.hpp @@ -447,7 +447,7 @@ class Items { static const std::string getAugmentNameByType(Augment_t augmentType); - static const bool isAugmentWithoutValueDescription(Augment_t augmentType) { + static bool isAugmentWithoutValueDescription(Augment_t augmentType) { static std::vector vector = { Augment_t::IncreasedDamage, Augment_t::PowerfulImpact, diff --git a/src/utils/tools.cpp b/src/utils/tools.cpp index b1fe671f416..584d4a6b5b6 100644 --- a/src/utils/tools.cpp +++ b/src/utils/tools.cpp @@ -1560,16 +1560,15 @@ void capitalizeWords(std::string &source) { void capitalizeWordsIgnoringString(std::string &source, const std::string stringToIgnore) { toLowerCaseString(source); - uint8_t size = (uint8_t)source.size(); - uint8_t indexFound = source.find(stringToIgnore); + auto size = static_cast(source.size()); + auto indexFound = source.find(stringToIgnore); + for (uint8_t i = 0; i < size; i++) { - if (indexFound != std::string::npos && (i > indexFound - 1) && i < (indexFound + stringToIgnore.size())) { + if (indexFound != std::string::npos && indexFound > 0 && std::cmp_greater(i, static_cast(indexFound - 1)) && i < (indexFound + stringToIgnore.size())) { continue; } - if (i == 0) { - source[i] = (char)toupper(source[i]); - } else if (source[i - 1] == ' ' || source[i - 1] == '\'') { - source[i] = (char)toupper(source[i]); + if (i == 0 || source[i - 1] == ' ' || source[i - 1] == '\'') { + source[i] = static_cast(std::toupper(source[i])); } } } From b83c9b44d12f36705195220a62a7e8a656d39731 Mon Sep 17 00:00:00 2001 From: Aluisio Penna Date: Wed, 15 May 2024 21:11:45 -0300 Subject: [PATCH 5/8] fix: log error 'primal pack beast not exist' and health display (#2598) Resolves the log error stating "Monster with name primal pack beast not exist" that appears when a player engages with 'the primal menace'. It also corrects the health bar display for primal beasts to ensure it appears filled upon their creation, aligning with the global standards for creature health displays. These adjustments improve both the accuracy of the game's logging system and the visual feedback provided to players during encounters with primal beasts. --- data-otservbr-global/lib/quests/the_primal_ordeal.lua | 6 ++---- .../quests/primal_ordeal_quest/the_primal_menace.lua | 3 --- src/game/game.cpp | 5 +++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/data-otservbr-global/lib/quests/the_primal_ordeal.lua b/data-otservbr-global/lib/quests/the_primal_ordeal.lua index de708ee4de2..24324e1147b 100644 --- a/data-otservbr-global/lib/quests/the_primal_ordeal.lua +++ b/data-otservbr-global/lib/quests/the_primal_ordeal.lua @@ -6,12 +6,10 @@ function RegisterPrimalPackBeast(template) primalMonster.loot = {} primalMonster.name = "Primal Pack Beast" primalMonster.description = "a primal pack beast" - - primalMonster.health = primalMonster.health - primalMonster.maxHealth = primalMonster.maxHealth + primalMonster.maxHealth = primalMonster.maxHealth * 0.7 + primalMonster.health = primalMonster.maxHealth primalMonster.raceId = nil primalMonster.Bestiary = nil primalMonster.corpse = 0 - primal:register(primalMonster) end diff --git a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua index b0bc59364d6..7ad43b016c9 100644 --- a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua +++ b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_primal_menace.lua @@ -24,7 +24,6 @@ local thePrimalMenaceConfig = { CountGrowthPerHazard = 1.05, CountMax = 6, - HpRateOnSpawn = 0.7, MonsterPool = { "Emerald Tortoise (Primal)", "Gore Horn (Primal)", @@ -291,8 +290,6 @@ local function spawnMonster(monsterId, spawnPosition) MonsterId = primalMonster:getId(), Created = os.time(), } - local monsterMaxHealth = primalMonster:getMaxHealth() - primalMonster:setHealth(monsterMaxHealth * thePrimalMenaceConfig.MonsterConfig.HpRateOnSpawn) local primalBeasts = monster:getStorageValue(thePrimalMenaceConfig.Storage.PrimalBeasts) table.insert(primalBeasts, primalBeastEntry) diff --git a/src/game/game.cpp b/src/game/game.cpp index 67a02ea8523..00ec056ccb3 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -6493,9 +6493,10 @@ bool Game::combatBlockHit(CombatDamage &damage, std::shared_ptr attack InternalGame::sendBlockEffect(primaryBlockType, damage.primary.type, target->getPosition(), attacker); // Damage reflection primary if (!damage.extension && attacker) { - if (targetPlayer && attacker->getMonster() && damage.primary.type != COMBAT_HEALING) { + std::shared_ptr attackerMonster = attacker->getMonster(); + if (attackerMonster && targetPlayer && damage.primary.type != COMBAT_HEALING) { // Charm rune (target as player) - const auto mType = g_monsters().getMonsterType(attacker->getName()); + const auto &mType = attackerMonster->getMonsterType(); if (mType) { charmRune_t activeCharm = g_iobestiary().getCharmFromTarget(targetPlayer, mType); if (activeCharm == CHARM_PARRY) { From 216653966cb2be4416de80b1aef698c71605f021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Fri, 17 May 2024 09:42:33 -0300 Subject: [PATCH 6/8] fix: doctor marrow's spell null reference (#2624) --- .../monster/doctor_marrow_explosion.lua | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/data-otservbr-global/scripts/spells/monster/doctor_marrow_explosion.lua b/data-otservbr-global/scripts/spells/monster/doctor_marrow_explosion.lua index f616e8b8cee..491d9f2516d 100644 --- a/data-otservbr-global/scripts/spells/monster/doctor_marrow_explosion.lua +++ b/data-otservbr-global/scripts/spells/monster/doctor_marrow_explosion.lua @@ -21,7 +21,7 @@ end local spell = Spell("instant") function onTargetCreature(creature, target) - if not targetPos then + if not target then return true end local master = target:getMaster() @@ -29,7 +29,7 @@ function onTargetCreature(creature, target) return true end - local distance = math.floor(targetPos:getDistance(target:getPosition())) + local distance = math.floor(creature:getPosition():getDistance(target:getPosition())) local actualDamage = damage / (2 ^ distance) doTargetCombatHealth(0, target, COMBAT_EARTHDAMAGE, actualDamage, actualDamage, CONST_ME_NONE) if crit then @@ -63,21 +63,26 @@ function spell.onCastSpell(creature, var) end, i * 100, targetPos) end - addEvent(function(cid) + addEvent(function(cid, pos) local creature = Creature(cid) - creature:getPosition():sendMagicEffect(CONST_ME_ORANGE_ENERGY_SPARK) - targetPos:sendMagicEffect(CONST_ME_ORANGETELEPORT) - end, 2000, creature:getId()) + if creature then + creature:getPosition():sendMagicEffect(CONST_ME_ORANGE_ENERGY_SPARK) + pos:sendMagicEffect(CONST_ME_ORANGETELEPORT) + end + end, 2000, creature:getId(), targetPos) addEvent(function(cid, pos) - damage = -math.random(3500, 7000) - if math.random(1, 100) <= 10 then - crit = true - damage = damage * 1.5 - else - crit = false + local creature = Creature(cid) + if creature then + damage = -math.random(3500, 7000) + if math.random(1, 100) <= 10 then + crit = true + damage = damage * 1.5 + else + crit = false + end + spellCombat:execute(creature, Variant(pos)) end - spellCombat:execute(creature, Variant(pos)) end, totalDelay, creature:getId(), targetPos) return true end From c67424169752c1e417dc86bd0843993745d17598 Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Fri, 17 May 2024 21:17:20 -0300 Subject: [PATCH 7/8] fix: check nil storage key from setStorageValue (#2636) When a key from Lua is nil, it is automatically transformed into 0 without being checked. Consequently, even with a nil key, no error is thrown, and the code continues as if everything had occurred normally, resulting in the storage not being set. Removed two duplicated checks in creature.cpp; they are already verified in the if statement above. --- src/creatures/creature.cpp | 2 +- src/lua/functions/creatures/player/player_functions.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/creatures/creature.cpp b/src/creatures/creature.cpp index 43e7ab89ccf..7796863f066 100644 --- a/src/creatures/creature.cpp +++ b/src/creatures/creature.cpp @@ -824,7 +824,7 @@ bool Creature::dropCorpse(std::shared_ptr lastHitCreature, std::shared auto isReachable = g_game().map.getPathMatching(player->getPosition(), dirList, FrozenPathingConditionCall(corpse->getPosition()), fpp); - if (player->checkAutoLoot(monster->isRewardBoss()) && corpseContainer && mostDamageCreature->getPlayer() && isReachable) { + if (player->checkAutoLoot(monster->isRewardBoss()) && isReachable) { g_dispatcher().addEvent([player, corpseContainer, corpsePosition = corpse->getPosition()] { g_game().playerQuickLootCorpse(player, corpseContainer, corpsePosition); }, diff --git a/src/lua/functions/creatures/player/player_functions.cpp b/src/lua/functions/creatures/player/player_functions.cpp index 7f4d96f3773..50774e35e2a 100644 --- a/src/lua/functions/creatures/player/player_functions.cpp +++ b/src/lua/functions/creatures/player/player_functions.cpp @@ -1744,6 +1744,11 @@ int PlayerFunctions::luaPlayerSetStorageValue(lua_State* L) { return 1; } + if (key == 0) { + reportErrorFunc("Storage key is nil"); + return 1; + } + if (player) { player->addStorageValue(key, value); pushBoolean(L, true); From 7dda937c32e7caaf66151e5152c9ab7b86c81b39 Mon Sep 17 00:00:00 2001 From: Guilherme Date: Mon, 20 May 2024 12:41:57 -0300 Subject: [PATCH 8/8] fix: items on npcs shop, update monsters spawn and items (#2616) --- data-otservbr-global/npc/alaistar.lua | 5 ++- data-otservbr-global/npc/alexander.lua | 22 +++++++++ data-otservbr-global/npc/asima.lua | 33 ++++++++++++++ data-otservbr-global/npc/briasol.lua | 2 +- data-otservbr-global/npc/chantalle.lua | 2 +- data-otservbr-global/npc/chuckles.lua | 32 +++++++++++++ data-otservbr-global/npc/edmund.lua | 2 +- data-otservbr-global/npc/fenech.lua | 14 ++++++ data-otservbr-global/npc/frans.lua | 14 ++++++ data-otservbr-global/npc/frederik.lua | 14 ++++++ data-otservbr-global/npc/gail.lua | 2 +- data-otservbr-global/npc/gnomegica.lua | 14 ++++++ data-otservbr-global/npc/hanna.lua | 2 +- data-otservbr-global/npc/ishina.lua | 2 +- data-otservbr-global/npc/iwan.lua | 2 +- data-otservbr-global/npc/jessica.lua | 2 +- data-otservbr-global/npc/khanna.lua | 42 ++++++++++++++++- data-otservbr-global/npc/mordecai.lua | 11 +++++ data-otservbr-global/npc/nelly.lua | 14 ++++++ data-otservbr-global/npc/nipuna.lua | 11 +++++ data-otservbr-global/npc/odemara.lua | 2 +- data-otservbr-global/npc/oiriz.lua | 2 +- data-otservbr-global/npc/rabaz.lua | 14 ++++++ data-otservbr-global/npc/rachel.lua | 17 +++++++ data-otservbr-global/npc/romir.lua | 14 ++++++ data-otservbr-global/npc/shiriel.lua | 14 ++++++ data-otservbr-global/npc/sigurd.lua | 14 ++++++ data-otservbr-global/npc/sundara.lua | 11 +++++ data-otservbr-global/npc/tandros.lua | 14 ++++++ data-otservbr-global/npc/tesha.lua | 2 +- data-otservbr-global/npc/tezila.lua | 2 +- data-otservbr-global/npc/topsy.lua | 14 ++++++ data-otservbr-global/npc/valindara.lua | 2 +- data-otservbr-global/npc/xodet.lua | 14 ++++++ data-otservbr-global/npc/yasir.lua | 10 +++++ data-otservbr-global/npc/yonan.lua | 2 +- .../world/otservbr-monster.xml | 45 ++++--------------- data/items/items.xml | 16 ++++++- 38 files changed, 396 insertions(+), 55 deletions(-) diff --git a/data-otservbr-global/npc/alaistar.lua b/data-otservbr-global/npc/alaistar.lua index e893975b24b..68aaa75679a 100644 --- a/data-otservbr-global/npc/alaistar.lua +++ b/data-otservbr-global/npc/alaistar.lua @@ -36,13 +36,14 @@ local itemsTable = { { itemName = "strong health potion", clientId = 236, buy = 115 }, { itemName = "strong mana potion", clientId = 237, buy = 93 }, { itemName = "supreme health potion", clientId = 23375, buy = 625 }, - { itemName = "ultimate health potion", clientId = 7643, buy = 438 }, - { itemName = "ultimate mana potion", clientId = 23373, buy = 379 }, + { itemName = "ultimate health potion", clientId = 7643, buy = 379 }, + { itemName = "ultimate mana potion", clientId = 23373, buy = 438 }, { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, { itemName = "vial", clientId = 2874, sell = 5 }, }, ["creature products"] = { { itemName = "cowbell", clientId = 21204, sell = 210 }, + { itemName = "execowtioner mask", clientId = 21201, sell = 240 }, { itemName = "giant pacifier", clientId = 21199, sell = 170 }, { itemName = "glob of glooth", clientId = 21182, sell = 125 }, { itemName = "glooth injection tube", clientId = 21103, sell = 350 }, diff --git a/data-otservbr-global/npc/alexander.lua b/data-otservbr-global/npc/alexander.lua index 78f51e486c8..fda2799bf4d 100644 --- a/data-otservbr-global/npc/alexander.lua +++ b/data-otservbr-global/npc/alexander.lua @@ -30,6 +30,28 @@ npcConfig.voices = { } local itemsTable = { + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["creature products"] = { + { itemName = "crystal ball", clientId = 3076, buy = 530, sell = 190 }, + { itemName = "life crystal", clientId = 3061, sell = 83 }, + { itemName = "mind stone", clientId = 3062, sell = 170 }, + }, + ["shields"] = { + { itemName = "spellbook of enlightenment", clientId = 8072, sell = 4000 }, + { itemName = "spellbook of warding", clientId = 8073, sell = 8000 }, + { itemName = "spellbook of mind control", clientId = 8074, sell = 13000 }, + { itemName = "spellbook of lost souls", clientId = 8075, sell = 19000 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, ["runes"] = { { itemName = "animate dead rune", clientId = 3203, buy = 375 }, { itemName = "blank rune", clientId = 3147, buy = 10 }, diff --git a/data-otservbr-global/npc/asima.lua b/data-otservbr-global/npc/asima.lua index 645689c42d4..c3aca3fcd5e 100644 --- a/data-otservbr-global/npc/asima.lua +++ b/data-otservbr-global/npc/asima.lua @@ -24,6 +24,14 @@ npcConfig.flags = { } local itemsTable = { + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, ["potions"] = { { itemName = "empty potion flask", clientId = 283, sell = 5 }, { itemName = "empty potion flask", clientId = 284, sell = 5 }, @@ -41,6 +49,12 @@ local itemsTable = { { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, { itemName = "vial", clientId = 2874, sell = 5 }, }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, ["runes"] = { { itemName = "avalanche rune", clientId = 3161, buy = 57 }, { itemName = "blank rune", clientId = 3147, buy = 10 }, @@ -61,8 +75,27 @@ local itemsTable = { { itemName = "poison field rune", clientId = 3172, buy = 21 }, { itemName = "poison wall rune", clientId = 3176, buy = 52 }, { itemName = "sudden death rune", clientId = 3155, buy = 135 }, + { itemName = "stalagmite rune", clientId = 3179, buy = 12 }, { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, }, + ["wands"] = { + { itemName = "hailstorm rod", clientId = 3067, buy = 15000 }, + { itemName = "moonlight rod", clientId = 3070, buy = 1000 }, + { itemName = "necrotic rod", clientId = 3069, buy = 5000 }, + { itemName = "northwind rod", clientId = 8083, buy = 7500 }, + { itemName = "snakebite rod", clientId = 3066, buy = 500 }, + { itemName = "springsprout rod", clientId = 8084, buy = 18000 }, + { itemName = "terra rod", clientId = 3065, buy = 10000 }, + { itemName = "underworld rod", clientId = 8082, buy = 22000 }, + { itemName = "wand of cosmic energy", clientId = 3073, buy = 10000 }, + { itemName = "wand of decay", clientId = 3072, buy = 5000 }, + { itemName = "wand of draconia", clientId = 8093, buy = 7500 }, + { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, + { itemName = "wand of inferno", clientId = 3071, buy = 15000 }, + { itemName = "wand of starstorm", clientId = 8092, buy = 18000 }, + { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, + { itemName = "wand of vortex", clientId = 3074, buy = 500 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/briasol.lua b/data-otservbr-global/npc/briasol.lua index 6905011fee9..38dcd074159 100644 --- a/data-otservbr-global/npc/briasol.lua +++ b/data-otservbr-global/npc/briasol.lua @@ -113,7 +113,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/chantalle.lua b/data-otservbr-global/npc/chantalle.lua index 2615f6557da..3ed42984f5c 100644 --- a/data-otservbr-global/npc/chantalle.lua +++ b/data-otservbr-global/npc/chantalle.lua @@ -99,7 +99,7 @@ npcConfig.shop = { { itemName = "diamond", clientId = 32770, sell = 15000 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/chuckles.lua b/data-otservbr-global/npc/chuckles.lua index 51fb3f2add6..4eb06b6bb3d 100644 --- a/data-otservbr-global/npc/chuckles.lua +++ b/data-otservbr-global/npc/chuckles.lua @@ -59,6 +59,38 @@ local itemsTable = { { itemName = "sudden death rune", clientId = 3155, buy = 135 }, { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, }, + ["wands"] = { + { itemName = "hailstorm rod", clientId = 3067, buy = 15000 }, + { itemName = "moonlight rod", clientId = 3070, buy = 1000 }, + { itemName = "necrotic rod", clientId = 3069, buy = 5000 }, + { itemName = "northwind rod", clientId = 8083, buy = 7500 }, + { itemName = "snakebite rod", clientId = 3066, buy = 500 }, + { itemName = "springsprout rod", clientId = 8084, buy = 18000 }, + { itemName = "terra rod", clientId = 3065, buy = 10000 }, + { itemName = "underworld rod", clientId = 8082, buy = 22000 }, + { itemName = "wand of cosmic energy", clientId = 3073, buy = 10000 }, + { itemName = "wand of decay", clientId = 3072, buy = 5000 }, + { itemName = "wand of draconia", clientId = 8093, buy = 7500 }, + { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, + { itemName = "wand of inferno", clientId = 3071, buy = 15000 }, + { itemName = "wand of starstorm", clientId = 8092, buy = 18000 }, + { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, + { itemName = "wand of vortex", clientId = 3074, buy = 500 }, + }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/edmund.lua b/data-otservbr-global/npc/edmund.lua index d8635297949..c61a95bcd72 100644 --- a/data-otservbr-global/npc/edmund.lua +++ b/data-otservbr-global/npc/edmund.lua @@ -68,7 +68,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/fenech.lua b/data-otservbr-global/npc/fenech.lua index 7152c0ef9c5..f69dcafaa89 100644 --- a/data-otservbr-global/npc/fenech.lua +++ b/data-otservbr-global/npc/fenech.lua @@ -71,6 +71,20 @@ local itemsTable = { { itemName = "sudden death rune", clientId = 3155, buy = 135 }, { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/frans.lua b/data-otservbr-global/npc/frans.lua index 8761a7d89d6..a1b695adf14 100644 --- a/data-otservbr-global/npc/frans.lua +++ b/data-otservbr-global/npc/frans.lua @@ -58,6 +58,20 @@ local itemsTable = { { itemName = "sudden death rune", clientId = 3155, buy = 135 }, { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/frederik.lua b/data-otservbr-global/npc/frederik.lua index 9b33ccf9684..81ff1ec58b6 100644 --- a/data-otservbr-global/npc/frederik.lua +++ b/data-otservbr-global/npc/frederik.lua @@ -82,6 +82,20 @@ local itemsTable = { { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, { itemName = "vial", clientId = 2874, sell = 5 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/gail.lua b/data-otservbr-global/npc/gail.lua index 80a9b54b3e5..de2a52dc7f4 100644 --- a/data-otservbr-global/npc/gail.lua +++ b/data-otservbr-global/npc/gail.lua @@ -109,7 +109,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/gnomegica.lua b/data-otservbr-global/npc/gnomegica.lua index 0805ca33ace..b860caf3962 100644 --- a/data-otservbr-global/npc/gnomegica.lua +++ b/data-otservbr-global/npc/gnomegica.lua @@ -78,6 +78,20 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/hanna.lua b/data-otservbr-global/npc/hanna.lua index 7fca4c908aa..dfea1547135 100644 --- a/data-otservbr-global/npc/hanna.lua +++ b/data-otservbr-global/npc/hanna.lua @@ -145,7 +145,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/ishina.lua b/data-otservbr-global/npc/ishina.lua index 1fd61200c15..358ee2619a3 100644 --- a/data-otservbr-global/npc/ishina.lua +++ b/data-otservbr-global/npc/ishina.lua @@ -139,7 +139,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/iwan.lua b/data-otservbr-global/npc/iwan.lua index 2cc24843318..77689b12003 100644 --- a/data-otservbr-global/npc/iwan.lua +++ b/data-otservbr-global/npc/iwan.lua @@ -78,7 +78,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/jessica.lua b/data-otservbr-global/npc/jessica.lua index 37ac18ed54a..43b1839b3ee 100644 --- a/data-otservbr-global/npc/jessica.lua +++ b/data-otservbr-global/npc/jessica.lua @@ -98,7 +98,7 @@ npcConfig.shop = { { itemName = "diamond", clientId = 32770, sell = 15000 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/khanna.lua b/data-otservbr-global/npc/khanna.lua index 02fcee7b6d5..76b5c1e70da 100644 --- a/data-otservbr-global/npc/khanna.lua +++ b/data-otservbr-global/npc/khanna.lua @@ -34,7 +34,7 @@ local itemsTable = { ["runes"] = { { itemName = "animate dead rune", clientId = 3203, buy = 375 }, { itemName = "avalanche rune", clientId = 3161, buy = 57 }, - { itemName = "blank rune", clientId = 3147, buy = 10 }, + { itemName = "blank rune", clientId = 3147, buy = 20 }, { itemName = "chameleon rune", clientId = 3178, buy = 210 }, { itemName = "convince creature rune", clientId = 3177, buy = 80 }, { itemName = "cure poison rune", clientId = 3153, buy = 65 }, @@ -84,6 +84,46 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["creature products"] = { + { itemName = "bashmu fang", clientId = 36820, sell = 600 }, + { itemName = "bashmu feather", clientId = 36820, sell = 350 }, + { itemName = "bashmu tongue", clientId = 36820, sell = 400 }, + { itemName = "blue goanna scale", clientId = 31559, sell = 230 }, + { itemName = "crystal ball", clientId = 3076, buy = 650 }, + { itemName = "fafnar symbol", clientId = 31443, sell = 950 }, + { itemName = "goanna claw", clientId = 31561, sell = 950 }, + { itemName = "goanna meat", clientId = 31560, sell = 190 }, + { itemName = "lamassu hoof", clientId = 31441, sell = 330 }, + { itemName = "lamassu horn", clientId = 31442, sell = 240 }, + { itemName = "life crystal", clientId = 3061, sell = 85 }, + { itemName = "lizard heart", clientId = 31340, sell = 530 }, + { itemName = "manticore ear", clientId = 31440, sell = 310 }, + { itemName = "manticore tail", clientId = 31439, sell = 220 }, + { itemName = "mind stone", clientId = 3062, sell = 170 }, + { itemName = "old girtablilu carapace", clientId = 36972, sell = 570 }, + { itemName = "red goanna scale", clientId = 31558, sell = 270 }, + { itemName = "scorpion charm", clientId = 36822, sell = 620 }, + { itemName = "sphinx feather", clientId = 31437, sell = 470 }, + { itemName = "sphinx tiara", clientId = 31438, sell = 360 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + { itemName = "spellbook of enlightenment", clientId = 8072, sell = 4000 }, + { itemName = "spellbook of lost souls", clientId = 8075, sell = 19000 }, + { itemName = "spellbook of mind control", clientId = 8074, sell = 13000 }, + { itemName = "spellbook of warding", clientId = 8073, sell = 8000 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/mordecai.lua b/data-otservbr-global/npc/mordecai.lua index 60063a423ba..dc0e3c07a77 100644 --- a/data-otservbr-global/npc/mordecai.lua +++ b/data-otservbr-global/npc/mordecai.lua @@ -88,6 +88,17 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/nelly.lua b/data-otservbr-global/npc/nelly.lua index 8c3b123c47a..911464524c6 100644 --- a/data-otservbr-global/npc/nelly.lua +++ b/data-otservbr-global/npc/nelly.lua @@ -94,6 +94,20 @@ local itemsTable = { { itemName = "letter", clientId = 3505, buy = 8 }, { itemName = "parcel", clientId = 3503, buy = 15 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/nipuna.lua b/data-otservbr-global/npc/nipuna.lua index aa9d74cec52..ef3211bce42 100644 --- a/data-otservbr-global/npc/nipuna.lua +++ b/data-otservbr-global/npc/nipuna.lua @@ -101,6 +101,17 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/odemara.lua b/data-otservbr-global/npc/odemara.lua index bcfe94bf8eb..3e1986714c7 100644 --- a/data-otservbr-global/npc/odemara.lua +++ b/data-otservbr-global/npc/odemara.lua @@ -70,7 +70,7 @@ npcConfig.shop = { { itemName = "diamond", clientId = 32770, sell = 15000 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/oiriz.lua b/data-otservbr-global/npc/oiriz.lua index 3a5d3a6b411..4b731c015a2 100644 --- a/data-otservbr-global/npc/oiriz.lua +++ b/data-otservbr-global/npc/oiriz.lua @@ -68,7 +68,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/rabaz.lua b/data-otservbr-global/npc/rabaz.lua index 3e47da6a5ca..e532e7def66 100644 --- a/data-otservbr-global/npc/rabaz.lua +++ b/data-otservbr-global/npc/rabaz.lua @@ -82,6 +82,20 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/rachel.lua b/data-otservbr-global/npc/rachel.lua index 3206c99864a..057787692c9 100644 --- a/data-otservbr-global/npc/rachel.lua +++ b/data-otservbr-global/npc/rachel.lua @@ -71,6 +71,23 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["valuables"] = { + { itemName = "talon", clientId = 3034, sell = 320 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/romir.lua b/data-otservbr-global/npc/romir.lua index 11ea038d266..09ab62ab1a4 100644 --- a/data-otservbr-global/npc/romir.lua +++ b/data-otservbr-global/npc/romir.lua @@ -82,6 +82,20 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/shiriel.lua b/data-otservbr-global/npc/shiriel.lua index 546bb26447b..fd982f345b9 100644 --- a/data-otservbr-global/npc/shiriel.lua +++ b/data-otservbr-global/npc/shiriel.lua @@ -70,6 +70,20 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/sigurd.lua b/data-otservbr-global/npc/sigurd.lua index cca63a33e3e..e4d1b585307 100644 --- a/data-otservbr-global/npc/sigurd.lua +++ b/data-otservbr-global/npc/sigurd.lua @@ -72,6 +72,20 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/sundara.lua b/data-otservbr-global/npc/sundara.lua index c1364240fa9..95ff206f2ad 100644 --- a/data-otservbr-global/npc/sundara.lua +++ b/data-otservbr-global/npc/sundara.lua @@ -101,6 +101,17 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/tandros.lua b/data-otservbr-global/npc/tandros.lua index e25ba65f2a3..ae647b26127 100644 --- a/data-otservbr-global/npc/tandros.lua +++ b/data-otservbr-global/npc/tandros.lua @@ -88,6 +88,20 @@ local itemsTable = { { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/tesha.lua b/data-otservbr-global/npc/tesha.lua index 95e31f97cb7..6a3c4b9fadb 100644 --- a/data-otservbr-global/npc/tesha.lua +++ b/data-otservbr-global/npc/tesha.lua @@ -98,7 +98,7 @@ npcConfig.shop = { { itemName = "diamond", clientId = 32770, sell = 15000 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/tezila.lua b/data-otservbr-global/npc/tezila.lua index dab92c807f5..fe667133ad7 100644 --- a/data-otservbr-global/npc/tezila.lua +++ b/data-otservbr-global/npc/tezila.lua @@ -67,7 +67,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/topsy.lua b/data-otservbr-global/npc/topsy.lua index 395fd23cbeb..66ea6f27e6a 100644 --- a/data-otservbr-global/npc/topsy.lua +++ b/data-otservbr-global/npc/topsy.lua @@ -78,6 +78,20 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/valindara.lua b/data-otservbr-global/npc/valindara.lua index 69655358dfe..cf9506fcdd5 100644 --- a/data-otservbr-global/npc/valindara.lua +++ b/data-otservbr-global/npc/valindara.lua @@ -111,7 +111,7 @@ npcConfig.shop = { { itemName = "fire wall rune", clientId = 3190, buy = 61 }, { itemName = "fireball rune", clientId = 3189, buy = 30 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/npc/xodet.lua b/data-otservbr-global/npc/xodet.lua index 2d8832bd964..f687b491e89 100644 --- a/data-otservbr-global/npc/xodet.lua +++ b/data-otservbr-global/npc/xodet.lua @@ -72,6 +72,20 @@ local itemsTable = { { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, { itemName = "wand of vortex", clientId = 3074, buy = 500 }, }, + ["exercise weapons"] = { + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, count = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, count = 1800 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, count = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, count = 500 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, count = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, count = 14400 }, + }, + ["others"] = { + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["shields"] = { + { itemName = "spellbook", clientId = 3059, buy = 150 }, + }, } npcConfig.shop = {} diff --git a/data-otservbr-global/npc/yasir.lua b/data-otservbr-global/npc/yasir.lua index d576b611e53..9c5cf3dbf69 100644 --- a/data-otservbr-global/npc/yasir.lua +++ b/data-otservbr-global/npc/yasir.lua @@ -60,6 +60,7 @@ npcConfig.shop = { { itemName = "ape fur", clientId = 5883, sell = 120 }, { itemName = "apron", clientId = 33933, sell = 1300 }, { itemName = "badger fur", clientId = 903, sell = 15 }, + { itemName = "bakragore's amalgamation", clientId = 43968, sell = 2000000 }, { itemName = "bamboo stick", clientId = 11445, sell = 30 }, { itemName = "banana sash", clientId = 11511, sell = 55 }, { itemName = "basalt fetish", clientId = 17856, sell = 210 }, @@ -75,6 +76,7 @@ npcConfig.shop = { { itemName = "black hood", clientId = 9645, sell = 190 }, { itemName = "black wool", clientId = 11448, sell = 300 }, { itemName = "blazing bone", clientId = 16131, sell = 610 }, + { itemName = "bloated maggot", clientId = 43856, sell = 5200 }, { itemName = "blood preservation", clientId = 11449, sell = 320 }, { itemName = "blood tincture in a vial", clientId = 18928, sell = 360 }, { itemName = "bloody dwarven beard", clientId = 17827, sell = 110 }, @@ -173,7 +175,11 @@ npcConfig.shop = { { itemName = "dandelion seeds", clientId = 25695, sell = 200 }, { itemName = "dangerous proto matter", clientId = 23515, sell = 300 }, { itemName = "dark bell", clientId = 32596, sell = 310000 }, + { itemName = "dark obsidian splinter", clientId = 43850, sell = 4400 }, { itemName = "dark rosary", clientId = 10303, sell = 48 }, + { itemName = "darklight core", clientId = 43853, sell = 4100 }, + { itemName = "darklight figurine", clientId = 43961, sell = 3400000 }, + { itemName = "darklight matter", clientId = 43851, sell = 5500 }, { itemName = "dead weight", clientId = 20202, sell = 450 }, { itemName = "deepling breaktime snack", clientId = 14011, sell = 90 }, { itemName = "deepling claw", clientId = 14044, sell = 430 }, @@ -229,6 +235,7 @@ npcConfig.shop = { { itemName = "falcon crest", clientId = 28823, sell = 650 }, { itemName = "fern", clientId = 3737, sell = 20 }, { itemName = "fiery heart", clientId = 9636, sell = 375 }, + { itemName = "fiery tear", clientId = 39040, sell = 1070000 }, { itemName = "fig leaf", clientId = 25742, sell = 200 }, { itemName = "figurine of cruelty", clientId = 34019, sell = 3100000 }, { itemName = "figurine of greed", clientId = 34021, sell = 2900000 }, @@ -480,6 +487,8 @@ npcConfig.shop = { { itemName = "rorc feather", clientId = 18993, sell = 70 }, { itemName = "rotten heart", clientId = 31589, sell = 74000 }, { itemName = "rotten piece of cloth", clientId = 10291, sell = 30 }, + { itemName = "rotten roots", clientId = 43849, sell = 3800 }, + { itemName = "rotten vermin ichor", clientId = 43847, sell = 4500 }, { itemName = "sabretooth", clientId = 10311, sell = 400 }, { itemName = "sabretooth fur", clientId = 39378, sell = 2500 }, { itemName = "safety pin", clientId = 11493, sell = 120 }, @@ -636,6 +645,7 @@ npcConfig.shop = { { itemName = "wolf paw", clientId = 5897, sell = 70 }, { itemName = "wood", clientId = 5901, sell = 5 }, { itemName = "wool", clientId = 10319, sell = 15 }, + { itemName = "worm sponge", clientId = 43848, sell = 4200 }, { itemName = "writhing brain", clientId = 32600, sell = 370000 }, { itemName = "writhing heart", clientId = 32599, sell = 185000 }, { itemName = "wyrm scale", clientId = 9665, sell = 400 }, diff --git a/data-otservbr-global/npc/yonan.lua b/data-otservbr-global/npc/yonan.lua index 44dbb8dd83c..69bddee5cb3 100644 --- a/data-otservbr-global/npc/yonan.lua +++ b/data-otservbr-global/npc/yonan.lua @@ -39,7 +39,7 @@ npcConfig.shop = { { itemName = "cyan crystal fragment", clientId = 16125, sell = 800 }, { itemName = "dragon figurine", clientId = 30053, sell = 45000 }, { itemName = "gemmed figurine", clientId = 24392, sell = 3500 }, - { itemName = "giant amethyst", clientId = 30061, sell = 60000 }, + { itemName = "giant amethyst", clientId = 32622, sell = 60000 }, { itemName = "giant emerald", clientId = 30060, sell = 90000 }, { itemName = "giant ruby", clientId = 30059, sell = 70000 }, { itemName = "giant sapphire", clientId = 30061, sell = 50000 }, diff --git a/data-otservbr-global/world/otservbr-monster.xml b/data-otservbr-global/world/otservbr-monster.xml index d3bbc69e858..974c2ea6809 100644 --- a/data-otservbr-global/world/otservbr-monster.xml +++ b/data-otservbr-global/world/otservbr-monster.xml @@ -4076,7 +4076,6 @@ - @@ -4122,9 +4121,6 @@ - - - @@ -6928,19 +6924,13 @@ - - - - - - @@ -6953,9 +6943,6 @@ - - - @@ -6963,7 +6950,6 @@ - @@ -6985,15 +6971,11 @@ - - - - @@ -7009,9 +6991,6 @@ - - - @@ -63284,9 +63263,6 @@ - - - @@ -63491,9 +63467,6 @@ - - - @@ -96125,15 +96098,15 @@ + + + - - - @@ -96718,6 +96691,9 @@ + + + @@ -96725,9 +96701,6 @@ - - - @@ -118889,12 +118862,12 @@ - - - + + + diff --git a/data/items/items.xml b/data/items/items.xml index 45cde62bd9d..e7e73d9753b 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -64466,8 +64466,8 @@ hands of its owner. Granted by TibiaRoyal.com"/> + - @@ -74873,11 +74873,14 @@ Granted by TibiaGoals.com"/> - + + + + @@ -74994,6 +74997,15 @@ Granted by TibiaGoals.com"/> + + + + + + + + +