summaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands/PlayerCommand.cpp
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.com>2021-11-22 17:24:39 +0700
committerGitHub <noreply@github.com>2021-11-22 17:24:39 +0700
commitf62664c9874bda6a49c67872c2e951eeabff56ce (patch)
tree4f8853c099aedd5d7be4aa1731890fd19e4b84e0 /src/server/scripts/Commands/PlayerCommand.cpp
parent699d4835df24976b8d58e83fda7749eb68e706c3 (diff)
refactor(Core/Misc): headers cleanup (#9259)
Diffstat (limited to 'src/server/scripts/Commands/PlayerCommand.cpp')
-rw-r--r--src/server/scripts/Commands/PlayerCommand.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/server/scripts/Commands/PlayerCommand.cpp b/src/server/scripts/Commands/PlayerCommand.cpp
index d842f92810..4e14530085 100644
--- a/src/server/scripts/Commands/PlayerCommand.cpp
+++ b/src/server/scripts/Commands/PlayerCommand.cpp
@@ -15,9 +15,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "SpellInfo.h"
#include "PlayerCommand.h"
#include "Language.h"
+#include "Player.h"
+#include "SpellInfo.h"
+#include "SpellMgr.h"
bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player* targetPlayer, SpellInfo const* spell, Optional<EXACT_SEQUENCE("all")> allRanks)
{
@@ -31,23 +33,34 @@ bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player*
if (!allRanks && targetPlayer->HasSpell(spell->Id))
{
if (targetPlayer == handler->GetPlayer())
+ {
handler->SendSysMessage(LANG_YOU_KNOWN_SPELL);
+ }
else
+ {
handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL, handler->GetNameLink(targetPlayer).c_str());
+ }
+
handler->SetSentErrorMessage(true);
return false;
}
targetPlayer->learnSpell(spell->Id, false);
+
if (allRanks)
{
uint32 spellId = spell->Id;
+
while ((spellId = sSpellMgr->GetNextSpellInChain(spellId)))
+ {
targetPlayer->learnSpell(spellId, false);
+ }
}
if (GetTalentSpellCost(spell->GetFirstRankSpell()->Id))
+ {
targetPlayer->SendTalentsInfoData(false);
+ }
return true;
}
@@ -55,16 +68,25 @@ bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player*
bool Acore::PlayerCommand::HandleUnlearnSpellCommand(ChatHandler* handler, Player* target, SpellInfo const* spell, Optional<EXACT_SEQUENCE("all")> allRanks)
{
uint32 spellId = spell->Id;
+
if (allRanks)
- spellId = sSpellMgr->GetFirstSpellInChain (spellId);
+ {
+ spellId = sSpellMgr->GetFirstSpellInChain(spellId);
+ }
if (target->HasSpell(spellId))
+ {
target->removeSpell(spellId, SPEC_MASK_ALL, false);
+ }
else
+ {
handler->SendSysMessage(LANG_FORGET_SPELL);
+ }
if (GetTalentSpellCost(spellId))
+ {
target->SendTalentsInfoData(false);
+ }
return true;
}