Skip to content

Commit

Permalink
Merge branch 'main' into feature/title-system
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored May 9, 2024
2 parents f0f1cdc + 10bc46b commit 767579e
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 29 deletions.
2 changes: 1 addition & 1 deletion data-otservbr-global/migrations/43.lua
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
10 changes: 9 additions & 1 deletion data-otservbr-global/migrations/44.lua
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions data-otservbr-global/migrations/45.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function onUpdateDatabase()
return false -- true = There are others migrations file | false = this is the last migration file
end
4 changes: 4 additions & 0 deletions data/items/items.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75422,6 +75422,7 @@ Granted by TibiaGoals.com"/>
<attribute key="firemagiclevelpoints" value="1"/>
<attribute key="energymagiclevelpoints" value="1"/>
<attribute key="criticalhitdamage" value="1200"/>
<attribute key="range" value="6"/>
<attribute key="criticalhitchance" value="1000"/>
<attribute key="weight" value="2200"/>
<attribute key="imbuementslot" value="2">
Expand Down Expand Up @@ -75449,6 +75450,7 @@ Granted by TibiaGoals.com"/>
<attribute key="magiclevelpoints" value="5"/>
<attribute key="firemagiclevelpoints" value="1"/>
<attribute key="energymagiclevelpoints" value="1"/>
<attribute key="range" value="6"/>
<attribute key="criticalhitdamage" value="1200"/>
<attribute key="criticalhitchance" value="1000"/>
<attribute key="weight" value="2100"/>
Expand Down Expand Up @@ -75492,6 +75494,7 @@ Granted by TibiaGoals.com"/>
<attribute key="weaponType" value="wand"/>
<attribute key="shootType" value="earth"/>
<attribute key="absorbpercentdeath" value="7"/>
<attribute key="range" value="6"/>
<attribute key="magiclevelpoints" value="5"/>
<attribute key="earthmagiclevelpoints" value="1"/>
<attribute key="icemagiclevelpoints" value="1"/>
Expand Down Expand Up @@ -75522,6 +75525,7 @@ Granted by TibiaGoals.com"/>
<attribute key="absorbpercentdeath" value="7"/>
<attribute key="magiclevelpoints" value="5"/>
<attribute key="earthmagiclevelpoints" value="1"/>
<attribute key="range" value="6"/>
<attribute key="icemagiclevelpoints" value="1"/>
<attribute key="criticalhitdamage" value="500"/>
<attribute key="criticalhitchance" value="1000"/>
Expand Down
6 changes: 3 additions & 3 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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` (
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ CombatDamage Combat::applyImbuementElementalDamage(std::shared_ptr<Player> attac
continue;
}

if (damage.primary.type != COMBAT_PHYSICALDAMAGE) {
break;
}

float damagePercent = imbuementInfo.imbuement->elementDamage / 100.0;

damage.secondary.type = imbuementInfo.imbuement->combatType;
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ void ConditionManaShield::addCondition(std::shared_ptr<Creature> creature, const

bool ConditionManaShield::unserializeProp(ConditionAttr_t attr, PropStream &propStream) {
if (attr == CONDITIONATTR_MANASHIELD) {
return propStream.read<uint16_t>(manaShield);
return propStream.read<uint32_t>(manaShield);
}
return Condition::unserializeProp(attr, propStream);
}
Expand All @@ -1317,7 +1317,7 @@ void ConditionManaShield::serialize(PropWriteStream &propWriteStream) {
Condition::serialize(propWriteStream);

propWriteStream.write<uint8_t>(CONDITIONATTR_MANASHIELD);
propWriteStream.write<uint16_t>(manaShield);
propWriteStream.write<uint32_t>(manaShield);
}

bool ConditionManaShield::setParam(ConditionParam_t param, int32_t value) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/condition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/creatures/creature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7092,7 +7092,7 @@ bool Game::combatChangeHealth(std::shared_ptr<Creature> attacker, std::shared_pt

if (target->hasCondition(CONDITION_MANASHIELD) && damage.primary.type != COMBAT_UNDEFINEDDAMAGE) {
int32_t manaDamage = std::min<int32_t>(target->getMana(), healthChange);
uint16_t manaShield = target->getManaShield();
uint32_t manaShield = target->getManaShield();
if (manaShield > 0) {
if (manaShield > manaDamage) {
target->setManaShield(manaShield - manaDamage);
Expand Down
4 changes: 2 additions & 2 deletions src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ bool IOLoginDataLoad::loadPlayerFirst(std::shared_ptr<Player> player, DBResult_p
player->setXpBoostPercent(result->getNumber<uint16_t>("xpboost_value"));
player->setXpBoostTime(result->getNumber<uint16_t>("xpboost_stamina"));

player->setManaShield(result->getNumber<uint16_t>("manashield"));
player->setMaxManaShield(result->getNumber<uint16_t>("max_manashield"));
player->setManaShield(result->getNumber<uint32_t>("manashield"));
player->setMaxManaShield(result->getNumber<uint32_t>("max_manashield"));
return true;
}

Expand Down
33 changes: 20 additions & 13 deletions src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,10 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> 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<int32_t>(ItemAttribute_t::CHARGES);
if (charges != 0) {
Expand Down Expand Up @@ -1403,10 +1407,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> 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) {
Expand Down Expand Up @@ -1562,6 +1562,10 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> 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;
Expand Down Expand Up @@ -1781,10 +1785,6 @@ Item::getDescriptions(const ItemType &it, std::shared_ptr<Item> 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));
}
Expand Down Expand Up @@ -2075,13 +2075,18 @@ std::string Item::parseShowDuration(std::shared_ptr<Item> item) {
std::string Item::parseShowAttributesDescription(std::shared_ptr<Item> 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) {
Expand Down Expand Up @@ -2167,7 +2172,7 @@ std::string Item::parseShowAttributesDescription(std::shared_ptr<Item> 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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5662,7 +5662,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<uint16_t>(0x00);
Expand Down

0 comments on commit 767579e

Please sign in to comment.