Core/SAI: Fixed memory leaks in targeting (lists were not being deleted)

This commit is contained in:
Shauren
2011-03-26 23:45:23 +01:00
parent 592ad10866
commit cbb552ead7
2 changed files with 1572 additions and 1307 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -100,29 +100,43 @@ class SmartScript
void StoreTargetList(ObjectList* targets, uint32 id)
{
if (!targets) return;
if(mTargetStorage->find(id) != mTargetStorage->end())
mTargetStorage->erase(id);
if (!targets)
return;
if (mTargetStorage->find(id) != mTargetStorage->end())
delete (*mTargetStorage)[id];
(*mTargetStorage)[id] = targets;
}
bool IsSmart(Creature* c = NULL)
{
bool smart = true;
if (c && c->GetAIName() != "SmartAI") smart = false;
if (!me || me->GetAIName() != "SmartAI") smart = false;
if (c && c->GetAIName() != "SmartAI")
smart = false;
if (!me || me->GetAIName() != "SmartAI")
smart = false;
if (!smart)
sLog->outErrorDb("SmartScript: Action target Creature(entry: %u) is not using SmartAI, action skipped to prevent crash.", c?c->GetEntry():(me?me->GetEntry():0));
return smart;
}
bool IsSmartGO(GameObject* g = NULL)
{
bool smart = true;
if (g && g->GetAIName() != "SmartGameObjectAI") smart = false;
if (!go || go->GetAIName() != "SmartGameObjectAI") smart = false;
if (g && g->GetAIName() != "SmartGameObjectAI")
smart = false;
if (!go || go->GetAIName() != "SmartGameObjectAI")
smart = false;
if (!smart)
sLog->outErrorDb("SmartScript: Action target GameObject(entry: %u) is not using SmartGameObjectAI, action skipped to prevent crash.", g?g->GetEntry():(go?go->GetEntry():0));
return smart;
}
ObjectList* GetTargetList(uint32 id)
{
ObjectListMap::iterator itr = mTargetStorage->find(id);