Core/SAI/EAI: Pass struct parameters by reference instead of value, saves unneeded copying

This commit is contained in:
Shauren
2011-05-12 10:40:53 +02:00
parent bca01dd419
commit 339e8cb7e0
7 changed files with 43 additions and 39 deletions
@@ -1025,9 +1025,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_SUMMON_CREATURE:
{
WorldObject* obj = GetBaseObject();
if (!obj)
obj = unit;
float x, y, z, o;
ObjectList* targets = GetTargets(e, unit);
if (targets)
@@ -1356,6 +1353,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
ne.minMaxRepeat.repeatMin = e.action.timeEvent.repeatMin;
ne.minMaxRepeat.repeatMax = e.action.timeEvent.repeatMax;
ne.event_flags = 0;
if (!ne.minMaxRepeat.repeatMin && !ne.minMaxRepeat.repeatMax)
ne.event_flags |= SMART_EVENT_FLAG_NOT_REPEATABLE;
@@ -1395,9 +1393,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
goOrigGUID = go ? go->GetGUID() : 0;
go = NULL;
me = (*itr)->ToCreature();
delete targets;
return;
break;
}
else if (IsGameObject(*itr))
{
@@ -1407,9 +1403,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
goOrigGUID = go ? go->GetGUID() : 0;
go = (*itr)->ToGameObject();
me = NULL;
delete targets;
return;
break;
}
}
@@ -1532,7 +1526,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
(*itr)->ToUnit()->InterruptNonMeleeSpells(false);
for (ObjectList::const_iterator it = targets->begin(); it != targets->end(); it++)
for (ObjectList::const_iterator it = targets->begin(); it != targets->end(); ++it)
if (IsUnit(*it))
(*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) ? true : false);
}
@@ -1708,7 +1702,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
}
}
void SmartScript::InstallTemplate(SmartScriptHolder e)
void SmartScript::InstallTemplate(SmartScriptHolder const& e)
{
if (!GetBaseObject())
return;
@@ -1814,7 +1808,7 @@ SmartScriptHolder SmartScript::CreateEvent(SMART_EVENT e, uint32 event_flags, ui
return script;
}
ObjectList* SmartScript::GetTargets(SmartScriptHolder e, Unit* invoker)
ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*= NULL*/)
{
Unit* trigger = NULL;
if (invoker)
@@ -221,7 +221,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
sLog->outString();
}
bool SmartAIMgr::IsTargetValid(SmartScriptHolder e)
bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e)
{
if (e.GetActionType() == SMART_ACTION_INSTALL_AI_TEMPLATE)
return true; //AI template has special handling
@@ -780,7 +780,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
return true;
}
bool SmartAIMgr::IsTextValid(SmartScriptHolder e, uint32 id)
bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id)
{
bool error = false;
uint32 entry = 0;
@@ -1225,7 +1225,8 @@ class SmartAIMgr
SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX];
bool IsEventValid(SmartScriptHolder &e);
bool IsTargetValid(SmartScriptHolder e);
bool IsTargetValid(SmartScriptHolder const& e);
/*inline bool IsTargetValid(SmartScriptHolder e, int32 target)
{
if (target < SMART_TARGET_NONE || target >= SMART_TARGET_END)
@@ -1235,7 +1236,8 @@ class SmartAIMgr
}
return true;
}*/
inline bool IsMinMaxValid(SmartScriptHolder e, uint32 min, uint32 max)
bool IsMinMaxValid(SmartScriptHolder const& e, uint32 min, uint32 max)
{
if (max < min)
{
@@ -1244,6 +1246,7 @@ class SmartAIMgr
}
return true;
}
/*inline bool IsPercentValid(SmartScriptHolder e, int32 pct)
{
if (pct < -100 || pct > 100)
@@ -1253,7 +1256,8 @@ class SmartAIMgr
}
return true;
}*/
inline bool NotNULL(SmartScriptHolder e, uint32 data)
bool NotNULL(SmartScriptHolder const& e, uint32 data)
{
if (!data)
{
@@ -1262,7 +1266,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsCreatureValid(SmartScriptHolder e, uint32 entry)
bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sObjectMgr->GetCreatureTemplate(entry))
{
@@ -1271,7 +1276,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsQuestValid(SmartScriptHolder e, uint32 entry)
bool IsQuestValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sObjectMgr->GetQuestTemplate(entry))
{
@@ -1280,7 +1286,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsGameObjectValid(SmartScriptHolder e, uint32 entry)
bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sObjectMgr->GetGameObjectTemplate(entry))
{
@@ -1289,7 +1296,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsSpellValid(SmartScriptHolder e, uint32 entry)
bool IsSpellValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sSpellStore.LookupEntry(entry))
{
@@ -1298,7 +1306,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsItemValid(SmartScriptHolder e, uint32 entry)
bool IsItemValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sItemStore.LookupEntry(entry))
{
@@ -1327,7 +1336,8 @@ class SmartAIMgr
}
return true;
}*/
inline bool IsTextEmoteValid(SmartScriptHolder e, uint32 entry)
bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sEmotesTextStore.LookupEntry(entry))
{
@@ -1336,7 +1346,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsEmoteValid(SmartScriptHolder e, uint32 entry)
bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sEmotesStore.LookupEntry(entry))
{
@@ -1345,7 +1356,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsAreaTriggerValid(SmartScriptHolder e, uint32 entry)
bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sAreaTriggerStore.LookupEntry(entry))
{
@@ -1354,7 +1366,8 @@ class SmartAIMgr
}
return true;
}
inline bool IsSoundValid(SmartScriptHolder e, uint32 entry)
bool IsSoundValid(SmartScriptHolder const& e, uint32 entry)
{
if (!sSoundEntriesStore.LookupEntry(entry))
{
@@ -1363,7 +1376,8 @@ class SmartAIMgr
}
return true;
}
bool IsTextValid(SmartScriptHolder e, uint32 id);
bool IsTextValid(SmartScriptHolder const& e, uint32 id);
};
#define sSmartScriptMgr ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>::instance()