Index: trunk/src/shared/ProgressBar.h
===================================================================
--- trunk/src/shared/ProgressBar.h (revision 102)
+++ trunk/src/shared/ProgressBar.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #ifndef TRINITYCORE_PROGRESSBAR_H
Index: trunk/src/shared/Database/SQLStorageImpl.h
===================================================================
--- trunk/src/shared/Database/SQLStorageImpl.h (revision 260)
+++ trunk/src/shared/Database/SQLStorageImpl.h (revision 260)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "ProgressBar.h"
+#include "Log.h"
+#include "dbcfile.h"
+
+template<class T>
+template<class S, class D>
+void SQLStorageLoaderBase<T>::convert(uint32 field_pos, S src, D &dst)
+{
+    dst = D(src);
+}
+
+template<class T>
+void SQLStorageLoaderBase<T>::convert_str_to_str(uint32 field_pos, char *src, char *&dst)
+{
+    if(!src)
+    {
+        dst = new char[1];
+        *dst = 0;
+    }
+    else
+    {
+        uint32 l = strlen(src) + 1;
+        dst = new char[l];
+        memcpy(dst, src, l);
+    }
+}
+
+template<class T>
+template<class S>
+void SQLStorageLoaderBase<T>::convert_to_str(uint32 field_pos, S src, char * & dst)
+{
+    dst = new char[1];
+    *dst = 0;
+}
+
+template<class T>
+template<class D>
+void SQLStorageLoaderBase<T>::convert_from_str(uint32 field_pos, char * src, D& dst)
+{
+    dst = 0;
+}
+
+template<class T>
+template<class V>
+void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset)
+{
+    T * subclass = (static_cast<T*>(this));
+    switch(store.dst_format[x])
+    {
+        case FT_LOGIC:
+            subclass->convert(x, value, *((bool*)(&p[offset])) );
+            offset+=sizeof(bool);
+            break;
+        case FT_BYTE:
+            subclass->convert(x, value, *((char*)(&p[offset])) );
+            offset+=sizeof(char);
+            break;
+        case FT_INT:
+            subclass->convert(x, value, *((uint32*)(&p[offset])) );
+            offset+=sizeof(uint32);
+            break;
+        case FT_FLOAT:
+            subclass->convert(x, value, *((float*)(&p[offset])) );
+            offset+=sizeof(float);
+            break;
+        case FT_STRING:
+            subclass->convert_to_str(x, value, *((char**)(&p[offset])) );
+            offset+=sizeof(char*);
+            break;
+    }
+}
+
+template<class T>
+void SQLStorageLoaderBase<T>::storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset)
+{
+    T * subclass = (static_cast<T*>(this));
+    switch(store.dst_format[x])
+    {
+        case FT_LOGIC:
+            subclass->convert_from_str(x, value, *((bool*)(&p[offset])) );
+            offset+=sizeof(bool);
+            break;
+        case FT_BYTE:
+            subclass->convert_from_str(x, value, *((char*)(&p[offset])) );
+            offset+=sizeof(char);
+            break;
+        case FT_INT:
+            subclass->convert_from_str(x, value, *((uint32*)(&p[offset])) );
+            offset+=sizeof(uint32);
+            break;
+        case FT_FLOAT:
+            subclass->convert_from_str(x, value, *((float*)(&p[offset])) );
+            offset+=sizeof(float);
+            break;
+        case FT_STRING:
+            subclass->convert_str_to_str(x, value, *((char**)(&p[offset])) );
+            offset+=sizeof(char*);
+            break;
+    }
+}
+
+template<class T>
+void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
+{
+    uint32 maxi;
+    Field *fields;
+    QueryResult *result  = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s", store.entry_field, store.table);
+    if(!result)
+    {
+        sLog.outError("Error loading %s table (not exist?)\n", store.table);
+        exit(1);                                            // Stop server at loading non exited table or not accessable table
+    }
+
+    maxi = (*result)[0].GetUInt32()+1;
+    delete result;
+
+    result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s", store.table);
+    if(result)
+    {
+        fields = result->Fetch();
+        store.RecordCount = fields[0].GetUInt32();
+        delete result;
+    }
+    else
+        store.RecordCount = 0;
+
+    result = WorldDatabase.PQuery("SELECT * FROM %s", store.table);
+
+    if(!result)
+    {
+        sLog.outError("%s table is empty!\n", store.table);
+        store.RecordCount = 0;
+        return;
+    }
+
+    uint32 recordsize = 0;
+    uint32 offset = 0;
+
+    if(store.iNumFields != result->GetFieldCount())
+    {
+        store.RecordCount = 0;
+        sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n", store.table, store.iNumFields);
+        delete result;
+        exit(1);                                            // Stop server at loading broken or non-compatible table.
+    }
+
+    //get struct size
+    uint32 sc=0;
+    uint32 bo=0;
+    uint32 bb=0;
+    for(uint32 x=0; x< store.iNumFields; x++)
+        if(store.dst_format[x]==FT_STRING)
+            ++sc;
+        else if (store.dst_format[x]==FT_LOGIC)
+            ++bo;
+        else if (store.dst_format[x]==FT_BYTE)
+            ++bb;
+    recordsize=(store.iNumFields-sc-bo-bb)*4+sc*sizeof(char*)+bo*sizeof(bool)+bb*sizeof(char);
+
+    char** newIndex=new char*[maxi];
+    memset(newIndex,0,maxi*sizeof(char*));
+
+    char * _data= new char[store.RecordCount *recordsize];
+    uint32 count=0;
+    barGoLink bar( store.RecordCount );
+    do
+    {
+        fields = result->Fetch();
+        bar.step();
+        char *p=(char*)&_data[recordsize*count];
+        newIndex[fields[0].GetUInt32()]=p;
+
+        offset=0;
+        for(uint32 x = 0; x < store.iNumFields; x++)
+            switch(store.src_format[x])
+            {
+                case FT_LOGIC:
+                    storeValue((bool)(fields[x].GetUInt32() > 0), store, p, x, offset); break;
+                case FT_BYTE:
+                    storeValue((char)fields[x].GetUInt8(), store, p, x, offset); break;
+                case FT_INT:
+                    storeValue((uint32)fields[x].GetUInt32(), store, p, x, offset); break;
+                case FT_FLOAT:
+                    storeValue((float)fields[x].GetFloat(), store, p, x, offset); break;
+                case FT_STRING:
+                    storeValue((char*)fields[x].GetString(), store, p, x, offset); break;
+            }
+        ++count;
+    }while( result->NextRow() );
+
+    delete result;
+
+    store.pIndex = newIndex;
+    store.MaxEntry = maxi;
+    store.data = _data;
+}
Index: trunk/src/shared/Database/DBCStores.cpp
===================================================================
--- trunk/src/shared/Database/DBCStores.cpp (revision 229)
+++ trunk/src/shared/Database/DBCStores.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -122,19 +122,7 @@
 // DBC used only for initialization sTaxiPathSetBySource at startup.
 TaxiPathNodesByPath sTaxiPathNodesByPath;
-struct TaxiPathNodeEntry
-{
-    uint32    path;
-    uint32    index;
-    uint32    mapid;
-    float     x;
-    float     y;
-    float     z;
-    uint32    actionFlag;
-    uint32    delay;
-};
+
 static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt);
-
 DBCStorage <TotemCategoryEntry> sTotemCategoryStore(TotemCategoryEntryfmt);
-
 DBCStorage <WorldMapAreaEntry>  sWorldMapAreaStore(WorldMapAreaEntryfmt);
 DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
@@ -236,5 +224,5 @@
         }
     }
-    
+
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore,     dbcPath,"FactionTemplate.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore,       dbcPath,"GemProperties.dbc");
@@ -284,5 +272,5 @@
     {
         SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
-    
+
         if(!skillLine)
             continue;
@@ -291,5 +279,5 @@
 
         if(spellInfo && (spellInfo->Attributes & 0x1D0) == 0x1D0)
-        {      
+        {
             for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
             {
@@ -298,5 +286,5 @@
                     continue;
 
-                if(skillLine->skillId != cFamily->skillLine && skillLine->skillId != cFamily->skillLine2)
+                if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
                     continue;
 
@@ -310,5 +298,4 @@
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore,    dbcPath,"SpellFocusObject.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc");
-    
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore,         dbcPath,"SpellRadius.dbc");
@@ -456,9 +443,9 @@
     // check at up-to-date DBC files (71 is last char title added in 2.4.3)
     // check at up-to-date DBC files (1768 is last area added in 2.4.3)
-    if( !sSpellStore.LookupEntry(53085)            || 
-        !sSkillLineAbilityStore.LookupEntry(17514) || 
+    if( !sSpellStore.LookupEntry(53085)            ||
+        !sSkillLineAbilityStore.LookupEntry(17514) ||
         !sMapStore.LookupEntry(598)                ||
-        !sGemPropertiesStore.LookupEntry(1127)     || 
-        !sItemExtendedCostStore.LookupEntry(2425)  || 
+        !sGemPropertiesStore.LookupEntry(1127)     ||
+        !sItemExtendedCostStore.LookupEntry(2425)  ||
         !sCharTitlesStore.LookupEntry(71)          ||
         !sAreaStore.LookupEntry(1768)              )
Index: trunk/src/shared/Database/SQLStorage.h
===================================================================
--- trunk/src/shared/Database/SQLStorage.h (revision 102)
+++ trunk/src/shared/Database/SQLStorage.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -27,16 +27,24 @@
 class SQLStorage
 {
+    template<class T>
+    friend struct SQLStorageLoaderBase;
+
     public:
 
-        SQLStorage(const char*fmt,const char * _entry_field,const char * sqlname)
+        SQLStorage(const char* fmt, const char * _entry_field, const char * sqlname)
         {
-            format=fmt;
-            entry_field = _entry_field;
-            table=sqlname;
-            data=NULL;
-            pIndex=NULL;
-            iNumFields =strlen(fmt);
-            MaxEntry = 0;
+            src_format = fmt;
+            dst_format = fmt;
+            init(_entry_field, sqlname);
         }
+
+        SQLStorage(const char* src_fmt, const char* dst_fmt, const char * _entry_field, const char * sqlname)
+        {
+            src_format = src_fmt;
+            dst_format = dst_fmt;
+            init(_entry_field, sqlname);
+        }
+
+
         ~SQLStorage()
         {
@@ -57,14 +65,52 @@
         uint32 MaxEntry;
         uint32 iNumFields;
+
         void Load();
         void Free();
+
     private:
+        void init(const char * _entry_field, const char * sqlname)
+        {
+            entry_field = _entry_field;
+            table=sqlname;
+            data=NULL;
+            pIndex=NULL;
+            iNumFields = strlen(src_format);
+            MaxEntry = 0;
+        }
+
         char** pIndex;
 
         char *data;
-        const char *format;
+        const char *src_format;
+        const char *dst_format;
         const char *table;
         const char *entry_field;
         //bool HasString;
 };
+
+template <class T>
+struct SQLStorageLoaderBase
+{
+    public:
+        void Load(SQLStorage &storage);
+
+        template<class S, class D>
+            void convert(uint32 field_pos, S src, D &dst);
+        template<class S>
+            void convert_to_str(uint32 field_pos, S src, char * & dst);
+        template<class D>
+            void convert_from_str(uint32 field_pos, char * src, D& dst);
+        void convert_str_to_str(uint32 field_pos, char *src, char *&dst);
+
+    private:
+        template<class V>
+            void storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset);
+        void storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset);
+};
+
+struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader>
+{
+};
+
 #endif
Index: trunk/src/shared/Database/dbcfile.h
===================================================================
--- trunk/src/shared/Database/dbcfile.h (revision 102)
+++ trunk/src/shared/Database/dbcfile.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/shared/Database/DBCEnums.h
===================================================================
--- trunk/src/shared/Database/DBCEnums.h (revision 260)
+++ trunk/src/shared/Database/DBCEnums.h (revision 260)
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef DBCENUMS_H
+#define DBCENUMS_H
+
+enum AreaTeams
+{
+    AREATEAM_NONE  = 0,
+    AREATEAM_ALLY  = 2,
+    AREATEAM_HORDE = 4
+};
+
+enum AreaFlags
+{
+    AREA_FLAG_SNOW             = 0x00000001,                // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring)
+    AREA_FLAG_UNK1             = 0x00000002,                // unknown, (only Naxxramas and Razorfen Downs)
+    AREA_FLAG_UNK2             = 0x00000004,                // Only used on development map
+    AREA_FLAG_SLAVE_CAPITAL    = 0x00000008,                // slave capital city flag?
+    AREA_FLAG_UNK3             = 0x00000010,                // unknown
+    AREA_FLAG_SLAVE_CAPITAL2   = 0x00000020,                // slave capital city flag?
+    AREA_FLAG_UNK4             = 0x00000040,                // many zones have this flag
+    AREA_FLAG_ARENA            = 0x00000080,                // arena, both instanced and world arenas
+    AREA_FLAG_CAPITAL          = 0x00000100,                // main capital city flag
+    AREA_FLAG_CITY             = 0x00000200,                // only for one zone named "City" (where it located?)
+    AREA_FLAG_OUTLAND          = 0x00000400,                // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag)
+    AREA_FLAG_SANCTUARY        = 0x00000800,                // sanctuary area (PvP disabled)
+    AREA_FLAG_NEED_FLY         = 0x00001000,                // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway
+    AREA_FLAG_UNUSED1          = 0x00002000,                // not used now (no area/zones with this flag set in 2.4.2)
+    AREA_FLAG_OUTLAND2         = 0x00004000,                // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag)
+    AREA_FLAG_PVP              = 0x00008000,                // pvp objective area? (Death's Door also has this flag although it's no pvp object area)
+    AREA_FLAG_ARENA_INSTANCE   = 0x00010000,                // used by instanced arenas only
+    AREA_FLAG_UNUSED2          = 0x00020000,                // not used now (no area/zones with this flag set in 2.4.2)
+    AREA_FLAG_UNK5             = 0x00040000,                // just used for Amani Pass, Hatchet Hills
+    AREA_FLAG_LOWLEVEL         = 0x00100000                 // used for some starting areas with area_level <=15
+};
+
+enum FactionTemplateFlags
+{
+    FACTION_TEMPLATE_FLAG_CONTESTED_GUARD   =   0x00001000, // faction will attack players that were involved in PvP combats
+};
+
+enum FactionMasks
+{
+    FACTION_MASK_PLAYER   = 1,                              // any player
+    FACTION_MASK_ALLIANCE = 2,                              // player or creature from alliance team
+    FACTION_MASK_HORDE    = 4,                              // player or creature from horde team
+    FACTION_MASK_MONSTER  = 8                               // aggressive creature from monster team
+    // if none flags set then non-aggressive creature
+};
+
+enum MapTypes
+{
+    MAP_COMMON          = 0,
+    MAP_INSTANCE        = 1,
+    MAP_RAID            = 2,
+    MAP_BATTLEGROUND    = 3,
+    MAP_ARENA           = 4
+};
+
+enum AbilytyLearnType
+{
+    ABILITY_LEARNED_ON_GET_PROFESSION_SKILL     = 1,
+    ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL  = 2
+};
+
+enum ItemEnchantmentType
+{
+    ITEM_ENCHANTMENT_TYPE_NONE         = 0,
+    ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1,
+    ITEM_ENCHANTMENT_TYPE_DAMAGE       = 2,
+    ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL  = 3,
+    ITEM_ENCHANTMENT_TYPE_RESISTANCE   = 4,
+    ITEM_ENCHANTMENT_TYPE_STAT         = 5,
+    ITEM_ENCHANTMENT_TYPE_TOTEM        = 6
+};
+
+enum TotemCategoryType
+{
+    TOTEM_CATEGORY_TYPE_KNIFE   = 1,
+    TOTEM_CATEGORY_TYPE_TOTEM   = 2,
+    TOTEM_CATEGORY_TYPE_ROD     = 3,
+    TOTEM_CATEGORY_TYPE_PICK    = 21,
+    TOTEM_CATEGORY_TYPE_STONE   = 22,
+    TOTEM_CATEGORY_TYPE_HAMMER  = 23,
+    TOTEM_CATEGORY_TYPE_SPANNER = 24
+};
+
+#endif
Index: trunk/src/shared/Database/DBCStructure.h
===================================================================
--- trunk/src/shared/Database/DBCStructure.h (revision 230)
+++ trunk/src/shared/Database/DBCStructure.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -22,4 +22,5 @@
 #define DBCSTRUCTURE_H
 
+#include "DBCEnums.h"
 #include "Platform/Define.h"
 
@@ -36,40 +37,4 @@
 #pragma pack(push,1)
 #endif
-
-enum AreaTeams
-{
-    AREATEAM_NONE  = 0,
-    AREATEAM_ALLY  = 2,
-    AREATEAM_HORDE = 4
-};
-
-enum AreaFlags
-{
-    AREA_FLAG_SNOW             = 0x00000001,                // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring)
-    AREA_FLAG_UNK1             = 0x00000002,                // unknown, (only Naxxramas and Razorfen Downs)
-    AREA_FLAG_UNK2             = 0x00000004,                // Only used on development map
-    AREA_FLAG_SLAVE_CAPITAL    = 0x00000008,                // slave capital city flag?
-    AREA_FLAG_UNK3             = 0x00000010,                // unknown
-    AREA_FLAG_SLAVE_CAPITAL2   = 0x00000020,                // slave capital city flag?
-    AREA_FLAG_UNK4             = 0x00000040,                // many zones have this flag
-    AREA_FLAG_ARENA            = 0x00000080,                // arena, both instanced and world arenas
-    AREA_FLAG_CAPITAL          = 0x00000100,                // main capital city flag
-    AREA_FLAG_CITY             = 0x00000200,                // only for one zone named "City" (where it located?)
-    AREA_FLAG_OUTLAND          = 0x00000400,                // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag)
-    AREA_FLAG_SANCTUARY        = 0x00000800,                // sanctuary area (PvP disabled)
-    AREA_FLAG_NEED_FLY         = 0x00001000,                // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway
-    AREA_FLAG_UNUSED1          = 0x00002000,                // not used now (no area/zones with this flag set in 2.4.2)
-    AREA_FLAG_OUTLAND2         = 0x00004000,                // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag)
-    AREA_FLAG_PVP              = 0x00008000,                // pvp objective area? (Death's Door also has this flag although it's no pvp object area)
-    AREA_FLAG_ARENA_INSTANCE   = 0x00010000,                // used by instanced arenas only
-    AREA_FLAG_UNUSED2          = 0x00020000,                // not used now (no area/zones with this flag set in 2.4.2)
-    AREA_FLAG_UNK5             = 0x00040000,                // just used for Amani Pass, Hatchet Hills
-    AREA_FLAG_LOWLEVEL         = 0x00100000                 // used for some starting areas with area_level <=15
-};
-
-enum FactionTemplateFlags
-{
-    FACTION_TEMPLATE_FLAG_CONTESTED_GUARD   =   0x00001000, // faction will attack players that were involved in PvP combats
-};
 
 struct AreaTableEntry
@@ -180,5 +145,5 @@
                                                             // 64 string flags, unused
                                                             // 65-67 unused
-    uint32    addon;                                         // 68 (0 - original race, 1 - tbc addon, ...)
+    uint32      addon;                                      // 68 (0 - original race, 1 - tbc addon, ...)
 };
 
@@ -194,10 +159,9 @@
 {
     uint32    ID;                                           // 0
-    float     minScale;                                     // 1  
-    uint32    minScaleLevel;                                // 2 0/1      
+    float     minScale;                                     // 1
+    uint32    minScaleLevel;                                // 2 0/1
     float     maxScale;                                     // 3
     uint32    maxScaleLevel;                                // 4 0/60
-    uint32    skillLine;                                    // 5
-    uint32    skillLine2;                                   // 6
+    uint32    skillLine[2];                                 // 5-6
     uint32    petFoodMask;                                  // 7
     char*     Name[16];                                     // 8-23
@@ -243,13 +207,4 @@
     //char*     description[16];                            // 36-51 unused
                                                             // 52 string flags, unused
-};
-
-enum FactionMasks
-{
-    FACTION_MASK_PLAYER   = 1,                              // any player
-    FACTION_MASK_ALLIANCE = 2,                              // player or creature from alliance team
-    FACTION_MASK_HORDE    = 4,                              // player or creature from horde team
-    FACTION_MASK_MONSTER  = 8                               // aggressive creature from monster team
-                                                            // if none flags set then non-aggressive creature
 };
 
@@ -302,4 +257,5 @@
 
 #define GT_MAX_LEVEL    100
+
 struct GtCombatRatingsEntry
 {
@@ -430,13 +386,4 @@
                                                             // 17 name flags, unused
     //char*       content[16];                              // 18-33
-};
-
-enum MapTypes
-{
-    MAP_COMMON          = 0,
-    MAP_INSTANCE        = 1,
-    MAP_RAID            = 2,
-    MAP_BATTLEGROUND    = 3,
-    MAP_ARENA           = 4
 };
 
@@ -544,10 +491,4 @@
                                                             // 36 string flags, not used
     uint32    spellIcon;                                    // 37
-};
-
-enum AbilytyLearnType
-{
-    ABILITY_LEARNED_ON_GET_PROFESSION_SKILL     = 1,
-    ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL  = 2
 };
 
@@ -759,15 +700,4 @@
 };
 
-enum ItemEnchantmentType
-{
-    ITEM_ENCHANTMENT_TYPE_NONE         = 0,
-    ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1,
-    ITEM_ENCHANTMENT_TYPE_DAMAGE       = 2,
-    ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL  = 3,
-    ITEM_ENCHANTMENT_TYPE_RESISTANCE   = 4,
-    ITEM_ENCHANTMENT_TYPE_STAT         = 5,
-    ITEM_ENCHANTMENT_TYPE_TOTEM        = 6
-};
-
 struct SpellItemEnchantmentEntry
 {
@@ -827,12 +757,4 @@
 };
 
-struct TaxiPathEntry
-{
-    uint32    ID;
-    uint32    from;
-    uint32    to;
-    uint32    price;
-};
-
 struct TaxiNodesEntry
 {
@@ -848,13 +770,22 @@
 };
 
-enum TotemCategoryType
-{
-    TOTEM_CATEGORY_TYPE_KNIFE   = 1,
-    TOTEM_CATEGORY_TYPE_TOTEM   = 2,
-    TOTEM_CATEGORY_TYPE_ROD     = 3,
-    TOTEM_CATEGORY_TYPE_PICK    = 21,
-    TOTEM_CATEGORY_TYPE_STONE   = 22,
-    TOTEM_CATEGORY_TYPE_HAMMER  = 23,
-    TOTEM_CATEGORY_TYPE_SPANNER = 24
+struct TaxiPathEntry
+{
+    uint32    ID;
+    uint32    from;
+    uint32    to;
+    uint32    price;
+};
+
+struct TaxiPathNodeEntry
+{
+    uint32    path;
+    uint32    index;
+    uint32    mapid;
+    float     x;
+    float     y;
+    float     z;
+    uint32    actionFlag;
+    uint32    delay;
 };
 
Index: trunk/src/shared/Database/SQLStorage.cpp
===================================================================
--- trunk/src/shared/Database/SQLStorage.cpp (revision 102)
+++ trunk/src/shared/Database/SQLStorage.cpp (revision 260)
@@ -11,16 +11,14 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "SQLStorage.h"
-#include "ProgressBar.h"
-#include "Log.h"
-#include "dbcfile.h"
+#include "SQLStorageImpl.h"
 
 #ifdef DO_POSTGRESQL
@@ -30,25 +28,29 @@
 #endif
 
-const char CreatureInfofmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis";
+const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis";
+const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiii";
 const char CreatureDataAddonInfofmt[]="iiiiiiis";
 const char CreatureModelfmt[]="iffbi";
 const char CreatureInfoAddonInfofmt[]="iiiiiiis";
 const char EquipmentInfofmt[]="iiiiiiiiii";
-const char GameObjectInfofmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis";
-const char ItemPrototypefmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii";
+const char GameObjectInfosrcfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis";
+const char GameObjectInfodstfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiii";
+const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii";
+const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiii";
 const char PageTextfmt[]="isi";
 const char SpellThreatfmt[]="ii";
-const char InstanceTemplatefmt[]="iiiiiiffffs";
+const char InstanceTemplatesrcfmt[]="iiiiiiffffs";
+const char InstanceTemplatedstfmt[]="iiiiiiffffi";
 
-SQLStorage sCreatureStorage(CreatureInfofmt,"entry","creature_template");
+SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template");
 SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon");
 SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info");
 SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon");
 SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template");
-SQLStorage sGOStorage(GameObjectInfofmt,"entry","gameobject_template");
-SQLStorage sItemStorage(ItemPrototypefmt,"entry","item_template");
+SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template");
+SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template");
 SQLStorage sPageTextStore(PageTextfmt,"entry","page_text");
 SQLStorage sSpellThreatStore(SpellThreatfmt,"entry","spell_threat");
-SQLStorage sInstanceTemplate(InstanceTemplatefmt,"map","instance_template");
+SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template");
 
 void SQLStorage::Free ()
@@ -56,5 +58,5 @@
     uint32 offset=0;
     for(uint32 x=0;x<iNumFields;x++)
-        if (format[x]==FT_STRING)
+        if (dst_format[x]==FT_STRING)
         {
             for(uint32 y=0;y<MaxEntry;y++)
@@ -62,12 +64,12 @@
                     delete [] *(char**)((char*)(pIndex[y])+offset);
 
-            offset+=sizeof(char*);
+            offset += sizeof(char*);
         }
-        else if (format[x]==FT_LOGIC)
-            offset+=sizeof(bool);
-        else if (format[x]==FT_BYTE)
-            offset+=sizeof(char);
+        else if (dst_format[x]==FT_LOGIC)
+            offset += sizeof(bool);
+        else if (dst_format[x]==FT_BYTE)
+            offset += sizeof(char);
         else
-            offset+=4;
+            offset += 4;
 
     delete [] pIndex;
@@ -75,119 +77,7 @@
 }
 
-void SQLStorage::Load ()
+void SQLStorage::Load()
 {
-    uint32 maxi;
-    Field *fields;
-    QueryResult *result  = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s",entry_field,table);
-    if(!result)
-    {
-        sLog.outError("Error loading %s table (not exist?)\n",table);
-        exit(1);                                            // Stop server at loading non exited table or not accessable table
-    }
-
-    maxi= (*result)[0].GetUInt32()+1;
-    delete result;
-
-    result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s",table);
-    if(result)
-    {
-        fields = result->Fetch();
-        RecordCount=fields[0].GetUInt32();
-        delete result;
-    }
-    else
-        RecordCount = 0;
-
-    result = WorldDatabase.PQuery("SELECT * FROM %s",table);
-
-    if(!result)
-    {
-        sLog.outError("%s table is empty!\n",table);
-        RecordCount = 0;
-        return;
-    }
-
-    uint32 recordsize=0;
-    uint32 offset=0;
-
-    if(iNumFields!=result->GetFieldCount())
-    {
-        RecordCount = 0;
-        sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n",table,iNumFields);
-        delete result;
-        exit(1);                                            // Stop server at loading broken or non-compatiable table.
-    }
-
-    //get struct size
-    uint32 sc=0;
-    uint32 bo=0;
-    uint32 bb=0;
-    for(uint32 x=0;x<iNumFields;x++)
-        if(format[x]==FT_STRING)
-            ++sc;
-        else if (format[x]==FT_LOGIC)
-            ++bo;
-        else if (format[x]==FT_BYTE)
-            ++bb;
-    recordsize=(iNumFields-sc-bo-bb)*4+sc*sizeof(char*)+bo*sizeof(bool)+bb*sizeof(char);
-
-    char** newIndex=new char*[maxi];
-    memset(newIndex,0,maxi*sizeof(char*));
-
-    char * _data= new char[RecordCount *recordsize];
-    uint32 count=0;
-    barGoLink bar( RecordCount );
-    do
-    {
-        fields = result->Fetch();
-        bar.step();
-        char *p=(char*)&_data[recordsize*count];
-        newIndex[fields[0].GetUInt32()]=p;
-
-        offset=0;
-        for(uint32 x=0;x<iNumFields;x++)
-            switch(format[x])
-            {
-                case FT_LOGIC:
-                    *((bool*)(&p[offset]))=(fields[x].GetUInt32()>0);
-                    offset+=sizeof(bool);
-                    break;
-                case FT_BYTE:
-                    *((char*)(&p[offset]))=(fields[x].GetUInt8());
-                    offset+=sizeof(char);
-                    break;
-                case FT_INT:
-                    *((uint32*)(&p[offset]))=fields[x].GetUInt32();
-                    offset+=sizeof(uint32);
-                    break;
-                case FT_FLOAT:
-                    *((float*)(&p[offset]))=fields[x].GetFloat();
-                    offset+=sizeof(float);
-                    break;
-                case FT_STRING:
-                    char const* tmp = fields[x].GetString();
-                    char* st;
-                    if(!tmp)
-                    {
-                        st=new char[1];
-                        *st=0;
-                    }
-                    else
-                    {
-                        uint32 l=strlen(tmp)+1;
-                        st=new char[l];
-                        memcpy(st,tmp,l);
-                    }
-                    *((char**)(&p[offset]))=st;
-                    offset+=sizeof(char*);
-                    break;
-            }
-        ++count;
-    }while( result->NextRow() );
-
-    delete result;
-
-    pIndex =newIndex;
-    MaxEntry=maxi;
-    data=_data;
+    SQLStorageLoader loader;
+    loader.Load(*this);
 }
Index: trunk/src/shared/Database/dbcfile.cpp
===================================================================
--- trunk/src/shared/Database/dbcfile.cpp (revision 102)
+++ trunk/src/shared/Database/dbcfile.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/shared/Database/DBCStores.h
===================================================================
--- trunk/src/shared/Database/DBCStores.h (revision 102)
+++ trunk/src/shared/Database/DBCStores.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -76,5 +76,4 @@
         bool Load(char const* fn)
         {
-
             DBCFile dbc;
             // Check if load was sucessful, only then continue
Index: trunk/src/shared/ProgressBar.cpp
===================================================================
--- trunk/src/shared/ProgressBar.cpp (revision 102)
+++ trunk/src/shared/ProgressBar.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/Bag.cpp
===================================================================
--- trunk/src/game/Bag.cpp (revision 177)
+++ trunk/src/game/Bag.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -42,5 +42,5 @@
     for(int i = 0; i < MAX_BAG_SIZE; ++i)
         if (m_bagslot[i])
-             delete m_bagslot[i];
+            delete m_bagslot[i];
 }
 
@@ -72,5 +72,5 @@
     Object::_Create( guidlow, 0, HIGHGUID_CONTAINER );
 
-    SetUInt32Value(OBJECT_FIELD_ENTRY, itemid);
+    SetEntry(itemid);
     SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
 
@@ -86,5 +86,5 @@
     SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots);
 
-    // Cleanning 20 slots
+    // Cleaning 20 slots
     for (uint8 i = 0; i < MAX_BAG_SIZE; i++)
     {
@@ -214,4 +214,5 @@
             if(m_bagslot[i]->GetGUID() == guid)
                 return i;
+
     return NULL_SLOT;
 }
@@ -221,5 +222,5 @@
     if( slot < GetBagSize() )
         return m_bagslot[slot];
-        
+
     return NULL;
 }
Index: trunk/src/game/Level3.cpp
===================================================================
--- trunk/src/game/Level3.cpp (revision 235)
+++ trunk/src/game/Level3.cpp (revision 260)
@@ -136,4 +136,5 @@
     HandleReloadSpellScriptsCommand("a");
     SendGlobalSysMessage("DB tables `*_scripts` reloaded.");
+    HandleReloadDbScriptStringCommand("a");
     return true;
 }
@@ -599,4 +600,12 @@
         SendGlobalSysMessage("DB table `spell_scripts` reloaded.");
 
+    return true;
+}
+
+bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg)
+{
+    sLog.outString( "Re-Loading Script strings from `db_script_string`...");
+    objmgr.LoadDbScriptStrings();
+    SendGlobalSysMessage("DB table `db_script_string` reloaded.");
     return true;
 }
@@ -1768,5 +1777,6 @@
         // search highest talent rank
         uint32 spellid = 0;
-        for(int rank = 4; rank >= 0; --rank)
+        int rank = 4;
+        for(; rank >= 0; --rank)
         {
             if(talentInfo->RankID[rank]!=0)
@@ -4646,89 +4656,147 @@
 }
 
-bool ChatHandler::HandleShutDownCommand(const char* args)
+bool ChatHandler::HandleServerShutDownCancelCommand(const char* args)
+{
+    sWorld.ShutdownCancel();
+    return true;
+}
+
+bool ChatHandler::HandleServerShutDownCommand(const char* args)
 {
     if(!*args)
         return false;
 
-    if(std::string(args)=="cancel")
-    {
-        sWorld.ShutdownCancel();
+    char* time_str = strtok ((char*) args, " ");
+    char* exitcode_str = strtok (NULL, "");
+
+    int32 time = atoi (time_str);
+
+    ///- Prevent interpret wrong arg value as 0 secs shutdown time
+    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
+        return false;
+
+    if (exitcode_str)
+    {
+        int32 exitcode = atoi (exitcode_str);
+
+        // Handle atoi() errors
+        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
+            return false;
+
+        // Exit code should be in range of 0-125, 126-255 is used
+        // in many shells for their own return codes and code > 255
+        // is not supported in many others
+        if (exitcode < 0 || exitcode > 125)
+            return false;
+
+        sWorld.ShutdownServ (time, 0, exitcode);
     }
     else
-    {
-        int32 time = atoi(args);
-
-        ///- Prevent interpret wrong arg value as 0 secs shutdown time
-        if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0)
+        sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE);
+    return true;
+}
+
+bool ChatHandler::HandleServerRestartCommand(const char* args)
+{
+    if(!*args)
+        return false;
+
+    char* time_str = strtok ((char*) args, " ");
+    char* exitcode_str = strtok (NULL, "");
+
+    int32 time = atoi (time_str);
+
+    ///- Prevent interpret wrong arg value as 0 secs shutdown time
+    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
+        return false;
+
+    if (exitcode_str)
+    {
+        int32 exitcode = atoi (exitcode_str);
+
+        // Handle atoi() errors
+        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
             return false;
 
-        sWorld.ShutdownServ(time);
-    }
-    return true;
-}
-
-bool ChatHandler::HandleRestartCommand(const char* args)
+        // Exit code should be in range of 0-125, 126-255 is used
+        // in many shells for their own return codes and code > 255
+        // is not supported in many others
+        if (exitcode < 0 || exitcode > 125)
+            return false;
+
+        sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART, exitcode);
+    }
+    else
+        sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART, RESTART_EXIT_CODE);
+    return true;
+}
+
+bool ChatHandler::HandleServerIdleRestartCommand(const char* args)
 {
     if(!*args)
         return false;
 
-    if(std::string(args)=="cancel")
-    {
-        sWorld.ShutdownCancel();
+    char* time_str = strtok ((char*) args, " ");
+    char* exitcode_str = strtok (NULL, "");
+
+    int32 time = atoi (time_str);
+
+    ///- Prevent interpret wrong arg value as 0 secs shutdown time
+    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
+        return false;
+
+    if (exitcode_str)
+    {
+        int32 exitcode = atoi (exitcode_str);
+
+        // Handle atoi() errors
+        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
+            return false;
+
+        // Exit code should be in range of 0-125, 126-255 is used
+        // in many shells for their own return codes and code > 255
+        // is not supported in many others
+        if (exitcode < 0 || exitcode > 125)
+            return false;
+
+        sWorld.ShutdownServ (time, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode);
     }
     else
-    {
-        int32 time = atoi(args);
-
-        ///- Prevent interpret wrong arg value as 0 secs shutdown time
-        if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0)
+        sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE,RESTART_EXIT_CODE);
+    return true;
+}
+
+bool ChatHandler::HandleServerIdleShutDownCommand(const char* args)
+{
+    if(!*args)
+        return false;
+
+    char* time_str = strtok ((char*) args, " ");
+    char* exitcode_str = strtok (NULL, "");
+
+    int32 time = atoi (time_str);
+
+    ///- Prevent interpret wrong arg value as 0 secs shutdown time
+    if(time == 0 && (time_str[0]!='0' || time_str[1]!='\0') || time < 0)
+        return false;
+
+    if (exitcode_str)
+    {
+        int32 exitcode = atoi (exitcode_str);
+
+        // Handle atoi() errors
+        if (exitcode == 0 && (exitcode_str[0] != '0' || exitcode_str[1] != '\0'))
             return false;
 
-        sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART);
-    }
-    return true;
-}
-
-bool ChatHandler::HandleIdleRestartCommand(const char* args)
-{
-    if(!*args)
-        return false;
-
-    if(std::string(args)=="cancel")
-    {
-        sWorld.ShutdownCancel();
+        // Exit code should be in range of 0-125, 126-255 is used
+        // in many shells for their own return codes and code > 255
+        // is not supported in many others
+        if (exitcode < 0 || exitcode > 125)
+            return false;
+
+        sWorld.ShutdownServ (time, SHUTDOWN_MASK_IDLE, exitcode);
     }
     else
-    {
-        int32 time = atoi(args);
-
-        ///- Prevent interpret wrong arg value as 0 secs shutdown time
-        if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0)
-            return false;
-
-        sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE);
-    }
-    return true;
-}
-
-bool ChatHandler::HandleIdleShutDownCommand(const char* args)
-{
-    if(!*args)
-        return false;
-
-    if(std::string(args)=="cancel")
-    {
-        sWorld.ShutdownCancel();
-    }
-    else
-    {
-        int32 time = atoi(args);
-
-        ///- Prevent interpret wrong arg value as 0 secs shutdown time
-        if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0)
-            return false;
-
-        sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE);
-    }
+        sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE);
     return true;
 }
Index: trunk/src/game/WaypointMovementGenerator.cpp
===================================================================
--- trunk/src/game/WaypointMovementGenerator.cpp (revision 229)
+++ trunk/src/game/WaypointMovementGenerator.cpp (revision 260)
@@ -22,9 +22,9 @@
 creature_movement Table
 
-alter table creature_movement add `text1` varchar(255) default NULL;
-alter table creature_movement add `text2` varchar(255) default NULL;
-alter table creature_movement add `text3` varchar(255) default NULL;
-alter table creature_movement add `text4` varchar(255) default NULL;
-alter table creature_movement add `text5` varchar(255) default NULL;
+alter table creature_movement add `textid1` int(11) NOT NULL default '0';
+alter table creature_movement add `textid2` int(11) NOT NULL default '0';
+alter table creature_movement add `textid3` int(11) NOT NULL default '0';
+alter table creature_movement add `textid4` int(11) NOT NULL default '0';
+alter table creature_movement add `textid5` int(11) NOT NULL default '0';
 alter table creature_movement add `emote` int(10) unsigned default '0';
 alter table creature_movement add `spell` int(5) unsigned default '0';
@@ -149,20 +149,19 @@
                 if(behavior->model1 != 0)
                     creature.SetDisplayId(behavior->model1);
-                if(!behavior->text[0].empty())
+                if(behavior->textid[0])
                 {
-                    // Only one text is set
-                    if( !behavior->text[1].empty() )
+                    // Not only one text is set
+                    if( behavior->textid[1] )
                     {
                         // Select one from max 5 texts (0 and 1 already checked)
                         int i = 2;
-                        for( ; i < 5; ++i )
-                            if( behavior->text[i].empty() )
+                        for( ; i < MAX_WAYPOINT_TEXT; ++i )
+                            if( !behavior->textid[i] )
                                 break;
 
-                        creature.Say(behavior->text[rand() % i].c_str(), 0, 0);
-
+                        creature.Say(behavior->textid[rand() % i], 0, 0);
                     }
                     else
-                        creature.Say(behavior->text[0].c_str(), 0, 0);
+                        creature.Say(behavior->textid[0], 0, 0);
                 }
             }                                               // wpBehaviour found
Index: trunk/src/game/GameObject.h
===================================================================
--- trunk/src/game/GameObject.h (revision 230)
+++ trunk/src/game/GameObject.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -358,5 +358,5 @@
         } raw;
     };
-    char   *ScriptName;
+    uint32 ScriptId;
 };
 
Index: trunk/src/game/CreatureAIImpl.h
===================================================================
--- trunk/src/game/CreatureAIImpl.h (revision 102)
+++ trunk/src/game/CreatureAIImpl.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #ifndef CREATUREAIIMPL_H
Index: trunk/src/game/SpellHandler.cpp
===================================================================
--- trunk/src/game/SpellHandler.cpp (revision 252)
+++ trunk/src/game/SpellHandler.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -55,4 +55,10 @@
     }
 
+    if(pItem->GetGUID() != item_guid)
+    {
+        pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL );
+        return;
+    }
+
     sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, spell_count: %u , cast_count: %u, Item: %u, data length = %i", bagIndex, slot, spell_count, cast_count, pItem->GetEntry(), recvPacket.size());
 
@@ -238,5 +244,5 @@
 
             pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
-            pItem->SetUInt32Value(OBJECT_FIELD_ENTRY, entry);
+            pItem->SetEntry(entry);
             pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
             pItem->SetState(ITEM_CHANGED, pUser);
@@ -260,5 +266,4 @@
 
     uint64 guid;
-    uint32 spellId = OPEN_CHEST;
 
     recv_data >> guid;
@@ -323,5 +328,5 @@
 
     Spell *spell = new Spell(_player, spellInfo, false);
-    spell->m_cast_count = cast_count;                       //set count of casts
+    spell->m_cast_count = cast_count;                       // set count of casts
     spell->prepare(&targets);
 }
Index: trunk/src/game/MapManager.h
===================================================================
--- trunk/src/game/MapManager.h (revision 206)
+++ trunk/src/game/MapManager.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -28,4 +28,5 @@
 #include "Map.h"
 #include "GridStates.h"
+
 class Transport;
 
@@ -45,5 +46,5 @@
         // only const version for outer users
         Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); }
-        void DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode);
+        void DeleteInstance(uint32 mapid, uint32 instanceId);
 
         inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const
Index: trunk/src/game/Chat.cpp
===================================================================
--- trunk/src/game/Chat.cpp (revision 233)
+++ trunk/src/game/Chat.cpp (revision 260)
@@ -64,14 +64,42 @@
     };
 
+    static ChatCommand serverIdleRestartCommandTable[] =
+    {
+        { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
+        { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerIdleRestartCommand,   "", NULL },
+        { NULL,             0,                  false, NULL,                                           "", NULL }
+    };
+
+    static ChatCommand serverIdleShutdownCommandTable[] =
+    {
+        { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
+        { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerIdleShutDownCommand,  "", NULL },
+        { NULL,             0,                  false, NULL,                                           "", NULL }
+    };
+
+    static ChatCommand serverRestartCommandTable[] =
+    {
+        { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
+        { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerRestartCommand,       "", NULL },
+        { NULL,             0,                  false, NULL,                                           "", NULL }
+    };
+
+    static ChatCommand serverShutdownCommandTable[] =
+    {
+        { "cancel",         SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCancelCommand,"", NULL },
+        { ""   ,            SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleServerShutDownCommand,      "", NULL },
+        { NULL,             0,                  false, NULL,                                           "", NULL }
+    };
+
     static ChatCommand serverCommandTable[] =
     {
         { "corpses",        SEC_GAMEMASTER,     true,  &ChatHandler::HandleServerCorpsesCommand,       "", NULL },
         { "exit",           SEC_CONSOLE,        true,  &ChatHandler::HandleServerExitCommand,          "", NULL },
-        { "idlerestart",    SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleIdleRestartCommand,         "", NULL },
-        { "idleshutdown",   SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleIdleShutDownCommand,        "", NULL },
+        { "idlerestart",    SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverIdleRestartCommandTable },
+        { "idleshutdown",   SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverShutdownCommandTable },
         { "info",           SEC_PLAYER,         true,  &ChatHandler::HandleServerInfoCommand,          "", NULL },
         { "motd",           SEC_PLAYER,         true,  &ChatHandler::HandleServerMotdCommand,          "", NULL },
-        { "restart",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleRestartCommand,             "", NULL },
-        { "shutdown",       SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleShutDownCommand,            "", NULL },
+        { "restart",        SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverRestartCommandTable },
+        { "shutdown",       SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverShutdownCommandTable },
         { "set",            SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverSetCommandTable },
         { NULL,             0,                  false, NULL,                                           "", NULL }
Index: trunk/src/game/ItemEnchantmentMgr.cpp
===================================================================
--- trunk/src/game/ItemEnchantmentMgr.cpp (revision 206)
+++ trunk/src/game/ItemEnchantmentMgr.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/Map.h
===================================================================
--- trunk/src/game/Map.h (revision 257)
+++ trunk/src/game/Map.h (revision 260)
@@ -106,5 +106,5 @@
     float startLocZ;
     float startLocO;
-    char const* script;
+    uint32 script_id;
 };
 
@@ -344,5 +344,5 @@
         void CreateInstanceData(bool load);
         bool Reset(uint8 method);
-        std::string GetScript() { return i_script; }
+        uint32 GetScriptId() { return i_script_id; }
         InstanceData* GetInstanceData() { return i_data; }
         void PermBindAllPlayers(Player *player);
@@ -356,8 +356,5 @@
         bool m_unloadWhenEmpty;
         InstanceData* i_data;
-        std::string i_script;
-        // only online players that are inside the instance currently
-        // TODO ? - use the grid instead to access the players
-        PlayerList i_Players;
+        uint32 i_script_id;
 };
 
Index: trunk/src/game/WaypointManager.cpp
===================================================================
--- trunk/src/game/WaypointManager.cpp (revision 207)
+++ trunk/src/game/WaypointManager.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -25,4 +25,5 @@
 #include "ProgressBar.h"
 #include "MapManager.h"
+#include "ObjectMgr.h"
 
 INSTANTIATE_SINGLETON_1(WaypointManager);
@@ -30,13 +31,22 @@
 bool WaypointBehavior::isEmpty()
 {
-    return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() &&
-        text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty();
+    if (emote || spell || model1 || model2)
+        return false;
+
+    for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
+        if(textid[i])
+            return false;
+
+    return true;
 }
 
 WaypointBehavior::WaypointBehavior(const WaypointBehavior &b)
 {
-    emote = b.emote; spell = b.spell; model1 = b.model1; model2 = b.model2;
-    text[0] = b.text[0]; text[1] = b.text[1]; text[2] = b.text[2];
-    text[3] = b.text[3]; text[4] = b.text[4];
+    emote = b.emote;
+    spell = b.spell;
+    model1 = b.model1;
+    model2 = b.model2;
+    for(int i=0; i < MAX_WAYPOINT_TEXT; ++i)
+        textid[i] = b.textid[i];
 }
 
@@ -67,5 +77,5 @@
     }
 
-    result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id, point FROM creature_movement");
+    result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");
     if(result)
     {
@@ -114,9 +124,31 @@
             be.emote            = fields[7].GetUInt32();
             be.spell            = fields[8].GetUInt32();
-            be.text[0]          = fields[9].GetCppString();
-            be.text[1]          = fields[10].GetCppString();
-            be.text[2]          = fields[11].GetCppString();
-            be.text[3]          = fields[12].GetCppString();
-            be.text[4]          = fields[13].GetCppString();
+
+            // load and store without holes in array
+            int j = 0;
+            for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
+            {
+                be.textid[j]        = fields[9+i].GetUInt32();
+                if(be.textid[j])
+                {
+                    if (be.textid[j] < MIN_DB_SCRIPT_STRING_ID || be.textid[j] >= MAX_DB_SCRIPT_STRING_ID)
+                    {
+                        sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[j]);
+                        continue;
+                    }
+
+                    if (!objmgr.GetTrinityStringLocale (be.textid[j]))
+                    {
+                        sLog.outErrorDb("ERROR: Waypoint path %d (point %d), have invalid text id (%i) in `textid%d, ignored.",
+                            id, point, be.textid[j], i+1);
+                        continue;
+                    }
+
+                    ++j;                                    // to next internal field
+                }
+            }
+            // fill array tail
+            for(; j < MAX_WAYPOINT_TEXT; ++j)
+                be.textid[j] = 0;
 
             // save memory by not storing empty behaviors
@@ -266,9 +298,9 @@
         if(!node.behavior) node.behavior = new WaypointBehavior();
 
-        if(field == "text1") node.behavior->text[0] = text ? text : "";
-        if(field == "text2") node.behavior->text[1] = text ? text : "";
-        if(field == "text3") node.behavior->text[2] = text ? text : "";
-        if(field == "text4") node.behavior->text[3] = text ? text : "";
-        if(field == "text5") node.behavior->text[4] = text ? text : "";
+//        if(field == "text1") node.behavior->text[0] = text ? text : "";
+//        if(field == "text2") node.behavior->text[1] = text ? text : "";
+//        if(field == "text3") node.behavior->text[2] = text ? text : "";
+//        if(field == "text4") node.behavior->text[3] = text ? text : "";
+//        if(field == "text5") node.behavior->text[4] = text ? text : "";
         if(field == "emote") node.behavior->emote   = text ? atoi(text) : 0;
         if(field == "spell") node.behavior->spell   = text ? atoi(text) : 0;
Index: trunk/src/game/GMTicketMgr.h
===================================================================
--- trunk/src/game/GMTicketMgr.h (revision 229)
+++ trunk/src/game/GMTicketMgr.h (revision 260)
@@ -51,5 +51,8 @@
             m_text = text ? text : "";
             m_lastUpdate = time(NULL);
-            CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid);
+
+            std::string escapedString = m_text;
+            CharacterDatabase.escape_string(escapedString);
+            CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid);
         }
 
@@ -63,5 +66,9 @@
             CharacterDatabase.BeginTransaction();
             DeleteFromDB();
-            CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText());
+
+            std::string escapedString = m_text;
+            CharacterDatabase.escape_string(escapedString);
+
+            CharacterDatabase.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, escapedString.c_str());
             CharacterDatabase.CommitTransaction();
         }
Index: trunk/src/game/CreatureAISelector.cpp
===================================================================
--- trunk/src/game/CreatureAISelector.cpp (revision 174)
+++ trunk/src/game/CreatureAISelector.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/ArenaTeam.cpp
===================================================================
--- trunk/src/game/ArenaTeam.cpp (revision 247)
+++ trunk/src/game/ArenaTeam.cpp (revision 260)
Index: trunk/src/game/World.cpp
===================================================================
--- trunk/src/game/World.cpp (revision 230)
+++ trunk/src/game/World.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -67,4 +67,5 @@
 
 volatile bool World::m_stopEvent = false;
+uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
 volatile uint32 World::m_worldLoopCounter = 0;
 
@@ -543,5 +544,4 @@
         m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME);
 
-
     m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74);
     /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define
@@ -606,5 +606,4 @@
     }
 
-
     if(reload)
     {
@@ -770,6 +769,6 @@
     m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100);
 
-    // always use declined names in the Russian client
-    m_configs[CONFIG_DECLINED_NAMES_USED] = 
+    // always use declined names in the russian client
+    m_configs[CONFIG_DECLINED_NAMES_USED] =
         (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false);
 
@@ -966,4 +965,7 @@
     DetectDBCLang();
 
+    sLog.outString( "Loading Script Names...");
+    objmgr.LoadScriptNames();
+
     sLog.outString( "Loading InstanceTemplate" );
     objmgr.LoadInstanceTemplate();
@@ -1081,8 +1083,7 @@
     sLog.outString( "Loading Tavern Area Triggers..." );
     objmgr.LoadTavernAreaTriggers();
-    
+
     sLog.outString( "Loading AreaTrigger script names..." );
     objmgr.LoadAreaTriggerScripts();
-
 
     sLog.outString( "Loading Graveyard-zone links...");
@@ -1165,5 +1166,5 @@
     sLog.outString( "Loading Npc Text Id..." );
     objmgr.LoadNpcTextId();                                 // must be after load Creature and NpcText
-    
+
     sLog.outString( "Loading Npc Options..." );
     objmgr.LoadNpcOptions();
@@ -1193,4 +1194,7 @@
     objmgr.LoadEventScripts();                              // must be after load Creature/Gameobject(Template/Data)
 
+    sLog.outString( "Loading Scripts text locales..." );    // must be after Load*Scripts calls
+    objmgr.LoadDbScriptStrings();
+
     sLog.outString( "Initializing Scripts..." );
     if(!LoadScriptingModule())
@@ -1263,4 +1267,5 @@
     sLog.outString( "WORLD: World initialized" );
 }
+
 void World::DetectDBCLang()
 {
@@ -1463,5 +1468,7 @@
     }
 
-    MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
+    /// </ul>
+    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
+    MapManager::Instance().DoDelayedMovesAndRemoves();
 
     // update the instance reset times
@@ -1583,4 +1590,6 @@
         }
 
+        //if(source && !source->IsInWorld()) source = NULL;
+
         Object* target = NULL;
 
@@ -1610,4 +1619,6 @@
         }
 
+        //if(target && !target->IsInWorld()) target = NULL;
+
         switch (step.script->command)
         {
@@ -1637,5 +1648,5 @@
                 {
                     case 0:                                 // Say
-                        ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target);
+                        ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target);
                         break;
                     case 1:                                 // Whisper
@@ -1645,11 +1656,11 @@
                             break;
                         }
-                        ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target);
+                        ((Creature *)source)->Whisper(step.script->dataint,unit_target);
                         break;
                     case 2:                                 // Yell
-                        ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target);
+                        ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target);
                         break;
                     case 3:                                 // Emote text
-                        ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target);
+                        ((Creature *)source)->TextEmote(step.script->dataint, unit_target);
                         break;
                     default:
@@ -1702,5 +1713,5 @@
                 }
                 ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 );
-                MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
+                ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
                 break;
             case SCRIPT_COMMAND_FLAG_SET:
@@ -1852,5 +1863,5 @@
                 go->SetRespawnTime(time_to_despawn);        //despawn object in ? seconds
 
-                MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go);
+                go->GetMap()->Add(go);
                 break;
             }
@@ -2374,5 +2385,5 @@
 
     ///- if there is a shutdown timer
-    if(m_ShutdownTimer > 0 && elapsed > 0)
+    if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0)
     {
         ///- ... and it is overdue, stop the world (set m_stopEvent)
@@ -2380,5 +2391,5 @@
         {
             if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0)
-                m_stopEvent = true;
+                m_stopEvent = true;                         // exist code already set
             else
                 m_ShutdownTimer = 1;                        // minimum timer value to wait idle state
@@ -2395,7 +2406,12 @@
 
 /// Shutdown the server
-void World::ShutdownServ(uint32 time, uint32 options)
-{
+void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
+{
+    // ignore if server shutdown at next tick
+    if(m_stopEvent)
+        return;
+
     m_ShutdownMask = options;
+    m_ExitCode = exitcode;
 
     ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
@@ -2403,5 +2419,5 @@
     {
         if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0)
-            m_stopEvent = true;
+            m_stopEvent = true;                             // exist code already set
         else
             m_ShutdownTimer = 1;                            //So that the session count is re-evaluated at next world tick
@@ -2448,5 +2464,6 @@
 void World::ShutdownCancel()
 {
-    if(!m_ShutdownTimer)
+    // nothing cancel or too later
+    if(!m_ShutdownTimer || m_stopEvent)
         return;
 
@@ -2455,7 +2472,8 @@
     m_ShutdownMask = 0;
     m_ShutdownTimer = 0;
+    m_ExitCode = SHUTDOWN_EXIT_CODE;                       // to default value
     SendServerMessage(msgid);
 
-    DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
+    DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
 }
 
@@ -2502,4 +2520,5 @@
         if(!itr->second->Update(diff))                      // As interval = 0
         {
+            RemoveQueuedPlayer (itr->second);
             delete itr->second;
             m_sessions.erase(itr);
Index: trunk/src/game/ItemEnchantmentMgr.h
===================================================================
--- trunk/src/game/ItemEnchantmentMgr.h (revision 102)
+++ trunk/src/game/ItemEnchantmentMgr.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/Item.h
===================================================================
--- trunk/src/game/Item.h (revision 102)
+++ trunk/src/game/Item.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -229,5 +229,4 @@
         bool GemsFitSockets() const;
 
-        uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
         uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); }
         void SetCount(uint32 value) { SetUInt32Value (ITEM_FIELD_STACK_COUNT, value); }
Index: trunk/src/game/Mail.cpp
===================================================================
--- trunk/src/game/Mail.cpp (revision 229)
+++ trunk/src/game/Mail.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -188,5 +188,4 @@
                 return;
             }
-
             if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION))
             {
@@ -195,9 +194,9 @@
             }
 
-			if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
-			{
-				pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD);
-				return;
-			}
+            if(COD && mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
+            {
+                pl->SendMailResult(0, 0, MAIL_ERR_CANT_SEND_WRAPPED_COD);
+                return;
+            }
         }
     }
Index: trunk/src/game/Creature.cpp
===================================================================
--- trunk/src/game/Creature.cpp (revision 230)
+++ trunk/src/game/Creature.cpp (revision 260)
@@ -178,5 +178,5 @@
     float x,y,z,o;
     GetRespawnCoord(x, y, z, &o);
-    MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o);
+    GetMap()->CreatureRelocation(this,x,y,z,o);
 }
 
@@ -210,5 +210,5 @@
     }
 
-    SetUInt32Value(OBJECT_FIELD_ENTRY, Entry);              // normal entry always
+    SetEntry(Entry);                                        // normal entry always
     m_creatureInfo = cinfo;                                 // map mode related always
 
@@ -353,5 +353,5 @@
                 lootForBody         = false;
 
-                if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY))
+                if(m_originalEntry != GetEntry())
                     UpdateEntry(m_originalEntry);
 
@@ -372,7 +372,7 @@
 
                 //Call AI respawn virtual function
-                AI()->JustRespawned();
-
-                MapManager::Instance().GetMap(GetMapId(), this)->Add(this);
+                i_AI->JustRespawned();
+
+                GetMap()->Add(this);
             }
             break;
@@ -436,5 +436,5 @@
                 // do not allow the AI to be changed during update
                 m_AI_locked = true;
-                AI()->UpdateAI(diff);
+                i_AI->UpdateAI(diff);
                 m_AI_locked = false;
             }
@@ -2097,7 +2097,12 @@
 }
 
-char const* Creature::GetScriptName() const
-{
-    return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName;
+std::string Creature::GetScriptName()
+{
+    return objmgr.GetScriptName(GetScriptId());
+}
+
+uint32 Creature::GetScriptId()
+{
+    return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID;
 }
 
Index: trunk/src/game/CreatureAIRegistry.cpp
===================================================================
--- trunk/src/game/CreatureAIRegistry.cpp (revision 174)
+++ trunk/src/game/CreatureAIRegistry.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/Map.cpp
===================================================================
--- trunk/src/game/Map.cpp (revision 257)
+++ trunk/src/game/Map.cpp (revision 260)
@@ -1714,5 +1714,5 @@
     if (mInstance)
     {
-        i_script = mInstance->script;
+        i_script_id = mInstance->script_id;
         i_data = Script->CreateInstanceData(this);
     }
@@ -1731,5 +1731,5 @@
             if(data)
             {
-                sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId);
+                sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId);
                 i_data->Load(data);
             }
@@ -1739,5 +1739,5 @@
     else
     {
-        sLog.outDebug("New instance data, \"%s\" ,initialized!",i_script.c_str());
+        sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id));
         i_data->Initialize();
     }
Index: trunk/src/game/Creature.h
===================================================================
--- trunk/src/game/Creature.h (revision 230)
+++ trunk/src/game/Creature.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -206,8 +206,9 @@
     uint32  MechanicImmuneMask;
     uint32  flags_extra;
-    char const* ScriptName;
+    uint32  ScriptID;
     uint32 GetRandomValidModelId() const;
     uint32 GetFirstValidModelId() const;
-    
+
+    // helpers
     SkillType GetRequiredLootSkill() const
     {
@@ -219,5 +220,5 @@
             return SKILL_SKINNING;                          // normal case
     }
-    
+
     bool isTameable() const
     {
@@ -499,5 +500,7 @@
         CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
         CreatureDataAddon const* GetCreatureAddon() const;
-        char const* GetScriptName() const;
+
+        std::string GetScriptName();
+        uint32 GetScriptId();
 
         void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
@@ -525,5 +528,5 @@
         // overwrite WorldObject function for proper name localization
         const char* GetNameForLocaleIdx(int32 locale_idx) const;
-    
+
         void setDeathState(DeathState s);                   // overwrite virtual Unit::setDeathState
 
Index: trunk/src/game/PlayerDump.cpp
===================================================================
--- trunk/src/game/PlayerDump.cpp (revision 112)
+++ trunk/src/game/PlayerDump.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -278,5 +278,5 @@
     // for guid set stop if set is empty
     if(guids && guids->empty())
-        return;                                        // nothing to do
+        return;                                             // nothing to do
 
     // setup for guids case start position
@@ -344,5 +344,5 @@
     FILE *fout = fopen(file.c_str(), "w");
     if (!fout)
-		return DUMP_FILE_OPEN_ERROR;
+        return DUMP_FILE_OPEN_ERROR;
 
     std::string dump = GetDump(guid);
@@ -372,7 +372,8 @@
         }
     }
+
     FILE *fin = fopen(file.c_str(), "r");
     if(!fin)
-		return DUMP_FILE_OPEN_ERROR;
+        return DUMP_FILE_OPEN_ERROR;
 
     QueryResult * result = NULL;
@@ -391,5 +392,6 @@
         else incHighest = false;
     }
-    else guid = objmgr.m_hiCharGuid;
+    else
+        guid = objmgr.m_hiCharGuid;
 
     // normalize the name if specified and check if it exists
@@ -469,5 +471,5 @@
             case DTT_CHAR_TABLE:
                 if(!changenth(line, 1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
 
@@ -475,21 +477,17 @@
             {
                 if(!changenth(line, 1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 // guid, data field:guid, items
                 if(!changenth(line, 2, chraccount))
-					ROLLBACK(DUMP_FILE_BROKEN);
-
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 std::string vals = getnth(line, 3);
                 if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 for(uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++)
                     if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true))
-						ROLLBACK(DUMP_FILE_BROKEN);
-
+                        ROLLBACK(DUMP_FILE_BROKEN);
                 if(!changenth(line, 3, vals.c_str()))
-					ROLLBACK(DUMP_FILE_BROKEN);
-
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 if (name == "")
                 {
@@ -504,9 +502,9 @@
                                                             // rename on login: `at_login` field 30 in raw field list
                         if(!changenth(line, 30, "1"))
-							ROLLBACK(DUMP_FILE_BROKEN);
+                            ROLLBACK(DUMP_FILE_BROKEN);
                     }
                 }
                 else if(!changenth(line, 4, name.c_str()))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 break;
@@ -515,11 +513,11 @@
             {
                 if(!changenth(line, 1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 // bag, item
                 if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
             }
@@ -528,15 +526,14 @@
                 // item, owner, data field:item, owner guid
                 if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changenth(line, 2, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changenth(line, 2, newguid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 std::string vals = getnth(line,3);
                 if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changenth(line, 3, vals.c_str()))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changenth(line, 3, vals.c_str()))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
             }
@@ -545,7 +542,7 @@
                 // guid,item_guid,
                 if(!changenth(line, 1, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
             }
@@ -570,7 +567,7 @@
                 // item, entry, owner, ...
                 if(!changenth(line, 1, newpetid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changenth(line, 3, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changenth(line, 3, newguid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 break;
@@ -583,10 +580,10 @@
                 std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
                 if(petids_iter == petids.end())             // couldn't find new inserted id
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 snprintf(newpetid, 20, "%d", petids_iter->second);
 
                 if(!changenth(line, 1, newpetid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
 
                 break;
@@ -596,7 +593,7 @@
                 // id,messageType,stationery,sender,receiver
                 if(!changeGuid(line, 1, mails, objmgr.m_mailid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changenth(line, 5, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changenth(line, 5, newguid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
             }
@@ -605,9 +602,9 @@
                 // mail_id,item_guid,item_template,receiver
                 if(!changeGuid(line, 1, mails, objmgr.m_mailid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
-					ROLLBACK(DUMP_FILE_BROKEN);
-				if(!changenth(line, 4, newguid))
-					ROLLBACK(DUMP_FILE_BROKEN);
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
+                if(!changenth(line, 4, newguid))
+                    ROLLBACK(DUMP_FILE_BROKEN);
                 break;
             }
@@ -618,5 +615,5 @@
 
         if(!CharacterDatabase.Execute(line.c_str()))
-			ROLLBACK(DUMP_FILE_BROKEN);
+            ROLLBACK(DUMP_FILE_BROKEN);
     }
 
Index: trunk/src/game/Chat.h
===================================================================
--- trunk/src/game/Chat.h (revision 233)
+++ trunk/src/game/Chat.h (revision 260)
@@ -176,4 +176,5 @@
         bool HandleModifyRepCommand(const char* args);
         bool HandleModifyArenaCommand(const char* args);
+        bool HandleModifyGenderCommand(const char* args);
 
         bool HandleNpcAddCommand(const char* args);
@@ -192,4 +193,5 @@
         bool HandleNpcSpawnDistCommand(const char* args);
         bool HandleNpcSpawnTimeCommand(const char* args);
+        bool HandleNpcTameCommand(const char* args);
         bool HandleNpcTextEmoteCommand(const char* args);
         bool HandleNpcUnFollowCommand(const char* args);
@@ -216,4 +218,5 @@
         bool HandleReloadCreatureQuestRelationsCommand(const char* args);
         bool HandleReloadCreatureQuestInvRelationsCommand(const char* args);
+        bool HandleReloadDbScriptStringCommand(const char* args);
         bool HandleReloadGameGraveyardZoneCommand(const char* args);
         bool HandleReloadGameObjectScriptsCommand(const char* args);
@@ -271,8 +274,13 @@
         bool HandleServerCorpsesCommand(const char* args);
         bool HandleServerExitCommand(const char* args);
+        bool HandleServerIdleRestartCommand(const char* args);
+        bool HandleServerIdleShutDownCommand(const char* args);
         bool HandleServerInfoCommand(const char* args);
         bool HandleServerMotdCommand(const char* args);
+        bool HandleServerRestartCommand(const char* args);
         bool HandleServerSetMotdCommand(const char* args);
         bool HandleServerSetLogLevelCommand(const char* args);
+        bool HandleServerShutDownCommand(const char* args);
+        bool HandleServerShutDownCancelCommand(const char* args);
 
         bool HandleAddHonorCommand(const char* args);
@@ -328,9 +336,4 @@
         bool HandleBanListCharacterCommand(const char* args);
         bool HandleBanListIPCommand(const char* args);
-        bool HandleIdleRestartCommand(const char* args);
-        bool HandleIdleShutDownCommand(const char* args);
-        bool HandleShutDownCommand(const char* args);
-        bool HandleRestartCommand(const char* args);
-        bool HandleSecurityCommand(const char* args);
         bool HandleGoXYCommand(const char* args);
         bool HandleGoXYZCommand(const char* args);
@@ -366,5 +369,4 @@
         bool HandleAddItemCommand(const char* args);
         bool HandleAddItemSetCommand(const char* args);
-        bool HandleModifyGenderCommand(const char* args);
         bool HandlePetTpCommand(const char* args);
         bool HandlePetUnlearnCommand(const char* args);
Index: trunk/src/game/ItemHandler.cpp
===================================================================
--- trunk/src/game/ItemHandler.cpp (revision 229)
+++ trunk/src/game/ItemHandler.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -314,7 +314,7 @@
             if (il)
             {
-                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
+                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
                     Name = il->Name[loc_idx];
-                if (il->Description.size() > loc_idx && !il->Description[loc_idx].empty())
+                if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty())
                     Description = il->Description[loc_idx];
             }
@@ -361,4 +361,6 @@
             data << pProto->Damage[i].DamageType;
         }
+
+        // resistances (7)
         data << pProto->Armor;
         data << pProto->HolyRes;
@@ -368,8 +370,9 @@
         data << pProto->ShadowRes;
         data << pProto->ArcaneRes;
+
         data << pProto->Delay;
         data << pProto->Ammo_type;
-
-        data << (float)pProto->RangedModRange;
+        data << pProto->RangedModRange;
+
         for(int s = 0; s < 5; s++)
         {
@@ -977,5 +980,5 @@
             if (il)
             {
-                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
+                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
                     Name = il->Name[loc_idx];
             }
@@ -1028,5 +1031,5 @@
     }
 
-    if(item==gift)                                          // not possible with pacjket from real client
+    if(item==gift)                                          // not possable with pacjket from real client
     {
         _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL );
@@ -1073,14 +1076,14 @@
     CharacterDatabase.BeginTransaction();
     CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
-    item->SetUInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY));
+    item->SetEntry(gift->GetEntry());
 
     switch (item->GetEntry())
     {
-        case 5042:  item->SetUInt32Value(OBJECT_FIELD_ENTRY,  5043); break;
-        case 5048:  item->SetUInt32Value(OBJECT_FIELD_ENTRY,  5044); break;
-        case 17303: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17302); break;
-        case 17304: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17305); break;
-        case 17307: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 17308); break;
-        case 21830: item->SetUInt32Value(OBJECT_FIELD_ENTRY, 21831); break;
+        case 5042:  item->SetEntry( 5043); break;
+        case 5048:  item->SetEntry( 5044); break;
+        case 17303: item->SetEntry(17302); break;
+        case 17304: item->SetEntry(17305); break;
+        case 17307: item->SetEntry(17308); break;
+        case 21830: item->SetEntry(21831); break;
     }
     item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
Index: trunk/src/game/Formulas.h
===================================================================
--- trunk/src/game/Formulas.h (revision 111)
+++ trunk/src/game/Formulas.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -30,5 +30,5 @@
         inline uint32 hk_honor_at_level(uint32 level, uint32 count=1)
         {
-            return (uint32) ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
+            return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
         }
     }
@@ -81,4 +81,5 @@
         inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content)
         {
+            //TODO: need modifier for CONTENT_71_80 different from CONTENT_61_70?
             const uint32 nBaseExp = content == CONTENT_1_60 ? 45 : 235;
             if( mob_level >= pl_level )
Index: trunk/src/game/GMTicketHandler.cpp
===================================================================
--- trunk/src/game/GMTicketHandler.cpp (revision 229)
+++ trunk/src/game/GMTicketHandler.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -67,6 +67,4 @@
     recv_data >> ticketText;
 
-    CharacterDatabase.escape_string(ticketText);
-
     if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
         ticket->SetText(ticketText.c_str());
@@ -106,7 +104,5 @@
     sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2);
 
-    CharacterDatabase.escape_string(ticketText);
-
-    if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
+    if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
     {
         WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
Index: trunk/src/game/CreatureAI.cpp
===================================================================
--- trunk/src/game/CreatureAI.cpp (revision 207)
+++ trunk/src/game/CreatureAI.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
Index: trunk/src/game/World.h
===================================================================
--- trunk/src/game/World.h (revision 229)
+++ trunk/src/game/World.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -52,4 +52,11 @@
 };
 
+enum ShutdownExitCode
+{
+    SHUTDOWN_EXIT_CODE = 0,
+    ERROR_EXIT_CODE    = 1,
+    RESTART_EXIT_CODE  = 2,
+};
+
 /// Timers for different object refresh rates
 enum WorldTimers
@@ -62,6 +69,5 @@
     WUPDATE_CORPSES     = 5,
     WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7,
-
+    WUPDATE_COUNT       = 7
 };
 
@@ -106,4 +112,6 @@
     CONFIG_INSTANCE_IGNORE_RAID,
     CONFIG_BATTLEGROUND_CAST_DESERTER,
+    CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE,
+    CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY,
     CONFIG_INSTANCE_RESET_TIME_HOUR,
     CONFIG_INSTANCE_UNLOAD_DELAY,
@@ -144,4 +152,5 @@
     CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF,
     CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF,
+    CONFIG_DETECT_POS_COLLISION,
     CONFIG_RESTRICTED_LFG_CHANNEL,
     CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL,
@@ -317,18 +326,18 @@
 struct CliCommandHolder
 {
-	typedef void Print(const char*);
-
-	char *m_command;
-	Print* m_print;
-
-	CliCommandHolder(const char *command, Print* zprint)
-		: m_print(zprint)
-	{
-		size_t len = strlen(command)+1;
-		m_command = new char[len];
-		memcpy(m_command, command, len);
-	}
-
-	~CliCommandHolder() { delete[] m_command; }
+    typedef void Print(const char*);
+
+    char *m_command;
+    Print* m_print;
+
+    CliCommandHolder(const char *command, Print* zprint)
+        : m_print(zprint)
+    {
+        size_t len = strlen(command)+1;
+        m_command = new char[len];
+        memcpy(m_command, command, len);
+    }
+
+    ~CliCommandHolder() { delete[] m_command; }
 };
 
@@ -337,5 +346,4 @@
 {
     public:
-        static volatile bool m_stopEvent;
         static volatile uint32 m_worldLoopCounter;
 
@@ -345,5 +353,4 @@
         WorldSession* FindSession(uint32 id) const;
         void AddSession(WorldSession *s);
-
         bool RemoveSession(uint32 id);
         /// Get the number of current active sessions
@@ -408,5 +415,5 @@
         void LoadConfigSettings(bool reload = false);
 
-        void SendWorldText(int32 string_id, ...); 
+        void SendWorldText(int32 string_id, ...);
         void SendGlobalMessage(WorldPacket *packet, WorldSession *self = 0, uint32 team = 0);
         void SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self = 0, uint32 team = 0);
@@ -415,9 +422,11 @@
 
         /// Are we in the middle of a shutdown?
-        uint32 GetShutdownMask() const { return m_ShutdownMask; }
         bool IsShutdowning() const { return m_ShutdownTimer > 0; }
-        void ShutdownServ(uint32 time, uint32 options = 0);
+        void ShutdownServ(uint32 time, uint32 options, uint8 exitcode);
         void ShutdownCancel();
         void ShutdownMsg(bool show = false, Player* player = NULL);
+        static uint8 GetExitCode() { return m_ExitCode; }
+        static void StopNow(uint8 exitcode) { m_stopEvent = true; m_ExitCode = exitcode; }
+        static bool IsStopped() { return m_stopEvent; }
 
         void Update(time_t diff);
@@ -454,5 +463,5 @@
         void KickAllQueued();
         BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author);
-		bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
+        bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
 
         void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
@@ -482,11 +491,11 @@
         LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; }
 
-		//used World DB version
-		void LoadDBVersion();
-		char const* GetDBVersion() { return m_DBVersion.c_str(); }
-
-		//used Script version
-		void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; }
-		char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }
+        //used World DB version
+        void LoadDBVersion();
+        char const* GetDBVersion() { return m_DBVersion.c_str(); }
+
+        //used Script version
+        void SetScriptsVersion(char const* version) { m_ScriptsVersion = version ? version : "unknown scripting library"; }
+        char const* GetScriptsVersion() { return m_ScriptsVersion.c_str(); }
 
     protected:
@@ -499,4 +508,9 @@
         void ResetDailyQuests();
     private:
+        static volatile bool m_stopEvent;
+        static uint8 m_ExitCode;
+        uint32 m_ShutdownTimer;
+        uint32 m_ShutdownMask;
+
         time_t m_startTime;
         time_t m_gameTime;
@@ -526,7 +540,4 @@
         std::set<uint32> m_forbiddenMapIds;
 
-        uint32 m_ShutdownTimer;
-        uint32 m_ShutdownMask;
-
         // for max speed access
         static float m_MaxVisibleDistanceForCreature;
@@ -546,12 +557,12 @@
         //Player Queue
         Queue m_QueuedPlayer;
-        
+
         //sessions that are added async
         void AddSession_(WorldSession* s);
         ZThread::LockedQueue<WorldSession*, ZThread::FastMutex> addSessQueue;
 
-		//used versions
-		std::string m_DBVersion;
-		std::string m_ScriptsVersion;
+        //used versions
+        std::string m_DBVersion;
+        std::string m_ScriptsVersion;
 };
 
Index: trunk/src/game/Item.cpp
===================================================================
--- trunk/src/game/Item.cpp (revision 102)
+++ trunk/src/game/Item.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -180,5 +180,5 @@
                     return true;
                 case ITEM_SUBCLASS_SOUL_CONTAINER:
-                    if(!(pProto->BagFamily & BAG_FAMILY_MASK_SHARDS))
+                    if(!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS))
                         return false;
                     return true;
@@ -248,5 +248,5 @@
     Object::_Create( guidlow, 0, HIGHGUID_ITEM );
 
-    SetUInt32Value(OBJECT_FIELD_ENTRY, itemid);
+    SetEntry(itemid);
     SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
 
@@ -430,5 +430,5 @@
 ItemPrototype const *Item::GetProto() const
 {
-    return objmgr.GetItemPrototype(GetUInt32Value(OBJECT_FIELD_ENTRY));
+    return objmgr.GetItemPrototype(GetEntry());
 }
 
@@ -763,7 +763,5 @@
 {
     // Better lost small time at check in comparison lost time at item save to DB.
-    if( GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET)==id &&
-        GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration &&
-        GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET)==charges )
+    if((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
         return;
 
@@ -776,5 +774,5 @@
 void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
 {
-    if(GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration)
+    if(GetEnchantmentDuration(slot) == duration)
         return;
 
@@ -785,4 +783,7 @@
 void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
 {
+    if(GetEnchantmentCharges(slot) == charges)
+        return;
+
     SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges);
     SetState(ITEM_CHANGED);
@@ -791,9 +792,9 @@
 void Item::ClearEnchantment(EnchantmentSlot slot)
 {
-    if(!GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET))
-        return;
-
-    for(int x=0;x<3;x++)
-        SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x,0);
+    if(!GetEnchantmentId(slot))
+        return;
+
+    for(uint8 x = 0; x < 3; ++x)
+        SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
     SetState(ITEM_CHANGED);
 }
Index: trunk/src/game/MapManager.cpp
===================================================================
--- trunk/src/game/MapManager.cpp (revision 257)
+++ trunk/src/game/MapManager.cpp (revision 260)
@@ -223,5 +223,5 @@
 }
 
-void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode)
+void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
 {
     Map *m = _GetBaseMap(mapid);
Index: trunk/src/game/ObjectMgr.h
===================================================================
--- trunk/src/game/ObjectMgr.h (revision 206)
+++ trunk/src/game/ObjectMgr.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -85,5 +85,5 @@
     uint32 datalong;
     uint32 datalong2;
-    std::string datatext;
+    int32  dataint;
     float x;
     float y;
@@ -128,4 +128,11 @@
 
 typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes;
+
+
+// mangos string ranges
+#define MIN_TRINITY_STRING_ID    1
+#define MAX_TRINITY_STRING_ID    2000000000
+#define MIN_DB_SCRIPT_STRING_ID MAX_TRINITY_STRING_ID
+#define MAX_DB_SCRIPT_STRING_ID 2000010000
 
 struct TrinityStringLocale
@@ -208,6 +215,6 @@
     CONDITION_QUESTTAKEN            = 9,                    // quest_id     0,      for condition true while quest active.
     CONDITION_AD_COMMISSION_AURA    = 10,                   // 0            0,      for condition true while one from AD ñommission aura active
-	CONDITION_NO_AURA               = 11,                   // spell_id     effindex
-	CONDITION_ACTIVE_EVENT          = 12,                   // event_id
+    CONDITION_NO_AURA               = 11,                   // spell_id     effindex
+    CONDITION_ACTIVE_EVENT          = 12,                   // event_id
 };
 
@@ -251,5 +258,5 @@
 // NPC gossip text id
 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap;
-
+typedef std::list<GossipOption> CacheNpcOptionList;
 
 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap;
@@ -300,7 +307,8 @@
         typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
 
+
         typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
 
-        typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap;
+        typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
 
         typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@@ -309,4 +317,6 @@
 
         typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap;
+
+        typedef std::vector<std::string> ScriptNameMap;
 
         Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
@@ -477,5 +487,5 @@
         AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
 
-        const char* GetAreaTriggerScriptName(uint32 id);
+        uint32 GetAreaTriggerScriptId(uint32 trigger_id);
 
         ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
@@ -523,5 +533,6 @@
 
         bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
-        bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); }
+        bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
+	void LoadDbScriptStrings();
         void LoadPetCreateSpells();
         void LoadCreatureLocales();
@@ -593,4 +604,6 @@
         uint32 GenerateItemTextID();
         uint32 GeneratePetNumber();
+        uint32 GenerateArenaTeamId();
+        uint32 GenerateGuildId();
         
         void LoadPlayerInfoInCache();
@@ -669,5 +682,4 @@
             return &itr->second;
         }
-        
         NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const
         {
@@ -694,5 +706,5 @@
         const char *GetTrinityString(int32 entry, int locale_idx) const;
         const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); }
-		int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
+	int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
         void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
 
@@ -733,5 +745,5 @@
         LocaleConstant GetLocaleForIndex(int i);
         // guild bank tabs
-        const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }
+        uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }
 
         uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
@@ -754,5 +766,5 @@
         bool AddGameTele(GameTele& data);
         bool DeleteGameTele(std::string name);
-        
+
         CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; }
 
@@ -762,5 +774,5 @@
             if(iter == m_mCacheNpcTextIdMap.end())
                 return 0;
-            
+
             return iter->second;
         }
@@ -783,13 +795,23 @@
             return &iter->second;
         }
-        void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true);
-        bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true);
-        bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0) const;
-
+        void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, bool savetodb = true); // for event
+        bool RemoveVendorItem(uint32 entry,uint32 item, bool savetodb = true); // for event
+        bool IsVendorItemValid( uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL, uint32 ORnpcflag = 0 ) const;
+
+        void LoadScriptNames();
+        ScriptNameMap &GetScriptNames() { return m_scriptNames; }
+        const char * GetScriptName(uint32 id) { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
+        uint32 GetScriptId(const char *name);
     protected:
+
+        // first free id for selected id type
         uint32 m_auctionid;
         uint32 m_mailid;
         uint32 m_ItemTextId;
-
+        uint32 m_arenaTeamId;
+        uint32 m_guildId;
+        uint32 m_hiPetNumber;
+
+        // first free low guid for seelcted guid type
         uint32 m_hiCharGuid;
         uint32 m_hiCreatureGuid;
@@ -800,7 +822,5 @@
         uint32 m_hiCorpseGuid;
 
-        uint32 m_hiPetNumber;
-
-        QuestMap mQuestTemplates;
+        QuestMap            mQuestTemplates;
 
         typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;
@@ -849,4 +869,6 @@
         GameTeleMap         m_GameTeleMap;
 
+        ScriptNameMap       m_scriptNames;
+
         typedef             std::vector<LocaleConstant> LocalForIndex;
         LocalForIndex        m_LocalForIndex;
@@ -856,4 +878,5 @@
     private:
         void LoadScripts(ScriptMapMap& scripts, char const* tablename);
+        void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids);
         void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
         void LoadQuestRelationsHelper(QuestRelations& map,char const* table);
@@ -908,6 +931,8 @@
 
 // scripting access functions
-bool TRINITY_DLL_SPEC LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min());
-TRINITY_DLL_SPEC const char* GetAreaTriggerScriptNameById(uint32 id);
+TRINITY_DLL_SPEC bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value = -1, int32 end_value = std::numeric_limits<int32>::min());
+TRINITY_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 trigger_id);
+TRINITY_DLL_SPEC uint32 GetScriptId(const char *name);
+TRINITY_DLL_SPEC ObjectMgr::ScriptNameMap& GetScriptNames();
 
 #endif
Index: trunk/src/game/Level2.cpp
===================================================================
--- trunk/src/game/Level2.cpp (revision 230)
+++ trunk/src/game/Level2.cpp (revision 260)
@@ -2362,6 +2362,6 @@
     // Check
     // Remember: "show" must also be the name of a column!
-    if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2")
-        && (show != "text3") && (show != "text4") && (show != "text5")
+    if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2")
+        && (show != "textid3") && (show != "textid4") && (show != "textid5")
         && (show != "waittime") && (show != "del") && (show != "move") && (show != "add")
         && (show != "model1") && (show != "model2") && (show != "orientation"))
@@ -2703,4 +2703,11 @@
         PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, lowguid);
         SetSentErrorMessage(true);
+        return false;
+    }
+
+    // set in game textids not supported
+    if( show == "textid1" || show == "textid2" || show == "textid3" ||
+        show == "textid4" || show == "textid5" )
+    {
         return false;
     }
@@ -2843,5 +2850,5 @@
 
         QueryResult *result =
-            WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u",
+            WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u",
             target->GetGUIDLow() );
         if(!result)
@@ -2855,5 +2862,5 @@
             PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID());
 
-            result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",
+            result = WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE (abs(position_x - %f) <= %s ) and (abs(position_y - %f) <= %s ) and (abs(position_z - %f) <= %s )",
                 target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
             if(!result)
@@ -2872,9 +2879,7 @@
             uint32 emote            = fields[3].GetUInt32();
             uint32 spell            = fields[4].GetUInt32();
-            const char * text1      = fields[5].GetString();
-            const char * text2      = fields[6].GetString();
-            const char * text3      = fields[7].GetString();
-            const char * text4      = fields[8].GetString();
-            const char * text5      = fields[9].GetString();
+            uint32 textid[MAX_WAYPOINT_TEXT];
+            for(int i = 0;  i < MAX_WAYPOINT_TEXT; ++i)
+                textid[i]           = fields[5+i].GetUInt32();
             uint32 model1           = fields[10].GetUInt32();
             uint32 model2           = fields[11].GetUInt32();
@@ -2889,9 +2894,6 @@
             PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote);
             PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell);
-            PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 1, text1);
-            PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 2, text2);
-            PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 3, text3);
-            PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 4, text4);
-            PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, 5, text5);
+            for(int i = 0;  i < MAX_WAYPOINT_TEXT; ++i)
+                PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetTrinityString(textid[i]) : ""));
 
         }while( result->NextRow() );
@@ -3214,6 +3216,6 @@
 
     QueryResult *result = WorldDatabase.PQuery(
-    //          0      1           2           3           4            5       6       7         8      9      10     11     12     13     14     15
-        "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );
+    //          0      1           2           3           4            5       6       7         8      9      10       11       12       13       14       15
+        "SELECT point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );
 
     if (!result)
@@ -3232,5 +3234,5 @@
 
         outfile << "INSERT INTO creature_movement ";
-        outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES ";
+        outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES ";
 
         outfile << "( ";
@@ -3257,63 +3259,13 @@
         outfile << fields[9].GetUInt32();                   // spell
         outfile << ", ";
-        const char *tmpChar = fields[10].GetString();
-        if( !tmpChar )
-        {
-            outfile << "NULL";                              // text1
-        }
-        else
-        {
-            outfile << "'";
-            outfile << tmpChar;                             // text1
-            outfile << "'";
-        }
+        outfile << fields[10].GetUInt32();                  // textid1
         outfile << ", ";
-        tmpChar = fields[11].GetString();
-        if( !tmpChar )
-        {
-            outfile << "NULL";                              // text2
-        }
-        else
-        {
-            outfile << "'";
-            outfile << tmpChar;                             // text2
-            outfile << "'";
-        }
+        outfile << fields[11].GetUInt32();                  // textid2
         outfile << ", ";
-        tmpChar = fields[12].GetString();
-        if( !tmpChar )
-        {
-            outfile << "NULL";                              // text3
-        }
-        else
-        {
-            outfile << "'";
-            outfile << tmpChar;                             // text3
-            outfile << "'";
-        }
+        outfile << fields[12].GetUInt32();                  // textid3
         outfile << ", ";
-        tmpChar = fields[13].GetString();
-        if( !tmpChar )
-        {
-            outfile << "NULL";                              // text4
-        }
-        else
-        {
-            outfile << "'";
-            outfile << tmpChar;                             // text4
-            outfile << "'";
-        }
+        outfile << fields[13].GetUInt32();                  // textid4
         outfile << ", ";
-        tmpChar = fields[14].GetString();
-        if( !tmpChar )
-        {
-            outfile << "NULL";                              // text5
-        }
-        else
-        {
-            outfile << "'";
-            outfile << tmpChar;                             // text5
-            outfile << "'";
-        }
+        outfile << fields[14].GetUInt32();                  // textid5
         outfile << ");\n ";
 
Index: trunk/src/game/ItemPrototype.h
===================================================================
--- trunk/src/game/ItemPrototype.h (revision 257)
+++ trunk/src/game/ItemPrototype.h (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -100,5 +100,7 @@
     ITEM_FLAGS_USEABLE_IN_ARENA               = 0x00200000,
     ITEM_FLAGS_THROWABLE                      = 0x00400000, // not used in game for check trow possibility, only for item in game tooltip
-    ITEM_FLAGS_SPECIALUSE                     = 0x00800000  // last used flag in 2.3.0
+    ITEM_FLAGS_SPECIALUSE                     = 0x00800000, // last used flag in 2.3.0
+    ITEM_FLAGS_BOA                            = 0x08000000, // bind on account
+    ITEM_FLAGS_MILLABLE                       = 0x20000000
 };
 
@@ -107,7 +109,7 @@
     BAG_FAMILY_MASK_ARROWS                    = 0x00000001,
     BAG_FAMILY_MASK_BULLETS                   = 0x00000002,
-    BAG_FAMILY_MASK_SHARDS                    = 0x00000004,
+    BAG_FAMILY_MASK_SOUL_SHARDS               = 0x00000004,
     BAG_FAMILY_MASK_LEATHERWORKING_SUPP       = 0x00000008,
-    BAG_FAMILY_MASK_UNUSED                    = 0x00000010, // not used currently
+    BAG_FAMILY_MASK_INSCRIPTION_SUPP          = 0x00000010,
     BAG_FAMILY_MASK_HERBS                     = 0x00000020,
     BAG_FAMILY_MASK_ENCHANTING_SUPP           = 0x00000040,
@@ -117,10 +119,8 @@
     BAG_FAMILY_MASK_MINING_SUPP               = 0x00000400,
     BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT       = 0x00000800,
-    BAG_FAMILY_MASK_VANITY_PETS               = 0x00001000
-};
-
-/* TODO: Not entirely positive on need for this??
-enum SOCKET_CONTENT ();
-*/
+    BAG_FAMILY_MASK_VANITY_PETS               = 0x00001000,
+    BAG_FAMILY_MASK_CURRENCY_TOKENS           = 0x00002000,
+    BAG_FAMILY_MASK_QUEST_ITEMS               = 0x00004000
+};
 
 enum SocketColor
@@ -276,5 +276,5 @@
 };
 
-#define MAX_ITEM_SUBCLASS_ARMOR                  10
+#define MAX_ITEM_SUBCLASS_ARMOR                   10
 
 enum ItemSubclassReagent
@@ -390,4 +390,20 @@
 
 #define MAX_ITEM_SUBCLASS_JUNK                    6
+
+enum ItemSubclassGlyph
+{
+    ITEM_SUBCLASS_GLYPH_WARRIOR                 = 1,
+    ITEM_SUBCLASS_GLYPH_PALADIN                 = 2,
+    ITEM_SUBCLASS_GLYPH_HUNTER                  = 3,
+    ITEM_SUBCLASS_GLYPH_ROGUE                   = 4,
+    ITEM_SUBCLASS_GLYPH_PRIEST                  = 5,
+    ITEM_SUBCLASS_GLYPH_DEATH_KNIGHT            = 6,
+    ITEM_SUBCLASS_GLYPH_SHAMAN                  = 7,
+    ITEM_SUBCLASS_GLYPH_MAGE                    = 8,
+    ITEM_SUBCLASS_GLYPH_WARLOCK                 = 9,
+    ITEM_SUBCLASS_GLYPH_DRUID                   = 11
+};
+
+#define MAX_ITEM_SUBCLASS_GLYPH                   12
 
 const uint32 MaxItemSubclassValues[MAX_ITEM_CLASS] =
@@ -525,5 +541,5 @@
     uint32 RequiredDisenchantSkill;
     float  ArmorDamageModifier;
-    char* ScriptName;
+    uint32 ScriptId;
     uint32 DisenchantID;
     uint32 FoodType;
Index: trunk/src/game/WaypointManager.h
===================================================================
--- trunk/src/game/WaypointManager.h (revision 206)
+++ trunk/src/game/WaypointManager.h (revision 260)
@@ -26,9 +26,10 @@
 #include "Utilities/UnorderedMap.h"
 
+#define MAX_WAYPOINT_TEXT 5
 struct WaypointBehavior
 {
     uint32 emote;
     uint32 spell;
-    std::string text[5];
+    int32  textid[MAX_WAYPOINT_TEXT];
     uint32 model1;
     uint32 model2;
Index: trunk/src/game/AuctionHouse.cpp
===================================================================
--- trunk/src/game/AuctionHouse.cpp (revision 229)
+++ trunk/src/game/AuctionHouse.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -90,6 +90,6 @@
         return false;
     }
-    data << auction->Id;
-    data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY);
+    data << (uint32) auction->Id;
+    data << (uint32) pItem->GetEntry();
 
     for (uint8 i = 0; i < MAX_INSPECTED_ENCHANTMENT_SLOT; i++)
@@ -246,5 +246,5 @@
         return;
     }
-    // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
+    // prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction)
     if(!it)
     {
@@ -717,5 +717,5 @@
                                             if (il)
                                             {
-                                                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
+                                                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
                                                     name = il->Name[loc_idx];
                                             }
Index: trunk/src/game/ObjectMgr.cpp
===================================================================
--- trunk/src/game/ObjectMgr.cpp (revision 230)
+++ trunk/src/game/ObjectMgr.cpp (revision 260)
@@ -11,10 +11,10 @@
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
@@ -22,4 +22,5 @@
 #include "Database/DatabaseEnv.h"
 #include "Database/SQLStorage.h"
+#include "Database/SQLStorageImpl.h"
 
 #include "Log.h"
@@ -117,6 +118,10 @@
     m_hiDoGuid          = 1;
     m_hiCorpseGuid      = 1;
-
     m_hiPetNumber       = 1;
+    m_ItemTextId        = 1;
+    m_mailid            = 1;
+    m_auctionid         = 1;
+    m_guildId           = 1;
+    m_arenaTeamId       = 1;
 
     mGuildBankTabPrice.resize(GUILD_BANK_MAX_TABS);
@@ -416,5 +421,5 @@
 
         //prepare mail data... :
-        uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() );
+        uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() );
 
         // set owner to bidder (to prevent delete item with sender char deleting)
@@ -467,5 +472,5 @@
         sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
 
-        uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() );
+        uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() );
 
         WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION);
@@ -499,5 +504,5 @@
         sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
 
-        uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() );
+        uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() );
 
         uint32 profit = auction->bid + auction->deposit - auctionCut;
@@ -546,5 +551,4 @@
         // will delete item or place to receiver mail list
         WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, GUID_LOPART(owner_guid), subject.str(), 0, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
-
     }
     // owner not found
@@ -564,6 +568,6 @@
 void ObjectMgr::LoadCreatureLocales()
 {
-    mCreatureLocaleMap.clear();
-    
+    mCreatureLocaleMap.clear();                              // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature");
 
@@ -624,5 +628,5 @@
     sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() );
 }
-
+   
 void ObjectMgr::LoadNpcOptionLocales()
 {
@@ -693,7 +697,17 @@
 }
 
+struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
+{
+    template<class D>
+    void convert_from_str(uint32 field_pos, char *src, D &dst)
+    {
+        dst = D(objmgr.GetScriptId(src));
+    }
+};
+
 void ObjectMgr::LoadCreatureTemplates()
 {
-    sCreatureStorage.Load();
+    SQLCreatureLoader loader;
+    loader.Load(sCreatureStorage);
 
     sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount );
@@ -1513,5 +1527,5 @@
         aItem->location = fields[11].GetUInt8();
         //check if sold item exists
-        if ( this->GetAItem( aItem->item_guidlow ) )
+        if ( GetAItem( aItem->item_guidlow ) )
         {
             GetAuctionsMap( aItem->location )->AddAuction(aItem);
@@ -1533,6 +1547,6 @@
 void ObjectMgr::LoadItemLocales()
 {
-    mItemLocaleMap.clear();
-    
+    mItemLocaleMap.clear();                                 // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item");
 
@@ -1595,7 +1609,17 @@
 }
 
+struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader>
+{
+    template<class D>
+    void convert_from_str(uint32 field_pos, char *src, D &dst)
+    {
+        dst = D(objmgr.GetScriptId(src));
+    }
+};
+
 void ObjectMgr::LoadItemPrototypes()
 {
-    sItemStorage.Load ();
+    SQLItemLoader loader;
+    loader.Load(sItemStorage);
     sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount );
     sLog.outString();
@@ -2507,5 +2531,5 @@
             if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI))
                 continue;
-                
+
             // skip expansion classes if not playing with expansion
             if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT)
@@ -3556,5 +3580,5 @@
 void ObjectMgr::LoadQuestLocales()
 {
-    mQuestLocaleMap.clear();
+    mQuestLocaleMap.clear();                                // need for reload case
 
     QueryResult *result = WorldDatabase.Query("SELECT entry,"
@@ -3750,5 +3774,5 @@
     scripts.clear();                                        // need for reload support
 
-    QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename );
+    QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename );
 
     uint32 count = 0;
@@ -3772,14 +3796,14 @@
         Field *fields = result->Fetch();
         ScriptInfo tmp;
-        tmp.id = fields[0].GetUInt32();
-        tmp.delay = fields[1].GetUInt32();
-        tmp.command = fields[2].GetUInt32();
-        tmp.datalong = fields[3].GetUInt32();
+        tmp.id        = fields[0].GetUInt32();
+        tmp.delay     = fields[1].GetUInt32();
+        tmp.command   = fields[2].GetUInt32();
+        tmp.datalong  = fields[3].GetUInt32();
         tmp.datalong2 = fields[4].GetUInt32();
-        tmp.datatext = fields[5].GetCppString();
-        tmp.x = fields[6].GetFloat();
-        tmp.y = fields[7].GetFloat();
-        tmp.z = fields[8].GetFloat();
-        tmp.o = fields[9].GetFloat();
+        tmp.dataint   = fields[5].GetInt32();
+        tmp.x         = fields[6].GetFloat();
+        tmp.y         = fields[7].GetFloat();
+        tmp.z         = fields[8].GetFloat();
+        tmp.o         = fields[9].GetFloat();
 
         // generic command args check
@@ -3793,4 +3817,16 @@
                     continue;
                 }
+                if(tmp.dataint==0)
+                {
+                    sLog.outErrorDb("Table `%s` has invalid talk text id (dataint = %i) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,tmp.id);
+                    continue;
+                }
+                if(tmp.dataint < MIN_DB_SCRIPT_STRING_ID || tmp.dataint >= MAX_DB_SCRIPT_STRING_ID)
+                {
+                    sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id);
+                    continue;
+                }
+
+                // if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading
                 break;
             }
@@ -4157,6 +4193,6 @@
 void ObjectMgr::LoadPageTextLocales()
 {
-    mPageTextLocaleMap.clear();
-    
+    mPageTextLocaleMap.clear();                             // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text");
 
@@ -4207,7 +4243,17 @@
 }
 
+struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader>
+{
+    template<class D>
+    void convert_from_str(uint32 field_pos, char *src, D &dst)
+    {
+        dst = D(objmgr.GetScriptId(src));
+    }
+};
+
 void ObjectMgr::LoadInstanceTemplate()
 {
-    sInstanceTemplate.Load();
+    SQLInstanceLoader loader;
+    loader.Load(sInstanceTemplate);
 
     for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++)
@@ -4325,6 +4371,6 @@
 void ObjectMgr::LoadNpcTextLocales()
 {
-    mNpcTextLocaleMap.clear();
-    
+    mNpcTextLocaleMap.clear();                              // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,"
         "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1,"
@@ -4623,5 +4669,5 @@
 
         uint32 Trigger_ID      = fields[0].GetUInt32();
-        std::string scriptName = fields[1].GetCppString();
+        const char *scriptName = fields[1].GetString();
 
         AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
@@ -4631,5 +4677,5 @@
             continue;
         }
-        mAreaTriggerScripts[Trigger_ID] = scriptName;
+        mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName);
     } while( result->NextRow() );
 
@@ -4639,4 +4685,5 @@
     sLog.outString( ">> Loaded %u areatrigger scripts", count );
 }
+
 uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid )
 {
@@ -4697,9 +4744,9 @@
 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team )
 {
-    uint32 mount_entry = 0;
-    uint32 mount_id = 0;
+    uint16 mount_entry = 0;
+    uint16 mount_id = 0;
 
     TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
-    if (node)
+    if(node)
     {
         if (team == ALLIANCE) mount_entry = node->alliance_mount_type;
@@ -4940,5 +4987,4 @@
     }
 
-            // find now nearest graveyard at same map
     if(entryNear)
         return entryNear;
@@ -5181,5 +5227,4 @@
     {
         m_hiCharGuid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
@@ -5189,15 +5234,9 @@
     {
         m_hiCreatureGuid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
 
-    result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" );
-    if( result )
-    {
-        m_hiPetGuid = (*result)[0].GetUInt32()+1;
-
-        delete result;
-    }
+    // pet guids are not saved to DB, set to 0 (pet guid != pet id)
+    m_hiPetGuid = 0;
 
     result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" );
@@ -5205,5 +5244,4 @@
     {
         m_hiItemGuid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
@@ -5219,5 +5257,4 @@
     {
         m_hiGoGuid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
@@ -5227,31 +5264,20 @@
     {
         m_auctionid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
-    else
-    {
-        m_auctionid = 0;
-    }
+
     result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" );
     if( result )
     {
         m_mailid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
-    else
-    {
-        m_mailid = 0;
-    }
+
     result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" );
     if( result )
     {
-        m_ItemTextId = (*result)[0].GetUInt32();
-
+        m_ItemTextId = (*result)[0].GetUInt32()+1;
         delete result;
     }
-    else
-        m_ItemTextId = 0;
 
     result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" );
@@ -5259,40 +5285,70 @@
     {
         m_hiCorpseGuid = (*result)[0].GetUInt32()+1;
-
         delete result;
     }
+
+    result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
+    if (result)
+    {
+        m_arenaTeamId = (*result)[0].GetUInt32()+1;
+        delete result;
+    }
+
+    result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" );
+    if (result)
+    {
+        m_guildId = (*result)[0].GetUInt32()+1;
+        delete result;
+    }
+}
+
+uint32 ObjectMgr::GenerateArenaTeamId()
+{
+    if(m_arenaTeamId>=0xFFFFFFFE)
+    {
+        sLog.outError("Arena team ids overflow!! Can't continue, shutting down server. ");
+        World::StopNow(ERROR_EXIT_CODE);
+    }
+    return m_arenaTeamId++;
+}
+
+uint32 ObjectMgr::GenerateGuildId()
+{
+    if(m_guildId>=0xFFFFFFFE)
+    {
+        sLog.outError("Guild ids overflow!! Can't continue, shutting down server. ");
+        World::StopNow(ERROR_EXIT_CODE);
+    }
+    return m_guildId++;
 }
 
 uint32 ObjectMgr::GenerateAuctionID()
 {
-    ++m_auctionid;
-    if(m_auctionid>=0xFFFFFFFF)
+    if(m_auctionid>=0xFFFFFFFE)
     {
         sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. ");
-        sWorld.m_stopEvent = true;
-    }
-    return m_auctionid;
+        World::StopNow(ERROR_EXIT_CODE);
+    }
+    return m_auctionid++;
 }
 
 uint32 ObjectMgr::GenerateMailID()
 {
-    ++m_mailid;
-    if(m_mailid>=0xFFFFFFFF)
+    if(m_mailid>=0xFFFFFFFE)
     {
         sLog.outError("Mail ids overflow!! Can't continue, shutting down server. ");
-        sWorld.m_stopEvent = true;
-    }
-    return m_mailid;
+        World::StopNow(ERROR_EXIT_CODE);
+    }
+    return m_mailid++;
 }
 
 uint32 ObjectMgr::GenerateItemTextID()
 {
-    ++m_ItemTextId;
-    if(m_ItemTextId>=0xFFFFFFFF)
+    if(m_ItemTextId>=0xFFFFFFFE)
     {
         sLog.outError("Item text ids overflow!! Can't continue, shutting down server. ");
-        sWorld.m_stopEvent = true;
-    }
-    return m_ItemTextId;
+        World::StopNow(ERROR_EXIT_CODE);
+    }
+    return m_ItemTextId++;
 }
 
@@ -5316,59 +5372,52 @@
     {
         case HIGHGUID_ITEM:
-            ++m_hiItemGuid;
-            if(m_hiItemGuid>=0xFFFFFFFF)
+            if(m_hiItemGuid>=0xFFFFFFFE)
             {
                 sLog.outError("Item guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiItemGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiItemGuid++;
         case HIGHGUID_UNIT:
-            ++m_hiCreatureGuid;
-            if(m_hiCreatureGuid>=0x00FFFFFF)
+            if(m_hiCreatureGuid>=0x00FFFFFE)
             {
                 sLog.outError("Creature guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiCreatureGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiCreatureGuid++;
         case HIGHGUID_PET:
-            ++m_hiPetGuid;
-            if(m_hiPetGuid>=0x00FFFFFF)
+            if(m_hiPetGuid>=0x00FFFFFE)
             {
                 sLog.outError("Pet guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiPetGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiPetGuid++;
         case HIGHGUID_PLAYER:
-            ++m_hiCharGuid;
-            if(m_hiCharGuid>=0xFFFFFFFF)
+            if(m_hiCharGuid>=0xFFFFFFFE)
             {
                 sLog.outError("Players guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiCharGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiCharGuid++;
         case HIGHGUID_GAMEOBJECT:
-            ++m_hiGoGuid;
-            if(m_hiGoGuid>=0x00FFFFFF)
+            if(m_hiGoGuid>=0x00FFFFFE)
             {
                 sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiGoGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiGoGuid++;
         case HIGHGUID_CORPSE:
-            ++m_hiCorpseGuid;
-            if(m_hiCorpseGuid>=0xFFFFFFFF)
+            if(m_hiCorpseGuid>=0xFFFFFFFE)
             {
                 sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiCorpseGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiCorpseGuid++;
         case HIGHGUID_DYNAMICOBJECT:
-            ++m_hiDoGuid;
-            if(m_hiDoGuid>=0xFFFFFFFF)
+            if(m_hiDoGuid>=0xFFFFFFFE)
             {
                 sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. ");
-                sWorld.m_stopEvent = true;
-            }
-            return m_hiDoGuid;
+                World::StopNow(ERROR_EXIT_CODE);
+            }
+            return m_hiDoGuid++;
         default:
             ASSERT(0);
@@ -5381,6 +5430,6 @@
 void ObjectMgr::LoadGameObjectLocales()
 {
-    mGameObjectLocaleMap.clear();
-    
+    mGameObjectLocaleMap.clear();                           // need for reload case
+
     QueryResult *result = WorldDatabase.Query("SELECT entry,"
         "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8,"
@@ -5450,7 +5499,17 @@
 }
 
+struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader>
+{
+    template<class D>
+    void convert_from_str(uint32 field_pos, char *src, D &dst)
+    {
+        dst = D(objmgr.GetScriptId(src));
+    }
+};
+
 void ObjectMgr::LoadGameobjectInfo()
 {
-    sGOStorage.Load();
+    SQLGameObjectLoader loader;
+    loader.Load(sGOStorage);
 
     // some checks
@@ -6625,10 +6684,10 @@
 }
 
-const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id)
-{
-    AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id);
+uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)
+{
+    AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id);
     if(i!= mAreaTriggerScripts.end())
-        return i->second.c_str();
-    return "";
+        return i->second;
+    return 0;
 }
 
@@ -6675,8 +6734,8 @@
             return false;
         }
-		case CONDITION_NO_AURA:
-			return !player->HasAura(value1, value2);
-		case CONDITION_ACTIVE_EVENT:
-			return gameeventmgr.IsActiveEvent(value1);
+        case CONDITION_NO_AURA:
+            return !player->HasAura(value1, value2);
+        case CONDITION_ACTIVE_EVENT:
+            return gameeventmgr.IsActiveEvent(value1);
         default:
             return false;
@@ -6799,28 +6858,28 @@
             break;
         }
-		case CONDITION_NO_AURA:
-		{
-			if(!sSpellStore.LookupEntry(value1))
-			{
-				sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1);
-				return false;
-			}
-			if(value2 > 2)
-			{
-				sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
-				return false;
-			}
-			break;
-		}
-		case CONDITION_ACTIVE_EVENT:
-		{
-			GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
-			if(value1 >=events.size() || !events[value1].isValid())
-			{
-				sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1);
-				return false;
-			}
-			break;
-		}
+        case CONDITION_NO_AURA:
+        {
+            if(!sSpellStore.LookupEntry(value1))
+            {
+                sLog.outErrorDb("Aura condition requires to have non existing spell (Id: %d), skipped", value1);
+                return false;
+            }
+            if(value2 > 2)
+            {
+                sLog.outErrorDb("Aura condition requires to have non existing effect index (%u) (must be 0..2), skipped", value2);
+                return false;
+            }
+            break;
+        }
+        case CONDITION_ACTIVE_EVENT:
+        {
+            GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
+            if(value1 >=events.size() || !events[value1].isValid())
+            {
+                sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1);
+                return false;
+            }
+            break;
+        }
     }
     return true;
@@ -6952,5 +7011,5 @@
         if(itr->first > new_id)
             new_id = itr->first;
-    
+
     // use next
     ++new_id;
@@ -6992,5 +7051,5 @@
 void ObjectMgr::LoadTrainerSpell()
 {
-    // For reload case 
+    // For reload case
     for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr)
         itr->second.Clear();
@@ -7083,5 +7142,5 @@
 void ObjectMgr::LoadVendors()
 {
-    // For reload case 
+    // For reload case
     for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
         itr->second.Clear();
@@ -7190,4 +7249,5 @@
         "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text "
         "FROM npc_option");
+
     if( !result )
     {
@@ -7342,8 +7402,82 @@
 }
 
+void ObjectMgr::LoadScriptNames()
+{
+    m_scriptNames.push_back("");
+    QueryResult *result = WorldDatabase.Query(
+      "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
+      "UNION "
+      "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
+      "UNION "
+      "SELECT DISTINCT(ScriptName) FROM item_template WHERE ScriptName <> '' "
+      "UNION "
+      "SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
+      "UNION "
+      "SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
+    if(result)
+    {
+        do
+        {
+            m_scriptNames.push_back((*result)[0].GetString());
+        } while (result->NextRow());
+        delete result;
+    }
+
+    std::sort(m_scriptNames.begin(), m_scriptNames.end());
+}
+
+uint32 ObjectMgr::GetScriptId(const char *name)
+{
+    // use binary search to find the script name in the sorted vector
+    // assume "" is the first element
+    if(!name) return 0;
+    ScriptNameMap::const_iterator itr =
+        std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name);
+    if(itr == m_scriptNames.end()) return 0;
+    return itr - m_scriptNames.begin();
+}
+
+void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids)
+{
+    for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM)
+    {
+        for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM)
+        {
+            if(itrM->second.dataint)
+            {
+                if(!GetTrinityStringLocale (itrM->second.dataint))
+                    sLog.outErrorDb( "Table `db_script_string` has not existed string id  %u", *itrM);
+
+                if(ids.count(itrM->second.dataint))
+                    ids.erase(itrM->second.dataint);
+            }
+        }
+    }
+}
+
+void ObjectMgr::LoadDbScriptStrings()
+{
+    LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID);
+
+    std::set<int32> ids;
+
+    for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i)
+        if(GetTrinityStringLocale(i))
+            ids.insert(i);
+
+    CheckScripts(sQuestEndScripts,ids);
+    CheckScripts(sQuestStartScripts,ids);
+    CheckScripts(sSpellScripts,ids);
+    CheckScripts(sGameObjectScripts,ids);
+    CheckScripts(sEventScripts,ids);
+
+    for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
+        sLog.outErrorDb( "Table `db_script_string` has unused string id  %u", *itr);
+}
+
 // Functions for scripting access
-const char* GetAreaTriggerScriptNameById(uint32 id)
-{
-    return objmgr.GetAreaTriggerScriptName(id);
+uint32 GetAreaTriggerScriptId(uint32 trigger_id)
+{
+    return objmgr.GetAreaTriggerScriptId(trigger_id);
 }
 
@@ -7360,2 +7494,12 @@
     return objmgr.LoadTrinityStrings(db,table,end_value,start_value);
 }
+
+uint32 TRINITY_DLL_SPEC GetScriptId(const char *name)
+{
+    return objmgr.GetScriptId(name);
+}
+
+ObjectMgr::ScriptNameMap & GetScriptNames()
+{
+    return objmgr.GetScriptNames();
+}
Index: trunk/src/trinitycore/CliRunnable.cpp
===================================================================
--- trunk/src/trinitycore/CliRunnable.cpp (revision 237)
+++ trunk/src/trinitycore/CliRunnable.cpp (revision 260)
@@ -170,5 +170,5 @@
 {
     SendSysMessage(LANG_COMMAND_EXIT);
-    World::m_stopEvent = true;
+    World::StopNow(SHUTDOWN_EXIT_CODE);
     return true;
 }
@@ -311,12 +311,12 @@
 
     ///- As long as the World is running (no World::m_stopEvent), get the command line and handle it
-    while (!World::m_stopEvent)
+    while (!World::IsStopped())
     {
         fflush(stdout);
         #ifdef linux
-        while (!kb_hit_return() && !World::m_stopEvent)
+        while (!kb_hit_return() && !World::IsStopped())
             // With this, we limit CLI to 10commands/second
             usleep(100);
-        if (World::m_stopEvent)
+        if (World::IsStopped())
             break;
         #endif
@@ -349,5 +349,5 @@
         else if (feof(stdin))
         {
-            World::m_stopEvent = true;
+            World::StopNow(SHUTDOWN_EXIT_CODE);
         }
     }
Index: trunk/src/trinitycore/WorldRunnable.cpp
===================================================================
--- trunk/src/trinitycore/WorldRunnable.cpp (revision 237)
+++ trunk/src/trinitycore/WorldRunnable.cpp (revision 260)
@@ -52,5 +52,5 @@
 
     ///- While we have not World::m_stopEvent, update the world
-    while (!World::m_stopEvent)
+    while (!World::IsStopped())
     {
         ++World::m_worldLoopCounter;
Index: trunk/src/trinitycore/Master.cpp
===================================================================
--- trunk/src/trinitycore/Master.cpp (revision 237)
+++ trunk/src/trinitycore/Master.cpp (revision 260)
@@ -78,5 +78,5 @@
         m_lastchange = 0;
         w_lastchange = 0;
-        while(!World::m_stopEvent)
+        while(!World::IsStopped())
         {
             ZThread::Thread::sleep(1000);
@@ -173,5 +173,5 @@
     // if use ra spend time waiting for io, if not use ra ,just sleep
     if (usera)
-      while (!World::m_stopEvent)
+      while (!World::IsStopped())
         {
           h.Select (0, socketSelecttime);
@@ -179,5 +179,5 @@
         }
     else
-      while (!World::m_stopEvent)
+      while (!World::IsStopped())
         {
           ZThread::Thread::sleep (static_cast<unsigned long> (socketSelecttime / 1000));
@@ -324,5 +324,5 @@
     {
       sLog.outError ("Failed to start network");
-      World::m_stopEvent = true;
+      World::StopNow(ERROR_EXIT_CODE);
       // go down and shutdown the server
     }
@@ -395,5 +395,6 @@
     UnloadScriptingModule();
 
-    return sWorld.GetShutdownMask() & SHUTDOWN_MASK_RESTART ? 2 : 0;
+    // Exit the process with specified return value
+    return World::GetExitCode();
 }
 
@@ -478,5 +479,4 @@
 
 /// Handle termination signals
-/** Put the World::m_stopEvent to 'true' if a termination signal is caught **/
 void Master::_OnSignal(int s)
 {
@@ -484,9 +484,11 @@
     {
         case SIGINT:
+            World::StopNow(RESTART_EXIT_CODE);
+            break;
         case SIGTERM:
         #ifdef _WIN32
         case SIGBREAK:
         #endif
-            World::m_stopEvent = true;
+            World::StopNow(SHUTDOWN_EXIT_CODE);
             break;
     }
Index: trunk/src/bindings/scripts/ScriptMgr.h
===================================================================
--- trunk/src/bindings/scripts/ScriptMgr.h (revision 149)
+++ trunk/src/bindings/scripts/ScriptMgr.h (revision 260)
@@ -25,5 +25,5 @@
 class WorldObject;
 
-#define MAX_SCRIPTS         1000                            //72 bytes each (approx 71kb)
+#define MAX_SCRIPTS         5000                            //72 bytes each (approx 351kb)
 #define VISIBLE_RANGE       (166.0f)                        //MAX visible range (size of grid)
 #define DEFAULT_TEXT        "<Trinity Script Text Entry Missing!>"
@@ -32,37 +32,36 @@
 {
     Script() :
-pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL),
-pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL),
-pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL),
-pGOChooseReward(NULL),pReceiveEmote(NULL),pItemUse(NULL), GetAI(NULL), GetInstanceData(NULL)
-{}
+        pGossipHello(NULL), pQuestAccept(NULL), pGossipSelect(NULL), pGossipSelectWithCode(NULL),
+        pQuestSelect(NULL), pQuestComplete(NULL), pNPCDialogStatus(NULL), pGODialogStatus(NULL), pChooseReward(NULL),
+        pItemHello(NULL), pGOHello(NULL), pAreaTrigger(NULL), pItemQuestAccept(NULL), pGOQuestAccept(NULL),
+        pGOChooseReward(NULL),pReceiveEmote(NULL),pItemUse(NULL), GetAI(NULL), GetInstanceData(NULL)
+    {}
 
-std::string Name;
+    std::string Name;
 
-// Quest/gossip Methods to be scripted
-bool (*pGossipHello         )(Player*, Creature*);
-bool (*pQuestAccept         )(Player*, Creature*, Quest const* );
-bool (*pGossipSelect        )(Player*, Creature*, uint32 , uint32  );
-bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* );
-bool (*pQuestSelect         )(Player*, Creature*, Quest const* );
-bool (*pQuestComplete       )(Player*, Creature*, Quest const* );
-uint32 (*pNPCDialogStatus   )(Player*, Creature* );
-uint32 (*pGODialogStatus    )(Player *player, GameObject * _GO );
-bool (*pChooseReward        )(Player*, Creature*, Quest const*, uint32 );
-bool (*pItemHello           )(Player*, Item*, Quest const* );
-bool (*pGOHello             )(Player*, GameObject* );
-bool (*pAreaTrigger         )(Player*, AreaTriggerEntry* );
-bool (*pItemQuestAccept     )(Player*, Item *, Quest const* );
-bool (*pGOQuestAccept       )(Player*, GameObject*, Quest const* );
-bool (*pGOChooseReward      )(Player*, GameObject*_GO, Quest const*, uint32 );
-bool (*pReceiveEmote        )(Player*, Creature*, uint32 );
-bool (*pItemUse             )(Player*, Item*, SpellCastTargets const& );
+    //Methods to be scripted
+    bool (*pGossipHello         )(Player*, Creature*);
+    bool (*pQuestAccept         )(Player*, Creature*, Quest const* );
+    bool (*pGossipSelect        )(Player*, Creature*, uint32 , uint32 );
+    bool (*pGossipSelectWithCode)(Player*, Creature*, uint32 , uint32 , const char* );
+    bool (*pQuestSelect         )(Player*, Creature*, Quest const* );
+    bool (*pQuestComplete       )(Player*, Creature*, Quest const* );
+    uint32 (*pNPCDialogStatus   )(Player*, Creature* );
+    uint32 (*pGODialogStatus    )(Player*, GameObject * _GO );
+    bool (*pChooseReward        )(Player*, Creature*, Quest const*, uint32 );
+    bool (*pItemHello           )(Player*, Item*, Quest const* );
+    bool (*pGOHello             )(Player*, GameObject* );
+    bool (*pAreaTrigger         )(Player*, AreaTriggerEntry* );
+    bool (*pItemQuestAccept     )(Player*, Item *, Quest const* );
+    bool (*pGOQuestAccept       )(Player*, GameObject*, Quest const* );
+    bool (*pGOChooseReward      )(Player*, GameObject*, Quest const*, uint32 );
+    bool (*pReceiveEmote        )(Player*, Creature*, uint32 );
+    bool (*pItemUse             )(Player*, Item*, SpellCastTargets const& );
 
-CreatureAI* (*GetAI)(Creature*);
-InstanceData* (*GetInstanceData)(Map*);
+    CreatureAI* (*GetAI)(Creature*);
+    InstanceData* (*GetInstanceData)(Map*);
+
+    void RegisterSelf();
 };
-
-extern int nrscripts;
-extern Script *m_scripts[MAX_SCRIPTS];
 
 //Generic scripting text function
Index: trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp (revision 260)
@@ -141,4 +141,4 @@
     newscript->pGossipHello = &GossipHello_npc_innkeeper;
     newscript->pGossipSelect = &GossipSelect_npc_innkeeper;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp (revision 260)
@@ -836,15 +836,15 @@
     newscript->pQuestAccept =   &QuestAccept_npc_chicken_cluck;
     newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_dancing_flames";
     newscript->pReceiveEmote =  &ReceiveEmote_npc_dancing_flames;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_injured_patient";
     newscript->GetAI = GetAI_npc_injured_patient;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -852,10 +852,10 @@
     newscript->GetAI = GetAI_npc_doctor;
     newscript->pQuestAccept = &QuestAccept_npc_doctor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_guardian";
     newscript->GetAI = GetAI_npc_guardian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -863,5 +863,5 @@
     newscript->pGossipHello =  &GossipHello_npc_mount_vendor;
     newscript->pGossipSelect = &GossipSelect_npc_mount_vendor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -869,5 +869,5 @@
     newscript->pGossipHello =  &GossipHello_npc_rogue_trainer;
     newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -875,4 +875,4 @@
     newscript->pGossipHello = &GossipHello_npc_sayge;
     newscript->pGossipSelect = &GossipSelect_npc_sayge;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp (revision 91)
+++ trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp (revision 260)
@@ -1178,5 +1178,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_alchemy;
     newscript->pGossipSelect = &GossipSelect_npc_prof_alchemy;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1184,5 +1184,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_blacksmith;
     newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1190,5 +1190,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_leather;
     newscript->pGossipSelect = &GossipSelect_npc_prof_leather;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1196,5 +1196,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_tailor;
     newscript->pGossipSelect = &GossipSelect_npc_prof_tailor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     /*newscript = new Script;
@@ -1202,4 +1202,4 @@
     newscript->pGOHello =  &GOHello_go_soothsaying_for_dummies;
     //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies;
-    m_scripts[nrscripts++] = newscript;*/
-}
+    newscript->RegisterSelf();*/
+}
Index: trunk/src/bindings/scripts/scripts/guard/guards.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/guard/guards.cpp (revision 159)
+++ trunk/src/bindings/scripts/scripts/guard/guards.cpp (revision 260)
@@ -3981,5 +3981,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_azuremyst;
     newscript->GetAI = GetAI_guard_azuremyst;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -3988,10 +3988,10 @@
     newscript->pGossipSelect         = &GossipSelect_guard_bluffwatcher;
     newscript->GetAI = GetAI_guard_bluffwatcher;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="guard_contested";
     newscript->GetAI = GetAI_guard_contested;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4000,5 +4000,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_darnassus;
     newscript->GetAI = GetAI_guard_darnassus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4007,5 +4007,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_dunmorogh;
     newscript->GetAI = GetAI_guard_dunmorogh;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4014,5 +4014,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_durotar;
     newscript->GetAI = GetAI_guard_durotar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4021,5 +4021,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_elwynnforest;
     newscript->GetAI = GetAI_guard_elwynnforest;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4028,5 +4028,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_eversong;
     newscript->GetAI = GetAI_guard_eversong;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4035,5 +4035,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_exodar;
     newscript->GetAI = GetAI_guard_exodar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4042,5 +4042,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_ironforge;
     newscript->GetAI = GetAI_guard_ironforge;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4049,5 +4049,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_mulgore;
     newscript->GetAI = GetAI_guard_mulgore;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4057,5 +4057,5 @@
     newscript->pReceiveEmote         = &ReceiveEmote_guard_orgrimmar;
     newscript->GetAI = GetAI_guard_orgrimmar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4064,5 +4064,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath;
     newscript->GetAI = GetAI_guard_shattrath;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4071,5 +4071,5 @@
     newscript->pGossipHello          = &GossipHello_guard_shattrath_aldor;
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath_aldor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4078,5 +4078,5 @@
     newscript->pGossipHello          = &GossipHello_guard_shattrath_scryer;
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath_scryer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4085,5 +4085,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_silvermoon;
     newscript->GetAI = GetAI_guard_silvermoon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4093,5 +4093,5 @@
     newscript->pReceiveEmote         = &ReceiveEmote_guard_stormwind;
     newscript->GetAI = GetAI_guard_stormwind;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4100,5 +4100,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_teldrassil;
     newscript->GetAI = GetAI_guard_teldrassil;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4107,5 +4107,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_tirisfal;
     newscript->GetAI = GetAI_guard_tirisfal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -4114,4 +4114,4 @@
     newscript->pGossipSelect         = &GossipSelect_guard_undercity;
     newscript->GetAI = GetAI_guard_undercity;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/go/go_scripts.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/go/go_scripts.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/go/go_scripts.cpp (revision 260)
@@ -166,44 +166,44 @@
     newscript->Name="go_northern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_northern_crystal_pylon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_eastern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_eastern_crystal_pylon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_western_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_western_crystal_pylon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_barov_journal";
     newscript->pGOHello =           &GOHello_go_barov_journal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_field_repair_bot_74A";
     newscript->pGOHello =           &GOHello_go_field_repair_bot_74A;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_orb_of_command";
     newscript->pGOHello =           &GOHello_go_orb_of_command;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_tablet_of_madness";
     newscript->pGOHello =           &GOHello_go_tablet_of_madness;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_tablet_of_the_seven";
     newscript->pGOHello =           &GOHello_go_tablet_of_the_seven;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_teleporter";
     newscript->pGOHello =           &GOHello_go_teleporter;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp (revision 260)
@@ -298,9 +298,9 @@
     newscript->Name="boss_taerar";
     newscript->GetAI = GetAI_boss_taerar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_shade_of_taerar";
     newscript->GetAI = GetAI_boss_shadeoftaerar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp (revision 260)
@@ -238,9 +238,9 @@
     newscript->Name="boss_ysondre";
     newscript->GetAI = GetAI_boss_ysondre;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_dementeddruids";
     newscript->GetAI = GetAI_mob_dementeddruids;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp (revision 260)
@@ -153,4 +153,4 @@
     newscript->Name="boss_emeriss";
     newscript->GetAI = GetAI_boss_emeriss;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp (revision 260)
@@ -169,4 +169,4 @@
     newscript->Name="generic_creature";
     newscript->GetAI = GetAI_generic_creature;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 260)
@@ -1401,4 +1401,4 @@
     newscript->Name="mob_eventai";
     newscript->GetAI = GetAI_Mob_EventAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/custom/test.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/custom/test.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/custom/test.cpp (revision 260)
@@ -197,4 +197,4 @@
     newscript->pGossipHello          = &GossipHello_npc_test;
     newscript->pGossipSelect         = &GossipSelect_npc_test;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp (revision 260)
@@ -78,4 +78,4 @@
     newscript->pGossipSelect =          &GossipSelect_custom_gossip_codebox;
     newscript->pGossipSelectWithCode =  &GossipSelectWithCode_custom_gossip_codebox;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/custom/custom_example.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/custom/custom_example.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/custom/custom_example.cpp (revision 260)
@@ -274,4 +274,4 @@
     newscript->pGossipSelect = &GossipSelect_custom_example;
     newscript->pReceiveEmote = &ReceiveEmote_custom_example;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp (revision 260)
@@ -97,4 +97,4 @@
     newscript->Name="boss_hazzarah";
     newscript->GetAI = GetAI_boss_hazzarah;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp (revision 260)
@@ -532,14 +532,14 @@
     newscript->Name="boss_thekal";
     newscript->GetAI = GetAI_boss_thekal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_zealot_lorkhan";
     newscript->GetAI = GetAI_mob_zealot_lorkhan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_zealot_zath";
     newscript->GetAI = GetAI_mob_zealot_zath;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp (revision 260)
@@ -289,9 +289,9 @@
     newscript->Name="boss_jeklik";
     newscript->GetAI = GetAI_boss_jeklik;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_batrider";
     newscript->GetAI = GetAI_mob_batrider;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp (revision 260)
@@ -81,4 +81,4 @@
     newscript->Name="boss_wushoolay";
     newscript->GetAI = GetAI_boss_wushoolay;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp (revision 260)
@@ -197,4 +197,4 @@
     newscript->Name="boss_venoxis";
     newscript->GetAI = GetAI_boss_venoxis;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp (revision 260)
@@ -89,4 +89,4 @@
     newscript->Name="boss_grilek";
     newscript->GetAI = GetAI_boss_grilek;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp (revision 260)
@@ -235,4 +235,4 @@
     newscript->Name = "instance_zulgurub";
     newscript->GetInstanceData = GetInstanceData_instance_zulgurub;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp (revision 260)
@@ -148,4 +148,4 @@
     newscript->Name="boss_renataki";
     newscript->GetAI = GetAI_boss_renataki;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp (revision 260)
@@ -253,4 +253,4 @@
     newscript->Name="boss_hakkar";
     newscript->GetAI = GetAI_boss_hakkar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp (revision 260)
@@ -208,4 +208,4 @@
     newscript->Name="boss_arlokk";
     newscript->GetAI = GetAI_boss_arlokk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp (revision 260)
@@ -259,14 +259,14 @@
     newscript->Name="boss_jindo";
     newscript->GetAI = GetAI_boss_jindo;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_healing_ward";
     newscript->GetAI = GetAI_mob_healing_ward;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_shade_of_jindo";
     newscript->GetAI = GetAI_mob_shade_of_jindo;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp (revision 260)
@@ -303,9 +303,9 @@
     newscript->Name="boss_mandokir";
     newscript->GetAI = GetAI_boss_mandokir;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_ohgan";
     newscript->GetAI = GetAI_mob_ohgan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp (revision 260)
@@ -245,9 +245,9 @@
     newscript->Name="boss_marli";
     newscript->GetAI = GetAI_boss_marli;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_spawn_of_marli";
     newscript->GetAI = GetAI_mob_spawn_of_marli;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp (revision 260)
@@ -89,4 +89,4 @@
     newscript->Name="boss_gahzranka";
     newscript->GetAI = GetAI_boss_gahzranka;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp (revision 166)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp (revision 260)
@@ -124,9 +124,9 @@
     newscript->Name="boss_broggok";
     newscript->GetAI = GetAI_boss_broggokAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_broggok_poisoncloud";
     newscript->GetAI = GetAI_mob_broggok_poisoncloudAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp (revision 260)
@@ -128,4 +128,4 @@
     newscript->Name="boss_the_maker";
     newscript->GetAI = GetAI_boss_the_makerAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp (revision 260)
@@ -226,9 +226,9 @@
     newscript->Name="boss_kelidan_the_breaker";
     newscript->GetAI = GetAI_boss_kelidan_the_breaker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_shadowmoon_channeler";
     newscript->GetAI = GetAI_mob_shadowmoon_channeler;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp (revision 260)
@@ -165,4 +165,4 @@
     newscript->Name="boss_watchkeeper_gargolmar";
     newscript->GetAI = GetAI_boss_watchkeeper_gargolmarAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp (revision 166)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp (revision 260)
@@ -210,4 +210,4 @@
     newscript->Name="boss_omor_the_unscarred";
     newscript->GetAI = GetAI_boss_omor_the_unscarredAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp (revision 166)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp (revision 260)
@@ -395,9 +395,9 @@
     newscript->Name="boss_warbringer_omrogg";
     newscript->GetAI = GetAI_boss_warbringer_omrogg;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_omrogg_heads";
     newscript->GetAI = GetAI_mob_omrogg_heads;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp (revision 260)
@@ -445,14 +445,14 @@
     newscript->Name="boss_grand_warlock_nethekurse";
     newscript->GetAI = GetAI_boss_grand_warlock_nethekurse;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_fel_orc_convert";
     newscript->GetAI = GetAI_mob_fel_orc_convert;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_lesser_shadow_fissure";
     newscript->GetAI = GetAI_mob_lesser_shadow_fissure;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp (revision 260)
@@ -111,4 +111,4 @@
     newscript->Name = "instance_shattered_halls";
     newscript->GetInstanceData = GetInstanceData_instance_shattered_halls;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp (revision 260)
@@ -283,4 +283,4 @@
     newscript->Name = "instance_magtheridons_lair";
     newscript->GetInstanceData = GetInstanceData_instance_magtheridons_lair;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp (revision 203)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp (revision 260)
@@ -546,20 +546,20 @@
     newscript->Name="boss_magtheridon";
     newscript->GetAI = GetAI_boss_magtheridon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_hellfire_channeler";
     newscript->GetAI = GetAI_mob_hellfire_channeler;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="go_manticron_cube";
     newscript->pGOHello = &GOHello_go_Manticron_Cube;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_abyssal";
     newscript->GetAI = GetAI_mob_abyssalAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp (revision 260)
@@ -576,14 +576,14 @@
     newscript->Name = "mob_doom_blossom";
     newscript->GetAI = GetAI_mob_doom_blossom;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_shadowy_construct";
     newscript->GetAI = GetAI_mob_shadowy_construct;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_teron_gorefiend";
     newscript->GetAI = GetAI_boss_teron_gorefiend;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp (revision 260)
@@ -65,4 +65,4 @@
     newscript->pGossipHello = GossipHello_npc_spirit_of_olum;
     newscript->pGossipSelect = GossipSelect_npc_spirit_of_olum;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 260)
@@ -2248,5 +2248,5 @@
     newscript->Name = "boss_illidan_stormrage";
     newscript->GetAI = GetAI_boss_illidan_stormrage;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -2255,44 +2255,44 @@
     newscript->pGossipHello = GossipHello_npc_akama_at_illidan;
     newscript->pGossipSelect = GossipSelect_npc_akama_at_illidan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "boss_maiev_shadowsong";
     newscript->GetAI = GetAI_boss_maiev;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_flame_of_azzinoth";
     newscript->GetAI = GetAI_mob_flame_of_azzinoth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_blade_of_azzinoth";
     newscript->GetAI = GetAI_blade_of_azzinoth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "gameobject_cage_trap";
     newscript->pGOHello = GOHello_cage_trap;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_cage_trap_trigger";
     newscript->GetAI = &GetAI_cage_trap_trigger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_shadow_demon";
     newscript->GetAI = GetAI_shadow_demon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_demon_fire";
     newscript->GetAI = GetAI_demonfire;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_parasitic_shadowfiend";
     newscript->GetAI = GetAI_parasitic_shadowfiend;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp (revision 260)
@@ -358,4 +358,4 @@
     newscript->Name="boss_mother_shahraz";
     newscript->GetAI = GetAI_boss_shahraz;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp (revision 108)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp (revision 260)
@@ -856,29 +856,29 @@
     newscript->Name="mob_illidari_council";
     newscript->GetAI = GetAI_mob_illidari_council;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_blood_elf_council_voice_trigger";
     newscript->GetAI = GetAI_mob_blood_elf_council_voice_trigger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_gathios_the_shatterer";
     newscript->GetAI = GetAI_boss_gathios_the_shatterer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lady_malande";
     newscript->GetAI = GetAI_boss_lady_malande;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_veras_darkshadow";
     newscript->GetAI = GetAI_boss_veras_darkshadow;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_high_nethermancer_zerevor";
     newscript->GetAI = GetAI_boss_high_nethermancer_zerevor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp (revision 178)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp (revision 260)
@@ -333,4 +333,4 @@
     newscript->Name = "instance_black_temple";
     newscript->GetInstanceData = GetInstanceData_instance_black_temple;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp (revision 160)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp (revision 260)
@@ -259,9 +259,9 @@
     newscript->Name="boss_najentus";
     newscript->GetAI = GetAI_boss_najentus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "go_najentus_spine";
     newscript->pGOHello = &GOHello_go_najentus_spine;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp (revision 222)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp (revision 260)
@@ -797,15 +797,15 @@
     newscript->Name="boss_shade_of_akama";
     newscript->GetAI = GetAI_boss_shade_of_akama;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_ashtongue_channeler";
     newscript->GetAI = GetAI_mob_ashtongue_channeler;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_ashtongue_sorcerer";
     newscript->GetAI = GetAI_mob_ashtongue_sorcerer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -814,4 +814,4 @@
     newscript->pGossipHello = &GossipHello_npc_akama;
     newscript->pGossipSelect = &GossipSelect_npc_akama;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp (revision 203)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp (revision 260)
@@ -237,9 +237,9 @@
     newscript->Name="boss_supremus";
     newscript->GetAI = GetAI_boss_supremus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="molten_flame";
     newscript->GetAI = GetAI_molten_flame;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp (revision 260)
@@ -362,4 +362,4 @@
     newscript->Name="boss_gurtogg_bloodboil";
     newscript->GetAI = GetAI_boss_gurtogg_bloodboil;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp (revision 260)
@@ -724,24 +724,24 @@
     newscript->Name="boss_reliquary_of_souls";
     newscript->GetAI = GetAI_boss_reliquary_of_souls;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_essence_of_suffering";
     newscript->GetAI = GetAI_boss_essence_of_suffering;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_essence_of_desire";
     newscript->GetAI = GetAI_boss_essence_of_desire;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_essence_of_anger";
     newscript->GetAI = GetAI_boss_essence_of_anger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_enslaved_soul";
     newscript->GetAI = GetAI_npc_enslaved_soul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp (revision 260)
@@ -77,4 +77,4 @@
     newscript->pGossipHello = &GossipHello_npc_braug_dimspirit;
     newscript->pGossipSelect = &GossipSelect_npc_braug_dimspirit;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp (revision 260)
@@ -294,9 +294,9 @@
     newscript->Name="boss_warp_splinter";
     newscript->GetAI = GetAI_boss_warp_splinter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_warp_splinter_treant";
     newscript->GetAI = GetAI_mob_treant;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp (revision 260)
@@ -212,4 +212,4 @@
     newscript->Name="boss_high_botanist_freywinn";
     newscript->GetAI = GetAI_boss_high_botanist_freywinn;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp (revision 260)
@@ -195,4 +195,4 @@
     newscript->Name="boss_laj";
     newscript->GetAI = GetAI_boss_laj;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp (revision 260)
@@ -1582,34 +1582,34 @@
     newscript->Name="boss_kaelthas";
     newscript->GetAI = GetAI_boss_kaelthas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_thaladred_the_darkener";
     newscript->GetAI = GetAI_boss_thaladred_the_darkener;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lord_sanguinar";
     newscript->GetAI = GetAI_boss_lord_sanguinar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_grand_astromancer_capernian";
     newscript->GetAI = GetAI_boss_grand_astromancer_capernian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_master_engineer_telonicus";
     newscript->GetAI = GetAI_boss_master_engineer_telonicus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name= "mob_kael_flamestrike";
     newscript->GetAI = GetAI_mob_kael_flamestrike;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_phoenix";
     newscript->GetAI = GetAI_mob_phoenix;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp (revision 260)
@@ -95,4 +95,4 @@
     newscript->Name="mob_crystalcore_devastator";
     newscript->GetAI = GetAI_mob_crystalcore_devastator;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp (revision 260)
@@ -537,9 +537,9 @@
     newscript->Name="boss_high_astromancer_solarian";
     newscript->GetAI = GetAI_boss_high_astromancer_solarian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_solarium_priest";
     newscript->GetAI = GetAI_mob_solarium_priest;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp (revision 260)
@@ -506,14 +506,14 @@
     newscript->Name="boss_alar";
     newscript->GetAI = GetAI_boss_alar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_ember_of_alar";
     newscript->GetAI = GetAI_mob_ember_of_alar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_flame_patch_alar";
     newscript->GetAI = GetAI_mob_flame_patch_alar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp (revision 260)
@@ -173,4 +173,4 @@
     newscript->Name = "instance_the_eye";
     newscript->GetInstanceData = GetInstanceData_instance_the_eye;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp (revision 260)
@@ -196,4 +196,4 @@
     newscript->Name="boss_void_reaver";
     newscript->GetAI = GetAI_boss_void_reaver;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp (revision 260)
@@ -368,9 +368,9 @@
     newscript->Name="boss_harbinger_skyriss";
     newscript->GetAI = GetAI_boss_harbinger_skyriss;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_harbinger_skyriss_illusion";
     newscript->GetAI = GetAI_boss_harbinger_skyriss_illusion;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp (revision 260)
@@ -576,14 +576,14 @@
     newscript->Name="npc_millhouse_manastorm";
     newscript->GetAI = GetAI_npc_millhouse_manastorm;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_warden_mellichar";
     newscript->GetAI = GetAI_npc_warden_mellichar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_zerekethvoidzone";
     newscript->GetAI = GetAI_mob_zerekethvoidzoneAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp (revision 260)
@@ -221,4 +221,4 @@
     newscript->Name = "instance_arcatraz";
     newscript->GetInstanceData = GetInstanceData_instance_arcatraz;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp (revision 260)
@@ -278,9 +278,9 @@
     newscript->Name="boss_nethermancer_sepethrea";    
     newscript->GetAI = GetAI_boss_nethermancer_sepethrea;    
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;    
     newscript->Name="mob_ragin_flames";    
     newscript->GetAI = GetAI_mob_ragin_flames;    
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp (revision 260)
@@ -87,4 +87,4 @@
     newscript->Name = "instance_mechanar";
     newscript->GetInstanceData = GetInstanceData_instance_mechanar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp (revision 260)
@@ -158,4 +158,4 @@
     newscript->Name="boss_gatewatcher_iron_hand";    
     newscript->GetAI = GetAI_boss_gatewatcher_iron_hand;    
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp (revision 260)
@@ -298,9 +298,9 @@
     newscript->Name="boss_pathaleon_the_calculator";    
     newscript->GetAI = GetAI_boss_pathaleon_the_calculator;    
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;    
     newscript->Name="mob_nether_wraith";    
     newscript->GetAI = GetAI_mob_nether_wraith;    
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp (revision 260)
@@ -246,5 +246,5 @@
     newscript->pGossipHello = &GossipHello_npc_archmage_malin;
     newscript->pGossipSelect = &GossipSelect_npc_archmage_malin;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -252,5 +252,5 @@
     newscript->GetAI = GetAI_npc_bartleby;
     newscript->pQuestAccept = &QuestAccept_npc_bartleby;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -258,10 +258,10 @@
     newscript->GetAI = GetAI_npc_dashel_stonefist;
     newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "npc_general_marcus_jonathan";
     newscript->pReceiveEmote = &ReceiveEmote_npc_general_marcus_jonathan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -269,4 +269,4 @@
     newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor;
     newscript->pGossipSelect = &GossipSelect_npc_lady_katrana_prestor;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp (revision 260)
@@ -335,14 +335,14 @@
     newscript->Name="boss_kri";
     newscript->GetAI = GetAI_boss_kri;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_vem";
     newscript->GetAI = GetAI_boss_vem;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_yauj";
     newscript->GetAI = GetAI_boss_yauj;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp (revision 260)
@@ -140,4 +140,4 @@
     newscript->Name="boss_huhuran";
     newscript->GetAI = GetAI_boss_huhuran;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp (revision 260)
@@ -690,9 +690,9 @@
     newscript->Name="boss_veknilash";
     newscript->GetAI = GetAI_boss_veknilash;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_veklor";
     newscript->GetAI = GetAI_boss_veklor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp (revision 260)
@@ -187,4 +187,4 @@
     newscript->Name="boss_fankriss";
     newscript->GetAI = GetAI_boss_fankriss;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp (revision 260)
@@ -1330,34 +1330,34 @@
     newscript->Name="boss_eye_of_cthun";
     newscript->GetAI = GetAI_eye_of_cthun;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_cthun";
     newscript->GetAI = GetAI_cthun;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_eye_tentacle";
     newscript->GetAI = GetAI_eye_tentacle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_claw_tentacle";
     newscript->GetAI = GetAI_claw_tentacle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_giant_claw_tentacle";
     newscript->GetAI = GetAI_giant_claw_tentacle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_giant_eye_tentacle";
     newscript->GetAI = GetAI_giant_eye_tentacle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_giant_flesh_tentacle";
     newscript->GetAI = GetAI_flesh_tentacle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp (revision 260)
@@ -260,9 +260,9 @@
     newscript->Name="boss_sartura";
     newscript->GetAI = GetAI_boss_sartura;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_sartura_royal_guard";
     newscript->GetAI = GetAI_mob_sartura_royal_guard;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp (revision 260)
@@ -311,4 +311,4 @@
     newscript->Name="boss_skeram";
     newscript->GetAI = GetAI_boss_skeram;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp (revision 260)
@@ -137,4 +137,4 @@
     newscript->Name="boss_ouro";
     newscript->GetAI = GetAI_boss_ouro;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp (revision 260)
@@ -162,4 +162,4 @@
     newscript->Name = "instance_temple_of_ahnqiraj";
     newscript->GetInstanceData = GetInstanceData_instance_temple_of_ahnqiraj;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp (revision 260)
@@ -310,5 +310,5 @@
     newscript->Name="mob_anubisath_sentinel";
     newscript->GetAI = GetAI_mob_anubisath_sentinelAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
 
Index: trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp (revision 260)
@@ -90,4 +90,4 @@
     newscript->pGossipHello =  &GossipHello_npc_royal_historian_archesonus;
     newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp (revision 260)
@@ -213,4 +213,4 @@
     newscript->Name="boss_doomwalker";
     newscript->GetAI = GetAI_boss_doomwalker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp (revision 141)
+++ trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp (revision 260)
@@ -1107,15 +1107,15 @@
     newscript->Name = "mob_mature_netherwing_drake";
     newscript->GetAI = GetAI_mob_mature_netherwing_drake;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_enslaved_netherwing_drake";
     newscript->GetAI = GetAI_mob_enslaved_netherwing_drake;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
 	newscript->Name = "mob_dragonmaw_peon";
 	newscript->GetAI = GetAI_mob_dragonmaw_peon;
-	m_scripts[nrscripts++] = newscript;
+	newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1123,10 +1123,10 @@
     newscript->pGossipHello =  &GossipHello_npc_drake_dealer_hurlunk;
     newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_invis_legion_teleporter";
     newscript->GetAI = GetAI_npc_invis_legion_teleporter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1134,5 +1134,5 @@
     newscript->pGossipHello =  &GossipHello_npcs_flanis_swiftwing_and_kagrosh;
     newscript->pGossipSelect = &GossipSelect_npcs_flanis_swiftwing_and_kagrosh;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1140,5 +1140,5 @@
     newscript->pGossipHello =  &GossipHello_npc_murkblood_overseer;
     newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1146,10 +1146,10 @@
     newscript->pGossipHello =  &GossipHello_npc_neltharaku;
     newscript->pGossipSelect = &GossipSelect_npc_neltharaku;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "npc_karynaku";
     newscript->pQuestAccept = &QuestAccept_npc_karynaku;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -1157,5 +1157,5 @@
     newscript->pGossipHello =  &GossipHello_npc_oronok_tornheart;
     newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
@@ -1163,10 +1163,10 @@
 	newscript->GetAI = GetAI_Overlord_Morghor;
 	newscript->pQuestAccept = &QuestAccept_Overlord_Morghor;
-	m_scripts[nrscripts++] = newscript;
+	newscript->RegisterSelf();
 
 	newscript = new Script;
 	newscript->Name = "npc_lord_illidan_stormrage";
 	newscript->GetAI = GetAI_Lord_Illidan;
-	m_scripts[nrscripts++] = newscript;
+	newscript->RegisterSelf();
 
 	newscript = new Script;
@@ -1175,4 +1175,4 @@
 	newscript->pGossipHello = &GossipHello_npc_yarzill_fly;
 	newscript->pGossipSelect = &GossipSelect_npc_yarzill_fly;
-	m_scripts[nrscripts++] = newscript;
-}
+	newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp (revision 260)
@@ -202,4 +202,4 @@
     newscript->Name="boss_gyth";
     newscript->GetAI = GetAI_boss_gyth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp (revision 260)
@@ -118,4 +118,4 @@
     newscript->Name="boss_warmaster_voone";
     newscript->GetAI = GetAI_boss_warmastervoone;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp (revision 260)
@@ -92,4 +92,4 @@
     newscript->Name="boss_halycon";
     newscript->GetAI = GetAI_boss_halycon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp (revision 260)
@@ -90,4 +90,4 @@
     newscript->Name="boss_the_beast";
     newscript->GetAI = GetAI_boss_thebeast;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp (revision 260)
@@ -124,4 +124,4 @@
     newscript->Name="boss_overlord_wyrmthalak";
     newscript->GetAI = GetAI_boss_overlordwyrmthalak;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp (revision 260)
@@ -88,4 +88,4 @@
     newscript->Name="boss_rend_blackhand";
     newscript->GetAI = GetAI_boss_rend_blackhand;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp (revision 260)
@@ -128,4 +128,4 @@
     newscript->Name="boss_highlord_omokk";
     newscript->GetAI = GetAI_boss_highlordomokk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp (revision 260)
@@ -83,4 +83,4 @@
     newscript->Name="boss_mother_smolderweb";
     newscript->GetAI = GetAI_boss_mothersmolderweb;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp (revision 260)
@@ -92,4 +92,4 @@
     newscript->Name="boss_shadow_hunter_voshgajin";
     newscript->GetAI = GetAI_boss_shadowvosh;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp (revision 260)
@@ -98,4 +98,4 @@
     newscript->Name="boss_drakkisath";
     newscript->GetAI = GetAI_boss_drakkisath;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp (revision 260)
@@ -90,4 +90,4 @@
     newscript->Name="boss_pyroguard_emberseer";
     newscript->GetAI = GetAI_boss_pyroguard_emberseer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp (revision 260)
@@ -82,4 +82,4 @@
     newscript->Name="quartermaster_zigris";
     newscript->GetAI = GetAI_boss_quatermasterzigris;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp (revision 260)
@@ -95,4 +95,4 @@
     newscript->Name="npc_henze_faulk";
     newscript->GetAI = GetAI_npc_henze_faulk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp (revision 260)
@@ -150,5 +150,5 @@
     newscript->pGossipHello =  &GossipHello_npc_deathly_usher;
     newscript->pGossipSelect = &GossipSelect_npc_deathly_usher;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -156,4 +156,4 @@
     newscript->pGossipHello =  &GossipHello_npc_fallen_hero_of_horde;
     newscript->pGossipSelect = &GossipSelect_npc_fallen_hero_of_horde;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp (revision 260)
@@ -179,4 +179,4 @@
     newscript->Name="boss_kruul";
     newscript->GetAI = GetAI_boss_kruul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp (revision 260)
@@ -375,10 +375,10 @@
     newscript->Name="mob_aquementas";
     newscript->GetAI = GetAI_mob_aquementas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_custodian_of_time";
     newscript->GetAI = GetAI_npc_custodian_of_time;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -386,5 +386,5 @@
     newscript->pGossipHello =  &GossipHello_npc_marin_noggenfogger;
     newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -393,5 +393,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_steward_of_time;
     newscript->pQuestAccept =  &QuestAccept_npc_steward_of_time;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -399,4 +399,4 @@
     newscript->pGossipHello =  &GossipHello_npc_stone_watcher_of_norgannon;
     newscript->pGossipSelect = &GossipSelect_npc_stone_watcher_of_norgannon;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp (revision 260)
@@ -415,5 +415,5 @@
     newscript->pGossipHello =  &GossipHello_npc_raliq_the_drunk;
     newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -421,5 +421,5 @@
     newscript->GetAI = GetAI_npc_salsalabim;
     newscript->pGossipHello =  &GossipHello_npc_salsalabim;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -427,5 +427,5 @@
     newscript->pGossipHello =  &GossipHello_npc_shattrathflaskvendors;
     newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -433,9 +433,9 @@
     newscript->pGossipHello =  &GossipHello_npc_zephyr;
     newscript->pGossipSelect = &GossipSelect_npc_zephyr;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
        newscript = new Script;
     newscript->Name="npc_kservant";
     newscript->GetAI = GetAI_npc_kservantAI;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp (revision 260)
@@ -153,5 +153,5 @@
     newscript->Name="mobs_mana_tapped";
     newscript->GetAI = GetAI_mobs_mana_tapped;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -160,4 +160,4 @@
     newscript->pGossipHello =  &GossipHello_npc_prospector_anvilward;
     newscript->pGossipSelect = &GossipSelect_npc_prospector_anvilward;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 260)
@@ -681,19 +681,19 @@
     newscript->Name="boss_kalecgos";
     newscript->GetAI = GetAI_boss_kalecgos;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_sathrovarr";
     newscript->GetAI = GetAI_boss_Sathrovarr;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_kalec";
     newscript->GetAI = GetAI_boss_kalec;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="kalocegos_teleporter";
     newscript->pGOHello = &GOkalocegos_teleporter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp (revision 141)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp (revision 260)
@@ -179,4 +179,4 @@
     newscript->Name="boss_brutallus";
     newscript->GetAI = GetAI_boss_brutallus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp (revision 260)
@@ -193,4 +193,4 @@
     newscript->Name = "instance_sunwell_plateau";
     newscript->GetInstanceData = GetInstanceData_instance_sunwell_plateau;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 260)
@@ -575,14 +575,14 @@
     newscript->Name="boss_felmyst";
     newscript->GetAI = GetAI_boss_felmyst;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_felmyst_vapor";
     newscript->GetAI = GetAI_mob_felmyst_vapor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_felmyst_trail";
     newscript->GetAI = GetAI_mob_felmyst_trail;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp (revision 260)
@@ -762,14 +762,14 @@
     newscript->Name="boss_sacrolash";
     newscript->GetAI = GetAI_boss_sacrolash;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_alythess";
     newscript->GetAI = GetAI_boss_alythess;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_shadow_image";
     newscript->GetAI = GetAI_mob_shadow_image;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp (revision 260)
@@ -546,5 +546,5 @@
     newscript->pGossipHello =  &GossipHello_npc_bunthen_plainswind;
     newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -552,5 +552,5 @@
     newscript->pGossipHello =  &GossipHello_npc_great_bear_spirit;
     newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -558,14 +558,14 @@
     newscript->pGossipHello =  &GossipHello_npc_silva_filnaveth;
     newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="npc_clintar_dreamwalker";
     newscript->pQuestAccept = &QuestAccept_npc_clintar_dreamwalker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_clintar_spirit";
     newscript->GetAI = GetAI_npc_clintar_spirit;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp (revision 260)
@@ -246,10 +246,10 @@
     newscript->GetAI = GetAI_npc_lady_sylvanas_windrunner;
     newscript->pChooseReward = &ChooseReward_npc_lady_sylvanas_windrunner;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_highborne_lamenter";
     newscript->GetAI = GetAI_npc_highborne_lamenter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -257,4 +257,4 @@
     newscript->pGossipHello = &GossipHello_npc_parqual_fintallas;
     newscript->pGossipSelect = &GossipSelect_npc_parqual_fintallas;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp (revision 260)
@@ -125,4 +125,4 @@
     newscript->Name="boss_broodlord";
     newscript->GetAI = GetAI_boss_broodlord;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp (revision 260)
@@ -91,4 +91,4 @@
     newscript->Name="boss_firemaw";
     newscript->GetAI = GetAI_boss_firemaw;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp (revision 260)
@@ -128,4 +128,4 @@
     newscript->Name="boss_razorgore";
     newscript->GetAI = GetAI_boss_razorgore;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp (revision 260)
@@ -91,4 +91,4 @@
     newscript->Name="boss_flamegor";
     newscript->GetAI = GetAI_boss_flamegor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp (revision 260)
@@ -311,4 +311,4 @@
     newscript->Name="boss_chromaggus";
     newscript->GetAI = GetAI_boss_chromaggus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp (revision 260)
@@ -258,4 +258,4 @@
     newscript->pGossipHello = &GossipHello_boss_vael;
     newscript->pGossipSelect = &GossipSelect_boss_vael;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp (revision 260)
@@ -391,4 +391,4 @@
     newscript->pGossipHello = &GossipHello_boss_victor_nefarius;
     newscript->pGossipSelect = &GossipSelect_boss_victor_nefarius;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp (revision 260)
@@ -224,4 +224,4 @@
     newscript->Name="boss_nefarian";
     newscript->GetAI = GetAI_boss_nefarian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp (revision 260)
@@ -100,4 +100,4 @@
     newscript->Name="boss_ebonroc";
     newscript->GetAI = GetAI_boss_ebonroc;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp (revision 260)
@@ -144,5 +144,5 @@
     newscript->pGossipHello =  &GossipHello_npc_kalaran_windblade;
     newscript->pGossipSelect = &GossipSelect_npc_kalaran_windblade;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -150,5 +150,5 @@
     newscript->pGossipHello          = &GossipHello_npc_lothos_riftwaker;
     newscript->pGossipSelect         = &GossipSelect_npc_lothos_riftwaker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -156,4 +156,4 @@
     newscript->pGossipHello =  &GossipHello_npc_zamael_lunthistle;
     newscript->pGossipSelect = &GossipSelect_npc_zamael_lunthistle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp (revision 260)
@@ -407,15 +407,15 @@
     newscript->Name="mobs_bladespire_ogre";
     newscript->GetAI = GetAI_mobs_bladespire_ogre;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mobs_nether_drake";
     newscript->GetAI = GetAI_mobs_nether_drake;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_daranelle";
     newscript->GetAI = GetAI_npc_daranelle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -423,5 +423,5 @@
     newscript->pGossipHello = &GossipHello_npc_overseer_nuaar;
     newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -429,5 +429,5 @@
     newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder;
     newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -435,4 +435,4 @@
     newscript->pGossipHello =  &GossipHello_npc_skyguard_handler_irena;
     newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_irena;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp (revision 260)
@@ -272,9 +272,9 @@
     newscript->Name="boss_nexusprince_shaffar";
     newscript->GetAI = GetAI_boss_nexusprince_shaffar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_ethereal_beacon";
     newscript->GetAI = GetAI_mob_ethereal_beacon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp (revision 115)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp (revision 260)
@@ -135,4 +135,4 @@
     newscript->Name="boss_pandemonius";
     newscript->GetAI = GetAI_boss_pandemonius;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp (revision 260)
@@ -349,14 +349,14 @@
     newscript->Name="boss_exarch_maladaar";
     newscript->GetAI = GetAI_boss_exarch_maladaar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_avatar_of_martyred";
     newscript->GetAI = GetAI_mob_avatar_of_martyred;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_stolen_soul";
     newscript->GetAI = GetAI_mob_stolen_soul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp (revision 260)
@@ -71,4 +71,4 @@
     newscript->Name = "instance_sethekk_halls";
     newscript->GetInstanceData = GetInstanceData_instance_sethekk_halls;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp (revision 260)
@@ -220,4 +220,4 @@
     newscript->Name="boss_talon_king_ikiss";
     newscript->GetAI = GetAI_boss_talon_king_ikiss;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp (revision 115)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp (revision 260)
@@ -393,24 +393,24 @@
     newscript->Name="boss_darkweaver_syth";
     newscript->GetAI = GetAI_boss_darkweaver_syth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_syth_fire";
     newscript->GetAI = GetAI_mob_syth_arcane;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_syth_arcane";
     newscript->GetAI = GetAI_mob_syth_arcane;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_syth_frost";
     newscript->GetAI = GetAI_mob_syth_frost;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_syth_shadow";
     newscript->GetAI = GetAI_mob_syth_shadow;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp (revision 115)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp (revision 260)
@@ -174,4 +174,4 @@
     newscript->Name="boss_blackheart_the_inciter";
     newscript->GetAI = GetAI_boss_blackheart_the_inciter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp (revision 260)
@@ -175,4 +175,4 @@
     newscript->Name = "instance_shadow_labyrinth";
     newscript->GetInstanceData = GetInstanceData_instance_shadow_labyrinth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp (revision 260)
@@ -364,9 +364,9 @@
     newscript->Name="boss_grandmaster_vorpil";
     newscript->GetAI = GetAI_boss_grandmaster_vorpil;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_voidtraveler";
     newscript->GetAI = GetAI_mob_voidtraveler;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp (revision 115)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp (revision 260)
@@ -195,4 +195,4 @@
     newscript->Name="boss_ambassador_hellmaw";
     newscript->GetAI = GetAI_boss_ambassador_hellmaw;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp (revision 260)
@@ -149,4 +149,4 @@
     newscript->Name="boss_murmur";
     newscript->GetAI = GetAI_boss_murmur;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp (revision 260)
@@ -262,5 +262,5 @@
     newscript->pGossipHello =  &GossipHello_npcs_ashyen_and_keleth;
     newscript->pGossipSelect = &GossipSelect_npcs_ashyen_and_keleth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -268,5 +268,5 @@
     newscript->pGossipHello =  &GossipHello_npc_cooshcoosh;
     newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -274,5 +274,5 @@
     newscript->pGossipHello =  &GossipHello_npc_elder_kuruti;
     newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -280,4 +280,4 @@
     newscript->pGossipHello =  &GossipHello_npc_mortog_steamhead;
     newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp (revision 260)
@@ -133,4 +133,4 @@
     newscript->pGossipHello = &GossipHello_npc_cairne_bloodhoof;
     newscript->pGossipSelect = &GossipSelect_npc_cairne_bloodhoof;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp (revision 260)
@@ -189,9 +189,9 @@
     newscript->Name="boss_hydromancer_thespia";
     newscript->GetAI = GetAI_boss_thespiaAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_coilfang_waterelemental";
     newscript->GetAI = GetAI_mob_coilfang_waterelementalAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp (revision 260)
@@ -227,9 +227,9 @@
     newscript->Name="mob_naga_distiller";
     newscript->GetAI = GetAI_mob_naga_distiller;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_warlord_kalithresh";
     newscript->GetAI = GetAI_boss_warlord_kalithresh;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp (revision 166)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp (revision 260)
@@ -272,9 +272,9 @@
     newscript->Name="boss_mekgineer_steamrigger";
     newscript->GetAI = GetAI_boss_mekgineer_steamrigger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_steamrigger_mechanic";
     newscript->GetAI = GetAI_mob_steamrigger_mechanic;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp (revision 260)
@@ -167,4 +167,4 @@
     newscript->Name = "instance_steam_vault";
     newscript->GetInstanceData = GetInstanceData_instance_steam_vault;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp (revision 260)
@@ -148,9 +148,9 @@
     newscript->Name="boss_hungarfen";
     newscript->GetAI = GetAI_boss_hungarfen;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_underbog_mushroom";
     newscript->GetAI = GetAI_mob_underbog_mushroom;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp (revision 182)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp (revision 260)
@@ -383,4 +383,4 @@
     newscript->Name="boss_hydross_the_unstable";
     newscript->GetAI = GetAI_boss_hydross_the_unstable;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp (revision 260)
@@ -168,15 +168,15 @@
     newscript->Name="boss_the_lurker_below";
     newscript->GetAI = GetAI_boss_the_lurker_below;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="mob_coilfang_guardian";
     newscript->GetAI = GetAI_mob_coilfang_guardian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="mob_coilfang_ambusher";
     newscript->GetAI = GetAI_mob_coilfang_ambusher;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
 
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp (revision 260)
@@ -805,19 +805,19 @@
     newscript->Name="boss_leotheras_the_blind";
     newscript->GetAI = GetAI_boss_leotheras_the_blind;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_leotheras_the_blind_demonform";
     newscript->GetAI = GetAI_boss_leotheras_the_blind_demonform;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="mob_greyheart_spellbinder";
     newscript->GetAI = GetAI_mob_greyheart_spellbinder;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="mob_inner_demon";
     newscript->GetAI = GetAI_mob_inner_demon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp (revision 260)
@@ -1030,40 +1030,40 @@
     newscript->Name="boss_lady_vashj";
     newscript->GetAI = GetAI_boss_lady_vashj;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_enchanted_elemental";
     newscript->GetAI = GetAI_mob_enchanted_elemental;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_tainted_elemental";
     newscript->GetAI = GetAI_mob_tainted_elemental;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_toxic_sporebat";
     newscript->GetAI = GetAI_mob_toxic_sporebat;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_coilfang_elite";
     newscript->GetAI = GetAI_mob_coilfang_elite;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_coilfang_strider";
     newscript->GetAI = GetAI_mob_coilfang_strider;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_shield_generator_channel";
     newscript->GetAI = GetAI_mob_shield_generator_channel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_tainted_core";
     newscript->pItemUse = ItemUse_item_tainted_core;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
 
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp (revision 164)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp (revision 260)
@@ -745,19 +745,19 @@
     newscript->Name="boss_fathomlord_karathress";
     newscript->GetAI = GetAI_boss_fathomlord_karathress;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_sharkkis";
     newscript->GetAI = GetAI_boss_fathomguard_sharkkis;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_tidalvess";
     newscript->GetAI = GetAI_boss_fathomguard_tidalvess;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_caribdis";
     newscript->GetAI = GetAI_boss_fathomguard_caribdis;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp (revision 260)
@@ -351,9 +351,9 @@
     newscript->Name="boss_morogrim_tidewalker";
     newscript->GetAI = GetAI_boss_morogrim_tidewalker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_water_globule";
     newscript->GetAI = GetAI_mob_water_globule;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp (revision 187)
+++ trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp (revision 260)
@@ -216,4 +216,4 @@
     newscript->Name = "instance_serpent_shrine";
     newscript->GetInstanceData = GetInstanceData_instance_serpentshrine_cavern;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp (revision 260)
@@ -114,4 +114,4 @@
     newscript->Name="boss_moam";
     newscript->GetAI = GetAI_boss_moam;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp (revision 260)
@@ -104,4 +104,4 @@
     newscript->Name="boss_ayamiss";
     newscript->GetAI = GetAI_boss_ayamiss;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp (revision 260)
@@ -90,4 +90,4 @@
     newscript->Name="boss_kurinnaxx";
     newscript->GetAI = GetAI_boss_kurinnaxx;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp (revision 260)
@@ -230,4 +230,4 @@
     newscript->Name="boss_onyxia";
     newscript->GetAI = GetAI_boss_onyxiaAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp (revision 260)
@@ -95,4 +95,4 @@
     newscript->Name="npc_narm_faulk";
     newscript->GetAI = GetAI_npc_narm_faulk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp (revision 260)
@@ -118,4 +118,4 @@
     newscript->Name="boss_aeonus";
     newscript->GetAI = GetAI_boss_aeonus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp (revision 260)
@@ -106,4 +106,4 @@
     newscript->Name="boss_chrono_lord_deja";
     newscript->GetAI = GetAI_boss_chrono_lord_deja;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp (revision 260)
@@ -140,4 +140,4 @@
     newscript->Name="boss_temporus";
     newscript->GetAI = GetAI_boss_temporus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp (revision 260)
@@ -894,5 +894,5 @@
     newscript->pGossipHello =   &GossipHello_npc_brazen;
     newscript->pGossipSelect =  &GossipSelect_npc_brazen;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -900,5 +900,5 @@
     newscript->pGossipHello =   &GossipHello_npc_erozion;
     newscript->pGossipSelect =  &GossipSelect_npc_erozion;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -907,5 +907,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad;
     newscript->GetAI = GetAI_npc_thrall_old_hillsbrad;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -913,4 +913,4 @@
     newscript->pGossipHello =   &GossipHello_npc_taretha;
     newscript->pGossipSelect =  &GossipSelect_npc_taretha;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp (revision 260)
@@ -153,4 +153,4 @@
     newscript->Name="boss_captain_skarloc";
     newscript->GetAI = GetAI_boss_captain_skarloc;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp (revision 260)
@@ -175,4 +175,4 @@
     newscript->Name = "instance_old_hillsbrad";
     newscript->GetInstanceData = GetInstanceData_instance_old_hillsbrad;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp (revision 125)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp (revision 260)
@@ -147,4 +147,4 @@
     newscript->Name="boss_epoch_hunter";
     newscript->GetAI = GetAI_boss_epoch_hunter;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp (revision 239)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp (revision 260)
@@ -195,9 +195,9 @@
     newscript->Name="go_barrel_old_hillsbrad";
     newscript->pGOHello = &GOHello_go_barrel_old_hillsbrad;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lieutenant_drake";
     newscript->GetAI = GetAI_boss_lieutenant_drake;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp (revision 260)
@@ -770,19 +770,19 @@
     newscript->Name="boss_archimonde";
     newscript->GetAI = GetAI_boss_archimonde;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_doomfire";
     newscript->GetAI = GetAI_mob_doomfire;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_doomfire_targetting";
     newscript->GetAI = GetAI_mob_doomfire_targetting;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_ancient_wisp";
     newscript->GetAI = GetAI_mob_ancient_wisp;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp (revision 260)
@@ -201,5 +201,5 @@
     newscript->pGossipHello = &GossipHello_npc_jaina_proudmoore;
     newscript->pGossipSelect = &GossipSelect_npc_jaina_proudmoore;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -208,5 +208,5 @@
     newscript->pGossipHello = &GossipHello_npc_thrall;
     newscript->pGossipSelect = &GossipSelect_npc_thrall;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -214,4 +214,4 @@
     newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind;
     newscript->pGossipSelect = &GossipSelect_npc_tyrande_whisperwind;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp (revision 260)
@@ -200,4 +200,4 @@
     newscript->Name = "instance_hyjal";
     newscript->GetInstanceData = GetInstanceData_instance_mount_hyjal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp (revision 260)
@@ -148,4 +148,4 @@
     newscript->pGossipHello =  &GossipHello_npc_ragged_john;
     newscript->pGossipSelect = &GossipSelect_npc_ragged_john;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp (revision 260)
@@ -59,4 +59,4 @@
     newscript->Name="npc_ravenholdt";
     newscript->GetAI = GetAI_npc_ravenholdt;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp (revision 260)
@@ -632,5 +632,5 @@
     newscript->Name="mob_shattered_rumbler";
     newscript->GetAI = GetAI_mob_shattered_rumbler;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -639,10 +639,10 @@
     newscript->pGossipHello =  &GossipHello_mob_lump;
     newscript->pGossipSelect = &GossipSelect_mob_lump;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_sunspring_villager";
     newscript->GetAI = GetAI_mob_sunspring_villager;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -651,5 +651,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_altruis_the_sufferer;
     newscript->pQuestAccept =  &QuestAccept_npc_altruis_the_sufferer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -657,5 +657,5 @@
     newscript->pGossipHello =  &GossipHello_npc_greatmother_geyah;
     newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -663,14 +663,14 @@
     newscript->pGossipHello =  &GossipHello_npc_lantresor_of_the_blade;
     newscript->pGossipSelect = &GossipSelect_npc_lantresor_of_the_blade;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_creditmarker_visit_with_ancestors";
     newscript->GetAI = GetAI_npc_creditmarker_visit_with_ancestors;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_sparrowhawk";
     newscript->GetAI = GetAI_mob_sparrowhawk;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp (revision 260)
@@ -159,5 +159,5 @@
     newscript->Name="mobs_ghoul_flayer";
     newscript->GetAI = GetAI_mobs_ghoul_flayer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -165,5 +165,5 @@
     newscript->pGossipHello = &GossipHello_npc_augustus_the_touched;
     newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -171,5 +171,5 @@
     newscript->GetAI = GetAI_npc_darrowshire_spirit;
     newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -177,4 +177,4 @@
     newscript->pGossipHello =  &GossipHello_npc_tirion_fordring;
     newscript->pGossipSelect = &GossipSelect_npc_tirion_fordring;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp (revision 260)
@@ -114,4 +114,4 @@
     newscript->pGossipSelect = &GossipSelect_npc_shadowfang_prisoner;
     newscript->GetAI = GetAI_npc_shadowfang_prisoner;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp (revision 260)
@@ -149,4 +149,4 @@
     newscript->Name = "instance_shadowfang_keep";
     newscript->GetInstanceData = GetInstanceData_instance_shadowfang_keep;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp (revision 260)
@@ -301,4 +301,4 @@
     newscript->Name="boss_gruul";
     newscript->GetAI = GetAI_boss_gruul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp (revision 260)
@@ -818,24 +818,24 @@
     newscript->Name="boss_high_king_maulgar";
     newscript->GetAI = GetAI_boss_high_king_maulgar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_kiggler_the_crazed";
     newscript->GetAI = GetAI_boss_kiggler_the_crazed;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_blindeye_the_seer";
     newscript->GetAI = GetAI_boss_blindeye_the_seer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_olm_the_summoner";
     newscript->GetAI = GetAI_boss_olm_the_summoner;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_krosh_firehand";
     newscript->GetAI = GetAI_boss_krosh_firehand;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp (revision 98)
+++ trunk/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp (revision 260)
@@ -185,4 +185,4 @@
     newscript->Name = "instance_gruuls_lair";
     newscript->GetInstanceData = GetInstanceData_instance_gruuls_lair;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp (revision 260)
@@ -132,5 +132,5 @@
     newscript->Name="mob_webbed_creature";
     newscript->GetAI = GetAI_mob_webbed_creature;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -138,4 +138,4 @@
     newscript->pGossipHello =  &GossipHello_npc_captured_sunhawk_agent;
     newscript->pGossipSelect = &GossipSelect_npc_captured_sunhawk_agent;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp (revision 260)
@@ -142,5 +142,5 @@
     newscript->pGossipHello =  &GossipHello_npc_lorax;
     newscript->pGossipSelect = &GossipSelect_npc_lorax;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -148,5 +148,5 @@
     newscript->pGossipHello =  &GossipHello_npc_rivern_frostwind;
     newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -154,4 +154,4 @@
     newscript->pGossipHello =  &GossipHello_npc_witch_doctor_mauari;
     newscript->pGossipSelect = &GossipSelect_npc_witch_doctor_mauari;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp (revision 92)
+++ trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp (revision 260)
@@ -370,5 +370,5 @@
     newscript->pGossipHello = &GossipHello_npc_beaten_corpse;
     newscript->pGossipSelect = &GossipSelect_npc_beaten_corpse;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -376,5 +376,5 @@
     newscript->pGossipHello = &GossipHello_npc_sputtervalve;
     newscript->pGossipSelect = &GossipSelect_npc_sputtervalve;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -382,9 +382,9 @@
     newscript->GetAI = GetAI_npc_taskmaster_fizzule;
     newscript->pReceiveEmote = &ReciveEmote_npc_taskmaster_fizzule;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_twiggy_flathead";
     newscript->GetAI = GetAI_npc_twiggy_flathead;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp (revision 260)
@@ -85,4 +85,4 @@
     newscript->GetAI = GetAI_npc_calvin_montague;
     newscript->pQuestAccept = &QuestAccept_npc_calvin_montague;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp (revision 101)
+++ trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp (revision 260)
@@ -100,4 +100,4 @@
     newscript->Name="npc_blood_knight_stillblade";
     newscript->GetAI = GetAI_npc_blood_knight_stillblade;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp (revision 260)
@@ -110,4 +110,4 @@
     newscript->Name="boss_interrogator_vishas";
     newscript->GetAI = GetAI_boss_interrogator_vishas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp (revision 260)
@@ -94,4 +94,4 @@
     newscript->Name="boss_azshir_the_sleepless";
     newscript->GetAI = GetAI_boss_azshir_the_sleepless;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp (revision 260)
@@ -75,4 +75,4 @@
     newscript->Name="boss_houndmaster_loksey";
     newscript->GetAI = GetAI_boss_houndmaster_loksey;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp (revision 260)
@@ -133,4 +133,4 @@
     newscript->Name="boss_bloodmage_thalnos";
     newscript->GetAI = GetAI_boss_bloodmage_thalnos;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp (revision 260)
@@ -194,4 +194,4 @@
     newscript->Name="boss_herod";
     newscript->GetAI = GetAI_boss_herod;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp (revision 260)
@@ -157,4 +157,4 @@
     newscript->Name="boss_scarlet_commander_mograine";
     newscript->GetAI = GetAI_boss_scarlet_commander_mograine;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp (revision 260)
@@ -97,4 +97,4 @@
     newscript->Name="boss_scorn";
     newscript->GetAI = GetAI_boss_scorn;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp (revision 260)
@@ -168,4 +168,4 @@
     newscript->Name="boss_arcanist_doan";
     newscript->GetAI = GetAI_boss_arcanist_doan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp (revision 260)
@@ -129,4 +129,4 @@
     newscript->Name="boss_high_inquisitor_fairbanks";
     newscript->GetAI = GetAI_boss_high_inquisitor_fairbanks;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp (revision 260)
@@ -174,4 +174,4 @@
     newscript->Name="boss_high_inquisitor_whitemane";
     newscript->GetAI = GetAI_boss_high_inquisitor_whitemane;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp (revision 260)
@@ -655,19 +655,19 @@
     newscript->Name="boss_shade_of_aran";
     newscript->GetAI = GetAI_boss_aran;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_shadow_of_aran";
     newscript->GetAI = GetAI_shadow_of_aran;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_aran_elemental";
     newscript->GetAI = GetAI_water_elemental;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     //newscript = new Script;
     //newscript->Name="mob_aran_blizzard";
     //newscript->GetAI = GetAI_boss_aran;
-    //m_scripts[nrscripts++] = newscript;
+    //newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 260)
@@ -461,5 +461,5 @@
     newscript->pGossipHello = GossipHello_npc_barnes;
     newscript->pGossipSelect = GossipSelect_npc_barnes;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -467,4 +467,4 @@
     newscript->pGossipHello = GossipHello_npc_berthold;
     newscript->pGossipSelect = GossipSelect_npc_berthold;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp (revision 260)
@@ -437,19 +437,19 @@
     newscript->Name="boss_terestian_illhoof";
     newscript->GetAI = GetAI_boss_terestian_illhoof;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_karazhan_imp";
     newscript->GetAI = GetAI_mob_karazhan_imp;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_kilrek";
     newscript->GetAI = GetAI_mob_kilrek;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_demon_chain";
     newscript->GetAI = GetAI_mob_demon_chain;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp (revision 260)
@@ -250,4 +250,4 @@
     newscript->Name = "instance_karazhan";
     newscript->GetInstanceData = GetInstanceData_instance_karazhan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp (revision 260)
@@ -1415,35 +1415,35 @@
     newscript->GetAI = GetAI_boss_dorothee;
     newscript->Name = "boss_dorothee";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_strawman;
     newscript->Name = "boss_strawman";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_tinhead;
     newscript->Name = "boss_tinhead";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_roar;
     newscript->Name = "boss_roar";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_crone;
     newscript->Name = "boss_crone";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_mob_tito;
     newscript->Name = "mob_tito";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_mob_cyclone;
     newscript->Name = "mob_cyclone";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     // Hood
@@ -1452,10 +1452,10 @@
     newscript->pGossipSelect = GossipSelect_npc_grandmother;
     newscript->Name = "npc_grandmother";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_bigbadwolf;
     newscript->Name = "boss_bigbadwolf";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     // Romeo And Juliet
@@ -1463,9 +1463,9 @@
     newscript->GetAI = GetAI_boss_julianne;
     newscript->Name = "boss_julianne";
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_romulo;
     newscript->Name = "boss_romulo";
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp (revision 260)
@@ -197,4 +197,4 @@
     newscript->Name="boss_curator";
     newscript->GetAI = GetAI_boss_curator;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp (revision 260)
@@ -180,4 +180,4 @@
     newscript->Name="boss_maiden_of_virtue";
     newscript->GetAI = GetAI_boss_maiden_of_virtue;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp (revision 260)
@@ -363,9 +363,9 @@
     newscript->Name="boss_attumen";
     newscript->GetAI = GetAI_boss_attumen;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_midnight";
     newscript->GetAI = GetAI_boss_midnight;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp (revision 109)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp (revision 260)
@@ -836,34 +836,34 @@
     newscript->Name="boss_moroes";
     newscript->GetAI = GetAI_boss_moroes;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_baroness_dorothea_millstipe";
     newscript->GetAI = GetAI_baroness_dorothea_millstipe;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_baron_rafe_dreuger";
     newscript->GetAI = GetAI_baron_rafe_dreuger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lady_catriona_von_indi";
     newscript->GetAI = GetAI_lady_catriona_von_indi;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lady_keira_berrybuck";
     newscript->GetAI = GetAI_lady_keira_berrybuck;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lord_robin_daris";
     newscript->GetAI = GetAI_lord_robin_daris;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lord_crispin_ference";
     newscript->GetAI = GetAI_lord_crispin_ference;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 260)
@@ -667,9 +667,9 @@
     newscript->Name="boss_malchezaar";
     newscript->GetAI = GetAI_boss_malchezaar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="netherspite_infernal";
     newscript->GetAI = GetAI_netherspite_infernal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp (revision 260)
@@ -86,4 +86,4 @@
     newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky;
     newscript->pGossipSelect = &GossipSelect_npcs_riverbreeze_and_silversky;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp (revision 260)
@@ -205,10 +205,10 @@
     newscript->Name="mobs_risen_husk_spirit";
     newscript->GetAI = GetAI_mobs_risen_husk_spirit;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_restless_apparition";
     newscript->pGossipHello =   &GossipHello_npc_restless_apparition;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -216,5 +216,5 @@
     newscript->GetAI = GetAI_npc_deserter_agitator;
     newscript->pGossipHello = &GossipHello_npc_deserter_agitator;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -222,5 +222,5 @@
     newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore;
     newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -228,4 +228,4 @@
     newscript->pGossipHello = &GossipHello_npc_nat_pagle;
     newscript->pGossipSelect = &GossipSelect_npc_nat_pagle;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp (revision 260)
@@ -248,5 +248,5 @@
     newscript->pGossipHello =  &GossipHello_npc_neeru_fireblade;
     newscript->pGossipSelect = &GossipSelect_npc_neeru_fireblade;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -255,5 +255,5 @@
     newscript->pQuestAccept =  &QuestAccept_npc_shenthul;
     newscript->pReceiveEmote = &ReciveEmote_npc_shenthul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -262,4 +262,4 @@
     newscript->pGossipHello =  &GossipHello_npc_thrall_warchief;
     newscript->pGossipSelect = &GossipSelect_npc_thrall_warchief;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp (revision 260)
@@ -137,4 +137,4 @@
     newscript->Name="boss_amnennar_the_coldbringer";
     newscript->GetAI = GetAI_boss_amnennar_the_coldbringer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp (revision 260)
@@ -214,5 +214,5 @@
     newscript->pGossipHello =  &GossipHello_npc_sergeant_bly;
     newscript->pGossipSelect = &GossipSelect_npc_sergeant_bly;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -221,4 +221,4 @@
     newscript->pGossipHello =  &GossipHello_npc_weegli_blastfuse;
     newscript->pGossipSelect = &GossipSelect_npc_weegli_blastfuse;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp (revision 260)
@@ -104,4 +104,4 @@
     newscript->Name = "mob_yenniku";
     newscript->GetAI = GetAI_mob_yenniku;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp (revision 260)
@@ -102,4 +102,4 @@
     newscript->Name="boss_high_interrogator_gerstahn";
     newscript->GetAI = GetAI_boss_high_interrogator_gerstahn;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp (revision 260)
@@ -112,4 +112,4 @@
     newscript->Name="boss_seethrel";
     newscript->GetAI = GetAI_boss_seethrel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp (revision 260)
@@ -222,5 +222,5 @@
     newscript->Name="phalanx";
     newscript->GetAI = GetAI_mob_phalanx;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -228,5 +228,5 @@
     newscript->pGossipHello =  &GossipHello_npc_kharan_mighthammer;
     newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -234,4 +234,4 @@
     newscript->pGossipHello =  &GossipHello_npc_lokhtos_darkbargainer;
     newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp (revision 260)
@@ -164,4 +164,4 @@
     newscript->Name="boss_general_angerforge";
     newscript->GetAI = GetAI_boss_general_angerforge;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp (revision 260)
@@ -139,4 +139,4 @@
     newscript->pGossipHello = &GossipHello_boss_gloomrel;
     newscript->pGossipSelect = &GossipSelect_boss_gloomrel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp (revision 260)
@@ -102,4 +102,4 @@
     newscript->Name="boss_haterel";
     newscript->GetAI = GetAI_boss_haterel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp (revision 260)
@@ -96,4 +96,4 @@
     newscript->Name="boss_moira_bronzebeard";
     newscript->GetAI = GetAI_boss_moira_bronzebeard;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp (revision 260)
@@ -78,4 +78,4 @@
     newscript->Name="boss_gorosh_the_dervish";
     newscript->GetAI = GetAI_boss_gorosh_the_dervish;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp (revision 260)
@@ -101,4 +101,4 @@
     newscript->Name="boss_emperor_dagran_thaurissan";
     newscript->GetAI = GetAI_boss_draganthaurissan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp (revision 260)
@@ -83,4 +83,4 @@
     newscript->Name="boss_grizzle";
     newscript->GetAI = GetAI_boss_grizzle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp (revision 260)
@@ -103,4 +103,4 @@
     newscript->Name="boss_ambassador_flamelash";
     newscript->GetAI = GetAI_boss_ambassador_flamelash;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp (revision 260)
@@ -81,4 +81,4 @@
     newscript->Name="boss_magmus";
     newscript->GetAI = GetAI_boss_magmus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp (revision 260)
@@ -88,4 +88,4 @@
     newscript->Name="boss_doperel";
     newscript->GetAI = GetAI_boss_doperel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp (revision 260)
@@ -88,4 +88,4 @@
     newscript->Name="boss_angerrel";
     newscript->GetAI = GetAI_boss_angerrel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp (revision 260)
@@ -136,4 +136,4 @@
     newscript->Name="boss_doomrel";
     newscript->GetAI = GetAI_boss_doomrel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp (revision 260)
@@ -112,4 +112,4 @@
     newscript->Name="boss_anubshiah";
     newscript->GetAI = GetAI_boss_anubshiah;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp (revision 260)
@@ -98,4 +98,4 @@
     newscript->Name="boss_vilerel";
     newscript->GetAI = GetAI_boss_vilerel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp (revision 260)
@@ -88,4 +88,4 @@
     newscript->pGossipHello =  &GossipHello_npc_mountaineer_pebblebitty;
     newscript->pGossipSelect = &GossipSelect_npc_mountaineer_pebblebitty;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp (revision 260)
@@ -369,20 +369,20 @@
     newscript->Name="mob_unkor_the_ruthless";
     newscript->GetAI = GetAI_mob_unkor_the_ruthless;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_infested_root_walker";
     newscript->GetAI = GetAI_mob_infested_root_walker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_rotting_forest_rager";
     newscript->GetAI = GetAI_mob_rotting_forest_rager;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_netherweb_victim";
     newscript->GetAI = GetAI_mob_netherweb_victim;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -390,5 +390,5 @@
     newscript->pGossipHello =  &GossipHello_npc_floon;
     newscript->pGossipSelect = &GossipSelect_npc_floon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -396,4 +396,4 @@
     newscript->pGossipHello =  &GossipHello_npc_skyguard_handler_deesak;
     newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_deesak;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp (revision 260)
@@ -168,9 +168,9 @@
     newscript->pGossipHello = &GossipHello_npcs_dithers_and_arbington;
     newscript->pGossipSelect = &GossipSelect_npcs_dithers_and_arbington;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_the_scourge_cauldron";
     newscript->GetAI = GetAI_npc_the_scourge_cauldron;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp (revision 205)
+++ trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp (revision 260)
@@ -134,5 +134,5 @@
     newscript->pGossipHello = &GossipHello_npc_blood_knight_dawnstar;
     newscript->pGossipSelect = &GossipSelect_npc_blood_knight_dawnstar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -140,5 +140,5 @@
     newscript->pGossipHello = &GossipHello_npc_budd_nedreck;
     newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -146,9 +146,9 @@
     newscript->pGossipHello = &GossipHello_npc_rathis_tomber;
     newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "go_gilded_brazier";
     newscript->pGOHello = &GOHello_gilded_brazier;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp (revision 260)
@@ -88,4 +88,4 @@
     newscript->Name="boss_gehennas";
     newscript->GetAI = GetAI_boss_gehennas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp (revision 260)
@@ -94,4 +94,4 @@
     newscript->Name="boss_magmadar";
     newscript->GetAI = GetAI_boss_magmadar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp (revision 260)
@@ -118,4 +118,4 @@
     newscript->Name="boss_shazzrah";
     newscript->GetAI = GetAI_boss_shazzrah;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp (revision 260)
@@ -141,9 +141,9 @@
     newscript->Name="boss_garr";
     newscript->GetAI = GetAI_boss_garr;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_firesworn";
     newscript->GetAI = GetAI_mob_firesworn;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp (revision 260)
@@ -130,4 +130,4 @@
     newscript->Name="boss_majordomo";
     newscript->GetAI = GetAI_boss_majordomo;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp (revision 260)
@@ -314,4 +314,4 @@
     newscript->Name="boss_ragnaros";
     newscript->GetAI = GetAI_boss_ragnaros;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp (revision 260)
@@ -207,9 +207,9 @@
     newscript->Name="boss_sulfuron";
     newscript->GetAI = GetAI_boss_sulfuron;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_flamewaker_priest";
     newscript->GetAI = GetAI_mob_flamewaker_priest;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp (revision 260)
@@ -85,4 +85,4 @@
     newscript->Name="mob_ancient_core_hound";
     newscript->GetAI = GetAI_mob_ancient_core_hound;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp (revision 260)
@@ -102,4 +102,4 @@
     newscript->Name="boss_baron_geddon";
     newscript->GetAI = GetAI_boss_baron_geddon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp (revision 260)
@@ -87,4 +87,4 @@
     newscript->Name="boss_lucifron";
     newscript->GetAI = GetAI_boss_lucifron;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp (revision 260)
@@ -193,9 +193,9 @@
     newscript->Name="boss_golemagg";
     newscript->GetAI = GetAI_boss_golemagg;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_core_rager";
     newscript->GetAI = GetAI_mob_core_rager;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp (revision 260)
@@ -254,4 +254,4 @@
     newscript->Name="instance_molten_core";
     newscript->GetInstanceData = &GetInstance_instance_molten_core;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp (revision 260)
@@ -630,14 +630,14 @@
     newscript->Name="boss_zuljin";
     newscript->GetAI = GetAI_boss_zuljin;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="do_nothing";
     newscript->GetAI = GetAI_do_nothing;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_zuljin_vortex";
     newscript->GetAI = GetAI_feather_vortexAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 260)
@@ -707,24 +707,24 @@
     newscript->Name="boss_janalai";
     newscript->GetAI = GetAI_boss_janalaiAI;
-    m_scripts[nrscripts++] = newscript;  
+    newscript->RegisterSelf();  
 
     newscript = new Script;
     newscript->Name="mob_janalai_firebomb";
     newscript->GetAI = GetAI_mob_jandalai_firebombAI;
-    m_scripts[nrscripts++] = newscript;  
+    newscript->RegisterSelf();  
 
     newscript = new Script;
     newscript->Name="mob_janalai_hatcher";
     newscript->GetAI = GetAI_mob_amanishi_hatcherAI;
-    m_scripts[nrscripts++] = newscript; 
+    newscript->RegisterSelf(); 
 
     newscript = new Script;
     newscript->Name="mob_janalai_hatchling";
     newscript->GetAI = GetAI_mob_hatchlingAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_janalai_egg";
     newscript->GetAI = GetAI_mob_eggAI;
-    m_scripts[nrscripts++] = newscript; 
+    newscript->RegisterSelf(); 
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp (revision 260)
@@ -172,5 +172,5 @@
     newscript->Name="npc_forest_frog";
     newscript->GetAI = GetAI_npc_forest_frog;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -179,4 +179,4 @@
     newscript->pGossipHello = GossipHello_npc_zulaman_hostage;
     newscript->pGossipSelect = GossipSelect_npc_zulaman_hostage;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp (revision 154)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp (revision 260)
@@ -395,9 +395,9 @@
     newscript->Name="boss_halazzi";
     newscript->GetAI = GetAI_boss_halazziAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_halazzi_lynx";
     newscript->GetAI = GetAI_boss_spiritlynxAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp (revision 260)
@@ -301,4 +301,4 @@
     newscript->Name="boss_nalorakk";
     newscript->GetAI = GetAI_boss_nalorakk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 260)
@@ -869,44 +869,44 @@
     newscript->Name="boss_hexlord_malacrass";
     newscript->GetAI = GetAI_boss_hex_lord_malacrass;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_thurg";
     newscript->GetAI = GetAI_boss_thurg;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_gazakroth";
     newscript->GetAI = GetAI_boss_gazakroth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_lord_raadan";
     newscript->GetAI = GetAI_boss_lord_raadan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_darkheart";
     newscript->GetAI = GetAI_boss_darkheart;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_slither";
     newscript->GetAI = GetAI_boss_slither;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_fenstalker";
     newscript->GetAI = GetAI_boss_fenstalker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_koragg";
     newscript->GetAI = GetAI_boss_koragg;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_alyson_antille";
     newscript->GetAI = GetAI_boss_alyson_antille;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 260)
@@ -329,4 +329,4 @@
     newscript->Name = "instance_zulaman";
     newscript->GetInstanceData = GetInstanceData_instance_zulaman;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp (revision 154)
+++ trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp (revision 260)
@@ -462,9 +462,9 @@
     newscript->Name="boss_akilzon";
     newscript->GetAI = GetAI_boss_akilzon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_akilzon_eagle";
     newscript->GetAI = GetAI_mob_soaring_eagle;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp (revision 260)
@@ -401,10 +401,10 @@
     newscript->Name="go_manaforge_control_console";
     newscript->pGOHello = &GOHello_go_manaforge_control_console;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_manaforge_control_console";
     newscript->GetAI = GetAI_npc_manaforge_control_console;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -412,5 +412,5 @@
     newscript->pGossipHello =   &GossipHello_npc_protectorate_nether_drake;
     newscript->pGossipSelect =  &GossipSelect_npc_protectorate_nether_drake;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -418,4 +418,4 @@
     newscript->pGossipHello =   &GossipHello_npc_veronia;
     newscript->pGossipSelect =  &GossipSelect_npc_veronia;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp (revision 260)
@@ -141,10 +141,10 @@
     newscript->pGossipHello = &GossipHello_npc_ayren_cloudbreaker;
     newscript->pGossipSelect = &GossipSelect_npc_ayren_cloudbreaker;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_converted_sentry";
     newscript->GetAI = GetAI_npc_converted_sentry;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -152,4 +152,4 @@
     newscript->pGossipHello = &GossipHello_npc_unrestrained_dragonhawk;
     newscript->pGossipSelect = &GossipSelect_npc_unrestrained_dragonhawk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp (revision 260)
@@ -351,5 +351,5 @@
     newscript->Name="npc_draenei_survivor";
     newscript->GetAI = GetAI_npc_draenei_survivor;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -358,10 +358,10 @@
     newscript->pGossipHello =  &GossipHello_npc_engineer_spark_overgrind;
     newscript->pGossipSelect = &GossipSelect_npc_engineer_spark_overgrind;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_injured_draenei";
     newscript->GetAI = GetAI_npc_injured_draenei;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -369,4 +369,4 @@
     newscript->pGossipHello =  &GossipHello_npc_susurrus;
     newscript->pGossipSelect = &GossipSelect_npc_susurrus;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp (revision 260)
@@ -178,5 +178,5 @@
     newscript->Name="mob_jadespine_basilisk";
     newscript->GetAI = GetAI_mob_jadespine_basilisk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -184,4 +184,4 @@
     newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon;
     newscript->pGossipSelect = &GossipSelect_npc_lore_keeper_of_norgannon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp (revision 260)
@@ -104,4 +104,4 @@
     newscript->Name="boss_ironaya";
     newscript->GetAI = GetAI_boss_ironaya;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp (revision 260)
@@ -135,4 +135,4 @@
     newscript->Name="boss_nerubenkan";
     newscript->GetAI = GetAI_boss_nerubenkan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp (revision 260)
@@ -111,4 +111,4 @@
     newscript->Name="boss_magistrate_barthilas";
     newscript->GetAI = GetAI_boss_magistrate_barthilas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp (revision 260)
@@ -97,4 +97,4 @@
     newscript->Name="boss_timmy_the_cruel";
     newscript->GetAI = GetAI_boss_timmy_the_cruel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp (revision 260)
@@ -218,4 +218,4 @@
     newscript->Name="boss_cannon_master_willey";
     newscript->GetAI = GetAI_boss_cannon_master_willey;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp (revision 260)
@@ -313,4 +313,4 @@
     newscript->Name="boss_dathrohan_balnazzar";
     newscript->GetAI = GetAI_boss_dathrohan_balnazzar;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp (revision 260)
@@ -311,10 +311,10 @@
     newscript->Name="mob_freed_soul";
     newscript->GetAI = GetAI_mob_freed_soul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_restless_soul";
     newscript->GetAI = GetAI_mob_restless_soul;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -322,14 +322,14 @@
     newscript->GetAI = GetAI_mobs_spectral_ghostly_citizen;
     newscript->pReceiveEmote = &ReciveEmote_mobs_spectral_ghostly_citizen;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_mindless_skeleton";
     newscript->GetAI = GetAI_mob_mindless_skeleton;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_thuzadin_acolyte";
     newscript->GetAI = GetAI_mob_thuzadin_acolyte;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp (revision 260)
@@ -158,4 +158,4 @@
     newscript->Name="boss_silver_hand_bosses";
     newscript->GetAI = GetAI_boss_silver_hand_bossesAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp (revision 260)
@@ -121,4 +121,4 @@
     newscript->Name="boss_baroness_anastari";
     newscript->GetAI = GetAI_boss_baroness_anastari;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp (revision 260)
@@ -141,4 +141,4 @@
     newscript->Name="boss_postmaster_malown";
     newscript->GetAI = GetAI_boss_postmaster_malown;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp (revision 260)
@@ -212,4 +212,4 @@
     newscript->Name="boss_baron_rivendare";
     newscript->GetAI = GetAI_boss_baron_rivendare;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp (revision 260)
@@ -74,4 +74,4 @@
     newscript->Name = "instance_stratholme";
     newscript->GetInstanceData = GetInstanceData_instance_stratholme;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp (revision 260)
@@ -116,4 +116,4 @@
     newscript->Name="boss_maleki_the_pallid";
     newscript->GetAI = GetAI_boss_maleki_the_pallid;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp (revision 260)
@@ -89,4 +89,4 @@
     newscript->Name="boss_ramstein_the_gorger";
     newscript->GetAI = GetAI_boss_ramstein_the_gorger;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp (revision 260)
@@ -150,4 +150,4 @@
     newscript->Name="boss_azuregos";
     newscript->GetAI = GetAI_boss_azuregos;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp (revision 204)
+++ trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp (revision 260)
@@ -493,5 +493,5 @@
     newscript->Name="mobs_spitelashes";
     newscript->GetAI = GetAI_mobs_spitelashes;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -499,5 +499,5 @@
     newscript->pGossipHello =  &GossipHello_npc_loramus_thalipedes;
     newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
@@ -506,9 +506,9 @@
     newscript->pGossipHello =  &GossipHello_mob_rizzle_sprysprocket;
     newscript->pGossipSelect = &GossipSelect_mob_rizzle_sprysprocket;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_depth_charge";
     newscript->GetAI = GetAI_mob_depth_charge;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp (revision 260)
@@ -105,4 +105,4 @@
     newscript->Name="boss_doctor_theolen_krastinov";
     newscript->GetAI = GetAI_boss_theolenkrastinov;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp (revision 260)
@@ -92,4 +92,4 @@
     newscript->Name="boss_vectus";
     newscript->GetAI = GetAI_boss_vectus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp (revision 260)
@@ -99,4 +99,4 @@
     newscript->Name = "instance_scholomance";
     newscript->GetInstanceData = GetInstanceData_instance_scholomance;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp (revision 260)
@@ -113,4 +113,4 @@
     newscript->Name="boss_illucia_barov";
     newscript->GetAI = GetAI_boss_illuciabarov;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp (revision 260)
@@ -149,4 +149,4 @@
     newscript->Name="boss_instructor_malicia";
     newscript->GetAI = GetAI_boss_instructormalicia;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp (revision 260)
@@ -56,4 +56,4 @@
     newscript->Name="boss_death_knight_darkreaver";
     newscript->GetAI = GetAI_boss_death_knight_darkreaver;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp (revision 260)
@@ -189,4 +189,4 @@
     newscript->Name="boss_darkmaster_gandling";
     newscript->GetAI = GetAI_boss_darkmaster_gandling;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp (revision 260)
@@ -95,4 +95,4 @@
     newscript->Name="boss_lord_alexei_barov";
     newscript->GetAI = GetAI_boss_lordalexeibarov;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp (revision 260)
@@ -152,4 +152,4 @@
     newscript->Name="boss_kormok";
     newscript->GetAI = GetAI_boss_kormok;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp (revision 260)
@@ -115,4 +115,4 @@
     newscript->Name="boss_the_ravenian";
     newscript->GetAI = GetAI_boss_theravenian;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp (revision 260)
@@ -122,4 +122,4 @@
     newscript->Name="boss_boss_ras_frostwhisper";
     newscript->GetAI = GetAI_boss_rasfrost;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp (revision 223)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp (revision 260)
@@ -213,9 +213,9 @@
     newscript->Name="boss_jandice_barov";
     newscript->GetAI = GetAI_boss_jandicebarov;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_illusionofjandicebarov";
     newscript->GetAI = GetAI_mob_illusionofjandicebarov;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp (revision 260)
@@ -110,4 +110,4 @@
     newscript->Name="boss_lorekeeper_polkelt";
     newscript->GetAI = GetAI_boss_lorekeeperpolkelt;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp (revision 260)
@@ -97,4 +97,4 @@
     newscript->pGossipSelect = &GossipSelect_npc_astor_hadren;
     newscript->GetAI = GetAI_npc_astor_hadren;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp (revision 260)
@@ -177,4 +177,4 @@
     newscript->Name="boss_noth";
     newscript->GetAI = GetAI_boss_noth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp (revision 260)
@@ -209,4 +209,4 @@
     newscript->Name="boss_anubrekhan";
     newscript->GetAI = GetAI_boss_anubrekhan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp (revision 260)
@@ -213,4 +213,4 @@
     newscript->Name="boss_loatheb";
     newscript->GetAI = GetAI_boss_loatheb;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp (revision 229)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp (revision 260)
@@ -198,4 +198,4 @@
     newscript->Name="boss_faerlina";
     newscript->GetAI = GetAI_boss_faerlina;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp (revision 260)
@@ -175,4 +175,4 @@
     newscript->Name="boss_highlord_mograine";
     newscript->GetAI = GetAI_boss_highlord_mograine;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp (revision 260)
@@ -171,4 +171,4 @@
     newscript->Name="boss_gluth";
     newscript->GetAI = GetAI_boss_gluth;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp (revision 260)
@@ -157,4 +157,4 @@
     newscript->Name="boss_patchwerk";
     newscript->GetAI = GetAI_boss_patchwerk;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp (revision 260)
@@ -144,4 +144,4 @@
     newscript->Name="boss_thane_korthazz";
     newscript->GetAI = GetAI_boss_thane_korthazz;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp (revision 260)
@@ -538,5 +538,5 @@
     newscript->Name="boss_kelthuzad";
     newscript->GetAI = GetAI_boss_kelthuzadAI;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
     */
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp (revision 260)
@@ -144,4 +144,4 @@
     newscript->Name="boss_lady_blaumeux";
     newscript->GetAI = GetAI_boss_lady_blaumeux;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp (revision 260)
@@ -143,4 +143,4 @@
     newscript->Name="boss_sir_zeliek";
     newscript->GetAI = GetAI_boss_sir_zeliek;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp (revision 260)
@@ -238,9 +238,9 @@
     newscript->Name="boss_maexxna";
     newscript->GetAI = GetAI_boss_maexxna;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_webwrap";
     newscript->GetAI = GetAI_mob_webwrap;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp (revision 158)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp (revision 260)
@@ -196,4 +196,4 @@
     newscript->Name="boss_sapphiron";
     newscript->GetAI = GetAI_boss_sapphiron;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp (revision 260)
@@ -164,4 +164,4 @@
     newscript->Name="boss_razuvious";
     newscript->GetAI = GetAI_boss_razuvious;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp (revision 137)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp (revision 260)
@@ -250,4 +250,4 @@
     newscript->Name = "instance_magisters_terrace";
     newscript->GetInstanceData = GetInstanceData_instance_magisters_terrace;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp (revision 257)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp (revision 260)
@@ -762,34 +762,34 @@
     newscript->Name = "boss_felblood_kaelthas";
     newscript->GetAI = GetAI_boss_felblood_kaelthas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name = "mob_arcane_sphere";
     newscript->GetAI = GetAI_mob_arcane_sphere;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_felkael_phoenix";
     newscript->GetAI = GetAI_mob_felkael_phoenix;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_felkael_phoenix_egg";
     newscript->GetAI = GetAI_mob_felkael_phoenix_egg;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_felkael_flamestrike";
     newscript->GetAI = GetAI_mob_felkael_flamestrike;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="go_kael_orb";
     newscript->pGOHello = &GOHello_go_kael_orb;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
 	newscript = new Script;
     newscript->Name="go_movie_orb";
     newscript->pGOHello = &GOHello_go_movie_orb;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp (revision 137)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp (revision 260)
@@ -404,9 +404,9 @@
     newscript->Name="boss_selin_fireheart";
     newscript->GetAI = GetAI_boss_selin_fireheart;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_fel_crystal";
     newscript->GetAI = GetAI_mob_fel_crystal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp (revision 137)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp (revision 260)
@@ -239,9 +239,9 @@
     newscript->Name="boss_vexallus";
     newscript->GetAI = GetAI_boss_vexallus;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="mob_pure_energy";
     newscript->GetAI = GetAI_mob_pure_energy;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp (revision 137)
+++ trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp (revision 260)
@@ -1356,59 +1356,59 @@
     newscript->Name="boss_priestess_delrissa";
     newscript->GetAI = GetAI_boss_priestess_delrissa;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_kagani_nightstrike";
     newscript->GetAI = GetAI_boss_kagani_nightstrike;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_ellris_duskhallow";
     newscript->GetAI = GetAI_ellris_duskhallow;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_eramas_brightblaze";
     newscript->GetAI = GetAI_eramas_brightblaze;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_yazzai";
     newscript->GetAI = GetAI_yazzai;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_warlord_salaris";
     newscript->GetAI = GetAI_warlord_salaris;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_garaxxas";
     newscript->GetAI = GetAI_garaxxas;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_apoko";
     newscript->GetAI = GetAI_apoko;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="boss_zelfan";
     newscript->GetAI = GetAI_zelfan;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     /*newscript = new Script;
     newscript->Name="mob_high_explosive_sheep";
     newscript->GetAI = GetAI_mob_high_explosive_sheep;
-    m_scripts[nrscripts++] = newscript;*/
+    newscript->RegisterSelf();*/
 
     /*newscript = new Script;
     newscript->Name="mob_fizzle";
     newscript->GetAI = GetAI_mob_fizzle;
-    m_scripts[nrscripts++] = newscript;*/
+    newscript->RegisterSelf();*/
 
     /*newscript = new Script;
     newscript->Name="mob_sliver";
     newscript->GetAI = GetAI_mob_sliver;
-    m_scripts[nrscripts++] = newscript;*/
+    newscript->RegisterSelf();*/
 }
Index: trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp (revision 260)
@@ -146,4 +146,4 @@
     newscript->pGossipHello =   &GossipHello_npcs_rutgar_and_frankal;
     newscript->pGossipSelect =  &GossipSelect_npcs_rutgar_and_frankal;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp (revision 260)
@@ -91,4 +91,4 @@
     newscript->Name="boss_landslide";
     newscript->GetAI = GetAI_boss_landslide;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp (revision 260)
@@ -146,4 +146,4 @@
     newscript->Name="boss_noxxion";
     newscript->GetAI = GetAI_boss_noxxion;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp (revision 260)
@@ -105,4 +105,4 @@
     newscript->Name="boss_princess_theradras";
     newscript->GetAI = GetAI_boss_ptheradras;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp (revision 260)
@@ -94,4 +94,4 @@
     newscript->Name="celebras_the_cursed";
     newscript->GetAI = GetAI_celebras_the_cursed;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp (revision 260)
@@ -138,4 +138,4 @@
     newscript->Name="boss_doomlord_kazzak";
     newscript->GetAI = GetAI_boss_doomlordkazzak;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp (revision 260)
@@ -172,5 +172,5 @@
     newscript->pGossipHello =   &GossipHello_npc_wing_commander_dabiree;
     newscript->pGossipSelect =  &GossipSelect_npc_wing_commander_dabiree;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -178,5 +178,5 @@
     newscript->pGossipHello =   &GossipHello_npc_gryphoneer_windbellow;
     newscript->pGossipSelect =  &GossipSelect_npc_gryphoneer_windbellow;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
@@ -184,4 +184,4 @@
     newscript->pGossipHello =   &GossipHello_npc_wing_commander_brack;
     newscript->pGossipSelect =  &GossipSelect_npc_wing_commander_brack;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp (revision 260)
@@ -61,4 +61,4 @@
     newscript->pGossipHello          = &GossipHello_npc_skorn_whitecloud;
     newscript->pGossipSelect         = &GossipSelect_npc_skorn_whitecloud;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp (revision 260)
@@ -77,9 +77,9 @@
     newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer;
     newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="npc_screecher_spirit";
     newscript->pGossipHello = &GossipHello_npc_screecher_spirit;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp (revision 260)
@@ -41,4 +41,4 @@
     newscript->Name="at_test";
     newscript->pAreaTrigger = ATtest;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/scripts/item/item_scripts.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/item/item_scripts.cpp (revision 105)
+++ trunk/src/bindings/scripts/scripts/item/item_scripts.cpp (revision 260)
@@ -456,94 +456,94 @@
     newscript->Name="item_area_52_special";
     newscript->pItemUse = ItemUse_item_area_52_special;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_arcane_charges";
     newscript->pItemUse = ItemUse_item_arcane_charges;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_attuned_crystal_cores";
     newscript->pItemUse = ItemUse_item_attuned_crystal_cores;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_blackwhelp_net";
     newscript->pItemUse = ItemUse_item_blackwhelp_net;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_disciplinary_rod";
     newscript->pItemUse = ItemUse_item_disciplinary_rod;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_draenei_fishing_net";
     newscript->pItemUse = ItemUse_item_draenei_fishing_net;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_nether_wraith_beacon";
     newscript->pItemUse = ItemUse_item_nether_wraith_beacon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_flying_machine";
     newscript->pItemUse = ItemUse_item_flying_machine;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_gor_dreks_ointment";
     newscript->pItemUse = ItemUse_item_gor_dreks_ointment;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_muiseks_vessel";
     newscript->pItemUse = ItemUse_item_muiseks_vessel;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_razorthorn_flayer_gland";
     newscript->pItemUse = ItemUse_item_razorthorn_flayer_gland;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_tame_beast_rods";
     newscript->pItemUse = ItemUse_item_tame_beast_rods;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_protovoltaic_magneto_collector";
     newscript->pItemUse = ItemUse_item_protovoltaic_magneto_collector;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_soul_cannon";
     newscript->pItemUse = ItemUse_item_soul_cannon;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_sparrowhawk_net";
     newscript->pItemUse = ItemUse_item_sparrowhawk_net;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_voodoo_charm";
     newscript->pItemUse = ItemUse_item_voodoo_charm;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_vorenthals_presence";
     newscript->pItemUse = ItemUse_item_vorenthals_presence;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_yehkinyas_bramble";
     newscript->pItemUse = ItemUse_item_yehkinyas_bramble;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 
     newscript = new Script;
     newscript->Name="item_zezzaks_shard";
     newscript->pItemUse = ItemUse_item_zezzak_shard;
-    m_scripts[nrscripts++] = newscript;
-}
+    newscript->RegisterSelf();
+}
Index: trunk/src/bindings/scripts/scripts/item/item_test.cpp
===================================================================
--- trunk/src/bindings/scripts/scripts/item/item_test.cpp (revision 90)
+++ trunk/src/bindings/scripts/scripts/item/item_test.cpp (revision 260)
@@ -39,4 +39,4 @@
     newscript->Name="item_test";
     newscript->pItemUse = ItemUse_item_test;
-    m_scripts[nrscripts++] = newscript;
+    newscript->RegisterSelf();
 }
Index: trunk/src/bindings/scripts/ScriptMgr.cpp
===================================================================
--- trunk/src/bindings/scripts/ScriptMgr.cpp (revision 223)
+++ trunk/src/bindings/scripts/ScriptMgr.cpp (revision 260)
@@ -18,5 +18,6 @@
 
 //*** Global data ***
-int nrscripts;
+int num_db_scripts;
+int num_sc_scripts;
 Script *m_scripts[MAX_SCRIPTS];
 
@@ -47,5 +48,4 @@
 // Text Maps
 UNORDERED_MAP<int32, StringTextData> TextMap;
-
 
 //*** End Global data ***
@@ -1181,13 +1181,14 @@
 TRINITY_DLL_EXPORT
 void ScriptsFree()
-{   
+{
     // Free Spell Summary
     delete []SpellSummary;
 
     // Free resources before library unload
-    for(int i=0;i<nrscripts;i++)
+    for(int i=0;i<num_db_scripts;i++)
         delete m_scripts[i];
 
-    nrscripts = 0;
+    num_db_scripts = 0;
+    num_sc_scripts = 0;
 }
 
@@ -1240,4 +1241,6 @@
         LoadDatabase();
 
+    num_db_scripts = GetScriptNames().size();
+
     outstring_log("TSCR: Loading C++ scripts");
     barGoLink bar(1);
@@ -1245,5 +1248,4 @@
     outstring_log("");
 
-    nrscripts = 0;
     for(int i=0;i<MAX_SCRIPTS;i++)
         m_scripts[i]=NULL;
@@ -1776,6 +1778,5 @@
     // -------------------
 
-    outstring_log("TSCR: Loaded %u C++ Scripts", nrscripts);
-    outstring_log("");
+    outstring_log(">> Loaded %i C++ Scripts (of %i ScriptNames defined in Mangos database)", num_sc_scripts, num_db_scripts);
 }
 
@@ -1849,21 +1850,13 @@
 //*** Functions used internally ***
 
-TRINITY_DLL_EXPORT
-char const* ScriptsVersion()
-{
-	return "Default Trinity scripting library";
-}
-
-Script* GetScriptByName(std::string Name)
-{
-    if (Name.empty())
-        return NULL;
-
-    for(int i=0;i<MAX_SCRIPTS;i++)
-    {
-        if (m_scripts[i] && m_scripts[i]->Name == Name)
-            return m_scripts[i];
-    }
-    return NULL;
+void Script::RegisterSelf()
+{
+    int id = GetScriptId(Name.c_str());
+    if (id != 0)
+    {
+        m_scripts[id] = this;
+        ++num_sc_scripts;
+    } else
+        debug_log("SD2: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str());
 }
 
@@ -1872,7 +1865,12 @@
 
 TRINITY_DLL_EXPORT
+char const* ScriptsVersion()
+{
+	return "Default Trinity scripting library";
+}
+TRINITY_DLL_EXPORT
 bool GossipHello ( Player * player, Creature *_Creature )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipHello) return false;
 
@@ -1886,5 +1884,5 @@
     debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action);
 
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipSelect) return false;
 
@@ -1898,5 +1896,5 @@
     debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action);
 
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false;
 
@@ -1908,5 +1906,5 @@
 bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestAccept) return false;
 
@@ -1918,5 +1916,5 @@
 bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestSelect) return false;
 
@@ -1928,5 +1926,5 @@
 bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pQuestComplete) return false;
 
@@ -1938,5 +1936,5 @@
 bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pChooseReward) return false;
 
@@ -1948,5 +1946,5 @@
 uint32 NPCDialogStatus( Player *player, Creature *_Creature )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100;
 
@@ -1958,6 +1956,6 @@
 uint32 GODialogStatus( Player *player, GameObject *_GO )
 {
-    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
-    if(!tmpscript || !tmpscript->pGODialogStatus) return 100;
+    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+    if (!tmpscript || !tmpscript->pGODialogStatus) return 100;
 
     player->PlayerTalkClass->ClearMenus();
@@ -1968,5 +1966,5 @@
 bool ItemHello( Player *player, Item *_Item, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
+    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemHello) return false;
 
@@ -1978,5 +1976,5 @@
 bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
+    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemQuestAccept) return false;
 
@@ -1988,5 +1986,5 @@
 bool GOHello( Player *player, GameObject *_GO )
 {
-    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
+    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOHello) return false;
 
@@ -1998,5 +1996,5 @@
 bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest )
 {
-    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
+    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOQuestAccept) return false;
 
@@ -2008,5 +2006,5 @@
 bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt )
 {
-    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
+    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
     if (!tmpscript || !tmpscript->pGOChooseReward) return false;
 
@@ -2018,7 +2016,5 @@
 bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry)
 {
-    Script *tmpscript = NULL;
-
-    tmpscript = GetScriptByName(GetAreaTriggerScriptNameById(atEntry->id));
+    Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
     if (!tmpscript || !tmpscript->pAreaTrigger) return false;
 
@@ -2029,7 +2025,7 @@
 CreatureAI* GetAI(Creature *_Creature)
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
-
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->GetAI) return NULL;
+
     return tmpscript->GetAI(_Creature);
 }
@@ -2038,5 +2034,5 @@
 bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
 {
-    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
+    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
     if (!tmpscript || !tmpscript->pItemUse) return false;
 
@@ -2047,5 +2043,5 @@
 bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote )
 {
-    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
     if (!tmpscript || !tmpscript->pReceiveEmote) return false;
 
@@ -2056,10 +2052,8 @@
 InstanceData* CreateInstanceData(Map *map)
 {
-    Script *tmpscript = NULL;
-
-    if (!map->IsDungeon()) return false;
-
-    tmpscript = GetScriptByName(((InstanceMap*)map)->GetScript());
-    if (!tmpscript || !tmpscript->GetInstanceData) return false;
+    if (!map->IsDungeon()) return NULL;
+
+    Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()];
+    if (!tmpscript || !tmpscript->GetInstanceData) return NULL;
 
     return tmpscript->GetInstanceData(map);
