Generate an error message when forgot to allocate memory for a script.

This message is useful to find don't allocated scripts, like in rev r5915a3a871.

--HG--
branch : trunk
This commit is contained in:
Anubisss
2010-05-14 20:07:45 +02:00
parent 486d66e94b
commit 5c596f32d4

View File

@@ -158,6 +158,20 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
void Script::RegisterSelf()
{
// try to find scripts which try to use another script's allocated memory
// that means didn't allocate memory for script
for (uint16 i = 0; i < MAX_SCRIPTS; ++i)
{
// somebody forgot to allocate memory for a script by a method like this: newscript = new Script
if (m_scripts[i] == this)
{
error_log("ScriptName: '%s' - Forgot to allocate memory, so this script and/or the script before that can't work.", Name.c_str());
// don't register it
// and don't delete it because its memory is used for another script
return;
}
}
int id = GetScriptId(Name.c_str());
if (id)
{