From 34ad561ff5ef9c27aa96d468182f4c4beef7ed85 Mon Sep 17 00:00:00 2001 From: treeston Date: Tue, 31 May 2016 22:18:26 +0200 Subject: [PATCH] AI/PlayerAI: Code style cleanup. --- src/server/game/AI/PlayerAI/PlayerAI.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/server/game/AI/PlayerAI/PlayerAI.cpp b/src/server/game/AI/PlayerAI/PlayerAI.cpp index a046aaea449..fad6f0b46b1 100644 --- a/src/server/game/AI/PlayerAI/PlayerAI.cpp +++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp @@ -575,13 +575,22 @@ PlayerAI::TargetedSpell PlayerAI::VerifySpellCast(uint32 spellId, Unit* target) // Find highest spell rank that we know uint32 knownRank, nextRank; if (me->HasSpell(spellId)) + { // this will save us some lookups if the player has the highest rank (expected case) - nextRank = sSpellMgr->GetNextSpellInChain(knownRank = spellId); + knownRank = spellId; + nextRank = sSpellMgr->GetNextSpellInChain(spellId); + } else - knownRank = 0, nextRank = sSpellMgr->GetFirstSpellInChain(spellId); + { + knownRank = 0; + nextRank = sSpellMgr->GetFirstSpellInChain(spellId); + } while (nextRank && me->HasSpell(nextRank)) - nextRank = sSpellMgr->GetNextSpellInChain(knownRank = nextRank); + { + knownRank = nextRank; + nextRank = sSpellMgr->GetNextSpellInChain(knownRank); + } if (!knownRank) return {};