*Cleanup, fix many cases of unoptimized loops, potential crashes, excessively large data types, unnecessary or wrong casts, non-standardized function calls, and so on..
*Proper Maexxna Web Spray locations (old locations sent players flying into the air) --HG-- branch : trunk
This commit is contained in:
+52
-54
@@ -29,14 +29,14 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2)
|
||||
{
|
||||
return (rand()%2) ? v1 : v2;
|
||||
return (urand(0,1)) ? v1 : v2;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3)
|
||||
{
|
||||
switch(rand()%3)
|
||||
switch (urand(0,2))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -49,7 +49,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4)
|
||||
{
|
||||
switch(rand()%4)
|
||||
switch (urand(0,3))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -63,7 +63,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5)
|
||||
{
|
||||
switch(rand()%5)
|
||||
switch (urand(0,4))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -78,7 +78,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6)
|
||||
{
|
||||
switch(rand()%6)
|
||||
switch (urand(0,5))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -94,7 +94,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7)
|
||||
{
|
||||
switch(rand()%7)
|
||||
switch (urand(0,6))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -111,7 +111,7 @@ template<class T>
|
||||
inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8)
|
||||
{
|
||||
switch(rand()%8)
|
||||
switch (urand(0,7))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -130,7 +130,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9)
|
||||
{
|
||||
switch(rand()%9)
|
||||
switch (urand(0,8))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -150,7 +150,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10)
|
||||
{
|
||||
switch(rand()%10)
|
||||
switch (urand(0,9))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -171,7 +171,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11)
|
||||
{
|
||||
switch(rand()%11)
|
||||
switch (urand(0,10))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -193,7 +193,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11, const T& v12)
|
||||
{
|
||||
switch(rand()%12)
|
||||
switch (urand(0,11))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -216,7 +216,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13)
|
||||
{
|
||||
switch(rand()%13)
|
||||
switch (urand(0,12))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -240,7 +240,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14)
|
||||
{
|
||||
switch(rand()%14)
|
||||
switch (urand(0,13))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -265,7 +265,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15)
|
||||
{
|
||||
switch(rand()%15)
|
||||
switch (urand(0,14))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -291,7 +291,7 @@ inline
|
||||
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
|
||||
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16)
|
||||
{
|
||||
switch(rand()%16)
|
||||
switch (urand(0,15))
|
||||
{
|
||||
default:
|
||||
case 0: return v1;
|
||||
@@ -328,19 +328,19 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
void SetPhase(uint32 phase)
|
||||
{
|
||||
if(phase && phase < 9)
|
||||
if (phase && phase < 9)
|
||||
m_phase = (1 << (phase + 24));
|
||||
}
|
||||
|
||||
void ScheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
|
||||
{
|
||||
time += m_time;
|
||||
if(gcd && gcd < 9)
|
||||
if (gcd && gcd < 9)
|
||||
eventId |= (1 << (gcd + 16));
|
||||
if(phase && phase < 9)
|
||||
if (phase && phase < 9)
|
||||
eventId |= (1 << (phase + 24));
|
||||
iterator itr = find(time);
|
||||
while(itr != end())
|
||||
while (itr != end())
|
||||
{
|
||||
++time;
|
||||
itr = find(time);
|
||||
@@ -356,13 +356,13 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
void RepeatEvent(uint32 time)
|
||||
{
|
||||
if(empty())
|
||||
if (empty())
|
||||
return;
|
||||
uint32 eventId = begin()->second;
|
||||
erase(begin());
|
||||
time += m_time;
|
||||
iterator itr = find(time);
|
||||
while(itr != end())
|
||||
while (itr != end())
|
||||
{
|
||||
++time;
|
||||
itr = find(time);
|
||||
@@ -377,11 +377,11 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
uint32 ExecuteEvent()
|
||||
{
|
||||
while(!empty())
|
||||
while (!empty())
|
||||
{
|
||||
if(begin()->first > m_time)
|
||||
if (begin()->first > m_time)
|
||||
return 0;
|
||||
else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
|
||||
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
|
||||
erase(begin());
|
||||
else
|
||||
{
|
||||
@@ -395,16 +395,14 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
uint32 GetEvent()
|
||||
{
|
||||
while(!empty())
|
||||
while (!empty())
|
||||
{
|
||||
if(begin()->first > m_time)
|
||||
if (begin()->first > m_time)
|
||||
return 0;
|
||||
else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
|
||||
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
|
||||
erase(begin());
|
||||
else
|
||||
{
|
||||
return (begin()->second & 0x0000FFFF);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -413,11 +411,11 @@ class EventMap : private std::map<uint32, uint32>
|
||||
{
|
||||
time += m_time;
|
||||
gcd = (1 << (gcd + 16));
|
||||
for (iterator itr = begin(); itr != end(); )
|
||||
for (iterator itr = begin(); itr != end();)
|
||||
{
|
||||
if(itr->first >= time)
|
||||
if (itr->first >= time)
|
||||
break;
|
||||
if(itr->second & gcd)
|
||||
if (itr->second & gcd)
|
||||
{
|
||||
ScheduleEvent(time, itr->second);
|
||||
erase(itr++);
|
||||
@@ -429,9 +427,9 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
void CancelEvent(uint32 eventId)
|
||||
{
|
||||
for (iterator itr = begin(); itr != end(); )
|
||||
for (iterator itr = begin(); itr != end();)
|
||||
{
|
||||
if(eventId == (itr->second & 0x0000FFFF))
|
||||
if (eventId == (itr->second & 0x0000FFFF))
|
||||
erase(itr++);
|
||||
else
|
||||
++itr;
|
||||
@@ -440,9 +438,9 @@ class EventMap : private std::map<uint32, uint32>
|
||||
|
||||
void CancelEventsByGCD(uint32 gcd)
|
||||
{
|
||||
for (iterator itr = begin(); itr != end(); )
|
||||
for (iterator itr = begin(); itr != end();)
|
||||
{
|
||||
if(itr->second & gcd)
|
||||
if (itr->second & gcd)
|
||||
erase(itr++);
|
||||
else
|
||||
++itr;
|
||||
@@ -484,7 +482,7 @@ TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i);
|
||||
|
||||
inline void CreatureAI::SetGazeOn(Unit *target)
|
||||
{
|
||||
if(me->canAttack(target))
|
||||
if (me->canAttack(target))
|
||||
{
|
||||
AttackStart(target);
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
@@ -493,34 +491,34 @@ inline void CreatureAI::SetGazeOn(Unit *target)
|
||||
|
||||
inline bool CreatureAI::UpdateVictimWithGaze()
|
||||
{
|
||||
if(!me->isInCombat())
|
||||
if (!me->isInCombat())
|
||||
return false;
|
||||
|
||||
if(me->HasReactState(REACT_PASSIVE))
|
||||
if (me->HasReactState(REACT_PASSIVE))
|
||||
{
|
||||
if(me->getVictim())
|
||||
if (me->getVictim())
|
||||
return true;
|
||||
else
|
||||
me->SetReactState(REACT_AGGRESSIVE);
|
||||
}
|
||||
|
||||
if(Unit *victim = me->SelectVictim())
|
||||
if (Unit *victim = me->SelectVictim())
|
||||
AttackStart(victim);
|
||||
return me->getVictim();
|
||||
}
|
||||
|
||||
inline bool CreatureAI::UpdateCombatState()
|
||||
{
|
||||
if(!me->isInCombat())
|
||||
if (!me->isInCombat())
|
||||
return false;
|
||||
|
||||
if(!me->HasReactState(REACT_PASSIVE))
|
||||
if (!me->HasReactState(REACT_PASSIVE))
|
||||
{
|
||||
if(Unit *victim = me->SelectVictim())
|
||||
if (Unit *victim = me->SelectVictim())
|
||||
AttackStart(victim);
|
||||
return me->getVictim();
|
||||
}
|
||||
else if(me->getThreatManager().isThreatListEmpty())
|
||||
else if (me->getThreatManager().isThreatListEmpty())
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return false;
|
||||
@@ -531,16 +529,16 @@ inline bool CreatureAI::UpdateCombatState()
|
||||
|
||||
inline bool CreatureAI::UpdateVictim()
|
||||
{
|
||||
if(!me->isInCombat())
|
||||
if (!me->isInCombat())
|
||||
return false;
|
||||
|
||||
if(!me->HasReactState(REACT_PASSIVE))
|
||||
if (!me->HasReactState(REACT_PASSIVE))
|
||||
{
|
||||
if(Unit *victim = me->SelectVictim())
|
||||
AttackStart(victim);
|
||||
return me->getVictim();
|
||||
}
|
||||
else if(me->getThreatManager().isThreatListEmpty())
|
||||
else if (me->getThreatManager().isThreatListEmpty())
|
||||
{
|
||||
EnterEvadeMode();
|
||||
return false;
|
||||
@@ -552,9 +550,9 @@ inline bool CreatureAI::UpdateVictim()
|
||||
/*
|
||||
inline bool CreatureAI::UpdateVictim()
|
||||
{
|
||||
if(!me->isInCombat())
|
||||
if (!me->isInCombat())
|
||||
return false;
|
||||
if(Unit *victim = me->SelectVictim())
|
||||
if (Unit *victim = me->SelectVictim())
|
||||
AttackStart(victim);
|
||||
return me->getVictim();
|
||||
}
|
||||
@@ -562,7 +560,7 @@ inline bool CreatureAI::UpdateVictim()
|
||||
|
||||
inline bool CreatureAI::_EnterEvadeMode()
|
||||
{
|
||||
if(!me->isAlive())
|
||||
if (!me->isAlive())
|
||||
return false;
|
||||
|
||||
// sometimes bosses stuck in combat?
|
||||
@@ -573,7 +571,7 @@ inline bool CreatureAI::_EnterEvadeMode()
|
||||
me->SetLootRecipient(NULL);
|
||||
me->ResetPlayerDamageReq();
|
||||
|
||||
if(me->IsInEvadeMode())
|
||||
if (me->IsInEvadeMode())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -581,7 +579,7 @@ inline bool CreatureAI::_EnterEvadeMode()
|
||||
|
||||
inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
|
||||
{
|
||||
if(!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
|
||||
if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
|
||||
return;
|
||||
|
||||
me->CastSpell(victim, spellId, triggered);
|
||||
@@ -594,7 +592,7 @@ inline void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
|
||||
|
||||
inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
|
||||
{
|
||||
if(!triggered && me->hasUnitState(UNIT_STAT_CASTING))
|
||||
if (!triggered && me->hasUnitState(UNIT_STAT_CASTING))
|
||||
return;
|
||||
|
||||
me->CastSpell((Unit*)NULL, spellId, triggered);
|
||||
|
||||
Reference in New Issue
Block a user