From 2b3cf3d48003f55ced1ebbc1a2c237451e9063bb Mon Sep 17 00:00:00 2001 From: treeston Date: Tue, 31 May 2016 22:18:26 +0200 Subject: AI/PlayerAI: Code style cleanup. (cherry picked from commit e3aa19281f4d1e2437a5654715f75ae919bd4027) Build fix for horrendous, outdated, non-standards-compliant compilers. Such as the one in VS 2013. I hate VS 2013. Closes #17260. (cherry picked from commit 321d35417d39bd2531c63c63cd432cf86d84453f) --- src/server/game/AI/PlayerAI/PlayerAI.cpp | 15 ++++++++++++--- src/server/game/AI/PlayerAI/PlayerAI.h | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/AI/PlayerAI/PlayerAI.cpp b/src/server/game/AI/PlayerAI/PlayerAI.cpp index 2f84ad32f2c..a143dd6056a 100644 --- a/src/server/game/AI/PlayerAI/PlayerAI.cpp +++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp @@ -451,13 +451,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 {}; diff --git a/src/server/game/AI/PlayerAI/PlayerAI.h b/src/server/game/AI/PlayerAI/PlayerAI.h index 2d7adc6c551..b06f81f76c9 100644 --- a/src/server/game/AI/PlayerAI/PlayerAI.h +++ b/src/server/game/AI/PlayerAI/PlayerAI.h @@ -40,7 +40,8 @@ class TC_GAME_API PlayerAI : public UnitAI protected: struct TargetedSpell : public std::pair { - using std::pair::pair; + TargetedSpell() : pair() { } + TargetedSpell(Spell* first, Unit* second) : pair(first, second) { } explicit operator bool() { return !!first; } }; typedef std::pair PossibleSpell; -- cgit v1.2.3