diff options
Diffstat (limited to 'src/server/scripts/Commands/PlayerCommand.cpp')
-rw-r--r-- | src/server/scripts/Commands/PlayerCommand.cpp | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/src/server/scripts/Commands/PlayerCommand.cpp b/src/server/scripts/Commands/PlayerCommand.cpp index 3cf4aa2c40..d842f92810 100644 --- a/src/server/scripts/Commands/PlayerCommand.cpp +++ b/src/server/scripts/Commands/PlayerCommand.cpp @@ -15,46 +15,22 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "SpellInfo.h" #include "PlayerCommand.h" #include "Language.h" -bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player* targetPlayer, uint32 spell, char const* all) +bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player* targetPlayer, SpellInfo const* spell, Optional<EXACT_SEQUENCE("all")> allRanks) { - if (!spell) - return false; - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell); - if (!spellInfo) + if (!SpellMgr::IsSpellValid(spell)) { - handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND); + handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id); handler->SetSentErrorMessage(true); return false; } - if (!SpellMgr::IsSpellValid(spellInfo)) + if (!allRanks && targetPlayer->HasSpell(spell->Id)) { - handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); - handler->SetSentErrorMessage(true); - return false; - } - - if (handler->GetSession()) - { - SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spell); - uint32 spellDifficultyId = sSpellMgr->GetSpellDifficultyId(spell); - if (handler->GetSession() && handler->GetSession()->GetSecurity() < SEC_ADMINISTRATOR && (bounds.first != bounds.second || spellDifficultyId)) - { - handler->PSendSysMessage("Spell %u cannot be learnt using a command!", spell); - handler->SetSentErrorMessage(true); - return false; - } - } - - bool allRanks = all ? (strncmp(all, "all", 3) == 0) : false; - - if (!allRanks && targetPlayer->HasSpell(spell)) - { - if (handler->GetSession() && targetPlayer == handler->GetSession()->GetPlayer()) + if (targetPlayer == handler->GetPlayer()) handler->SendSysMessage(LANG_YOU_KNOWN_SPELL); else handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL, handler->GetNameLink(targetPlayer).c_str()); @@ -62,25 +38,23 @@ bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player* return false; } + targetPlayer->learnSpell(spell->Id, false); if (allRanks) - targetPlayer->learnSpellHighRank(spell); - else - targetPlayer->learnSpell(spell); + { + uint32 spellId = spell->Id; + while ((spellId = sSpellMgr->GetNextSpellInChain(spellId))) + targetPlayer->learnSpell(spellId, false); + } - uint32 firstSpell = sSpellMgr->GetFirstSpellInChain(spell); - if (GetTalentSpellCost(firstSpell)) + if (GetTalentSpellCost(spell->GetFirstRankSpell()->Id)) targetPlayer->SendTalentsInfoData(false); return true; } -bool Acore::PlayerCommand::HandleUnlearnSpellCommand(ChatHandler* handler, Player* target, uint32 spellId, char const* allStr) +bool Acore::PlayerCommand::HandleUnlearnSpellCommand(ChatHandler* handler, Player* target, SpellInfo const* spell, Optional<EXACT_SEQUENCE("all")> allRanks) { - if (!spellId) - return false; - - bool allRanks = allStr ? (strncmp(allStr, "all", 3) == 0) : false; - + uint32 spellId = spell->Id; if (allRanks) spellId = sSpellMgr->GetFirstSpellInChain (spellId); |