From afb1b0d7f0533df37d98728abd61f3e48d3ba988 Mon Sep 17 00:00:00 2001 From: Pedro Cruz Date: Tue, 7 May 2024 15:27:07 -0300 Subject: [PATCH 1/4] fix: quiver bugs (#2609) --- src/items/item.cpp | 33 ++++++++++++-------- src/server/network/protocol/protocolgame.cpp | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/items/item.cpp b/src/items/item.cpp index eea07a4e5dd..81d24a790e7 100644 --- a/src/items/item.cpp +++ b/src/items/item.cpp @@ -1147,6 +1147,10 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr descriptions.emplace_back("Description", it.description); } + if (item->getContainer()) { + descriptions.emplace_back("Capacity", std::to_string(item->getContainer()->capacity())); + } + if (it.showCharges) { auto charges = item->getAttribute(ItemAttribute_t::CHARGES); if (charges != 0) { @@ -1403,10 +1407,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr descriptions.emplace_back("Tier", std::to_string(item->getTier())); } - if (item->getContainer()) { - descriptions.emplace_back("Capacity", std::to_string(item->getContainer()->capacity())); - } - std::string slotName; if (item->getImbuementSlot() > 0) { for (uint8_t i = 0; i < item->getImbuementSlot(); ++i) { @@ -1562,6 +1562,10 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr descriptions.emplace_back("Description", it.description); } + if (it.isContainer()) { + descriptions.emplace_back("Capacity", std::to_string(it.maxItems)); + } + int32_t attack = it.attack; if (it.isRanged()) { bool separator = false; @@ -1781,10 +1785,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr item /*= nullptr } } - if (it.isContainer()) { - descriptions.emplace_back("Capacity", std::to_string(it.maxItems)); - } - if (it.imbuementSlot > 0) { descriptions.emplace_back("Imbuement Slots", std::to_string(it.imbuementSlot)); } @@ -2075,13 +2075,18 @@ std::string Item::parseShowDuration(std::shared_ptr item) { std::string Item::parseShowAttributesDescription(std::shared_ptr item, const uint16_t itemId) { std::ostringstream itemDescription; const ItemType &itemType = Item::items[itemId]; + if (itemType.armor != 0 || (item && item->getArmor() != 0) || itemType.showAttributes) { - bool begin = true; + bool begin = itemType.isQuiver() ? false : true; int32_t armor = (item ? item->getArmor() : itemType.armor); if (armor != 0) { - itemDescription << " (Arm:" << armor; - begin = false; + if (begin) { + itemDescription << " (Arm:" << armor; + begin = false; + } else { + itemDescription << ", Arm:" << armor; + } } if (itemType.abilities) { @@ -2167,7 +2172,7 @@ std::string Item::parseShowAttributesDescription(std::shared_ptr item, con itemDescription << ", "; } - itemDescription << "Perfect Shot " << std::showpos << itemType.abilities->perfectShotDamage << std::noshowpos << " at range " << unsigned(itemType.abilities->perfectShotRange); + itemDescription << "perfect shot " << std::showpos << itemType.abilities->perfectShotDamage << std::noshowpos << " at range " << unsigned(itemType.abilities->perfectShotRange); } if (itemType.abilities->reflectFlat[0] != 0) { @@ -2869,8 +2874,10 @@ std::string Item::getDescription(const ItemType &it, int32_t lookDistance, std:: } } - if (volume != 0) { + if (volume != 0 && !it.isQuiver()) { s << " (Vol:" << volume << ')'; + } else if (volume != 0 && it.isQuiver()) { + s << " (Vol:" << volume; } } else { bool found = true; diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index db850af5ecc..3b133d68893 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5643,7 +5643,7 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { if (it.abilities->perfectShotDamage > 0) { string.clear(); - string << std::showpos << it.abilities->perfectShotDamage << std::noshowpos << " at " << it.abilities->perfectShotRange << "%"; + string << std::showpos << it.abilities->perfectShotDamage << std::noshowpos << " at range " << unsigned(it.abilities->perfectShotRange); msg.addString(string.str(), "ProtocolGame::sendMarketDetail - string.str()"); } else { msg.add(0x00); From 231b3c8aed670f3030c99c2d0b3d2fb884c1a43a Mon Sep 17 00:00:00 2001 From: Karin Date: Tue, 7 May 2024 16:08:01 -0300 Subject: [PATCH 2/4] fix: convert 16 to 32 int mana shield (#2603) --- data-otservbr-global/migrations/43.lua | 2 +- data-otservbr-global/migrations/44.lua | 10 +++++++++- data-otservbr-global/migrations/45.lua | 3 +++ schema.sql | 6 +++--- src/creatures/combat/condition.cpp | 4 ++-- src/creatures/combat/condition.hpp | 2 +- src/creatures/creature.hpp | 8 ++++---- src/game/game.cpp | 2 +- src/io/functions/iologindata_load_player.cpp | 4 ++-- 9 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 data-otservbr-global/migrations/45.lua diff --git a/data-otservbr-global/migrations/43.lua b/data-otservbr-global/migrations/43.lua index 1464703c96e..6d3492a815a 100644 --- a/data-otservbr-global/migrations/43.lua +++ b/data-otservbr-global/migrations/43.lua @@ -1,5 +1,5 @@ function onUpdateDatabase() - logger.info("Updating database to version 43 (feat frags_limit, payment and duration_days in guild wars)") + logger.info("Updating database to version 44 (feat frags_limit, payment and duration_days in guild wars)") db.query([[ ALTER TABLE `guild_wars` diff --git a/data-otservbr-global/migrations/44.lua b/data-otservbr-global/migrations/44.lua index 86a6d8ffec1..c551fc79aeb 100644 --- a/data-otservbr-global/migrations/44.lua +++ b/data-otservbr-global/migrations/44.lua @@ -1,3 +1,11 @@ function onUpdateDatabase() - return false -- true = There are others migrations file | false = this is the last migration file + logger.info("Updating database to version 45 (fix: mana shield column size for more than 65k)") + + db.query([[ + ALTER TABLE `players` + MODIFY COLUMN `manashield` INT UNSIGNED NOT NULL DEFAULT '0', + MODIFY COLUMN `max_manashield` INT UNSIGNED NOT NULL DEFAULT '0'; + ]]) + + return true end diff --git a/data-otservbr-global/migrations/45.lua b/data-otservbr-global/migrations/45.lua new file mode 100644 index 00000000000..86a6d8ffec1 --- /dev/null +++ b/data-otservbr-global/migrations/45.lua @@ -0,0 +1,3 @@ +function onUpdateDatabase() + return false -- true = There are others migrations file | false = this is the last migration file +end diff --git a/schema.sql b/schema.sql index 58e6ea216ce..624f434509e 100644 --- a/schema.sql +++ b/schema.sql @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS `server_config` ( CONSTRAINT `server_config_pk` PRIMARY KEY (`config`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '44'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); +INSERT INTO `server_config` (`config`, `value`) VALUES ('db_version', '45'), ('motd_hash', ''), ('motd_num', '0'), ('players_record', '0'); -- Table structure `accounts` CREATE TABLE IF NOT EXISTS `accounts` ( @@ -127,8 +127,8 @@ CREATE TABLE IF NOT EXISTS `players` ( `skill_lifeleech_amount` bigint(20) UNSIGNED NOT NULL DEFAULT '0', `skill_manaleech_chance` bigint(20) UNSIGNED NOT NULL DEFAULT '0', `skill_manaleech_amount` bigint(20) UNSIGNED NOT NULL DEFAULT '0', - `manashield` SMALLINT UNSIGNED NOT NULL DEFAULT '0', - `max_manashield` SMALLINT UNSIGNED NOT NULL DEFAULT '0', + `manashield` INT UNSIGNED NOT NULL DEFAULT '0', + `max_manashield` INT UNSIGNED NOT NULL DEFAULT '0', `xpboost_stamina` smallint(5) UNSIGNED DEFAULT NULL, `xpboost_value` tinyint(4) UNSIGNED DEFAULT NULL, `marriage_status` bigint(20) UNSIGNED NOT NULL DEFAULT '0', diff --git a/src/creatures/combat/condition.cpp b/src/creatures/combat/condition.cpp index 9d0f6962884..56c67700d13 100644 --- a/src/creatures/combat/condition.cpp +++ b/src/creatures/combat/condition.cpp @@ -1308,7 +1308,7 @@ void ConditionManaShield::addCondition(std::shared_ptr creature, const bool ConditionManaShield::unserializeProp(ConditionAttr_t attr, PropStream &propStream) { if (attr == CONDITIONATTR_MANASHIELD) { - return propStream.read(manaShield); + return propStream.read(manaShield); } return Condition::unserializeProp(attr, propStream); } @@ -1317,7 +1317,7 @@ void ConditionManaShield::serialize(PropWriteStream &propWriteStream) { Condition::serialize(propWriteStream); propWriteStream.write(CONDITIONATTR_MANASHIELD); - propWriteStream.write(manaShield); + propWriteStream.write(manaShield); } bool ConditionManaShield::setParam(ConditionParam_t param, int32_t value) { diff --git a/src/creatures/combat/condition.hpp b/src/creatures/combat/condition.hpp index 1cffba99b50..539a8711723 100644 --- a/src/creatures/combat/condition.hpp +++ b/src/creatures/combat/condition.hpp @@ -219,7 +219,7 @@ class ConditionManaShield final : public Condition { bool unserializeProp(ConditionAttr_t attr, PropStream &propStream) override; private: - uint16_t manaShield = 0; + uint32_t manaShield = 0; }; class ConditionSoul final : public ConditionGeneric { diff --git a/src/creatures/creature.hpp b/src/creatures/creature.hpp index 4acbacb570a..2c92032bd65 100644 --- a/src/creatures/creature.hpp +++ b/src/creatures/creature.hpp @@ -209,19 +209,19 @@ class Creature : virtual public Thing, public SharedObject { return mana; } - uint16_t getManaShield() const { + uint32_t getManaShield() const { return manaShield; } - void setManaShield(uint16_t value) { + void setManaShield(uint32_t value) { manaShield = value; } - uint16_t getMaxManaShield() const { + uint32_t getMaxManaShield() const { return maxManaShield; } - void setMaxManaShield(uint16_t value) { + void setMaxManaShield(uint32_t value) { maxManaShield = value; } diff --git a/src/game/game.cpp b/src/game/game.cpp index eeaaabb39f7..18c46668a4f 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7008,7 +7008,7 @@ bool Game::combatChangeHealth(std::shared_ptr attacker, std::shared_pt if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) { int32_t manaDamage = std::min(target->getMana(), healthChange); - uint16_t manaShield = target->getManaShield(); + uint32_t manaShield = target->getManaShield(); if (manaShield > 0) { if (manaShield > manaDamage) { target->setManaShield(manaShield - manaDamage); diff --git a/src/io/functions/iologindata_load_player.cpp b/src/io/functions/iologindata_load_player.cpp index 041cd323e28..2ac2cc863ea 100644 --- a/src/io/functions/iologindata_load_player.cpp +++ b/src/io/functions/iologindata_load_player.cpp @@ -180,8 +180,8 @@ bool IOLoginDataLoad::loadPlayerFirst(std::shared_ptr player, DBResult_p player->setXpBoostPercent(result->getNumber("xpboost_value")); player->setXpBoostTime(result->getNumber("xpboost_stamina")); - player->setManaShield(result->getNumber("manashield")); - player->setMaxManaShield(result->getNumber("max_manashield")); + player->setManaShield(result->getNumber("manashield")); + player->setMaxManaShield(result->getNumber("max_manashield")); return true; } From 62991d4fd3ac86059e271ca3fe72320f778bbcaf Mon Sep 17 00:00:00 2001 From: Karin Date: Wed, 8 May 2024 09:20:57 -0300 Subject: [PATCH 3/4] fix: imbuement elemental damage only to physical damage (#2614) --- src/creatures/combat/combat.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index cf98fcb6a7b..56cca63fe56 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -649,6 +649,10 @@ CombatDamage Combat::applyImbuementElementalDamage(std::shared_ptr attac continue; } + if (damage.primary.type != COMBAT_PHYSICALDAMAGE) { + break; + } + float damagePercent = imbuementInfo.imbuement->elementDamage / 100.0; damage.secondary.type = imbuementInfo.imbuement->combatType; From 10bc46b8fc84b3d6e24c289a8c54b8923779b972 Mon Sep 17 00:00:00 2001 From: Karin Date: Wed, 8 May 2024 09:31:56 -0300 Subject: [PATCH 4/4] fix: sanguine range wand/rod (#2606) --- data/items/items.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/items/items.xml b/data/items/items.xml index 421e981ad02..0858df99219 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -75422,6 +75422,7 @@ Granted by TibiaGoals.com"/> + @@ -75449,6 +75450,7 @@ Granted by TibiaGoals.com"/> + @@ -75492,6 +75494,7 @@ Granted by TibiaGoals.com"/> + @@ -75522,6 +75525,7 @@ Granted by TibiaGoals.com"/> +