From 5c596f32d49d635246246012575aaf02eea50cf3 Mon Sep 17 00:00:00 2001 From: Anubisss Date: Fri, 14 May 2010 20:07:45 +0200 Subject: 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 --- src/game/ScriptMgr.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/game') 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) { -- cgit v1.2.3