mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Scripts: Fixed uninitialized variable and memory leaks
This commit is contained in:
@@ -33,6 +33,12 @@
|
||||
#include "Player.h"
|
||||
#include "WorldPacket.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef std::set<ScriptObject*> ExampleScriptContainer;
|
||||
ExampleScriptContainer ExampleScripts;
|
||||
}
|
||||
|
||||
// This is the global static registry of scripts.
|
||||
template<class TScript>
|
||||
class ScriptRegistry
|
||||
@@ -104,6 +110,9 @@ class ScriptRegistry
|
||||
if (script->GetName().find("example") == std::string::npos && script->GetName().find("Smart") == std::string::npos)
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "Script named '%s' does not have a script name assigned in database.",
|
||||
script->GetName().c_str());
|
||||
|
||||
// These scripts don't get stored anywhere so throw them into this to avoid leaking memory
|
||||
ExampleScripts.insert(script);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -160,7 +169,11 @@ class ScriptRegistry
|
||||
if (!V) \
|
||||
return R;
|
||||
|
||||
|
||||
struct TSpellSummary
|
||||
{
|
||||
uint8 Targets; // set of enum SelectTarget
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
} *SpellSummary;
|
||||
|
||||
ScriptMgr::ScriptMgr()
|
||||
: _scriptCount(0), _scheduledScripts(0)
|
||||
@@ -220,6 +233,13 @@ void ScriptMgr::Unload()
|
||||
SCR_CLEAR(UnitScript);
|
||||
|
||||
#undef SCR_CLEAR
|
||||
|
||||
for (ExampleScriptContainer::iterator itr = ExampleScripts.begin(); itr != ExampleScripts.end(); ++itr)
|
||||
delete *itr;
|
||||
ExampleScripts.clear();
|
||||
|
||||
delete[] SpellSummary;
|
||||
delete[] UnitAI::AISpellInfo;
|
||||
}
|
||||
|
||||
void ScriptMgr::LoadDatabase()
|
||||
@@ -227,14 +247,10 @@ void ScriptMgr::LoadDatabase()
|
||||
sScriptSystemMgr->LoadScriptWaypoints();
|
||||
}
|
||||
|
||||
struct TSpellSummary
|
||||
{
|
||||
uint8 Targets; // set of enum SelectTarget
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
} *SpellSummary;
|
||||
|
||||
void ScriptMgr::FillSpellSummary()
|
||||
{
|
||||
UnitAI::FillAISpellInfo();
|
||||
|
||||
SpellSummary = new TSpellSummary[sSpellMgr->GetSpellInfoStoreSize()];
|
||||
|
||||
SpellInfo const* pTempSpell;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "Chat.h"
|
||||
#include "Spell.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "MapManager.h"
|
||||
#include "BattlefieldWG.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
@@ -3001,8 +3000,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
|
||||
spellInfo->_InitializeExplicitTargetMask();
|
||||
}
|
||||
|
||||
CreatureAI::FillAISpellInfo();
|
||||
|
||||
TC_LOG_INFO(LOG_FILTER_SERVER_LOADING, ">> Loaded SpellInfo custom attributes in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
|
||||
@@ -364,10 +364,8 @@ public:
|
||||
me->GetRandomNearPosition(pos, 60);
|
||||
else
|
||||
{
|
||||
std::vector<InfernalPoint*>::iterator itr = positions.begin()+rand()%positions.size();
|
||||
point = *itr;
|
||||
positions.erase(itr);
|
||||
pos.Relocate(point->x, point->y, INFERNAL_Z, 0.0f);
|
||||
point = Trinity::Containers::SelectRandomContainerElement(positions);
|
||||
pos.Relocate(point->x, point->y, INFERNAL_Z, frand(0.0f, float(M_PI * 2)));
|
||||
}
|
||||
|
||||
Creature* infernal = me->SummonCreature(NETHERSPITE_INFERNAL, pos, TEMPSUMMON_TIMED_DESPAWN, 180000);
|
||||
|
||||
@@ -493,7 +493,7 @@ class npc_green_dragon_combat_trigger : public CreatureScript
|
||||
|
||||
struct npc_green_dragon_combat_triggerAI : public BossAI
|
||||
{
|
||||
npc_green_dragon_combat_triggerAI(Creature* creature) : BossAI(creature, DATA_VALITHRIA_DREAMWALKER)
|
||||
npc_green_dragon_combat_triggerAI(Creature* creature) : BossAI(creature, DATA_VALITHRIA_DREAMWALKER), _evadeCheck(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user