From 3d1ed0cf12ec8c060d81fae1d40692616b62355c Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Thu, 5 Sep 2024 21:16:38 -0300 Subject: [PATCH] fix: remove bakragore icons talkaction (#2828) --- data/scripts/talkactions/god/icons_functions.lua | 6 +----- src/creatures/players/player.cpp | 14 ++++++++++++++ src/creatures/players/player.hpp | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/data/scripts/talkactions/god/icons_functions.lua b/data/scripts/talkactions/god/icons_functions.lua index 9f1ee85c0f3..059d7ac6ed9 100644 --- a/data/scripts/talkactions/god/icons_functions.lua +++ b/data/scripts/talkactions/god/icons_functions.lua @@ -78,11 +78,7 @@ function bakragoreIcon.onSay(player, words, param) end if param == "remove" then - for i = 1, 10 do - if player:hasCondition(CONDITION_BAKRAGORE, i) then - player:removeCondition(CONDITION_BAKRAGORE, i) - end - end + player:removeIconBakragore() player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Removed all Bakragore icons.") return true end diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 6d14017330d..a2ac74aac32 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -6216,6 +6216,20 @@ void Player::sendIconBakragore(const IconBakragore icon) { } } +void Player::removeBakragoreIcons() { + for (auto icon : magic_enum::enum_values()) { + if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) { + removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true); + } + } +} + +void Player::removeBakragoreIcon(const IconBakragore icon) { + if (hasCondition(CONDITION_BAKRAGORE, enumToValue(icon))) { + removeCondition(CONDITION_BAKRAGORE, CONDITIONID_DEFAULT, true); + } +} + void Player::sendCyclopediaCharacterAchievements(uint16_t secretsUnlocked, std::vector> achievementsUnlocked) { if (client) { client->sendCyclopediaCharacterAchievements(secretsUnlocked, achievementsUnlocked); diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index b74465a86a1..a6b52c8cf6e 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -1419,6 +1419,8 @@ class Player final : public Creature, public Cylinder, public Bankable { void sendClosePrivate(uint16_t channelId); void sendIcons(); void sendIconBakragore(const IconBakragore icon); + void removeBakragoreIcons(); + void removeBakragoreIcon(const IconBakragore icon); void sendClientCheck() const { if (client) { client->sendClientCheck();