From 0ac8210bec4aa12db191ecdd6de380275ef8e1b0 Mon Sep 17 00:00:00 2001 From: Matt Gomez Date: Mon, 28 Aug 2023 16:16:58 -0600 Subject: [PATCH] Added: https://github.com/opentibiabr/canary/commit/ca0803c986d77c2c821fc6cf63657ebc484da748 --- config.lua.dist | 1 + data/items/items.xml | 6 ++++++ data/libs/hazard_lib.lua | 2 +- src/config/config_definitions.hpp | 1 + src/config/configmanager.cpp | 1 + src/creatures/players/imbuements/imbuements.cpp | 1 - src/creatures/players/player.cpp | 13 +++++++++++-- src/lua/functions/core/game/config_functions.cpp | 1 + src/security/argon.cpp | 1 + vcpkg.json | 2 +- 10 files changed, 24 insertions(+), 5 deletions(-) diff --git a/config.lua.dist b/config.lua.dist index da564ad68..beb0da057 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -234,6 +234,7 @@ saveIntervalTime = 15 -- Imbuement toggleImbuementShrineStorage = false +toggleImbuementNonAggressiveFightOnly = false -- Free quests -- Add quest access to player when logging in diff --git a/data/items/items.xml b/data/items/items.xml index cb9d4aa99..6c60c25fd 100644 --- a/data/items/items.xml +++ b/data/items/items.xml @@ -58873,21 +58873,27 @@ + + + + + + diff --git a/data/libs/hazard_lib.lua b/data/libs/hazard_lib.lua index 24f2159ff..25b09648d 100644 --- a/data/libs/hazard_lib.lua +++ b/data/libs/hazard_lib.lua @@ -29,7 +29,7 @@ function Hazard:getHazardPlayerAndPoints(damageMap) for key, _ in pairs(damageMap) do local player = Player(key) if player then - local playerHazardPoints = self:getPlayerCurrentLevel() + local playerHazardPoints = self:getPlayerCurrentLevel(player) if playerHazardPoints < hazardPoints or hazardPoints == -1 then hazardPlayer = player diff --git a/src/config/config_definitions.hpp b/src/config/config_definitions.hpp index 5168f64a5..f6df1d37b 100644 --- a/src/config/config_definitions.hpp +++ b/src/config/config_definitions.hpp @@ -57,6 +57,7 @@ enum booleanConfig_t { TASK_HUNTING_FREE_THIRD_SLOT, STASH_MOVING, TOGGLE_IMBUEMENT_SHRINE_STORAGE, + TOGGLE_IMBUEMENT_NON_AGGRESSIVE_FIGHT_ONLY, AUTOLOOT, AUTOBANK, RATE_USE_STAGES, diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 6e052a044..5bed1cd17 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -185,6 +185,7 @@ bool ConfigManager::load() { boolean[ONLY_PREMIUM_ACCOUNT] = getGlobalBoolean(L, "onlyPremiumAccount", false); boolean[RATE_USE_STAGES] = getGlobalBoolean(L, "rateUseStages", false); boolean[TOGGLE_IMBUEMENT_SHRINE_STORAGE] = getGlobalBoolean(L, "toggleImbuementShrineStorage", true); + boolean[TOGGLE_IMBUEMENT_NON_AGGRESSIVE_FIGHT_ONLY] = getGlobalBoolean(L, "toggleImbuementNonAggressiveFightOnly", false); boolean[TOGGLE_DOWNLOAD_MAP] = getGlobalBoolean(L, "toggleDownloadMap", false); boolean[USE_ANY_DATAPACK_FOLDER] = getGlobalBoolean(L, "useAnyDatapackFolder", false); diff --git a/src/creatures/players/imbuements/imbuements.cpp b/src/creatures/players/imbuements/imbuements.cpp index 6830f1bf6..664e2bd09 100644 --- a/src/creatures/players/imbuements/imbuements.cpp +++ b/src/creatures/players/imbuements/imbuements.cpp @@ -52,7 +52,6 @@ bool Imbuements::loadFromXml(bool /* reloading */) { pugi::cast(baseNode.attribute("removecost").value()), pugi::cast(baseNode.attribute("duration").value()), pugi::cast(baseNode.attribute("percent").value()) - ); // Category/Group diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 8fd483a0b..ba62b71e0 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -584,6 +584,7 @@ void Player::updateInventoryImbuement() { bool isInProtectionZone = playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE); // Check if the player is in fight mode bool isInFightMode = hasCondition(CONDITION_INFIGHT); + bool nonAggressiveFightOnly = g_configManager().getBoolean(TOGGLE_IMBUEMENT_NON_AGGRESSIVE_FIGHT_ONLY); // Iterate through all items in the player's inventory for (auto item : getAllInventoryItems()) { @@ -605,7 +606,7 @@ void Player::updateInventoryImbuement() { auto parent = item->getParent(); bool isInBackpack = parent && parent->getContainer(); // If the imbuement is aggressive and the player is not in fight mode or is in a protection zone, or the item is in a container, ignore it. - if (categoryImbuement && categoryImbuement->agressive && (isInProtectionZone || !isInFightMode || isInBackpack)) { + if (categoryImbuement && (categoryImbuement->agressive || nonAggressiveFightOnly) && (isInProtectionZone || !isInFightMode || isInBackpack)) { continue; } // If the item is not in the backpack slot and it's not a agressive imbuement, ignore it. @@ -622,9 +623,15 @@ void Player::updateInventoryImbuement() { g_logger().debug("Decaying imbuement {} from item {} of player {}", imbuement->getName(), item->getName(), getName()); // Calculate the new duration of the imbuement, making sure it doesn't go below 0 - uint64_t duration = std::max(0, imbuementInfo.duration - EVENT_IMBUEMENT_INTERVAL / 1000); + uint32_t duration = std::max(0, imbuementInfo.duration - EVENT_IMBUEMENT_INTERVAL / 1000); // Update the imbuement's duration in the item item->decayImbuementTime(slotid, imbuement->getID(), duration); + + if (duration == 0) { + removeItemImbuementStats(imbuement); + updateImbuementTrackerStats(); + continue; + } } } } @@ -2906,6 +2913,8 @@ void Player::addInFightTicks(bool pzlock /*= false*/) { sendIcons(); } + updateImbuementTrackerStats(); + Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_INFIGHT, g_configManager().getNumber(PZ_LOCKED), 0); addCondition(condition); } diff --git a/src/lua/functions/core/game/config_functions.cpp b/src/lua/functions/core/game/config_functions.cpp index 1086914ac..153844dd5 100644 --- a/src/lua/functions/core/game/config_functions.cpp +++ b/src/lua/functions/core/game/config_functions.cpp @@ -169,6 +169,7 @@ void ConfigFunctions::init(lua_State* L) { registerEnumIn(L, "configKeys", SAVE_INTERVAL_TIME); registerEnumIn(L, "configKeys", RATE_USE_STAGES); registerEnumIn(L, "configKeys", TOGGLE_IMBUEMENT_SHRINE_STORAGE); + registerEnumIn(L, "configKeys", TOGGLE_IMBUEMENT_NON_AGGRESSIVE_FIGHT_ONLY); registerEnumIn(L, "configKeys", GLOBAL_SERVER_SAVE_TIME); registerEnumIn(L, "configKeys", DATA_DIRECTORY); registerEnumIn(L, "configKeys", CORE_DIRECTORY); diff --git a/src/security/argon.cpp b/src/security/argon.cpp index 08f6ef7ea..7404ec667 100644 --- a/src/security/argon.cpp +++ b/src/security/argon.cpp @@ -55,6 +55,7 @@ bool Argon2::verifyPassword(const std::string &password, const std::string &phas std::vector computed_hash(hash.size()); if (argon2id_hash_raw(t_cost, m_cost, parallelism, password.c_str(), password.length(), salt.data(), salt.size(), computed_hash.data(), computed_hash.size()) != ARGON2_OK) { g_logger().warn("Error hashing password"); + return false; } // Compare diff --git a/vcpkg.json b/vcpkg.json index 7e13c27bb..be553722c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "otxserver", - "version-string": "1.0.0", + "version-string": "6.2.0", "dependencies": [ "argon2", "asio",