[10276] Use more appropriate vector container instead of list as container for CreatureEventAI holders

vector container provides less time to access to contained elements
This commit is contained in:
SilverIce 2010-07-27 03:34:27 +03:00
parent e1ff3579c9
commit 8827c72a79
3 changed files with 17 additions and 17 deletions

View file

@ -97,7 +97,7 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
//Handle Spawned Events //Handle Spawned Events
if (!bEmptyList) if (!bEmptyList)
{ {
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
if (SpawnedEventConditionsCheck((*i).Event)) if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i); ProcessEvent(*i);
} }
@ -794,7 +794,7 @@ void CreatureEventAI::JustRespawned()
return; return;
//Handle Spawned Events //Handle Spawned Events
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
if (SpawnedEventConditionsCheck((*i).Event)) if (SpawnedEventConditionsCheck((*i).Event))
ProcessEvent(*i); ProcessEvent(*i);
} }
@ -808,7 +808,7 @@ void CreatureEventAI::Reset()
return; return;
//Reset all events to enabled //Reset all events to enabled
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
CreatureEventAI_Event const& event = (*i).Event; CreatureEventAI_Event const& event = (*i).Event;
switch (event.event_type) switch (event.event_type)
@ -835,7 +835,7 @@ void CreatureEventAI::JustReachedHome()
if (!bEmptyList) if (!bEmptyList)
{ {
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_REACHED_HOME) if ((*i).Event.event_type == EVENT_T_REACHED_HOME)
ProcessEvent(*i); ProcessEvent(*i);
@ -860,7 +860,7 @@ void CreatureEventAI::EnterEvadeMode()
return; return;
//Handle Evade events //Handle Evade events
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_EVADE) if ((*i).Event.event_type == EVENT_T_EVADE)
ProcessEvent(*i); ProcessEvent(*i);
@ -882,7 +882,7 @@ void CreatureEventAI::JustDied(Unit* killer)
return; return;
//Handle Evade events //Handle Evade events
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_DEATH) if ((*i).Event.event_type == EVENT_T_DEATH)
ProcessEvent(*i, killer); ProcessEvent(*i, killer);
@ -897,7 +897,7 @@ void CreatureEventAI::KilledUnit(Unit* victim)
if (bEmptyList || victim->GetTypeId() != TYPEID_PLAYER) if (bEmptyList || victim->GetTypeId() != TYPEID_PLAYER)
return; return;
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_KILL) if ((*i).Event.event_type == EVENT_T_KILL)
ProcessEvent(*i, victim); ProcessEvent(*i, victim);
@ -909,7 +909,7 @@ void CreatureEventAI::JustSummoned(Creature* pUnit)
if (bEmptyList || !pUnit) if (bEmptyList || !pUnit)
return; return;
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT) if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT)
ProcessEvent(*i, pUnit); ProcessEvent(*i, pUnit);
@ -921,7 +921,7 @@ void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit)
if (bEmptyList || !pUnit) if (bEmptyList || !pUnit)
return; return;
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DIED) if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DIED)
ProcessEvent(*i, pUnit); ProcessEvent(*i, pUnit);
@ -933,7 +933,7 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit)
if (bEmptyList || !pUnit) if (bEmptyList || !pUnit)
return; return;
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN) if ((*i).Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN)
ProcessEvent(*i, pUnit); ProcessEvent(*i, pUnit);
@ -945,7 +945,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy)
//Check for on combat start events //Check for on combat start events
if (!bEmptyList) if (!bEmptyList)
{ {
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
CreatureEventAI_Event const& event = (*i).Event; CreatureEventAI_Event const& event = (*i).Event;
switch (event.event_type) switch (event.event_type)
@ -1003,7 +1003,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
//Check for OOC LOS Event //Check for OOC LOS Event
if (!bEmptyList && !m_creature->getVictim()) if (!bEmptyList && !m_creature->getVictim())
{ {
for (std::list<CreatureEventAIHolder>::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr) for (std::vector<CreatureEventAIHolder>::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr)
{ {
if ((*itr).Event.event_type == EVENT_T_OOC_LOS) if ((*itr).Event.event_type == EVENT_T_OOC_LOS)
{ {
@ -1054,7 +1054,7 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell)
if (bEmptyList) if (bEmptyList)
return; return;
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
if ((*i).Event.event_type == EVENT_T_SPELLHIT) if ((*i).Event.event_type == EVENT_T_SPELLHIT)
//If spell id matches (or no spell id) & if spell school matches (or no spell school) //If spell id matches (or no spell id) & if spell school matches (or no spell school)
if (!(*i).Event.spell_hit.spellId || pSpell->Id == (*i).Event.spell_hit.spellId) if (!(*i).Event.spell_hit.spellId || pSpell->Id == (*i).Event.spell_hit.spellId)
@ -1079,7 +1079,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
EventDiff += diff; EventDiff += diff;
//Check for time based events //Check for time based events
for (std::list<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i) for (std::vector<CreatureEventAIHolder>::iterator i = CreatureEventAIList.begin(); i != CreatureEventAIList.end(); ++i)
{ {
//Decrement Timers //Decrement Timers
if ((*i).Time) if ((*i).Time)
@ -1343,7 +1343,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote)
if (bEmptyList) if (bEmptyList)
return; return;
for (std::list<CreatureEventAIHolder>::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr) for (std::vector<CreatureEventAIHolder>::iterator itr = CreatureEventAIList.begin(); itr != CreatureEventAIList.end(); ++itr)
{ {
if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE)
{ {

View file

@ -608,7 +608,7 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void DoFindFriendlyCC(std::list<Creature*>& _list, float range); void DoFindFriendlyCC(std::list<Creature*>& _list, float range);
//Holder for events (stores enabled, time, and eventid) //Holder for events (stores enabled, time, and eventid)
std::list<CreatureEventAIHolder> CreatureEventAIList; std::vector<CreatureEventAIHolder> CreatureEventAIList;
uint32 EventUpdateTime; //Time between event updates uint32 EventUpdateTime; //Time between event updates
uint32 EventDiff; //Time between the last event call uint32 EventDiff; //Time between the last event call
bool bEmptyList; bool bEmptyList;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10275" #define REVISION_NR "10276"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__