aboutsummaryrefslogtreecommitdiff
path: root/src/game/ScriptMgr.cpp
diff options
context:
space:
mode:
authorAnubisss <none@none>2010-05-14 20:07:45 +0200
committerAnubisss <none@none>2010-05-14 20:07:45 +0200
commit5c596f32d49d635246246012575aaf02eea50cf3 (patch)
tree3d2b80d8ce98ee164208413d9955db00240dc5a3 /src/game/ScriptMgr.cpp
parent486d66e94b36fee0b4a61c3ef7031aaa70d80f45 (diff)
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
Diffstat (limited to 'src/game/ScriptMgr.cpp')
-rw-r--r--src/game/ScriptMgr.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
index 05dc57f2a00..6912631a3e5 100644
--- a/src/game/ScriptMgr.cpp
+++ b/src/game/ScriptMgr.cpp
@@ -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)
{