Index: /trunk/src/shared/ProgressBar.h
===================================================================
--- /trunk/src/shared/ProgressBar.h (revision 260)
+++ /trunk/src/shared/ProgressBar.h (revision 272)
@@ -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/DatabaseMysql.h
===================================================================
--- /trunk/src/shared/Database/DatabaseMysql.h (revision 262)
+++ /trunk/src/shared/Database/DatabaseMysql.h (revision 272)
@@ -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/SqlOperations.h
===================================================================
--- /trunk/src/shared/Database/SqlOperations.h (revision 262)
+++ /trunk/src/shared/Database/SqlOperations.h (revision 272)
@@ -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/DatabaseEnv.h
===================================================================
--- /trunk/src/shared/Database/DatabaseEnv.h (revision 262)
+++ /trunk/src/shared/Database/DatabaseEnv.h (revision 272)
@@ -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/Field.h
===================================================================
--- /trunk/src/shared/Database/Field.h (revision 262)
+++ /trunk/src/shared/Database/Field.h (revision 272)
@@ -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.cpp
===================================================================
--- /trunk/src/shared/Database/DBCStores.cpp (revision 260)
+++ /trunk/src/shared/Database/DBCStores.cpp (revision 272)
@@ -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,7 +122,19 @@
 // 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);
@@ -224,5 +236,5 @@
         }
     }
-
+    
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore,     dbcPath,"FactionTemplate.dbc");
     LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore,       dbcPath,"GemProperties.dbc");
@@ -272,5 +284,5 @@
     {
         SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j);
-
+    
         if(!skillLine)
             continue;
@@ -279,5 +291,5 @@
 
         if(spellInfo && (spellInfo->Attributes & 0x1D0) == 0x1D0)
-        {
+        {      
             for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i)
             {
@@ -286,5 +298,5 @@
                     continue;
 
-                if(skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
+                if(skillLine->skillId != cFamily->skillLine && skillLine->skillId != cFamily->skillLine2)
                     continue;
 
@@ -298,4 +310,5 @@
     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");
@@ -443,9 +456,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 260)
+++ /trunk/src/shared/Database/SQLStorage.h (revision 272)
@@ -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,24 +27,16 @@
 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)
         {
-            src_format = fmt;
-            dst_format = fmt;
-            init(_entry_field, sqlname);
+            format=fmt;
+            entry_field = _entry_field;
+            table=sqlname;
+            data=NULL;
+            pIndex=NULL;
+            iNumFields =strlen(fmt);
+            MaxEntry = 0;
         }
-
-        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()
         {
@@ -65,52 +57,14 @@
         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 *src_format;
-        const char *dst_format;
+        const char *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/DatabaseMysql.cpp
===================================================================
--- /trunk/src/shared/Database/DatabaseMysql.cpp (revision 262)
+++ /trunk/src/shared/Database/DatabaseMysql.cpp (revision 272)
@@ -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/dbcfile.h
===================================================================
--- /trunk/src/shared/Database/dbcfile.h (revision 260)
+++ /trunk/src/shared/Database/dbcfile.h (revision 272)
@@ -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/SqlOperations.cpp
===================================================================
--- /trunk/src/shared/Database/SqlOperations.cpp (revision 262)
+++ /trunk/src/shared/Database/SqlOperations.cpp (revision 272)
@@ -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/QueryResult.h
===================================================================
--- /trunk/src/shared/Database/QueryResult.h (revision 262)
+++ /trunk/src/shared/Database/QueryResult.h (revision 272)
@@ -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/DBCStructure.h
===================================================================
--- /trunk/src/shared/Database/DBCStructure.h (revision 260)
+++ /trunk/src/shared/Database/DBCStructure.h (revision 272)
@@ -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,5 +22,4 @@
 #define DBCSTRUCTURE_H
 
-#include "DBCEnums.h"
 #include "Platform/Define.h"
 
@@ -37,4 +36,40 @@
 #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
@@ -145,5 +180,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, ...)
 };
 
@@ -159,9 +194,10 @@
 {
     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[2];                                 // 5-6
+    uint32    skillLine;                                    // 5
+    uint32    skillLine2;                                   // 6
     uint32    petFoodMask;                                  // 7
     char*     Name[16];                                     // 8-23
@@ -207,4 +243,13 @@
     //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
 };
 
@@ -257,5 +302,4 @@
 
 #define GT_MAX_LEVEL    100
-
 struct GtCombatRatingsEntry
 {
@@ -386,4 +430,13 @@
                                                             // 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
 };
 
@@ -491,4 +544,10 @@
                                                             // 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
 };
 
@@ -700,4 +759,15 @@
 };
 
+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
 {
@@ -757,4 +827,12 @@
 };
 
+struct TaxiPathEntry
+{
+    uint32    ID;
+    uint32    from;
+    uint32    to;
+    uint32    price;
+};
+
 struct TaxiNodesEntry
 {
@@ -770,22 +848,13 @@
 };
 
-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;
+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
 };
 
Index: /trunk/src/shared/Database/Field.cpp
===================================================================
--- /trunk/src/shared/Database/Field.cpp (revision 262)
+++ /trunk/src/shared/Database/Field.cpp (revision 272)
@@ -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/SQLStorage.cpp
===================================================================
--- /trunk/src/shared/Database/SQLStorage.cpp (revision 260)
+++ /trunk/src/shared/Database/SQLStorage.cpp (revision 272)
@@ -11,14 +11,16 @@
  * 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 "SQLStorageImpl.h"
+#include "ProgressBar.h"
+#include "Log.h"
+#include "dbcfile.h"
 
 #ifdef DO_POSTGRESQL
@@ -28,29 +30,25 @@
 #endif
 
-const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis";
-const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiii";
+const char CreatureInfofmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis";
 const char CreatureDataAddonInfofmt[]="iiiiiiis";
 const char CreatureModelfmt[]="iffbi";
 const char CreatureInfoAddonInfofmt[]="iiiiiiis";
 const char EquipmentInfofmt[]="iiiiiiiiii";
-const char GameObjectInfosrcfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis";
-const char GameObjectInfodstfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiii";
-const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii";
-const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiii";
+const char GameObjectInfofmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis";
+const char ItemPrototypefmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii";
 const char PageTextfmt[]="isi";
 const char SpellThreatfmt[]="ii";
-const char InstanceTemplatesrcfmt[]="iiiiiiffffs";
-const char InstanceTemplatedstfmt[]="iiiiiiffffi";
+const char InstanceTemplatefmt[]="iiiiiiffffs";
 
-SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template");
+SQLStorage sCreatureStorage(CreatureInfofmt,"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(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template");
-SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template");
+SQLStorage sGOStorage(GameObjectInfofmt,"entry","gameobject_template");
+SQLStorage sItemStorage(ItemPrototypefmt,"entry","item_template");
 SQLStorage sPageTextStore(PageTextfmt,"entry","page_text");
 SQLStorage sSpellThreatStore(SpellThreatfmt,"entry","spell_threat");
-SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template");
+SQLStorage sInstanceTemplate(InstanceTemplatefmt,"map","instance_template");
 
 void SQLStorage::Free ()
@@ -58,5 +56,5 @@
     uint32 offset=0;
     for(uint32 x=0;x<iNumFields;x++)
-        if (dst_format[x]==FT_STRING)
+        if (format[x]==FT_STRING)
         {
             for(uint32 y=0;y<MaxEntry;y++)
@@ -64,12 +62,12 @@
                     delete [] *(char**)((char*)(pIndex[y])+offset);
 
-            offset += sizeof(char*);
+            offset+=sizeof(char*);
         }
-        else if (dst_format[x]==FT_LOGIC)
-            offset += sizeof(bool);
-        else if (dst_format[x]==FT_BYTE)
-            offset += sizeof(char);
+        else if (format[x]==FT_LOGIC)
+            offset+=sizeof(bool);
+        else if (format[x]==FT_BYTE)
+            offset+=sizeof(char);
         else
-            offset += 4;
+            offset+=4;
 
     delete [] pIndex;
@@ -77,7 +75,119 @@
 }
 
-void SQLStorage::Load()
+void SQLStorage::Load ()
 {
-    SQLStorageLoader loader;
-    loader.Load(*this);
+    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;
 }
Index: /trunk/src/shared/Database/dbcfile.cpp
===================================================================
--- /trunk/src/shared/Database/dbcfile.cpp (revision 260)
+++ /trunk/src/shared/Database/dbcfile.cpp (revision 272)
@@ -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/DatabaseImpl.h
===================================================================
--- /trunk/src/shared/Database/DatabaseImpl.h (revision 262)
+++ /trunk/src/shared/Database/DatabaseImpl.h (revision 272)
@@ -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 260)
+++ /trunk/src/shared/Database/DBCStores.h (revision 272)
@@ -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,4 +76,5 @@
         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 260)
+++ /trunk/src/shared/ProgressBar.cpp (revision 272)
@@ -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/SpellEffects.cpp
===================================================================
--- /trunk/src/game/SpellEffects.cpp (revision 257)
+++ /trunk/src/game/SpellEffects.cpp (revision 272)
@@ -334,24 +334,11 @@
                         break;
                     }
-                    // must only affect demons (also undead?)
+                    // must only affect demons
                     case 45072:
                     {
-                        if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON
-                            || unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD)
+                        if(unitTarget->GetCreatureType() != CREATURE_TYPE_DEMON)
                             return;
                         break;
                     }
-                    // gruul's shatter
-                    case 33671:
-                    {
-                        // don't damage self and only players
-                        if(unitTarget->GetGUID() == m_caster->GetGUID() || unitTarget->GetTypeId() != TYPEID_PLAYER)
-                            return;
-
-                        float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[0]));
-                        if(!radius) return;
-                        float distance = m_caster->GetDistance2d(unitTarget);
-                        damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius));
-                    }break;
                 }
                 break;
@@ -1172,5 +1159,5 @@
                     m_caster->CastSpell(m_caster, 45009, true);
                     return;
-                }
+                }                
                 case 45030:                                 // Impale Emissary
                 {
@@ -1275,5 +1262,5 @@
                         //Polymorph Cast Visual Rank 1
                         const uint32 spell_list[6] = {32813, 32816, 32817, 32818, 32819, 32820};
-                        unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true);
+                        unitTarget->CastSpell( unitTarget, spell_list[urand(0, 5)], true); 
                     }
                     return;
@@ -2251,5 +2238,5 @@
         m_caster->ModifyPower(POWER_MANA,gain);
         //send log
-        m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA);
+        m_caster->SendEnergizeSpellLog(m_caster, m_spellInfo->Id,gain,POWER_MANA,false);
     }
 }
@@ -2267,5 +2254,5 @@
                     /*do not uncomment .
                     if(bg->GetTypeID()==BATTLEGROUND_WS)
-                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
+                        bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);
                     sLog.outDebug("Send Event Horde Flag Picked Up");
                     break;
@@ -2280,5 +2267,5 @@
                     /*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion
                     if(bg->GetTypeID()==BATTLEGROUND_WS)
-                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
+                        bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);
                     sLog.outDebug("Send Event Alliance Flag Picked Up");
                     break;
@@ -2291,10 +2278,10 @@
                     case 23385:                                 // Alliance Flag Returns
                         if(bg->GetTypeID()==BATTLEGROUND_WS)
-                            bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
+                            bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);
                         sLog.outDebug("Alliance Flag Returned");
                         break;
                     case 23386:                                   // Horde Flag Returns
                         if(bg->GetTypeID()==BATTLEGROUND_WS)
-                            bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
+                            bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);
                         sLog.outDebug("Horde Flag Returned");
                         break;*/
@@ -2302,5 +2289,5 @@
                     /*
                     if(bg->GetTypeID()==BATTLEGROUND_EY)
-                        bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
+                        bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget);
                     */
                     break;
@@ -2651,5 +2638,4 @@
     float radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
     Unit *caster = m_originalCasterGUID ? m_originalCaster : m_caster;
-    if(!caster) return;
 
     if(Player* modOwner = caster->GetSpellModOwner())
@@ -2681,5 +2667,5 @@
 
     // Some level depends spells
-    int multiplier = 0;
+    int multiplier  = 0;
     int level_diff = 0;
     switch (m_spellInfo->Id)
@@ -2688,15 +2674,15 @@
         case 9512:
             level_diff = m_caster->getLevel() - 40;
-            multiplier = 2;
+            multiplier  = 2;
             break;
         // Blood Fury
         case 24571:
             level_diff = m_caster->getLevel() - 60;
-            multiplier = 10;
+            multiplier  = 10;
             break;
         // Burst of Energy
         case 24532:
             level_diff = m_caster->getLevel() - 60;
-            multiplier = 4;
+            multiplier  = 4;
             break;
         default:
@@ -3760,5 +3746,5 @@
         ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0));
     else
-        m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());
+        MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation());
 }
 
@@ -3781,5 +3767,5 @@
         return;
 
-    sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow());
+    sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow());
 
     // TODO: find formula for honor reward based on player's level!
@@ -3787,5 +3773,5 @@
     // now fixed only for level 70 players:
     if (((Player*)unitTarget)->getLevel() == 70)
-        ((Player*)unitTarget)->RewardHonor(NULL, 1, damage);
+        ((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage);
 }
 
@@ -4002,5 +3988,5 @@
 
     // add to world
-    pet->GetMap()->Add((Creature*)pet);
+    MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
 
     // visual effect for levelup
@@ -4032,5 +4018,5 @@
                 return;
 
-            OldSummon->GetMap()->Remove((Creature*)OldSummon,false);
+            MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false);
             OldSummon->SetMapId(m_caster->GetMapId());
 
@@ -4039,5 +4025,5 @@
 
             OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation());
-            m_caster->GetMap()->Add((Creature*)OldSummon);
+            MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon);
 
             if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() )
@@ -4122,8 +4108,8 @@
     if(m_caster->GetTypeId() == TYPEID_UNIT)
     {
-        if ( ((Creature*)m_caster)->isTotem() )
-            NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);
-        else
-            NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
+		if ( ((Creature*)m_caster)->isTotem() )
+			NewSummon->GetCharmInfo()->SetReactState(REACT_AGGRESSIVE);
+		else
+			NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
     }
 
@@ -4447,5 +4433,4 @@
             ((Player*)m_caster)->AddComboPoints(unitTarget, 1);
     }
-
     // Mangle (Cat): CP
     if(m_spellInfo->SpellFamilyName==SPELLFAMILY_DRUID && (m_spellInfo->SpellFamilyFlags==0x0000040000000000LL))
@@ -4454,4 +4439,5 @@
             ((Player*)m_caster)->AddComboPoints(unitTarget,1);
     }
+
 
     // take ammo
@@ -5449,5 +5435,5 @@
 }
 
-void Spell::EffectResurrect(uint32 /*effIndex*/)
+void Spell::EffectResurrect(uint32 i)
 {
     if(!unitTarget)
@@ -5670,5 +5656,5 @@
     int32 targetLevel = creature->getLevel();
 
-    uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill();
+    uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); 
 
     ((Player*)m_caster)->SendLoot(creature->GetGUID(),LOOT_SKINNING);
@@ -5697,5 +5683,5 @@
 
     if(m_caster->GetTypeId() != TYPEID_PLAYER)
-        m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation());
+        MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation());
 
     // not all charge effects used in negative spells
@@ -6133,5 +6119,5 @@
             linkedGO->SetOwnerGUID(m_caster->GetGUID() );
 
-            linkedGO->GetMap()->Add(linkedGO);
+            MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO);
         }
         else
Index: /trunk/src/game/Bag.cpp
===================================================================
--- /trunk/src/game/Bag.cpp (revision 260)
+++ /trunk/src/game/Bag.cpp (revision 272)
@@ -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 );
 
-    SetEntry(itemid);
+    SetUInt32Value(OBJECT_FIELD_ENTRY, itemid);
     SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
 
@@ -86,5 +86,5 @@
     SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots);
 
-    // Cleaning 20 slots
+    // Cleanning 20 slots
     for (uint8 i = 0; i < MAX_BAG_SIZE; i++)
     {
@@ -214,5 +214,4 @@
             if(m_bagslot[i]->GetGUID() == guid)
                 return i;
-
     return NULL_SLOT;
 }
@@ -222,5 +221,5 @@
     if( slot < GetBagSize() )
         return m_bagslot[slot];
-
+        
     return NULL;
 }
Index: /trunk/src/game/Level3.cpp
===================================================================
--- /trunk/src/game/Level3.cpp (revision 260)
+++ /trunk/src/game/Level3.cpp (revision 272)
@@ -136,5 +136,4 @@
     HandleReloadSpellScriptsCommand("a");
     SendGlobalSysMessage("DB tables `*_scripts` reloaded.");
-    HandleReloadDbScriptStringCommand("a");
     return true;
 }
@@ -600,12 +599,4 @@
         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;
 }
@@ -1777,6 +1768,5 @@
         // search highest talent rank
         uint32 spellid = 0;
-        int rank = 4;
-        for(; rank >= 0; --rank)
+        for(int rank = 4; rank >= 0; --rank)
         {
             if(talentInfo->RankID[rank]!=0)
@@ -4656,147 +4646,89 @@
 }
 
-bool ChatHandler::HandleServerShutDownCancelCommand(const char* args)
-{
-    sWorld.ShutdownCancel();
-    return true;
-}
-
-bool ChatHandler::HandleServerShutDownCommand(const char* args)
+bool ChatHandler::HandleShutDownCommand(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'))
+    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;
 
-        // 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)
+        sWorld.ShutdownServ(time);
+    }
+    return true;
+}
+
+bool ChatHandler::HandleRestartCommand(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, 0, exitcode);
+        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();
     }
     else
-        sWorld.ShutdownServ(time,0,SHUTDOWN_EXIT_CODE);
-    return true;
-}
-
-bool ChatHandler::HandleServerRestartCommand(const char* args)
+    {
+        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;
 
-    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'))
+    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;
 
-        // 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;
-
-    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
-        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;
-
-        // 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
-        sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE,SHUTDOWN_EXIT_CODE);
+        sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE);
+    }
     return true;
 }
Index: /trunk/src/game/WaypointMovementGenerator.cpp
===================================================================
--- /trunk/src/game/WaypointMovementGenerator.cpp (revision 263)
+++ /trunk/src/game/WaypointMovementGenerator.cpp (revision 272)
@@ -22,9 +22,9 @@
 creature_movement Table
 
-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 `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 `emote` int(10) unsigned default '0';
 alter table creature_movement add `spell` int(5) unsigned default '0';
@@ -149,19 +149,20 @@
                 if(behavior->model1 != 0)
                     creature.SetDisplayId(behavior->model1);
-                if(behavior->textid[0])
+                if(!behavior->text[0].empty())
                 {
-                    // Not only one text is set
-                    if( behavior->textid[1] )
+                    // Only one text is set
+                    if( !behavior->text[1].empty() )
                     {
                         // Select one from max 5 texts (0 and 1 already checked)
                         int i = 2;
-                        for( ; i < MAX_WAYPOINT_TEXT; ++i )
-                            if( !behavior->textid[i] )
+                        for( ; i < 5; ++i )
+                            if( behavior->text[i].empty() )
                                 break;
 
-                        creature.Say(behavior->textid[rand() % i], 0, 0);
+                        creature.Say(behavior->text[rand() % i].c_str(), 0, 0);
+
                     }
                     else
-                        creature.Say(behavior->textid[0], 0, 0);
+                        creature.Say(behavior->text[0].c_str(), 0, 0);
                 }
             }                                               // wpBehaviour found
Index: /trunk/src/game/GameObject.h
===================================================================
--- /trunk/src/game/GameObject.h (revision 260)
+++ /trunk/src/game/GameObject.h (revision 272)
@@ -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;
     };
-    uint32 ScriptId;
+    char   *ScriptName;
 };
 
Index: /trunk/src/game/Object.h
===================================================================
--- /trunk/src/game/Object.h (revision 268)
+++ /trunk/src/game/Object.h (revision 272)
@@ -456,5 +456,5 @@
         GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
         bool isActive() const { return m_isActive; }
-        void setActive(bool isActive);
+        virtual void setActive(bool isActive);
     protected:
         explicit WorldObject();
Index: /trunk/src/game/CreatureAIImpl.h
===================================================================
--- /trunk/src/game/CreatureAIImpl.h (revision 260)
+++ /trunk/src/game/CreatureAIImpl.h (revision 272)
@@ -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 267)
+++ /trunk/src/game/SpellHandler.cpp (revision 272)
@@ -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,10 +55,4 @@
     }
 
-    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());
 
@@ -244,5 +238,5 @@
 
             pItem->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, 0);
-            pItem->SetEntry(entry);
+            pItem->SetUInt32Value(OBJECT_FIELD_ENTRY, entry);
             pItem->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
             pItem->SetState(ITEM_CHANGED, pUser);
@@ -266,4 +260,5 @@
 
     uint64 guid;
+    uint32 spellId = OPEN_CHEST;
 
     recv_data >> guid;
@@ -328,5 +323,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);
 }
@@ -369,9 +364,8 @@
                 spellInfo->EffectApplyAuraName[i] == SPELL_AURA_BIND_SIGHT)
             {
-                // Fix me: creature may be killed during player aura cancel
                 _player->RemoveAurasDueToSpellByCancel(spellId);
                 if (_player->GetCharm())
                     _player->GetCharm()->RemoveAurasDueToSpellByCancel(spellId);
-                else if (_player->GetFarsightTarget() && _player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT)
+                else if (_player->GetFarsightTarget()->GetTypeId() != TYPEID_DYNAMICOBJECT)
                     ((Unit*)_player->GetFarsightTarget())->RemoveAurasDueToSpellByCancel(spellId);
                 return;
Index: /trunk/src/game/MapManager.h
===================================================================
--- /trunk/src/game/MapManager.h (revision 260)
+++ /trunk/src/game/MapManager.h (revision 272)
@@ -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,5 +28,4 @@
 #include "Map.h"
 #include "GridStates.h"
-
 class Transport;
 
@@ -46,5 +45,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);
+        void DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode);
 
         inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const
Index: /trunk/src/game/Chat.cpp
===================================================================
--- /trunk/src/game/Chat.cpp (revision 260)
+++ /trunk/src/game/Chat.cpp (revision 272)
@@ -64,42 +64,14 @@
     };
 
-    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,  NULL,                                           "", serverIdleRestartCommandTable },
-        { "idleshutdown",   SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverShutdownCommandTable },
+        { "idlerestart",    SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleIdleRestartCommand,         "", NULL },
+        { "idleshutdown",   SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleIdleShutDownCommand,        "", NULL },
         { "info",           SEC_PLAYER,         true,  &ChatHandler::HandleServerInfoCommand,          "", NULL },
         { "motd",           SEC_PLAYER,         true,  &ChatHandler::HandleServerMotdCommand,          "", NULL },
-        { "restart",        SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverRestartCommandTable },
-        { "shutdown",       SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverShutdownCommandTable },
+        { "restart",        SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleRestartCommand,             "", NULL },
+        { "shutdown",       SEC_ADMINISTRATOR,  true,  &ChatHandler::HandleShutDownCommand,            "", NULL },
         { "set",            SEC_ADMINISTRATOR,  true,  NULL,                                           "", serverSetCommandTable },
         { NULL,             0,                  false, NULL,                                           "", NULL }
Index: /trunk/src/game/ItemEnchantmentMgr.cpp
===================================================================
--- /trunk/src/game/ItemEnchantmentMgr.cpp (revision 260)
+++ /trunk/src/game/ItemEnchantmentMgr.cpp (revision 272)
@@ -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 268)
+++ /trunk/src/game/Map.h (revision 272)
@@ -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
  */
 
@@ -34,5 +34,4 @@
 #include "SharedDefines.h"
 #include "GameSystem/GridRefManager.h"
-#include "MapRefManager.h"
 
 #include <bitset>
@@ -106,5 +105,5 @@
     float startLocZ;
     float startLocO;
-    uint32 script_id;
+    char const* script;
 };
 
@@ -128,5 +127,4 @@
 class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::ObjectLevelLockable<Map, ZThread::Mutex>
 {
-    friend class MapReference;
     public:
         Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
@@ -240,16 +238,4 @@
         GameObject* GetGameObjectInMap(uint64 guid);
 
-        bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
-        uint32 GetPlayersCountExceptGMs() const;
-        bool PlayersNearGrid(uint32 x,uint32 y) const;
-        bool ActiveObjectsNearGrid(uint32 x, uint32 y) const;
-
-        void AddActiveObject(WorldObject* obj) { i_activeObjects.insert(obj); }
-        void RemoveActiveObject(WorldObject* obj) { i_activeObjects.erase(obj); }
-
-        void SendToPlayers(WorldPacket const* data) const;
-
-        typedef MapRefManager PlayerList;
-        PlayerList const& GetPlayers() const { return m_mapRefManager; }
         template<class T> void SwitchGridContainers(T* obj, bool active);
     private:
@@ -292,5 +278,4 @@
         inline void setNGrid(NGridType* grid, uint32 x, uint32 y);
 
-        void UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff);
     protected:
         typedef Trinity::ObjectLevelLockable<Map, ZThread::Mutex>::Lock Guard;
@@ -302,5 +287,4 @@
         uint32 m_unloadTimer;
 
-        MapRefManager m_mapRefManager;
     private:
         typedef GridReadGuard ReadGuard;
@@ -313,5 +297,4 @@
         time_t i_gridExpiry;
 
-        std::set<WorldObject *> i_activeObjects;
         std::set<WorldObject *> i_objectsToRemove;
 
@@ -343,4 +326,6 @@
 {
     public:
+        typedef std::list<Player *> PlayerList;                 // online players only
+
         InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
         ~InstanceMap();
@@ -350,11 +335,15 @@
         void CreateInstanceData(bool load);
         bool Reset(uint8 method);
-        uint32 GetScriptId() { return i_script_id; }
+        std::string GetScript() { return i_script; }
         InstanceData* GetInstanceData() { return i_data; }
         void PermBindAllPlayers(Player *player);
+        PlayerList const& GetPlayers() const { return i_Players;}
+        void SendToPlayers(WorldPacket const* data) const;
         time_t GetResetTime();
         void UnloadAll(bool pForce);
         bool CanEnter(Player* player);
-        void SendResetWarnings(uint32 timeLeft) const;
+        uint32 GetPlayersCountExceptGMs() const;
+        uint32 HavePlayers() const { return !i_Players.empty(); }
+        void SendResetWarnings(uint32 timeLeft);
         void SetResetSchedule(bool on);
     private:
@@ -362,5 +351,8 @@
         bool m_unloadWhenEmpty;
         InstanceData* i_data;
-        uint32 i_script_id;
+        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;
 };
 
@@ -368,4 +360,6 @@
 {
     public:
+        typedef std::list<Player *> PlayerList;                 // online players only
+
         BattleGroundMap(uint32 id, time_t, uint32 InstanceId);
         ~BattleGroundMap();
@@ -376,4 +370,6 @@
         void SetUnload();
         void UnloadAll(bool pForce);
+    private:
+        PlayerList i_Players;
 };
 
Index: /trunk/src/game/ObjectAccessor.h
===================================================================
--- /trunk/src/game/ObjectAccessor.h (revision 268)
+++ /trunk/src/game/ObjectAccessor.h (revision 272)
@@ -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
  */
 
@@ -187,5 +187,4 @@
 
         void Update(uint32 diff);
-        void UpdatePlayers(uint32 diff);
 
         Corpse* GetCorpseForPlayerGUID(uint64 guid);
@@ -195,4 +194,6 @@
         Corpse* ConvertCorpseForPlayer(uint64 player_guid);
 
+        bool ActiveObjectsNearGrid(uint32 x,uint32 y,uint32 m_id,uint32 i_id) const;
+
         static void UpdateObject(Object* obj, Player* exceptPlayer);
         static void _buildUpdateObject(Object* obj, UpdateDataMapType &);
@@ -200,4 +201,7 @@
         static void UpdateObjectVisibility(WorldObject* obj);
         static void UpdateVisibilityForPlayer(Player* player);
+
+        void AddActiveObject(WorldObject*);
+        void RemoveActiveObject(WorldObject*);
     private:
         struct WorldObjectChangeAccumulator
@@ -224,4 +228,5 @@
         void _update(void);
         std::set<Object *> i_objects;
+        std::set<WorldObject *> i_activeobjects;
         LockType i_playerGuard;
         LockType i_updateGuard;
Index: /trunk/src/game/WaypointManager.cpp
===================================================================
--- /trunk/src/game/WaypointManager.cpp (revision 263)
+++ /trunk/src/game/WaypointManager.cpp (revision 272)
@@ -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,5 +25,4 @@
 #include "ProgressBar.h"
 #include "MapManager.h"
-#include "ObjectMgr.h"
 
 INSTANTIATE_SINGLETON_1(WaypointManager);
@@ -31,22 +30,13 @@
 bool WaypointBehavior::isEmpty()
 {
-    if (emote || spell || model1 || model2)
-        return false;
-
-    for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
-        if(textid[i])
-            return false;
-
-    return true;
+    return emote == 0 && spell == 0 && model1 == 0 && model2 == 0 && text[0].empty() &&
+        text[1].empty() && text[2].empty() && text[3].empty() && text[4].empty();
 }
 
 WaypointBehavior::WaypointBehavior(const WaypointBehavior &b)
 {
-    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];
+    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];
 }
 
@@ -77,5 +67,5 @@
     }
 
-    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");
+    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");
     if(result)
     {
@@ -124,31 +114,9 @@
             be.emote            = fields[7].GetUInt32();
             be.spell            = fields[8].GetUInt32();
-
-            // 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;
+            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();
 
             // save memory by not storing empty behaviors
@@ -298,9 +266,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/GridNotifiers.h
===================================================================
--- /trunk/src/game/GridNotifiers.h (revision 267)
+++ /trunk/src/game/GridNotifiers.h (revision 272)
@@ -699,38 +699,17 @@
     // Creature checks
 
-    class NearestHostileUnitInAttackDistanceCheck
-    {
-        public:
-            explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : m_creature(creature) 
-            {
-                m_range = (dist == 0 ? 9999 : dist);
-                m_force = (dist == 0 ? false : true);
-            }
-            bool operator()(Unit* u)
-            {
-                // TODO: addthreat for every enemy in range?
-                if(!m_creature->IsWithinDistInMap(u, m_range))
-                    return false;
-
-                if(m_force)
-                {
-                    if(!m_creature->canAttack(u))
-                        return false;
-                }
-                else
-                {
-                    if(!m_creature->canStartAttack(u))
-                        return false;
-                }
-
-                m_range = m_creature->GetDistance(u);
-                return true;
-            }
-            float GetLastRange() const { return m_range; }
-        private:
-            Creature const *m_creature;
-            float m_range;
-            bool m_force;
-            NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&);
+    class InAttackDistanceFromAnyHostileCreatureCheck
+    {
+        public:
+            explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {}
+            bool operator()(Creature* u)
+            {
+                if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit)))
+                    return true;
+
+                return false;
+            }
+        private:
+            Unit* const i_funit;
     };
 
Index: /trunk/src/game/StatSystem.cpp
===================================================================
--- /trunk/src/game/StatSystem.cpp (revision 257)
+++ /trunk/src/game/StatSystem.cpp (revision 272)
@@ -385,5 +385,5 @@
         weapon_maxdamage = lvl*1.25*att_speed;
     }
-    else if(!IsUseEquipedWeapon(attType==BASE_ATTACK))      //check if player not in form but still can't use weapon (broken/etc)
+    else if(!IsUseEquippedWeapon(attType==BASE_ATTACK))      //check if player not in form but still can't use weapon (broken/etc)
     {
         weapon_mindamage = BASE_MINDAMAGE;
Index: /trunk/src/game/GMTicketMgr.h
===================================================================
--- /trunk/src/game/GMTicketMgr.h (revision 263)
+++ /trunk/src/game/GMTicketMgr.h (revision 272)
@@ -51,8 +51,5 @@
             m_text = text ? text : "";
             m_lastUpdate = time(NULL);
-
-            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);
+            CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", m_text.c_str(), m_guid);
         }
 
@@ -66,9 +63,5 @@
             CharacterDatabase.BeginTransaction();
             DeleteFromDB();
-
-            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.PExecute("INSERT INTO character_ticket (guid, ticket_text) VALUES ('%u', '%s')", m_guid, GetText());
             CharacterDatabase.CommitTransaction();
         }
Index: /trunk/src/game/Unit.h
===================================================================
--- /trunk/src/game/Unit.h (revision 266)
+++ /trunk/src/game/Unit.h (revision 272)
@@ -16,5 +16,5 @@
  * 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
  */
 
@@ -763,5 +763,5 @@
         void CombatStop(bool cast = false);
         void CombatStopWithPets(bool cast = false);
-        Unit* SelectNearbyTarget(float dist = ATTACK_DISTANCE) const;
+        Unit* SelectNearbyTarget() const;
 
         void addUnitState(uint32 f) { m_state |= f; }
@@ -934,5 +934,5 @@
 
         void SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool critical = false);
-        void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype);
+        void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype, bool critical = false);
         uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true);
         void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0);
@@ -1040,5 +1040,4 @@
         void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer);
         void RemoveAurasDueToSpellByCancel(uint32 spellId);
-        void RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo);
         void RemoveNotOwnSingleTargetAuras();
 
@@ -1372,10 +1371,8 @@
 
         void ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag, AuraTypeSet const& procAuraTypes, WeaponAttackType attType, SpellEntry const * procSpell, uint32 damage, SpellSchoolMask damageSchoolMask );
-        bool IsTriggeredAtSpellProcEvent( SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown );
-        bool HandleDummyAuraProc(   Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown);
-        bool HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, uint32 cooldown);
-        bool HandleHasteAuraProc(   Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 cooldown);
-        bool HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 cooldown);
-        bool HandleMeandingAuraProc(Aura* triggeredByAura);
+        bool HandleDummyAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown);
+        bool HandleProcTriggerSpell(Unit *pVictim,uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell, uint32 procFlags,WeaponAttackType attType,uint32 cooldown);
+        bool HandleHasteAuraProc(Unit *pVictim, SpellEntry const *spellProto, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag,uint32 cooldown);
+        bool HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura* triggeredByAura, SpellEntry const *procSpell,uint32 cooldown);
 
         uint32 m_state;                                     // Even derived shouldn't modify
Index: /trunk/src/game/CreatureAISelector.cpp
===================================================================
--- /trunk/src/game/CreatureAISelector.cpp (revision 260)
+++ /trunk/src/game/CreatureAISelector.cpp (revision 272)
@@ -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/SpellAuras.h
===================================================================
--- /trunk/src/game/SpellAuras.h (revision 257)
+++ /trunk/src/game/SpellAuras.h (revision 272)
@@ -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 TRINITY_SPELLAURAS_H
@@ -186,10 +186,13 @@
         void HandleModRating(bool apply, bool Real);
         void HandleModTargetResistance(bool apply, bool Real);
+        void HandleAuraAttackPowerAttacker(bool apply, bool Real);
         void HandleAuraModAttackPowerPercent(bool apply, bool Real);
         void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real);
         void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real);
         void HandleSpiritOfRedemption(bool apply, bool Real);
+        void HandleAuraHealingPct(bool apply, bool Real);
         void HandleModManaRegen(bool apply, bool Real);
         void HandleComprehendLanguage(bool apply, bool Real);
+        void HandleAuraHealing(bool apply, bool Real);
         void HandleShieldBlockValue(bool apply, bool Real);
         void HandleModSpellCritChanceShool(bool apply, bool Real);
@@ -251,5 +254,5 @@
             uint8 slot = GetAuraSlot();
 
-            // only aura in slot with charges and without stack limitation
+            // only aura inslot with charges and without stack limitation
             if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0)
                 SetAuraApplication(slot, m_procCharges - 1);
Index: /trunk/src/game/World.cpp
===================================================================
--- /trunk/src/game/World.cpp (revision 260)
+++ /trunk/src/game/World.cpp (revision 272)
@@ -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,5 +67,4 @@
 
 volatile bool World::m_stopEvent = false;
-uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
 volatile uint32 World::m_worldLoopCounter = 0;
 
@@ -544,4 +543,5 @@
         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,4 +606,5 @@
     }
 
+
     if(reload)
     {
@@ -769,6 +770,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);
 
@@ -965,7 +966,4 @@
     DetectDBCLang();
 
-    sLog.outString( "Loading Script Names...");
-    objmgr.LoadScriptNames();
-
     sLog.outString( "Loading InstanceTemplate" );
     objmgr.LoadInstanceTemplate();
@@ -1083,7 +1081,8 @@
     sLog.outString( "Loading Tavern Area Triggers..." );
     objmgr.LoadTavernAreaTriggers();
-
+    
     sLog.outString( "Loading AreaTrigger script names..." );
     objmgr.LoadAreaTriggerScripts();
+
 
     sLog.outString( "Loading Graveyard-zone links...");
@@ -1166,5 +1165,5 @@
     sLog.outString( "Loading Npc Text Id..." );
     objmgr.LoadNpcTextId();                                 // must be after load Creature and NpcText
-
+    
     sLog.outString( "Loading Npc Options..." );
     objmgr.LoadNpcOptions();
@@ -1194,7 +1193,4 @@
     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())
@@ -1267,5 +1263,4 @@
     sLog.outString( "WORLD: World initialized" );
 }
-
 void World::DetectDBCLang()
 {
@@ -1468,7 +1463,5 @@
     }
 
-    /// </ul>
-    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
-    MapManager::Instance().DoDelayedMovesAndRemoves();
+    MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove"
 
     // update the instance reset times
@@ -1590,6 +1583,4 @@
         }
 
-        //if(source && !source->IsInWorld()) source = NULL;
-
         Object* target = NULL;
 
@@ -1619,6 +1610,4 @@
         }
 
-        //if(target && !target->IsInWorld()) target = NULL;
-
         switch (step.script->command)
         {
@@ -1648,5 +1637,5 @@
                 {
                     case 0:                                 // Say
-                        ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target);
+                        ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target);
                         break;
                     case 1:                                 // Whisper
@@ -1656,11 +1645,11 @@
                             break;
                         }
-                        ((Creature *)source)->Whisper(step.script->dataint,unit_target);
+                        ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target);
                         break;
                     case 2:                                 // Yell
-                        ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target);
+                        ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target);
                         break;
                     case 3:                                 // Emote text
-                        ((Creature *)source)->TextEmote(step.script->dataint, unit_target);
+                        ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target);
                         break;
                     default:
@@ -1713,5 +1702,5 @@
                 }
                 ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 );
-                ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
+                MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0);
                 break;
             case SCRIPT_COMMAND_FLAG_SET:
@@ -1863,5 +1852,5 @@
                 go->SetRespawnTime(time_to_despawn);        //despawn object in ? seconds
 
-                go->GetMap()->Add(go);
+                MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go);
                 break;
             }
@@ -2385,5 +2374,5 @@
 
     ///- if there is a shutdown timer
-    if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0)
+    if(m_ShutdownTimer > 0 && elapsed > 0)
     {
         ///- ... and it is overdue, stop the world (set m_stopEvent)
@@ -2391,5 +2380,5 @@
         {
             if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0)
-                m_stopEvent = true;                         // exist code already set
+                m_stopEvent = true;
             else
                 m_ShutdownTimer = 1;                        // minimum timer value to wait idle state
@@ -2406,12 +2395,7 @@
 
 /// Shutdown the server
-void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
-{
-    // ignore if server shutdown at next tick
-    if(m_stopEvent)
-        return;
-
+void World::ShutdownServ(uint32 time, uint32 options)
+{
     m_ShutdownMask = options;
-    m_ExitCode = exitcode;
 
     ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
@@ -2419,5 +2403,5 @@
     {
         if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0)
-            m_stopEvent = true;                             // exist code already set
+            m_stopEvent = true;
         else
             m_ShutdownTimer = 1;                            //So that the session count is re-evaluated at next world tick
@@ -2464,6 +2448,5 @@
 void World::ShutdownCancel()
 {
-    // nothing cancel or too later
-    if(!m_ShutdownTimer || m_stopEvent)
+    if(!m_ShutdownTimer)
         return;
 
@@ -2472,8 +2455,7 @@
     m_ShutdownMask = 0;
     m_ShutdownTimer = 0;
-    m_ExitCode = SHUTDOWN_EXIT_CODE;                       // to default value
     SendServerMessage(msgid);
 
-    DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
+    DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));
 }
 
@@ -2520,5 +2502,4 @@
         if(!itr->second->Update(diff))                      // As interval = 0
         {
-            RemoveQueuedPlayer (itr->second);
             delete itr->second;
             m_sessions.erase(itr);
Index: /trunk/src/game/CharacterHandler.cpp
===================================================================
--- /trunk/src/game/CharacterHandler.cpp (revision 262)
+++ /trunk/src/game/CharacterHandler.cpp (revision 272)
@@ -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
  */
 
@@ -65,5 +65,5 @@
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP,           "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES,  "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
-    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS,           "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
+    res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS,           "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS,          "SELECT spell,slot,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid));
     res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS,     "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4 FROM character_queststatus WHERE guid = '%u'", GUID_LOPART(m_guid));
@@ -181,5 +181,4 @@
     std::string name;
     uint8 race_,class_;
-
     recv_data >> name;
 
@@ -216,5 +215,4 @@
     ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(class_);
     ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race_);
-
     if( !classEntry || !raceEntry )
     {
@@ -610,5 +608,5 @@
     }
 
-    if (!pCurrChar->GetMap()->Add(pCurrChar))
+    if (!MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar))
     {
         AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId());
@@ -1002,14 +1000,14 @@
     uint64 guid;
 
-    CHECK_PACKET_SIZE(recv_data, 8);
+    CHECK_PACKET_SIZE(recv_data, 8+6);
     recv_data >> guid;
 
     // not accept declined names for unsupported languages
     std::string name;
-    if(!objmgr.GetPlayerNameByGUID(guid, name))
-    {
-        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-        data << uint32(1);
-        data << uint64(guid);
+    if(!objmgr.GetPlayerNameByGUID(guid,name))
+    {
+        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+        data << (uint32)1;
+        data << guid;
         SendPacket(&data);
         return;
@@ -1017,9 +1015,9 @@
 
     std::wstring wname;
-    if(!Utf8toWStr(name, wname))
-    {
-        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-        data << uint32(1);
-        data << uint64(guid);
+    if(!Utf8toWStr(name,wname))
+    {
+        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+        data << (uint32)1;
+        data << guid;
         SendPacket(&data);
         return;
@@ -1028,7 +1026,7 @@
     if(!isCyrillicCharacter(wname[0]))                      // name already stored as only single alphabet using
     {
-        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-        data << uint32(1);
-        data << uint64(guid);
+        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+        data << (uint32)1;
+        data << guid;
         SendPacket(&data);
         return;
@@ -1038,12 +1036,11 @@
     DeclinedName declinedname;
 
-    CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
     recv_data >> name2;
 
-    if(name2 != name)                                       // character have different name
-    {
-        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-        data << uint32(1);
-        data << uint64(guid);
+    if(name2!=name)                                         // character have different name
+    {
+        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+        data << (uint32)1;
+        data << guid;
         SendPacket(&data);
         return;
@@ -1052,11 +1049,10 @@
     for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
     {
-        CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
         recv_data >> declinedname.name[i];
         if(!normalizePlayerName(declinedname.name[i]))
         {
-            WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-            data << uint32(1);
-            data << uint64(guid);
+            WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+            data << (uint32)1;
+            data << guid;
             SendPacket(&data);
             return;
@@ -1064,9 +1060,9 @@
     }
 
-    if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname))
-    {
-        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-        data << uint32(1);
-        data << uint64(guid);
+    if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
+    {
+        WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+        data << (uint32)1;
+        data << guid;
         SendPacket(&data);
         return;
@@ -1079,10 +1075,10 @@
     CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
     CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')",
-        GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
+        GUID_LOPART(guid), declinedname.name[0].c_str(),declinedname.name[1].c_str(),declinedname.name[2].c_str(),declinedname.name[3].c_str(),declinedname.name[4].c_str());
     CharacterDatabase.CommitTransaction();
 
-    WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
-    data << uint32(0);                                      // OK
-    data << uint64(guid);
+    WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT,4+8);
+    data << (uint32)0;                                      // OK
+    data << guid;
     SendPacket(&data);
 }
Index: /trunk/src/game/ItemEnchantmentMgr.h
===================================================================
--- /trunk/src/game/ItemEnchantmentMgr.h (revision 260)
+++ /trunk/src/game/ItemEnchantmentMgr.h (revision 272)
@@ -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/BattleGround.h
===================================================================
--- /trunk/src/game/BattleGround.h (revision 257)
+++ /trunk/src/game/BattleGround.h (revision 272)
@@ -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
  */
 
@@ -96,6 +96,5 @@
     RESPAWN_ONE_DAY                 = 86400,                // secs
     RESPAWN_IMMEDIATELY             = 0,                    // secs
-    BUFF_RESPAWN_TIME               = 180,                  // secs
-    BG_HONOR_SCORE_TICKS            = 330                   // points
+    BUFF_RESPAWN_TIME               = 180                  // secs
 };
 
@@ -435,4 +434,5 @@
 
         virtual void AddPlayer(Player *plr);                // must be implemented in BG subclass
+
         virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket);
                                                             // can be extended in in BG subclass
Index: /trunk/src/game/Item.h
===================================================================
--- /trunk/src/game/Item.h (revision 260)
+++ /trunk/src/game/Item.h (revision 272)
@@ -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,4 +229,5 @@
         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/SpellAuras.cpp
===================================================================
--- /trunk/src/game/SpellAuras.cpp (revision 257)
+++ /trunk/src/game/SpellAuras.cpp (revision 272)
@@ -171,8 +171,8 @@
     &Aura::HandleNoImmediateEffect,                         //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
     &Aura::HandleNoImmediateEffect,                         //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
-    &Aura::HandleNoImmediateEffect,                         //115 SPELL_AURA_MOD_HEALING                 implemented in Unit::SpellBaseHealingBonusForVictim
+    &Aura::HandleAuraHealing,                               //115 SPELL_AURA_MOD_HEALING
     &Aura::HandleNoImmediateEffect,                         //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
     &Aura::HandleNoImmediateEffect,                         //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE     implemented in Unit::MagicSpellHitResult
-    &Aura::HandleNoImmediateEffect,                         //118 SPELL_AURA_MOD_HEALING_PCT             implemented in Unit::SpellHealingBonus
+    &Aura::HandleAuraHealingPct,                            //118 SPELL_AURA_MOD_HEALING_PCT
     &Aura::HandleUnused,                                    //119 SPELL_AURA_SHARE_PET_TRACKING useless
     &Aura::HandleAuraUntrackable,                           //120 SPELL_AURA_UNTRACKABLE
@@ -192,5 +192,5 @@
     &Aura::HandleAuraModRegenInterrupt,                     //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
     &Aura::HandleModHealingDone,                            //135 SPELL_AURA_MOD_HEALING_DONE
-    &Aura::HandleNoImmediateEffect,                         //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT   implemented in Unit::SpellHealingBonus
+    &Aura::HandleAuraHealingPct,                            //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT   implemented in Unit::SpellHealingBonus
     &Aura::HandleModTotalPercentStat,                       //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
     &Aura::HandleHaste,                                     //138 SPELL_AURA_MOD_HASTE
@@ -221,5 +221,5 @@
     &Aura::HandleNoImmediateEffect,                         //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
     &Aura::HandleUnused,                                    //164 useless, only one test spell
-    &Aura::HandleNoImmediateEffect,                         //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
+    &Aura::HandleAuraAttackPowerAttacker,                   //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
     &Aura::HandleAuraModAttackPowerPercent,                 //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
     &Aura::HandleAuraModRangedAttackPowerPercent,           //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
@@ -2000,14 +2000,4 @@
         }
 
-        // Waiting to Resurrect
-        if(GetId()==2584)
-        {
-            // Waiting to resurrect spell cancel, we must remove player from resurrect queue
-            if(m_target->GetTypeId() == TYPEID_PLAYER)
-                if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
-                    bg->RemovePlayerFromResurrectQueue(m_target->GetGUID());
-            return;
-        }
-
         // Dark Fiend
         if(GetId()==45934)
@@ -2305,8 +2295,4 @@
 void Aura::HandleAuraMounted(bool apply, bool Real)
 {
-    // only at real add/remove aura
-    if(!Real)
-        return;
-
     if(apply)
     {
@@ -2708,7 +2694,5 @@
             else
             {
-                                                            // Will use the default model here
-                if (uint32 modelid = ci->GetRandomValidModelId())
-                    m_target->SetDisplayId(modelid);
+                if (uint32 modelid = ci->GetRandomValidModelId()) m_target->SetDisplayId(modelid);
 
                 // Dragonmaw Illusion (set mount model also)
@@ -3606,5 +3590,5 @@
 /***                  MODIFY SPEED                     ***/
 /*********************************************************/
-void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
+void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real)
 {
     // all applied/removed only at real aura add/remove
@@ -3615,5 +3599,5 @@
 }
 
-void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real)
+void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)
 {
     // all applied/removed only at real aura add/remove
@@ -3654,5 +3638,5 @@
 }
 
-void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
+void Aura::HandleAuraModIncreaseSwimSpeed(bool apply, bool Real)
 {
     // all applied/removed only at real aura add/remove
@@ -3663,5 +3647,5 @@
 }
 
-void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real)
+void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)
 {
     // all applied/removed only at real aura add/remove
@@ -3674,5 +3658,5 @@
 }
 
-void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
+void Aura::HandleAuraModUseNormalSpeed(bool apply, bool Real)
 {
     // all applied/removed only at real aura add/remove
@@ -4359,5 +4343,5 @@
 }
 
-void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real)
+void Aura::HandleModSpellDamagePercentFromStat(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4370,5 +4354,5 @@
 }
 
-void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real)
+void Aura::HandleModSpellHealingPercentFromStat(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4388,5 +4372,5 @@
 }
 
-void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real)
+void Aura::HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4399,5 +4383,5 @@
 }
 
-void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real)
+void Aura::HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4408,5 +4392,5 @@
 }
 
-void Aura::HandleModHealingDone(bool /*apply*/, bool Real)
+void Aura::HandleModHealingDone(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4448,5 +4432,5 @@
 }
 
-void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real)
+void Aura::HandleAuraModResistenceOfStatPercent(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -4583,5 +4567,5 @@
 }
 
-void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
+void Aura::HandleModPowerRegenPCT(bool apply, bool Real)
 {
     // spells required only Real aura add/remove
@@ -4597,5 +4581,5 @@
 }
 
-void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
+void Aura::HandleModManaRegen(bool apply, bool Real)
 {
     // spells required only Real aura add/remove
@@ -4684,5 +4668,5 @@
 /********************************/
 
-void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real)
+void Aura::HandleAuraModParryPercent(bool apply, bool Real)
 {
     if(m_target->GetTypeId()!=TYPEID_PLAYER)
@@ -4692,5 +4676,5 @@
 }
 
-void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real)
+void Aura::HandleAuraModDodgePercent(bool apply, bool Real)
 {
     if(m_target->GetTypeId()!=TYPEID_PLAYER)
@@ -4701,5 +4685,5 @@
 }
 
-void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real)
+void Aura::HandleAuraModBlockPercent(bool apply, bool Real)
 {
     if(m_target->GetTypeId()!=TYPEID_PLAYER)
@@ -4710,5 +4694,5 @@
 }
 
-void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
+void Aura::HandleAuraModRegenInterrupt(bool apply, bool Real)
 {
     // spells required only Real aura add/remove
@@ -4778,5 +4762,5 @@
 }
 
-void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
+void Aura::HandleModSpellCritChanceShool(bool apply, bool Real)
 {
     // spells required only Real aura add/remove
@@ -4858,4 +4842,37 @@
 
     m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
+}
+
+void Aura::HandleAuraAttackPowerAttacker(bool apply, bool Real)
+{
+    // spells required only Real aura add/remove
+    if(!Real)
+        return;
+    Unit *caster = GetCaster();
+
+    if (!caster)
+        return;
+
+    // Hunter's Mark
+    if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)
+    {
+        // Check Improved Hunter's Mark bonus on caster
+        Unit::AuraList const& mOverrideClassScript = caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
+        for(Unit::AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
+        {
+            Modifier* mod = (*i)->GetModifier();
+            // mproved Hunter's Mark script from 5236 to 5240
+            if (mod->m_miscvalue >= 5236 && mod->m_miscvalue <= 5240)
+            {
+                // Get amount of ranged bonus for this spell..
+                int32 ranged_bonus = caster->CalculateSpellDamage(m_spellProto, 1, m_spellProto->EffectBasePoints[1], m_target);
+                // Set melee attack power bonus % from ranged depends from Improved mask aura
+                m_modifier.m_amount = mod->m_amount * ranged_bonus / 100;
+                m_currentBasePoints = m_modifier.m_amount;
+                break;
+            }
+        }
+        return;
+    }
 }
 
@@ -5307,5 +5324,5 @@
 }
 
-void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real)
+void Aura::HandleAuraModExpertise(bool apply, bool Real)
 {
     if(m_target->GetTypeId() != TYPEID_PLAYER)
@@ -5330,4 +5347,15 @@
     if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
         m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply);
+}
+
+//HandleNoImmediateEffect auras implementation to support new stat system
+void Aura::HandleAuraHealing(bool apply, bool Real)
+{
+    //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_VALUE, float(m_modifier.m_amount), apply);
+}
+
+void Aura::HandleAuraHealingPct(bool apply, bool Real)
+{
+    //m_target->HandleStatModifier(UNIT_MOD_HEALING, TOTAL_PCT, float(m_modifier.m_amount), apply);
 }
 
Index: /trunk/src/game/Mail.cpp
===================================================================
--- /trunk/src/game/Mail.cpp (revision 260)
+++ /trunk/src/game/Mail.cpp (revision 272)
@@ -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,4 +188,5 @@
                 return;
             }
+
             if (mailItem.item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED) || mailItem.item->GetUInt32Value(ITEM_FIELD_DURATION))
             {
@@ -194,9 +195,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/SharedDefines.h
===================================================================
--- /trunk/src/game/SharedDefines.h (revision 262)
+++ /trunk/src/game/SharedDefines.h (revision 272)
@@ -249,5 +249,5 @@
 #define SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY    0x00008000            // 15 remove auras on immunity
 #define SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE 0x00010000            // 16 unaffected by school immunity
-#define SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET       0x00020000            // 17
+#define SPELL_ATTR_EX_UNK17                       0x00020000            // 17
 #define SPELL_ATTR_EX_UNK18                       0x00040000            // 18
 #define SPELL_ATTR_EX_UNK19                       0x00080000            // 19
Index: /trunk/src/game/Creature.cpp
===================================================================
--- /trunk/src/game/Creature.cpp (revision 267)
+++ /trunk/src/game/Creature.cpp (revision 272)
@@ -123,5 +123,5 @@
 m_lootMoney(0), m_lootRecipient(0),
 m_deathTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(0.0f),
-m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false), m_isAggressive(true),
+m_gossipOptionLoaded(false), m_emoteState(0), m_isPet(false), m_isTotem(false),
 m_regenTimer(2000), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
 m_AlreadyCallAssistence(false), m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false),
@@ -148,5 +148,9 @@
     i_AI = NULL;
 
-    DeletePossessedAI();
+    if (i_AI_possessed)
+    {
+        delete i_AI_possessed;
+        i_AI_possessed = NULL;
+    }
 }
 
@@ -178,5 +182,5 @@
     float x,y,z,o;
     GetRespawnCoord(x, y, z, &o);
-    GetMap()->CreatureRelocation(this,x,y,z,o);
+    MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o);
 }
 
@@ -210,5 +214,5 @@
     }
 
-    SetEntry(Entry);                                        // normal entry always
+    SetUInt32Value(OBJECT_FIELD_ENTRY, Entry);              // normal entry always
     m_creatureInfo = cinfo;                                 // map mode related always
 
@@ -294,5 +298,4 @@
     SetUInt32Value(UNIT_DYNAMIC_FLAGS,GetCreatureInfo()->dynamicflags);
 
-    SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
     SetModifierValue(UNIT_MOD_ARMOR,             BASE_VALUE, float(GetCreatureInfo()->armor));
     SetModifierValue(UNIT_MOD_RESISTANCE_HOLY,   BASE_VALUE, float(GetCreatureInfo()->resistance1));
@@ -325,10 +328,4 @@
         SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
 
-    if(isTotem() || isCivilian() || GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER
-        || GetCreatureType() == CREATURE_TYPE_CRITTER)
-        m_isAggressive = false;
-    else
-        m_isAggressive = true;
-
     return true;
 }
@@ -360,5 +357,5 @@
                 lootForBody         = false;
 
-                if(m_originalEntry != GetEntry())
+                if(m_originalEntry != GetUInt32Value(OBJECT_FIELD_ENTRY))
                     UpdateEntry(m_originalEntry);
 
@@ -379,7 +376,7 @@
 
                 //Call AI respawn virtual function
-                i_AI->JustRespawned();
-
-                GetMap()->Add(this);
+                AI()->JustRespawned();
+
+                MapManager::Instance().GetMap(GetMapId(), this)->Add(this);
             }
             break;
@@ -443,5 +440,5 @@
                 // do not allow the AI to be changed during update
                 m_AI_locked = true;
-                i_AI->UpdateAI(diff);
+                AI()->UpdateAI(diff);
                 m_AI_locked = false;
             }
@@ -563,10 +560,7 @@
 }
 
-void Creature::DeletePossessedAI()
+void Creature::DisablePossessedAI()
 {
     if (!i_AI_possessed) return;
-
-    delete i_AI_possessed;
-    i_AI_possessed = NULL;
 
     // Signal the old AI that it's been re-enabled
@@ -1418,4 +1412,6 @@
     SetPower(POWER_MANA,data->curmana);
 
+    SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->dmgschool));
+
     // checked at creature_template loading
     m_defaultMovementType = MovementGeneratorType(data->movementType);
@@ -1542,17 +1538,4 @@
 {
     return IsWithinDistInMap(u, sWorld.getConfig(CONFIG_SIGHT_MONSTER));
-}
-
-bool Creature::canStartAttack(Unit const* who) const
-{
-    if(!who->isInAccessiblePlaceFor(this)
-        || !canFly() && GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE
-        || !IsWithinDistInMap(who, GetAttackDistance(who)))
-        return false;
-
-    if(!canAttack(who))
-        return false;
-
-    return IsWithinLOSInMap(who);
 }
 
@@ -1836,28 +1819,4 @@
 }
 
-Unit* Creature::SelectNearestTarget(float dist) const
-{
-    CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
-    Cell cell(p);
-    cell.data.Part.reserved = ALL_DISTRICT;
-    cell.SetNoCreate();
-
-    Unit *target = NULL;
-
-    {
-        Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist);
-        Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check);
-
-        TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
-        TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer >  grid_unit_searcher(searcher);
-
-        CellLock<GridReadGuard> cell_lock(cell, p);
-        cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap());
-        cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap());
-    }
-
-    return target;
-}
-
 void Creature::CallAssistence()
 {
@@ -2139,12 +2098,7 @@
 }
 
-std::string Creature::GetScriptName()
-{
-    return objmgr.GetScriptName(GetScriptId());
-}
-
-uint32 Creature::GetScriptId()
-{
-    return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptID;
+char const* Creature::GetScriptName() const
+{
+    return ObjectMgr::GetCreatureTemplate(GetEntry())->ScriptName;
 }
 
Index: /trunk/src/game/CreatureAIRegistry.cpp
===================================================================
--- /trunk/src/game/CreatureAIRegistry.cpp (revision 260)
+++ /trunk/src/game/CreatureAIRegistry.cpp (revision 272)
@@ -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 268)
+++ /trunk/src/game/Map.cpp (revision 272)
@@ -36,5 +36,4 @@
 #include "ScriptCalls.h"
 #include "Group.h"
-#include "MapRefManager.h"
 
 #include "MapInstanced.h"
@@ -451,6 +450,4 @@
 bool Map::Add(Player *player)
 {
-    player->GetMapRef().link(this, player);
-
     player->SetInstanceId(GetInstanceId());
 
@@ -595,68 +592,6 @@
 }
 
-void Map::UpdateActiveCells(const float &x, const float &y, const uint32 &t_diff)
-{
-    CellPair standing_cell(Trinity::ComputeCellPair(x, y));
-
-    // Check for correctness of standing_cell, it also avoids problems with update_cell
-    if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
-        return;
-
-    // will this reduce the speed?
-    Trinity::ObjectUpdater updater(t_diff);
-    // for creature
-    TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer  > grid_object_update(updater);
-    // for pets
-    TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);
-
-    // the overloaded operators handle range checking
-    // so ther's no need for range checking inside the loop
-    CellPair begin_cell(standing_cell), end_cell(standing_cell);
-    begin_cell << 1; begin_cell -= 1;               // upper left
-    end_cell >> 1; end_cell += 1;                   // lower right
-
-    for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
-    {
-        for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
-        {
-            // marked cells are those that have been visited
-            // don't visit the same cell twice
-            uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
-            if(!isCellMarked(cell_id))
-            {
-                markCell(cell_id);
-                CellPair pair(x,y);
-                Cell cell(pair);
-                cell.data.Part.reserved = CENTER_DISTRICT;
-                cell.SetNoCreate();
-                CellLock<NullGuard> cell_lock(cell, pair);
-                cell_lock->Visit(cell_lock, grid_object_update,  *this);
-                cell_lock->Visit(cell_lock, world_object_update, *this);
-            }
-        }
-    }
-}
-
 void Map::Update(const uint32 &t_diff)
 {
-    resetMarkedCells();
-
-    // update cells around players
-    for(MapRefManager::iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
-    {
-        Player* plr = iter->getSource();
-        if(plr->IsInWorld())
-            UpdateActiveCells(plr->GetPositionX(), plr->GetPositionY(), t_diff);
-    }
-
-    // update cells around active objects
-    // clone the active object list, because update might remove from it
-    std::set<WorldObject *> activeObjects(i_activeObjects);
-    for(std::set<WorldObject *>::iterator iter = activeObjects.begin(); iter != activeObjects.end(); ++iter)
-    {
-        if((*iter)->IsInWorld())
-            UpdateActiveCells((*iter)->GetPositionX(), (*iter)->GetPositionY(), t_diff);
-    }
-
     // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load !
     // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
@@ -676,5 +611,4 @@
 void Map::Remove(Player *player, bool remove)
 {
-    player->GetMapRef().unlink();
     CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
     if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
@@ -826,11 +760,6 @@
         AddCreatureToMoveList(creature,x,y,z,ang);
         // in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList
-        if(creature->isActive())
-        {
-            if(creature->isPossessedByPlayer())
-                EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false);
-            else
-                EnsureGridLoadedForPlayer(new_cell, NULL, false);
-        }
+        if(creature->isPossessedByPlayer())
+            EnsureGridLoadedForPlayer(new_cell, (Player*)creature->GetCharmer(), false);
     }
     else
@@ -981,5 +910,5 @@
 
     {
-        if(!pForce && PlayersNearGrid(x, y) )
+        if(!pForce && ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, i_id, i_InstanceId) )
             return false;
 
@@ -1490,71 +1419,4 @@
 }
 
-uint32 Map::GetPlayersCountExceptGMs() const
-{
-    uint32 count = 0;
-    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-        if(!itr->getSource()->isGameMaster())
-            ++count;
-    return count;
-}
-
-void Map::SendToPlayers(WorldPacket const* data) const
-{
-    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-        itr->getSource()->GetSession()->SendPacket(data);
-}
-
-bool Map::PlayersNearGrid(uint32 x, uint32 y) const
-{
-    CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
-    CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
-    cell_min << 2;
-    cell_min -= 2;
-    cell_max >> 2;
-    cell_max += 2;
-
-    for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
-    {
-        Player* plr = iter->getSource();
-
-        CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());
-        if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
-            (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )
-            return true;
-    }
-
-    return false;
-}
-
-bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const
-{
-    CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
-    CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
-    cell_min << 2;
-    cell_min -= 2;
-    cell_max >> 2;
-    cell_max += 2;
-
-    for(MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
-    {
-        Player* plr = iter->getSource();
-
-        CellPair p = Trinity::ComputeCellPair(plr->GetPositionX(), plr->GetPositionY());
-        if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
-            (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )
-            return true;
-    }
-
-    for(std::set<WorldObject*>::const_iterator itr = i_activeObjects.begin(); itr != i_activeObjects.end(); ++itr)
-    {
-        CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY());
-        if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
-            (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )
-            return true;
-    }
-
-    return false;
-}
-
 template void Map::Add(Corpse *);
 template void Map::Add(Creature *);
@@ -1592,5 +1454,5 @@
 bool InstanceMap::CanEnter(Player *player)
 {
-    if(player->GetMapRef().getTarget() == this)
+    if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())
     {
         sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode());
@@ -1709,4 +1571,5 @@
         SetResetSchedule(false);
 
+        i_Players.push_back(player);
         player->SendInitWorldStates();
         sLog.outDetail("MAP: Player '%s' entered the instance '%u' of map '%s'", player->GetName(), GetInstanceId(), GetMapName());
@@ -1733,7 +1596,7 @@
 {
     sLog.outDetail("MAP: Removing player '%s' from instance '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
+    i_Players.remove(player);
     SetResetSchedule(true);
-    //if last player set unload timer
-    if(!m_unloadTimer && m_mapRefManager.getSize() == 1)
+    if(!m_unloadTimer && i_Players.empty())
         m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY);
     Map::Remove(player, remove);
@@ -1762,5 +1625,5 @@
     if (mInstance)
     {
-        i_script_id = mInstance->script_id;
+        i_script = mInstance->script;
         i_data = Script->CreateInstanceData(this);
     }
@@ -1779,5 +1642,5 @@
             if(data)
             {
-                sLog.outDebug("Loading instance data for `%s` with id %u", objmgr.GetScriptName(i_script_id), i_InstanceId);
+                sLog.outDebug("Loading instance data for `%s` with id %u", i_script.c_str(), i_InstanceId);
                 i_data->Load(data);
             }
@@ -1787,5 +1650,5 @@
     else
     {
-        sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id));
+        sLog.outDebug("New instance data, \"%s\" ,initialized!",i_script.c_str());
         i_data->Initialize();
     }
@@ -1800,11 +1663,11 @@
     // the instance must be deleted from the DB by InstanceSaveManager
 
-    if(HavePlayers())
+    if(!i_Players.empty())
     {
         if(method == INSTANCE_RESET_ALL)
         {
             // notify the players to leave the instance so it can be reset
-            for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-                itr->getSource()->SendResetFailedNotify(GetId());
+            for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+                (*itr)->SendResetFailedNotify(GetId());
         }
         else
@@ -1813,6 +1676,6 @@
             {
                 // set the homebind timer for players inside (1 minute)
-                for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-                    itr->getSource()->m_InstanceValid = false;
+                for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+                    (*itr)->m_InstanceValid = false;
             }
 
@@ -1830,5 +1693,14 @@
     }
 
-    return m_mapRefManager.isEmpty();
+    return i_Players.empty();
+}
+
+uint32 InstanceMap::GetPlayersCountExceptGMs() const
+{
+    uint32 count = 0;
+    for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+        if(!(*itr)->isGameMaster())
+            ++count;
+    return count;
 }
 
@@ -1844,21 +1716,23 @@
     Group *group = player->GetGroup();
     // group members outside the instance group don't get bound
-    for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-    {
-        Player* plr = itr->getSource();
-        // players inside an instance cannot be bound to other instances
-        // some players may already be permanently bound, in this case nothing happens
-        InstancePlayerBind *bind = plr->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
-        if(!bind || !bind->perm)
-        {
-            plr->BindToInstance(save, true);
-            WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
-            data << uint32(0);
-            plr->GetSession()->SendPacket(&data);
-        }
-
-        // if the leader is not in the instance the group will not get a perm bind
-        if(group && group->GetLeaderGUID() == plr->GetGUID())
-            group->BindToInstance(save, true);
+    for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+    {
+        if(*itr)
+        {
+            // players inside an instance cannot be bound to other instances
+            // some players may already be permanently bound, in this case nothing happens
+            InstancePlayerBind *bind = (*itr)->GetBoundInstance(save->GetMapId(), save->GetDifficulty());
+            if(!bind || !bind->perm)
+            {
+                (*itr)->BindToInstance(save, true);
+                WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4);
+                data << uint32(0);
+                (*itr)->GetSession()->SendPacket(&data);
+            }
+
+            // if the leader is not in the instance the group will not get a perm bind
+            if(group && group->GetLeaderGUID() == (*itr)->GetGUID())
+                group->BindToInstance(save, true);
+        }
     }
 }
@@ -1872,12 +1746,9 @@
 void InstanceMap::UnloadAll(bool pForce)
 {
-    if(HavePlayers())
+    if(!i_Players.empty())
     {
         sLog.outError("InstanceMap::UnloadAll: there are still players in the instance at unload, should not happen!");
-        for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-        {
-            Player* plr = itr->getSource();
-            plr->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation());
-        }
+        for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+            if(*itr) (*itr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation());
     }
 
@@ -1888,8 +1759,8 @@
 }
 
-void InstanceMap::SendResetWarnings(uint32 timeLeft) const
-{
-    for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
-        itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft);
+void InstanceMap::SendResetWarnings(uint32 timeLeft)
+{
+    for(PlayerList::iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+        (*itr)->SendInstanceResetWarning(GetId(), timeLeft);
 }
 
@@ -1899,5 +1770,5 @@
     // the reset time is only scheduled when there are no payers inside
     // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled
-    if(!HavePlayers() && !IsRaid() && !IsHeroic())
+    if(i_Players.empty() && !IsRaid() && !IsHeroic())
     {
         InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId());
@@ -1907,4 +1778,10 @@
 }
 
+void InstanceMap::SendToPlayers(WorldPacket const* data) const
+{
+    for(PlayerList::const_iterator itr = i_Players.begin(); itr != i_Players.end(); ++itr)
+        (*itr)->GetSession()->SendPacket(data);
+}
+
 /* ******* Battleground Instance Maps ******* */
 
@@ -1920,5 +1797,5 @@
 bool BattleGroundMap::CanEnter(Player * player)
 {
-    if(player->GetMapRef().getTarget() == this)
+    if(std::find(i_Players.begin(),i_Players.end(),player)!=i_Players.end())
     {
         sLog.outError("BGMap::CanEnter - player %u already in map!", player->GetGUIDLow());
@@ -1941,4 +1818,5 @@
         if(!CanEnter(player))
             return false;
+        i_Players.push_back(player);
         // reset instance validity, battleground maps do not homebind
         player->m_InstanceValid = true;
@@ -1950,4 +1828,5 @@
 {
     sLog.outDetail("MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map", player->GetName(), GetInstanceId(), GetMapName());
+    i_Players.remove(player);
     Map::Remove(player, remove);
 }
@@ -1960,12 +1839,13 @@
 void BattleGroundMap::UnloadAll(bool pForce)
 {
-    while(HavePlayers())
-    {
-        Player * plr = m_mapRefManager.getFirst()->getSource();
-        if(plr) (plr)->TeleportTo(plr->m_homebindMapId, plr->m_homebindX, plr->m_homebindY, plr->m_homebindZ, plr->GetOrientation());
+    while(!i_Players.empty())
+    {
+        PlayerList::iterator itr = i_Players.begin();
+        Player * plr = *itr;
+        if(plr) (plr)->TeleportTo((*itr)->m_homebindMapId, (*itr)->m_homebindX, (*itr)->m_homebindY, (*itr)->m_homebindZ, (*itr)->GetOrientation());
         // TeleportTo removes the player from this map (if the map exists) -> calls BattleGroundMap::Remove -> invalidates the iterator.
         // just in case, remove the player from the list explicitly here as well to prevent a possible infinite loop
         // note that this remove is not needed if the code works well in other places
-        plr->GetMapRef().unlink();
+        i_Players.remove(plr);
     }
 
Index: /trunk/src/game/Object.cpp
===================================================================
--- /trunk/src/game/Object.cpp (revision 268)
+++ /trunk/src/game/Object.cpp (revision 272)
@@ -991,6 +991,6 @@
 WorldObject::~WorldObject()
 {
-    if(m_isActive && !isType(TYPEMASK_PLAYER) && IsInWorld())
-        GetMap()->RemoveActiveObject(this);
+    if(m_isActive && IsInWorld())
+        ObjectAccessor::Instance().RemoveActiveObject(this);
 }
 
@@ -998,14 +998,13 @@
 {
     // if already in the same activity state as we try to set, do nothing
-    if(isActive == m_isActive || isType(TYPEMASK_PLAYER))
+    if(isActive == m_isActive)
         return;
-
     m_isActive = isActive;
     if(IsInWorld())
     {
         if(isActive)
-            GetMap()->AddActiveObject(this);
+            ObjectAccessor::Instance().AddActiveObject(this);
         else
-            GetMap()->RemoveActiveObject(this);
+            ObjectAccessor::Instance().RemoveActiveObject(this);
     }
 }
@@ -1014,12 +1013,12 @@
 {
     Object::AddToWorld();
-    if(m_isActive && !isType(TYPEMASK_PLAYER))
-        GetMap()->AddActiveObject(this);
+    if(m_isActive)
+        ObjectAccessor::Instance().AddActiveObject(this);
 }
 
 void WorldObject::RemoveFromWorld()
 {
-    if(m_isActive && !isType(TYPEMASK_PLAYER))
-        GetMap()->RemoveActiveObject(this);
+    if(m_isActive)
+        ObjectAccessor::Instance().RemoveActiveObject(this);
     Object::RemoveFromWorld();
 }
Index: /trunk/src/game/GridStates.cpp
===================================================================
--- /trunk/src/game/GridStates.cpp (revision 268)
+++ /trunk/src/game/GridStates.cpp (revision 272)
@@ -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
  */
 
@@ -37,5 +37,5 @@
     if( info.getTimeTracker().Passed() )
     {
-        if( grid.ActiveObjectsInGrid() == 0 && !m.ActiveObjectsNearGrid(x, y) )
+        if( grid.ActiveObjectsInGrid() == 0 && !ObjectAccessor::Instance().ActiveObjectsNearGrid(x, y, m.GetId(), m.GetInstanceId()) )
         {
             ObjectGridStoper stoper(grid);
@@ -51,5 +51,5 @@
 
 void
-IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32 &x, const uint32 &y, const uint32 &) const
+IdleState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 &x, const uint32 &y, const uint32 &) const
 {
     m.ResetGridExpiry(grid);
Index: /trunk/src/game/MapInstanced.h
===================================================================
--- /trunk/src/game/MapInstanced.h (revision 257)
+++ /trunk/src/game/MapInstanced.h (revision 272)
@@ -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
  */
 
@@ -31,5 +31,5 @@
         typedef UNORDERED_MAP< uint32, Map* > InstancedMaps;
 
-        MapInstanced(uint32 id, time_t expiry);
+        MapInstanced(uint32 id, time_t, uint32 aInstanceId);
         ~MapInstanced() {}
 
Index: /trunk/src/game/Creature.h
===================================================================
--- /trunk/src/game/Creature.h (revision 267)
+++ /trunk/src/game/Creature.h (revision 272)
@@ -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,9 +206,8 @@
     uint32  MechanicImmuneMask;
     uint32  flags_extra;
-    uint32  ScriptID;
+    char const* ScriptName;
     uint32 GetRandomValidModelId() const;
     uint32 GetFirstValidModelId() const;
-
-    // helpers
+    
     SkillType GetRequiredLootSkill() const
     {
@@ -220,5 +219,5 @@
             return SKILL_SKINNING;                          // normal case
     }
-
+    
     bool isTameable() const
     {
@@ -427,6 +426,4 @@
         bool canSwim() const { return GetCreatureInfo()->InhabitType & INHABIT_WATER; }
         bool canFly()  const { return GetCreatureInfo()->InhabitType & INHABIT_AIR; }
-        bool isAggressive() const { return m_isAggressive; }
-        void SetAggressive(bool agg) { m_isAggressive = agg; }
         ///// TODO RENAME THIS!!!!!
         bool isCanTrainingOf(Player* player, bool msg) const;
@@ -461,5 +458,5 @@
         bool AIM_Initialize();
         void InitPossessedAI();
-        void DeletePossessedAI();
+        void DisablePossessedAI();
 
         void AI_SendMoveToPacket(float x, float y, float z, uint32 time, uint32 MovementFlags, uint8 type);
@@ -502,7 +499,5 @@
         CreatureInfo const *GetCreatureInfo() const { return m_creatureInfo; }
         CreatureDataAddon const* GetCreatureAddon() const;
-
-        std::string GetScriptName();
-        uint32 GetScriptId();
+        char const* GetScriptName() const;
 
         void prepareGossipMenu( Player *pPlayer, uint32 gossipid = 0 );
@@ -530,5 +525,5 @@
         // overwrite WorldObject function for proper name localization
         const char* GetNameForLocaleIdx(int32 locale_idx) const;
-
+    
         void setDeathState(DeathState s);                   // overwrite virtual Unit::setDeathState
 
@@ -558,8 +553,6 @@
         bool canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList) const;
         bool IsWithinSightDist(Unit const* u) const;
-        bool canStartAttack(Unit const* u) const;
         float GetAttackDistance(Unit const* pl) const;
 
-        Unit* SelectNearestTarget(float dist = 0) const;
         void CallAssistence();
         void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; }
@@ -641,5 +634,4 @@
         bool m_isPet;                                       // set only in Pet::Pet
         bool m_isTotem;                                     // set only in Totem::Totem
-        bool m_isAggressive;
         void RegenerateMana();
         void RegenerateHealth();
Index: /trunk/src/game/PlayerDump.cpp
===================================================================
--- /trunk/src/game/PlayerDump.cpp (revision 263)
+++ /trunk/src/game/PlayerDump.cpp (revision 272)
@@ -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,8 +372,7 @@
         }
     }
-
     FILE *fin = fopen(file.c_str(), "r");
     if(!fin)
-        return DUMP_FILE_OPEN_ERROR;
+		return DUMP_FILE_OPEN_ERROR;
 
     QueryResult * result = NULL;
@@ -392,6 +391,5 @@
         else incHighest = false;
     }
-    else
-        guid = objmgr.m_hiCharGuid;
+    else guid = objmgr.m_hiCharGuid;
 
     // normalize the name if specified and check if it exists
@@ -471,5 +469,5 @@
             case DTT_CHAR_TABLE:
                 if(!changenth(line, 1, newguid))
-                    ROLLBACK(DUMP_FILE_BROKEN);
+					ROLLBACK(DUMP_FILE_BROKEN);
                 break;
 
@@ -477,17 +475,21 @@
             {
                 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 == "")
                 {
@@ -502,9 +504,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;
@@ -513,11 +515,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;
             }
@@ -526,14 +528,15 @@
                 // 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;
             }
@@ -542,7 +545,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;
             }
@@ -567,7 +570,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;
@@ -580,10 +583,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;
@@ -593,7 +596,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;
             }
@@ -602,9 +605,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;
             }
@@ -615,5 +618,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 260)
+++ /trunk/src/game/Chat.h (revision 272)
@@ -176,5 +176,4 @@
         bool HandleModifyRepCommand(const char* args);
         bool HandleModifyArenaCommand(const char* args);
-        bool HandleModifyGenderCommand(const char* args);
 
         bool HandleNpcAddCommand(const char* args);
@@ -193,5 +192,4 @@
         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);
@@ -218,5 +216,4 @@
         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);
@@ -274,13 +271,8 @@
         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);
@@ -336,4 +328,9 @@
         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);
@@ -369,4 +366,5 @@
         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 260)
+++ /trunk/src/game/ItemHandler.cpp (revision 272)
@@ -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() > size_t(loc_idx) && !il->Name[loc_idx].empty())
+                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
                     Name = il->Name[loc_idx];
-                if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty())
+                if (il->Description.size() > loc_idx && !il->Description[loc_idx].empty())
                     Description = il->Description[loc_idx];
             }
@@ -361,6 +361,4 @@
             data << pProto->Damage[i].DamageType;
         }
-
-        // resistances (7)
         data << pProto->Armor;
         data << pProto->HolyRes;
@@ -370,9 +368,8 @@
         data << pProto->ShadowRes;
         data << pProto->ArcaneRes;
-
         data << pProto->Delay;
         data << pProto->Ammo_type;
-        data << pProto->RangedModRange;
-
+
+        data << (float)pProto->RangedModRange;
         for(int s = 0; s < 5; s++)
         {
@@ -980,5 +977,5 @@
             if (il)
             {
-                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
+                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
                     Name = il->Name[loc_idx];
             }
@@ -1031,5 +1028,5 @@
     }
 
-    if(item==gift)                                          // not possable with pacjket from real client
+    if(item==gift)                                          // not possible with pacjket from real client
     {
         _player->SendEquipError( EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED, item, NULL );
@@ -1076,14 +1073,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->SetEntry(gift->GetEntry());
+    item->SetUInt32Value(OBJECT_FIELD_ENTRY, gift->GetUInt32Value(OBJECT_FIELD_ENTRY));
 
     switch (item->GetEntry())
     {
-        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;
+        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;
     }
     item->SetUInt64Value(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
Index: /trunk/src/game/Formulas.h
===================================================================
--- /trunk/src/game/Formulas.h (revision 263)
+++ /trunk/src/game/Formulas.h (revision 272)
@@ -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,5 +81,4 @@
         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/Totem.cpp
===================================================================
--- /trunk/src/game/Totem.cpp (revision 265)
+++ /trunk/src/game/Totem.cpp (revision 272)
@@ -98,7 +98,4 @@
         default: break;
     }
-
-    if(GetEntry() == SENTRY_TOTEM_ENTRY)
-        SetAggressive(true);
 }
 
Index: /trunk/src/game/Player.h
===================================================================
--- /trunk/src/game/Player.h (revision 268)
+++ /trunk/src/game/Player.h (revision 272)
@@ -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
  */
 
@@ -34,5 +34,4 @@
 #include "WorldSession.h"
 #include "Pet.h"
-#include "MapReference.h"
 #include "Util.h"                                           // for Tokens typedef
 
@@ -781,5 +780,5 @@
 
 /// Type of environmental damages
-enum EnviromentalDamage
+enum EnvironmentalDamageType
 {
     DAMAGE_EXHAUSTED = 0,
@@ -898,4 +897,6 @@
         void AddToWorld();
         void RemoveFromWorld();
+        // always active
+        void setActive(bool) {}
 
         void SetViewport(uint64 guid, bool movable);
@@ -1124,5 +1125,5 @@
         uint32 GetArmorProficiency() const { return m_ArmorProficiency; }
         bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
-        bool IsUseEquipedWeapon( bool mainhand ) const
+        bool IsUseEquippedWeapon( bool mainhand ) const
         {
             // disarm applied only to mainhand weapon
@@ -1306,5 +1307,5 @@
                 SetMoney (GetMoney() > uint32(-d) ? GetMoney() + d : 0);
             else
-                SetMoney (GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
+                SetMoney (GetMoney() < MAX_MONEY_AMOUNT - d ? GetMoney() + d : MAX_MONEY_AMOUNT);
 
             // "At Gold Limit"
@@ -1428,4 +1429,5 @@
         PlayerSpellMap const& GetSpellMap() const { return m_spells; }
         PlayerSpellMap      & GetSpellMap()       { return m_spells; }
+        ActionButtonList const& GetActionButtonList() const { return m_actionButtons; }
 
         void AddSpellMod(SpellModifier* mod, bool apply);
@@ -1517,6 +1519,6 @@
         void SendUpdateToOutOfRangeGroupMembers();
 
-        void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); }
-        void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); }
+        void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); }
+        void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); }
         void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
         uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID);  }
@@ -1531,5 +1533,5 @@
         {
             SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
-            SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID());
+            SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID());
         }
         uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
@@ -1607,5 +1609,5 @@
         void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
 
-        //Low Level Packets
+		//Low Level Packets
         void PlaySound(uint32 Sound, bool OnlySelf);
         //notifiers
@@ -1639,5 +1641,5 @@
         void KillPlayer();
         uint32 GetResurrectionSpellId();
-        void ResurrectPlayer(float restore_percent, bool applySickness = false);
+        void ResurrectPlayer(float restore_percent, bool updateToWorld = true, bool applySickness = false);
         void BuildPlayerRepop();
         void RepopAtGraveyard();
@@ -1761,5 +1763,5 @@
         void SetRegularAttackTime();
         void SetBaseModValue(BaseModGroup modGroup, BaseModType modType, float value) { m_auraBaseMod[modGroup][modType] = value; }
-        void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply);
+        void HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats = true);
         float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const;
         float GetTotalBaseModValue(BaseModGroup modGroup) const;
@@ -1768,5 +1770,5 @@
         void _RemoveAllStatBonuses();
 
-        void _ApplyWeaponDependentAuraMods(Item *item, WeaponAttackType attackType, bool apply);
+        void _ApplyWeaponDependentAuraMods(Item *item,WeaponAttackType attackType,bool apply);
         void _ApplyWeaponDependentAuraCritMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
         void _ApplyWeaponDependentAuraDamageMod(Item *item, WeaponAttackType attackType, Aura* aura, bool apply);
@@ -1933,8 +1935,8 @@
 
         /*********************************************************/
-        /***              ENVIROMENTAL SYSTEM                  ***/
-        /*********************************************************/
-
-        void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage);
+        /***              ENVIRONMENTAL SYSTEM                  ***/
+        /*********************************************************/
+
+        void EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage);
 
         /*********************************************************/
@@ -2061,6 +2063,4 @@
 
         GridReference<Player> &GetGridRef() { return m_gridRef; }
-        MapReference &GetMapRef() { return m_mapRef; }
-
         bool isAllowedToLoot(Creature* creature);
 
@@ -2308,5 +2308,4 @@
 
         GridReference<Player> m_gridRef;
-        MapReference m_mapRef;
 };
 
Index: /trunk/src/game/GMTicketHandler.cpp
===================================================================
--- /trunk/src/game/GMTicketHandler.cpp (revision 263)
+++ /trunk/src/game/GMTicketHandler.cpp (revision 272)
@@ -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,6 @@
     recv_data >> ticketText;
 
+    CharacterDatabase.escape_string(ticketText);
+
     if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
         ticket->SetText(ticketText.c_str());
@@ -104,5 +106,7 @@
     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);
 
-    if(ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
+    CharacterDatabase.escape_string(ticketText);
+
+    if(GMTicket* ticket = ticketmgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
     {
         WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
Index: /trunk/src/game/CreatureAI.cpp
===================================================================
--- /trunk/src/game/CreatureAI.cpp (revision 260)
+++ /trunk/src/game/CreatureAI.cpp (revision 272)
@@ -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/SpellMgr.h
===================================================================
--- /trunk/src/game/SpellMgr.h (revision 264)
+++ /trunk/src/game/SpellMgr.h (revision 272)
@@ -285,5 +285,5 @@
 }
 
-//bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2);
+bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2);
 
 inline bool IsSealSpell(SpellEntry const *spellInfo)
@@ -301,6 +301,5 @@
 
 int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2);
-bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1, uint32 spellSpec2);
-bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1, uint32 spellSpec2);
+bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2);
 bool IsPassiveSpell(uint32 spellId);
 
@@ -770,5 +769,5 @@
         bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const;
         static bool canStackSpellRanks(SpellEntry const *spellInfo);
-        bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const;
+        bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const;
 
         SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const;
Index: /trunk/src/game/GameEvent.cpp
===================================================================
--- /trunk/src/game/GameEvent.cpp (revision 259)
+++ /trunk/src/game/GameEvent.cpp (revision 272)
@@ -1504,5 +1504,5 @@
     CharacterDatabase.PExecute("DELETE FROM game_event_save WHERE event_id = '%u'",event_id);
     if(mGameEvent[event_id].nextstart)
-        CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,(uint64)(mGameEvent[event_id].nextstart));
+        CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u',FROM_UNIXTIME("I64FMTD"))",event_id,mGameEvent[event_id].state,mGameEvent[event_id].nextstart);
     else
         CharacterDatabase.PExecute("INSERT INTO game_event_save (event_id, state, next_start) VALUES ('%u','%u','0000-00-00 00:00:00')",event_id,mGameEvent[event_id].state);
Index: /trunk/src/game/World.h
===================================================================
--- /trunk/src/game/World.h (revision 260)
+++ /trunk/src/game/World.h (revision 272)
@@ -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,11 +52,4 @@
 };
 
-enum ShutdownExitCode
-{
-    SHUTDOWN_EXIT_CODE = 0,
-    ERROR_EXIT_CODE    = 1,
-    RESTART_EXIT_CODE  = 2,
-};
-
 /// Timers for different object refresh rates
 enum WorldTimers
@@ -69,5 +62,6 @@
     WUPDATE_CORPSES     = 5,
     WUPDATE_EVENTS      = 6,
-    WUPDATE_COUNT       = 7
+    WUPDATE_COUNT       = 7,
+
 };
 
@@ -112,6 +106,4 @@
     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,
@@ -152,5 +144,4 @@
     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,
@@ -326,18 +317,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; }
 };
 
@@ -346,4 +337,5 @@
 {
     public:
+        static volatile bool m_stopEvent;
         static volatile uint32 m_worldLoopCounter;
 
@@ -353,4 +345,5 @@
         WorldSession* FindSession(uint32 id) const;
         void AddSession(WorldSession *s);
+
         bool RemoveSession(uint32 id);
         /// Get the number of current active sessions
@@ -415,5 +408,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);
@@ -422,11 +415,9 @@
 
         /// 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, uint8 exitcode);
+        void ShutdownServ(uint32 time, uint32 options = 0);
         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);
@@ -463,5 +454,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);
@@ -491,11 +482,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:
@@ -508,9 +499,4 @@
         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;
@@ -540,4 +526,7 @@
         std::set<uint32> m_forbiddenMapIds;
 
+        uint32 m_ShutdownTimer;
+        uint32 m_ShutdownMask;
+
         // for max speed access
         static float m_MaxVisibleDistanceForCreature;
@@ -557,12 +546,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 260)
+++ /trunk/src/game/Item.cpp (revision 272)
@@ -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_SOUL_SHARDS))
+                    if(!(pProto->BagFamily & BAG_FAMILY_MASK_SHARDS))
                         return false;
                     return true;
@@ -248,5 +248,5 @@
     Object::_Create( guidlow, 0, HIGHGUID_ITEM );
 
-    SetEntry(itemid);
+    SetUInt32Value(OBJECT_FIELD_ENTRY, itemid);
     SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
 
@@ -430,5 +430,5 @@
 ItemPrototype const *Item::GetProto() const
 {
-    return objmgr.GetItemPrototype(GetEntry());
+    return objmgr.GetItemPrototype(GetUInt32Value(OBJECT_FIELD_ENTRY));
 }
 
@@ -763,5 +763,7 @@
 {
     // Better lost small time at check in comparison lost time at item save to DB.
-    if((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
+    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 )
         return;
 
@@ -774,5 +776,5 @@
 void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
 {
-    if(GetEnchantmentDuration(slot) == duration)
+    if(GetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET)==duration)
         return;
 
@@ -783,7 +785,4 @@
 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);
@@ -792,9 +791,9 @@
 void Item::ClearEnchantment(EnchantmentSlot slot)
 {
-    if(!GetEnchantmentId(slot))
-        return;
-
-    for(uint8 x = 0; x < 3; ++x)
-        SetUInt32Value(ITEM_FIELD_ENCHANTMENT + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
+    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);
     SetState(ITEM_CHANGED);
 }
Index: /trunk/src/game/GameObject.cpp
===================================================================
--- /trunk/src/game/GameObject.cpp (revision 246)
+++ /trunk/src/game/GameObject.cpp (revision 272)
@@ -1281,5 +1281,5 @@
     {
         trigger->setFaction(14);
-        trigger->CastSpell(target, spell, true, 0, 0, target->GetGUID());
+        trigger->CastSpell(target, spell, true);
     }
     //trigger->setDeathState(JUST_DIED);
Index: /trunk/src/game/MapManager.cpp
===================================================================
--- /trunk/src/game/MapManager.cpp (revision 260)
+++ /trunk/src/game/MapManager.cpp (revision 272)
@@ -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
  */
 
@@ -112,5 +112,5 @@
         if (entry && entry->Instanceable())
         {
-            m = new MapInstanced(id, i_gridCleanUpDelay);
+            m = new MapInstanced(id, i_gridCleanUpDelay, 0);
         }
         else
@@ -223,5 +223,5 @@
 }
 
-void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
+void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId, uint8 mode)
 {
     Map *m = _GetBaseMap(mapid);
@@ -246,6 +246,4 @@
     if( !i_timer.Passed() )
         return;
-
-    ObjectAccessor::Instance().UpdatePlayers(i_timer.GetCurrent());
 
     for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
@@ -339,5 +337,5 @@
         for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
             if(mitr->second->IsDungeon())
-                ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize();
+                ret += ((InstanceMap*)mitr->second)->GetPlayers().size();
     }
     return ret;
Index: /trunk/src/game/Unit.cpp
===================================================================
--- /trunk/src/game/Unit.cpp (revision 267)
+++ /trunk/src/game/Unit.cpp (revision 272)
@@ -1149,4 +1149,6 @@
             if ( GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_NORMAL )
             {
+                uint32 modDamage=*damage;
+
                 // apply spellmod to Done damage
                 if(Player* modOwner = GetSpellModOwner())
@@ -1433,5 +1435,5 @@
     if(!this || !pVictim)
         return 0;
-    if(!isAlive() || !pVictim->isAlive())
+    if(!this->isAlive() || !pVictim->isAlive())
         return 0;
 
@@ -3781,4 +3783,5 @@
         {
             m_ccAuras.push_back(Aur);
+            RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC);
         }
     }
@@ -3896,15 +3899,14 @@
         if(!is_triggered_by_spell)
         {
-            bool sameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID();
-            if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, sameCaster) )
-            {
-                //some spells should be not removed by lower rank of them
-                // what is this spell?
-                if (!sameCaster
-                    &&(spellProto->Effect[effIndex]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY)
-                    &&(spellProto->DurationIndex==21)
-                    &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId))
-                    &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0))
-                    return false;
+            SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId);
+
+            bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec);
+
+            if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() )
+            {
+                // cannot remove higher rank
+                if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId))
+                    if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)
+                        return false;
 
                 // Its a parent aura (create this aura in ApplyModifier)
@@ -3920,4 +3922,37 @@
                 else
                     next =  m_Auras.begin();
+            }
+            else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) )
+            {
+                // Its a parent aura (create this aura in ApplyModifier)
+                if ((*i).second->IsInUse())
+                {
+                    sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex());
+                    continue;
+                }
+                RemoveAurasDueToSpell(i_spellId);
+
+                if( m_Auras.empty() )
+                    break;
+                else
+                    next =  m_Auras.begin();
+            }
+            // Potions stack aura by aura (elixirs/flask already checked)
+            else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION )
+            {
+                if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex))
+                {
+                    if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)
+                        return false;                       // cannot remove higher rank
+
+                    // Its a parent aura (create this aura in ApplyModifier)
+                    if ((*i).second->IsInUse())
+                    {
+                        sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex());
+                        continue;
+                    }
+                    RemoveAura(i);
+                    next = i;
+                }
             }
         }
@@ -4094,15 +4129,10 @@
 void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
 {
-    Aura* Aur = i->second;
-    SpellEntry const* AurSpellInfo = Aur->GetSpellProto();
-
-    Unit* caster = NULL;
-    if (IsSingleTargetSpell(AurSpellInfo))
-    {
-        caster = Aur->GetCaster();
-        if(caster)
+    if (IsSingleTargetSpell((*i).second->GetSpellProto()))
+    {
+        if(Unit* caster = (*i).second->GetCaster())
         {
             AuraList& scAuras = caster->GetSingleCastAuras();
-            scAuras.remove(Aur);
+            scAuras.remove((*i).second);
         }
         else
@@ -4113,6 +4143,5 @@
     }
 
-    // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
-    if (Aur->GetModifier()->m_auraname < TOTAL_AURAS)
+    if ((*i).second->GetModifier()->m_auraname < TOTAL_AURAS)
     {
         m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second);
@@ -4126,4 +4155,6 @@
     }
 
+    // remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
+    Aura* Aur = i->second;
     // Set remove mode
     Aur->SetRemoveMode(mode);
@@ -4133,20 +4164,11 @@
     ++m_removedAuras;                                       // internal count used by unit update
 
-    // Statue unsummoned at aura remove
+    // Status unsummoned at aura remove
     Totem* statue = NULL;
-    bool caster_channeled = false;
-    if(IsChanneledSpell(AurSpellInfo))
-    {
-        if(!caster)                                         // can be already located for IsSingleTargetSpell case
-            caster = Aur->GetCaster();
-
-        if(caster)
-        {
+    if(IsChanneledSpell(Aur->GetSpellProto()))
+        if(Unit* caster = Aur->GetCaster())
             if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE)
                 statue = ((Totem*)caster);
-            else
-                caster_channeled = caster==this;
-        }
-    }
+
 
     if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id))
@@ -4165,7 +4187,4 @@
     Aur->_RemoveAura();
     delete Aur;
-
-    if(caster_channeled)
-        RemoveAurasAtChanneledTarget (AurSpellInfo);
 
     if(statue)
@@ -4594,8 +4613,6 @@
 }
 
-bool Unit::HandleHasteAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * /*procSpell*/, uint32 /*procFlag*/, uint32 cooldown)
-{
-    SpellEntry const *hasteSpell = triggeredByAura->GetSpellProto();
-
+bool Unit::HandleHasteAuraProc(Unit *pVictim, SpellEntry const *hasteSpell, uint32 /*effIndex*/, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 /*procFlag*/, uint32 cooldown)
+{
     Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER
         ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL;
@@ -4657,9 +4674,6 @@
 }
 
-bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown)
-{
-    SpellEntry const *dummySpell = triggeredByAura->GetSpellProto ();
-    uint32 effIndex = triggeredByAura->GetEffIndex ();
-
+bool Unit::HandleDummyAuraProc(Unit *pVictim, SpellEntry const *dummySpell, uint32 effIndex, uint32 damage, Aura* triggeredByAura, SpellEntry const * procSpell, uint32 procFlag, uint32 cooldown)
+{
     Item* castItem = triggeredByAura->GetCastItemGUID() && GetTypeId()==TYPEID_PLAYER
         ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGUID()) : NULL;
@@ -6249,4 +6263,5 @@
                             return false;
 
+                        uint32 spell = 0;
                         switch(triggeredByAura->GetSpellProto()->Id)
                         {
@@ -6278,4 +6293,5 @@
 
                         // overwrite non existing triggered spell call in spell.dbc
+                        uint32 spell = 0;
                         switch(triggeredByAura->GetSpellProto()->Id)
                         {
@@ -6477,8 +6493,6 @@
 }
 
-bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown)
-{
-    int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue;
-
+bool Unit::HandleOverrideClassScriptAuraProc(Unit *pVictim, int32 scriptId, uint32 damage, Aura *triggeredByAura, SpellEntry const *procSpell, uint32 cooldown)
+{
     if(!pVictim || !pVictim->isAlive())
         return false;
@@ -7246,5 +7260,5 @@
 }
 
-void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype)
+void Unit::SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers powertype, bool critical)
 {
     WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1));
@@ -7346,5 +7360,5 @@
     AuraList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN);
     for(AuraList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i)
-        if( (*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto) )
+        if((*i)->GetModifier()->m_miscvalue & GetSpellSchoolMask(spellProto))
             TakenTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
 
@@ -8194,5 +8208,5 @@
 
     // ..done (for creature type by mask) in taken
-    AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
+    AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
     for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i)
         if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue))
@@ -8262,5 +8276,5 @@
     // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT  included in weapon damage
 
-    AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
+    AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
     for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i)
         if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue))
@@ -8492,6 +8506,5 @@
         target->SetStandState(PLAYER_STATE_NONE);
 
-    if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER
-        && ((Creature*)target)->isAggressive() && ((Creature*)target)->AI())
+    if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && ((Creature*)target)->AI())
         ((Creature*)target)->AI()->AttackStart(this);
 
@@ -8542,7 +8555,4 @@
 {
     assert(target);
-
-    if(!IsHostileTo(target))
-        return false;
 
     if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED))
@@ -8721,5 +8731,5 @@
     if(IsInWorld())
     {
-        Map *m = GetMap();
+        Map *m = MapManager::Instance().GetMap(GetMapId(), this);
 
         if(GetTypeId()==TYPEID_PLAYER)
@@ -9130,11 +9140,4 @@
     }
 
-    // search nearby enemy before enter evade mode
-    if(Unit *target = ((Creature*)this)->SelectNearestTarget())
-    {
-        ((Creature*)this)->AI()->AttackStart(target);
-        return true;
-    }
-
     // enter in evade mode in other case
     ((Creature*)this)->AI()->EnterEvadeMode();
@@ -9790,4 +9793,6 @@
 }
 
+
+
 CharmInfo* Unit::InitCharmInfo(Unit *charm)
 {
@@ -9953,13 +9958,15 @@
 struct ProcTriggeredData
 {
-    ProcTriggeredData(Aura* _triggeredByAura, uint32 _cooldown)
-        : triggeredByAura(_triggeredByAura),
+    ProcTriggeredData(SpellEntry const * _spellInfo, uint32 _spellParam, Aura* _triggeredByAura, uint32 _cooldown)
+        : spellInfo(_spellInfo), spellParam(_spellParam), triggeredByAura(_triggeredByAura),
         triggeredByAura_SpellPair(Unit::spellEffectPair(triggeredByAura->GetId(),triggeredByAura->GetEffIndex())),
         cooldown(_cooldown)
-    {}
-
-    Aura* triggeredByAura;                                  // triggred aura, can be invalidate at triggered aura proccessing
-    Unit::spellEffectPair triggeredByAura_SpellPair;        // spell pair, used for re-find aura (by pointer comparison in range)
-    uint32 cooldown;                                        // possible hidden cooldown
+        {}
+
+    SpellEntry const * spellInfo;
+    uint32 spellParam;
+    Aura* triggeredByAura;
+    Unit::spellEffectPair triggeredByAura_SpellPair;
+    uint32 cooldown;
 };
 
@@ -9978,11 +9985,85 @@
             next = i; ++next;
 
-            Aura* i_aura = *i;
-
-            uint32 cooldown;                                // returned at next line
-            if(!IsTriggeredAtSpellProcEvent(i_aura->GetSpellProto(), procSpell, procFlag,attType,isVictim,cooldown))
+            SpellEntry const *spellProto = (*i)->GetSpellProto();
+            if(!spellProto)
                 continue;
 
-            procTriggered.push_back( ProcTriggeredData(i_aura, cooldown) );
+            SpellProcEventEntry const *spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id);
+            if(!spellProcEvent)
+            {
+                // used to prevent spam in log about same non-handled spells
+                static std::set<uint32> nonHandledSpellProcSet;
+
+                if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end())
+                {
+                    sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's"));
+                    nonHandledSpellProcSet.insert(spellProto->Id);
+                }
+
+                // spell.dbc use totally different flags, that only can create problems if used.
+                continue;
+            }
+
+            // Check spellProcEvent data requirements
+            if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag))
+                continue;
+
+            // Check if current equipment allows aura to proc
+            if(!isVictim && GetTypeId() == TYPEID_PLAYER )
+            {
+                if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON)
+                {
+                    Item *item = ((Player*)this)->GetWeaponForAttack(attType,true);
+
+                    if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
+                        continue;
+                }
+                else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR)
+                {
+                    // Check if player is wearing shield
+                    Item *item = ((Player*)this)->GetShield(true);
+                    if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
+                        continue;
+                }
+            }
+
+            float chance = (float)spellProto->procChance;
+
+            if(Player* modOwner = GetSpellModOwner())
+                modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance);
+
+            if(!isVictim && spellProcEvent->ppmRate != 0)
+            {
+                uint32 WeaponSpeed = GetAttackTime(attType);
+                chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate);
+            }
+
+            if(roll_chance_f(chance))
+            {
+                uint32 cooldown = spellProcEvent->cooldown;
+
+                uint32 i_spell_eff = (*i)->GetEffIndex();
+
+                int32 i_spell_param;
+                switch(*aur)
+                {
+                    case SPELL_AURA_PROC_TRIGGER_SPELL:
+                        i_spell_param = procFlag;
+                        break;
+                    case SPELL_AURA_DUMMY:
+                    case SPELL_AURA_PRAYER_OF_MENDING:
+                    case SPELL_AURA_MOD_HASTE:
+                        i_spell_param = i_spell_eff;
+                        break;
+                    case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS:
+                        i_spell_param = (*i)->GetModifier()->m_miscvalue;
+                        break;
+                    default:
+                        i_spell_param = (*i)->GetModifier()->m_amount;
+                        break;
+                }
+
+                procTriggered.push_back( ProcTriggeredData(spellProto,i_spell_param,*i, cooldown) );
+            }
         }
 
@@ -10017,31 +10098,21 @@
             }
 
-            /// this is aura triggering code call
-            Aura* triggeredByAura = i->triggeredByAura;
-
-            /// save charges existence before processing to prevent crash at access to deleted triggered aura after
-            /// used in speedup code check before check aura existance.
-            bool triggeredByAuraWithCharges =  triggeredByAura->m_procCharges > 0;
-
-            /// success in event proccesing
-            /// used in speedup code check before check aura existance.
+            // save charges existence before processing to prevent crash at access to deleted triggered aura after
+            bool triggeredByAuraWithCharges =  i->triggeredByAura->m_procCharges > 0;
+
             bool casted = false;
-
-            /// process triggered code
             switch(*aur)
             {
                 case SPELL_AURA_PROC_TRIGGER_SPELL:
                 {
-                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s proc aura of spell %u)",
-                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-                    casted = HandleProcTriggerSpell(pTarget, damage, triggeredByAura, procSpell, procFlag, attType, i->cooldown);
+                    sLog.outDebug("ProcDamageAndSpell: casting spell %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+                    casted = HandleProcTriggerSpell(pTarget, damage, i->triggeredByAura, procSpell,i->spellParam,attType,i->cooldown);
                     break;
                 }
                 case SPELL_AURA_PROC_TRIGGER_DAMAGE:
                 {
-                    uint32 triggered_damage = triggeredByAura->GetModifier()->m_amount;
-                    sLog.outDebug("ProcDamageAndSpell: doing %u damage (triggered by %s aura of spell %u)",
-                        triggered_damage, (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-                    SpellNonMeleeDamageLog(pTarget, triggeredByAura->GetId(), triggered_damage, true, true);
+                    sLog.outDebug("ProcDamageAndSpell: doing %u damage from spell id %u (triggered by %s aura of spell %u)", i->spellParam, i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+                    uint32 damage = i->spellParam;
+                    SpellNonMeleeDamageLog(pTarget, i->spellInfo->Id, damage, true, true);
                     casted = true;
                     break;
@@ -10049,23 +10120,69 @@
                 case SPELL_AURA_DUMMY:
                 {
-                    uint32 effect = triggeredByAura->GetEffIndex();
-                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s dummy aura of spell %u)",
-                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-                    casted = HandleDummyAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown);
+                    sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+                    casted = HandleDummyAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown);
                     break;
                 }
                 case SPELL_AURA_PRAYER_OF_MENDING:
                 {
-                    sLog.outDebug("ProcDamageAndSpell: casting mending (triggered by %s dummy aura of spell %u)",
-                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-
-                    casted = HandleMeandingAuraProc(triggeredByAura);
+                    sLog.outDebug("ProcDamageAndSpell(mending): casting spell id %u (triggered by %s dummy aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+
+                    // aura can be deleted at casts
+                    int32 heal = i->triggeredByAura->GetModifier()->m_amount;
+                    uint64 caster_guid = i->triggeredByAura->GetCasterGUID();
+
+                    // jumps
+                    int32 jumps = i->triggeredByAura->m_procCharges-1;
+
+                    // current aura expire
+                    i->triggeredByAura->m_procCharges = 1;  // will removed at next charges decrease
+
+                    // next target selection
+                    if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid))
+                    {
+                        Aura* aura = i->triggeredByAura;
+
+                        SpellEntry const* spellProto = aura->GetSpellProto();
+                        uint32 effIdx = aura->GetEffIndex();
+
+                        float radius;
+                        if (spellProto->EffectRadiusIndex[effIdx])
+                            radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx]));
+                        else
+                            radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex));
+
+                        if(Player* caster = ((Player*)aura->GetCaster()))
+                        {
+                            caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL);
+
+                            if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius))
+                            {
+                                // aura will applied from caster, but spell casted from current aura holder
+                                SpellModifier *mod = new SpellModifier;
+                                mod->op = SPELLMOD_CHARGES;
+                                mod->value = jumps-5;               // negative
+                                mod->type = SPELLMOD_FLAT;
+                                mod->spellId = spellProto->Id;
+                                mod->effectId = effIdx;
+                                mod->lastAffected = NULL;
+                                mod->mask = spellProto->SpellFamilyFlags;
+                                mod->charges = 0;
+
+                                caster->AddSpellMod(mod, true);
+                                CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,aura,caster->GetGUID());
+                                caster->AddSpellMod(mod, false);
+                            }
+                        }
+                    }
+
+                    // heal
+                    CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid);
+                    casted = true;
                     break;
                 }
                 case SPELL_AURA_MOD_HASTE:
                 {
-                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s haste aura of spell %u)",
-                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-                    casted = HandleHasteAuraProc(pTarget, damage, triggeredByAura, procSpell, procFlag,i->cooldown);
+                    sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s haste aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+                    casted = HandleHasteAuraProc(pTarget, i->spellInfo, i->spellParam, damage, i->triggeredByAura, procSpell, procFlag,i->cooldown);
                     break;
                 }
@@ -10074,12 +10191,11 @@
                     // nothing do, just charges counter
                     // but count only in case appropriate school damage
-                    casted = triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask;
+                    casted = i->triggeredByAura->GetModifier()->m_miscvalue & damageSchoolMask;
                     break;
                 }
                 case SPELL_AURA_OVERRIDE_CLASS_SCRIPTS:
                 {
-                    sLog.outDebug("ProcDamageAndSpell: casting spell (triggered by %s class script aura of spell %u)",
-                        (isVictim?"a victim's":"an attacker's"),triggeredByAura->GetId());
-                    casted = HandleOverrideClassScriptAuraProc(pTarget, triggeredByAura, procSpell,i->cooldown);
+                    sLog.outDebug("ProcDamageAndSpell: casting spell id %u (triggered by %s aura of spell %u)", i->spellInfo->Id,(isVictim?"a victim's":"an attacker's"),i->triggeredByAura->GetId());
+                    casted = HandleOverrideClassScriptAuraProc(pTarget, i->spellParam, damage, i->triggeredByAura, procSpell,i->cooldown);
                     break;
                 }
@@ -10092,18 +10208,18 @@
             }
 
-            /// Update charge (aura can be removed by triggers)
+            // Update charge (aura can be removed by triggers)
             if(casted && triggeredByAuraWithCharges)
             {
-                /// need re-found aura (can be dropped by triggers)
+                // need found aura (can be dropped by triggers)
                 AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair);
                 AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair);
                 for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr)
                 {
-                    if(itr->second == triggeredByAura)      // pointer still valid
+                    if(itr->second == i->triggeredByAura)
                     {
-                        if(triggeredByAura->m_procCharges > 0)
-                            triggeredByAura->m_procCharges -= 1;
-
-                        triggeredByAura->UpdateAuraCharges();
+                        if(i->triggeredByAura->m_procCharges > 0)
+                            i->triggeredByAura->m_procCharges -= 1;
+
+                        i->triggeredByAura->UpdateAuraCharges();
                         break;
                     }
@@ -10112,5 +10228,5 @@
         }
 
-        /// Safely remove auras with zero charges
+        // Safely remove auras with zero charges
         for(AuraList::const_iterator i = auras.begin(), next; i != auras.end(); i = next)
         {
@@ -10225,5 +10341,5 @@
     // send explicit stop packet
     // rely on vmaps here because for example stormwind is in air
-    //float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);
+    float z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true);
     //if (fabs(GetPositionZ() - z) < 2.0f)
     //    Relocate(GetPositionX(), GetPositionY(), z);
@@ -10435,5 +10551,5 @@
 }
 
-Unit* Unit::SelectNearbyTarget(float dist) const
+Unit* Unit::SelectNearbyTarget() const
 {
     CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY()));
@@ -10445,5 +10561,5 @@
 
     {
-        Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist);
+        Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE);
         Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(targets, u_check);
 
@@ -10709,7 +10825,7 @@
     }
 
-    pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID());
-    pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID());
-    pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction());
+    pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID());
+    pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID());
+    pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction());
     pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
 
@@ -10729,131 +10845,2 @@
     return pet;
 }
-
-bool Unit::IsTriggeredAtSpellProcEvent(SpellEntry const* spellProto, SpellEntry const* procSpell, uint32 procFlag, WeaponAttackType attType, bool isVictim, uint32& cooldown )
-{
-    SpellProcEventEntry const * spellProcEvent = spellmgr.GetSpellProcEvent(spellProto->Id);
-
-    if(!spellProcEvent)
-    {
-        // used to prevent spam in log about same non-handled spells
-        static std::set<uint32> nonHandledSpellProcSet;
-
-        if(spellProto->procFlags != 0 && nonHandledSpellProcSet.find(spellProto->Id)==nonHandledSpellProcSet.end())
-        {
-            sLog.outError("ProcDamageAndSpell: spell %u (%s aura source) not have record in `spell_proc_event`)",spellProto->Id,(isVictim?"a victim's":"an attacker's"));
-            nonHandledSpellProcSet.insert(spellProto->Id);
-        }
-
-        // spell.dbc use totally different flags, that only can create problems if used.
-        return false;
-    }
-
-    // Check spellProcEvent data requirements
-    if(!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, procSpell,procFlag))
-        return false;
-
-    // Check if current equipment allows aura to proc
-    if(!isVictim && GetTypeId() == TYPEID_PLAYER )
-    {
-        if(spellProto->EquippedItemClass == ITEM_CLASS_WEAPON)
-        {
-            Item *item = ((Player*)this)->GetWeaponForAttack(attType,true);
-
-            if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
-                return false;
-        }
-        else if(spellProto->EquippedItemClass == ITEM_CLASS_ARMOR)
-        {
-            // Check if player is wearing shield
-            Item *item = ((Player*)this)->GetShield(true);
-            if(!item || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask))
-                return false;
-        }
-    }
-
-    float chance = (float)spellProto->procChance;
-
-    if(Player* modOwner = GetSpellModOwner())
-        modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance);
-
-    if(!isVictim && spellProcEvent && spellProcEvent->ppmRate != 0)
-    {
-        uint32 WeaponSpeed = GetAttackTime(attType);
-        chance = GetPPMProcChance(WeaponSpeed, spellProcEvent->ppmRate);
-    }
-
-    cooldown = spellProcEvent ? spellProcEvent->cooldown : 0;
-    return roll_chance_f(chance);
-}
-
-bool Unit::HandleMeandingAuraProc( Aura* triggeredByAura )
-{
-    // aura can be deleted at casts
-    SpellEntry const* spellProto = triggeredByAura->GetSpellProto();
-    uint32 effIdx = triggeredByAura->GetEffIndex();
-    int32 heal = triggeredByAura->GetModifier()->m_amount;
-    uint64 caster_guid = triggeredByAura->GetCasterGUID();
-
-    // jumps
-    int32 jumps = triggeredByAura->m_procCharges-1;
-
-    // current aura expire
-    triggeredByAura->m_procCharges = 1;             // will removed at next charges decrease
-
-    // next target selection
-    if(jumps > 0 && GetTypeId()==TYPEID_PLAYER && IS_PLAYER_GUID(caster_guid))
-    {
-        float radius;
-        if (spellProto->EffectRadiusIndex[effIdx])
-            radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellProto->EffectRadiusIndex[effIdx]));
-        else
-            radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spellProto->rangeIndex));
-
-        if(Player* caster = ((Player*)triggeredByAura->GetCaster()))
-        {
-            caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL);
-
-            if(Player* target = ((Player*)this)->GetNextRandomRaidMember(radius))
-            {
-                // aura will applied from caster, but spell casted from current aura holder
-                SpellModifier *mod = new SpellModifier;
-                mod->op = SPELLMOD_CHARGES;
-                mod->value = jumps-5;               // negative
-                mod->type = SPELLMOD_FLAT;
-                mod->spellId = spellProto->Id;
-                mod->effectId = effIdx;
-                mod->lastAffected = NULL;
-                mod->mask = spellProto->SpellFamilyFlags;
-                mod->charges = 0;
-
-                caster->AddSpellMod(mod, true);
-                CastCustomSpell(target,spellProto->Id,&heal,NULL,NULL,true,NULL,triggeredByAura,caster->GetGUID());
-                caster->AddSpellMod(mod, false);
-            }
-        }
-    }
-
-    // heal
-    CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid);
-    return true;
-}
-
-void Unit::RemoveAurasAtChanneledTarget(SpellEntry const* spellInfo)
-{
-    uint64 target_guid = GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT);
-
-    if(!IS_UNIT_GUID(target_guid))
-        return;
-
-    Unit* target = ObjectAccessor::GetUnit(*this, target_guid);
-    if(!target)
-        return;
-
-    for (AuraMap::iterator iter = target->GetAuras().begin(); iter != target->GetAuras().end(); )
-    {
-        if (iter->second->GetId() == spellInfo->Id && iter->second->GetCasterGUID()==GetGUID())
-            target->RemoveAura(iter);
-        else
-            ++iter;
-    }
-}
Index: /trunk/src/game/ObjectMgr.h
===================================================================
--- /trunk/src/game/ObjectMgr.h (revision 263)
+++ /trunk/src/game/ObjectMgr.h (revision 272)
@@ -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;
-    int32  dataint;
+    std::string datatext;
     float x;
     float y;
@@ -128,11 +128,4 @@
 
 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
@@ -215,6 +208,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
 };
 
@@ -258,5 +251,5 @@
 // NPC gossip text id
 typedef UNORDERED_MAP<uint32, uint32> CacheNpcTextIdMap;
-typedef std::list<GossipOption> CacheNpcOptionList;
+
 
 typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemMap;
@@ -307,8 +300,7 @@
         typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
 
-
         typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
 
-        typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
+        typedef UNORDERED_MAP<uint32, std::string> AreaTriggerScriptMap;
 
         typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@@ -317,6 +309,4 @@
 
         typedef UNORDERED_MAP<uint32, PetCreateSpellEntry> PetCreateSpellMap;
-
-        typedef std::vector<std::string> ScriptNameMap;
 
         Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
@@ -487,5 +477,5 @@
         AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
 
-        uint32 GetAreaTriggerScriptId(uint32 trigger_id);
+        const char* GetAreaTriggerScriptName(uint32 id);
 
         ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
@@ -533,6 +523,5 @@
 
         bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
-        bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
-	void LoadDbScriptStrings();
+        bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",1,std::numeric_limits<int32>::max()); }
         void LoadPetCreateSpells();
         void LoadCreatureLocales();
@@ -604,6 +593,4 @@
         uint32 GenerateItemTextID();
         uint32 GeneratePetNumber();
-        uint32 GenerateArenaTeamId();
-        uint32 GenerateGuildId();
         
         void LoadPlayerInfoInCache();
@@ -682,4 +669,5 @@
             return &itr->second;
         }
+        
         NpcOptionLocale const* GetNpcOptionLocale(uint32 entry) const
         {
@@ -706,5 +694,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)); }
 
@@ -745,5 +733,5 @@
         LocaleConstant GetLocaleForIndex(int i);
         // guild bank tabs
-        uint32 GetGuildBankTabPrice(uint8 Index) const { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }
+        const uint32 GetGuildBankTabPrice(uint8 Index) { return Index < GUILD_BANK_MAX_TABS ? mGuildBankTabPrice[Index] : 0; }
 
         uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
@@ -766,5 +754,5 @@
         bool AddGameTele(GameTele& data);
         bool DeleteGameTele(std::string name);
-
+        
         CacheNpcOptionList const& GetNpcOptions() const { return m_mCacheNpcOptionList; }
 
@@ -774,5 +762,5 @@
             if(iter == m_mCacheNpcTextIdMap.end())
                 return 0;
-
+            
             return iter->second;
         }
@@ -795,23 +783,13 @@
             return &iter->second;
         }
-        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);
+        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;
+
     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;
@@ -822,5 +800,7 @@
         uint32 m_hiCorpseGuid;
 
-        QuestMap            mQuestTemplates;
+        uint32 m_hiPetNumber;
+
+        QuestMap mQuestTemplates;
 
         typedef UNORDERED_MAP<uint32, GossipText*> GossipTextMap;
@@ -869,6 +849,4 @@
         GameTeleMap         m_GameTeleMap;
 
-        ScriptNameMap       m_scriptNames;
-
         typedef             std::vector<LocaleConstant> LocalForIndex;
         LocalForIndex        m_LocalForIndex;
@@ -878,5 +856,4 @@
     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);
@@ -931,8 +908,6 @@
 
 // scripting access functions
-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();
+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);
 
 #endif
Index: /trunk/src/game/Level2.cpp
===================================================================
--- /trunk/src/game/Level2.cpp (revision 263)
+++ /trunk/src/game/Level2.cpp (revision 272)
@@ -2362,6 +2362,6 @@
     // Check
     // Remember: "show" must also be the name of a column!
-    if( (show != "emote") && (show != "spell") && (show != "textid1") && (show != "textid2")
-        && (show != "textid3") && (show != "textid4") && (show != "textid5")
+    if( (show != "emote") && (show != "spell") && (show != "text1") && (show != "text2")
+        && (show != "text3") && (show != "text4") && (show != "text5")
         && (show != "waittime") && (show != "del") && (show != "move") && (show != "add")
         && (show != "model1") && (show != "model2") && (show != "orientation"))
@@ -2703,11 +2703,4 @@
         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;
     }
@@ -2850,5 +2843,5 @@
 
         QueryResult *result =
-            WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, model1, model2 FROM creature_movement WHERE wpguid = %u",
+            WorldDatabase.PQuery( "SELECT id, point, waittime, emote, spell, text1, text2, text3, text4, text5, model1, model2 FROM creature_movement WHERE wpguid = %u",
             target->GetGUIDLow() );
         if(!result)
@@ -2862,5 +2855,5 @@
             PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID());
 
-            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 )",
+            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 )",
                 target->GetPositionX(), maxDIFF, target->GetPositionY(), maxDIFF, target->GetPositionZ(), maxDIFF);
             if(!result)
@@ -2879,7 +2872,9 @@
             uint32 emote            = fields[3].GetUInt32();
             uint32 spell            = fields[4].GetUInt32();
-            uint32 textid[MAX_WAYPOINT_TEXT];
-            for(int i = 0;  i < MAX_WAYPOINT_TEXT; ++i)
-                textid[i]           = fields[5+i].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 model1           = fields[10].GetUInt32();
             uint32 model2           = fields[11].GetUInt32();
@@ -2894,6 +2889,9 @@
             PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote);
             PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell);
-            for(int i = 0;  i < MAX_WAYPOINT_TEXT; ++i)
-                PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetTrinityString(textid[i]) : ""));
+            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);
 
         }while( result->NextRow() );
@@ -3216,6 +3214,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, textid1, textid2, textid3, textid4, textid5, 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, text1, text2, text3, text4, text5, id FROM creature_movement WHERE id = '%u' ORDER BY point", lowguid );
 
     if (!result)
@@ -3234,5 +3232,5 @@
 
         outfile << "INSERT INTO creature_movement ";
-        outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5 ) VALUES ";
+        outfile << "( id, point, position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, text1, text2, text3, text4, text5 ) VALUES ";
 
         outfile << "( ";
@@ -3259,13 +3257,63 @@
         outfile << fields[9].GetUInt32();                   // spell
         outfile << ", ";
-        outfile << fields[10].GetUInt32();                  // textid1
+        const char *tmpChar = fields[10].GetString();
+        if( !tmpChar )
+        {
+            outfile << "NULL";                              // text1
+        }
+        else
+        {
+            outfile << "'";
+            outfile << tmpChar;                             // text1
+            outfile << "'";
+        }
         outfile << ", ";
-        outfile << fields[11].GetUInt32();                  // textid2
+        tmpChar = fields[11].GetString();
+        if( !tmpChar )
+        {
+            outfile << "NULL";                              // text2
+        }
+        else
+        {
+            outfile << "'";
+            outfile << tmpChar;                             // text2
+            outfile << "'";
+        }
         outfile << ", ";
-        outfile << fields[12].GetUInt32();                  // textid3
+        tmpChar = fields[12].GetString();
+        if( !tmpChar )
+        {
+            outfile << "NULL";                              // text3
+        }
+        else
+        {
+            outfile << "'";
+            outfile << tmpChar;                             // text3
+            outfile << "'";
+        }
         outfile << ", ";
-        outfile << fields[13].GetUInt32();                  // textid4
+        tmpChar = fields[13].GetString();
+        if( !tmpChar )
+        {
+            outfile << "NULL";                              // text4
+        }
+        else
+        {
+            outfile << "'";
+            outfile << tmpChar;                             // text4
+            outfile << "'";
+        }
         outfile << ", ";
-        outfile << fields[14].GetUInt32();                  // textid5
+        tmpChar = fields[14].GetString();
+        if( !tmpChar )
+        {
+            outfile << "NULL";                              // text5
+        }
+        else
+        {
+            outfile << "'";
+            outfile << tmpChar;                             // text5
+            outfile << "'";
+        }
         outfile << ");\n ";
 
Index: /trunk/src/game/ItemPrototype.h
===================================================================
--- /trunk/src/game/ItemPrototype.h (revision 260)
+++ /trunk/src/game/ItemPrototype.h (revision 272)
@@ -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
  */
 
@@ -79,5 +79,5 @@
     NO_BIND                                     = 0,
     BIND_WHEN_PICKED_UP                         = 1,
-    BIND_WHEN_EQUIPED                           = 2,
+    BIND_WHEN_EQUIPPED                           = 2,
     BIND_WHEN_USE                               = 3,
     BIND_QUEST_ITEM                             = 4,
@@ -100,7 +100,5 @@
     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_BOA                            = 0x08000000, // bind on account
-    ITEM_FLAGS_MILLABLE                       = 0x20000000
+    ITEM_FLAGS_SPECIALUSE                     = 0x00800000  // last used flag in 2.3.0
 };
 
@@ -109,7 +107,7 @@
     BAG_FAMILY_MASK_ARROWS                    = 0x00000001,
     BAG_FAMILY_MASK_BULLETS                   = 0x00000002,
-    BAG_FAMILY_MASK_SOUL_SHARDS               = 0x00000004,
+    BAG_FAMILY_MASK_SHARDS                    = 0x00000004,
     BAG_FAMILY_MASK_LEATHERWORKING_SUPP       = 0x00000008,
-    BAG_FAMILY_MASK_INSCRIPTION_SUPP          = 0x00000010,
+    BAG_FAMILY_MASK_UNUSED                    = 0x00000010, // not used currently
     BAG_FAMILY_MASK_HERBS                     = 0x00000020,
     BAG_FAMILY_MASK_ENCHANTING_SUPP           = 0x00000040,
@@ -119,8 +117,10 @@
     BAG_FAMILY_MASK_MINING_SUPP               = 0x00000400,
     BAG_FAMILY_MASK_SOULBOUND_EQUIPMENT       = 0x00000800,
-    BAG_FAMILY_MASK_VANITY_PETS               = 0x00001000,
-    BAG_FAMILY_MASK_CURRENCY_TOKENS           = 0x00002000,
-    BAG_FAMILY_MASK_QUEST_ITEMS               = 0x00004000
-};
+    BAG_FAMILY_MASK_VANITY_PETS               = 0x00001000
+};
+
+/* TODO: Not entirely positive on need for this??
+enum SOCKET_CONTENT ();
+*/
 
 enum SocketColor
@@ -276,5 +276,5 @@
 };
 
-#define MAX_ITEM_SUBCLASS_ARMOR                   10
+#define MAX_ITEM_SUBCLASS_ARMOR                  10
 
 enum ItemSubclassReagent
@@ -390,20 +390,4 @@
 
 #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] =
@@ -541,5 +525,5 @@
     uint32 RequiredDisenchantSkill;
     float  ArmorDamageModifier;
-    uint32 ScriptId;
+    char* ScriptName;
     uint32 DisenchantID;
     uint32 FoodType;
Index: /trunk/src/game/Player.cpp
===================================================================
--- /trunk/src/game/Player.cpp (revision 257)
+++ /trunk/src/game/Player.cpp (revision 272)
@@ -800,5 +800,5 @@
 }
 
-void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage)
+void Player::EnvironmentalDamage(uint64 guid, EnvironmentalDamageType type, uint32 damage)
 {
     WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21));
@@ -1642,5 +1642,5 @@
     {
         // far teleport to another map
-        Map* oldmap = IsInWorld() ? GetMap() : NULL;
+        Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL;
         // check if we can enter before stopping combat / removing pet / totems / interrupting spells
 
@@ -3751,5 +3751,5 @@
 }
 
-void Player::ResurrectPlayer(float restore_percent, bool applySickness)
+void Player::ResurrectPlayer(float restore_percent, bool updateToWorld, bool applySickness)
 {
     WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4);          // remove spirit healer position
@@ -4282,5 +4282,5 @@
 }
 
-void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply)
+void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, float amount, bool apply, bool affectStats)
 {
     if(modGroup >= BASEMOD_END || modType >= MOD_END)
@@ -5244,5 +5244,5 @@
     }
 
-    Map *m = GetMap();
+    Map *m = MapManager::Instance().GetMap(GetMapId(), this);
 
     const float old_x = GetPositionX();
@@ -5262,5 +5262,5 @@
 
         // reread after Map::Relocation
-        m = GetMap();
+        m = MapManager::Instance().GetMap(GetMapId(), this);
         x = GetPositionX();
         y = GetPositionY();
@@ -6177,7 +6177,5 @@
         return 0;
 
-    uint32 id = (*result)[0].GetUInt32();
-    delete result;
-    return id;
+    return (*result)[0].GetUInt32();
 }
 
@@ -6710,5 +6708,5 @@
     }
 
-    if(!IsUseEquipedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))
+    if(!IsUseEquippedWeapon(slot==EQUIPMENT_SLOT_MAINHAND))
         return;
 
@@ -8488,5 +8486,5 @@
         return item;
 
-    if( item->IsBroken() || !IsUseEquipedWeapon(attackType==BASE_ATTACK) )
+    if( item->IsBroken() || !IsUseEquippedWeapon(attackType==BASE_ATTACK) )
         return NULL;
 
@@ -8642,5 +8640,4 @@
     return false;
 }
-
 
 bool Player::HasItemCount( uint32 item, uint32 count, bool inBankAlso ) const
@@ -10159,5 +10156,5 @@
         if( pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP ||
             pItem->GetProto()->Bonding == BIND_QUEST_ITEM ||
-            pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) )
+            pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) )
             pItem->SetBinding( true );
 
@@ -10205,5 +10202,5 @@
         if( pItem2->GetProto()->Bonding == BIND_WHEN_PICKED_UP ||
             pItem2->GetProto()->Bonding == BIND_QUEST_ITEM ||
-            pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos) )
+            pItem2->GetProto()->Bonding == BIND_WHEN_EQUIPPED && IsBagPos(pos) )
             pItem2->SetBinding( true );
 
@@ -10407,5 +10404,5 @@
 
     // check also  BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory)
-    if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM )
+    if( pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM )
         pItem->SetBinding( true );
 
@@ -10551,4 +10548,6 @@
         if(pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
             CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow());
+
+        ItemPrototype const *pProto = pItem->GetProto();
 
         RemoveEnchantmentDurations(pItem);
@@ -14209,5 +14208,5 @@
         SetUInt32Value(i, 0);
 
-    //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
+    //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow());
 
     if(result)
@@ -14219,9 +14218,8 @@
             uint32 spellid = fields[1].GetUInt32();
             uint32 effindex = fields[2].GetUInt32();
-            uint32 stackcount = fields[3].GetUInt32();
-            int32 damage     = (int32)fields[4].GetUInt32();
-            int32 maxduration = (int32)fields[5].GetUInt32();
-            int32 remaintime = (int32)fields[6].GetUInt32();
-            int32 remaincharges = (int32)fields[7].GetUInt32();
+            int32 damage     = (int32)fields[3].GetUInt32();
+            int32 maxduration = (int32)fields[4].GetUInt32();
+            int32 remaintime = (int32)fields[5].GetUInt32();
+            int32 remaincharges = (int32)fields[6].GetUInt32();
 
             SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
@@ -14260,13 +14258,9 @@
                 continue;
 
-            for(uint32 i=0; i<stackcount; i++)
-            {
-                Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
-                if(!damage)
-                    damage = aura->GetModifier()->m_amount;
-                aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
-                AddAura(aura);
-                sLog.outString("Added aura spellid %u, effect %u", spellproto->Id, effindex);
-            }
+            Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
+            if(!damage)
+                damage = aura->GetModifier()->m_amount;
+            aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
+            AddAura(aura);
         }
         while( result->NextRow() );
@@ -15327,52 +15321,29 @@
 
     AuraMap const& auras = GetAuras();
-
-    if (auras.empty())
-        return;
-
-    spellEffectPair lastEffectPair = auras.begin()->first;
-    uint32 stackCounter = 1;
-
-    for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
-    {
-        if(itr == auras.end() || lastEffectPair != itr->first)
-        {
-            AuraMap::const_iterator itr2 = itr;
-            // save previous spellEffectPair to db
-            itr2--;
-            SpellEntry const *spellInfo = itr2->second->GetSpellProto();
-
-            //skip all auras from spells that are passive or need a shapeshift
-            if (!(itr2->second->IsPassive() || itr2->second->IsRemovedOnShapeLost()))
-            {
-                //do not save single target auras (unless they were cast by the player)
-                if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
-                {
-                    uint8 i;
-                    // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras
-                    for (i = 0; i < 3; i++)
-                        if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT ||
-                        spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH)
-                            break;
-
-                    if (i == 3)
-                    {
-                        CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
-                            "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%u', '%d', '%d', '%d', '%d')",
-                            GetGUIDLow(), itr2->second->GetCasterGUID(), (uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges));
-                    }
-                }
-            }
-
-            if(itr == auras.end())
+    for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
+    {
+        SpellEntry const *spellInfo = itr->second->GetSpellProto();
+
+        //skip all auras from spells that are passive or need a shapeshift
+        if (itr->second->IsPassive() || itr->second->IsRemovedOnShapeLost())
+            continue;
+
+        //do not save single target auras (unless they were cast by the player)
+        if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
+            continue;
+
+        uint8 i;
+        // or apply at cast SPELL_AURA_MOD_SHAPESHIFT or SPELL_AURA_MOD_STEALTH auras
+        for (i = 0; i < 3; i++)
+            if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT ||
+            spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH)
                 break;
-        }
-
-        if (lastEffectPair == itr->first)
-            stackCounter++;
-        else
-        {
-            lastEffectPair = itr->first;
-            stackCounter = 1;
+
+        if (i == 3)
+        {
+            CharacterDatabase.PExecute("DELETE FROM character_aura WHERE guid = '%u' and spell = '%u' and  effect_index= '%u'",GetGUIDLow(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex());
+            CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
+                "VALUES ('%u', '" I64FMTD "' ,'%u', '%u', '%d', '%d', '%d', '%d')",
+                GetGUIDLow(), itr->second->GetCasterGUID(), (uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(), (*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges));
         }
     }
@@ -17940,5 +17911,5 @@
             continue;
 
-        if (sSpellStore.LookupEntry(pAbility->spellId))
+        if (SpellEntry const* spellentry = sSpellStore.LookupEntry(pAbility->spellId))
         {
             // Ok need learn spell
@@ -18353,4 +18324,5 @@
         Player* not_gray_member_with_max_level = NULL;
 
+        // gets the max member level of the group, and the max member level that still gets XP
         pGroup->GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level);
 
@@ -18361,5 +18333,5 @@
             xp = (PvP || !not_gray_member_with_max_level) ? 0 : Trinity::XP::Gain(not_gray_member_with_max_level, pVictim);
 
-            /// skip in check PvP case (for speed, not used)
+            // skip in check PvP case (for speed, not used)
             bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup();
             bool is_dungeon = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsDungeon();
@@ -18688,16 +18660,4 @@
     UpdateBlockPercentage();
 }
-
-bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
-{
-    for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
-        if(itr->pos == pos)
-            return true;
-    return false;
-}
-
-//***********************************
-//-------------TRINITY---------------
-//***********************************
 
 void Player::HandleFallDamage(MovementInfo& movementInfo)
@@ -18937,6 +18897,6 @@
                 target->AddThreat(this, 1000000.0f);
         }
-        // Delete the assigned possessed AI
-        ((Creature*)target)->DeletePossessedAI();
+        // Disable the assigned possessed AI
+        ((Creature*)target)->DisablePossessedAI();
     }
 }
@@ -19002,4 +18962,13 @@
 }
 
+bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
+{
+    for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
+        if(itr->pos == this->pos)
+            return true;
+
+    return false;
+}
+
 bool Player::isTotalImmunity()
 {
Index: /trunk/src/game/GridNotifiersImpl.h
===================================================================
--- /trunk/src/game/GridNotifiersImpl.h (revision 265)
+++ /trunk/src/game/GridNotifiersImpl.h (revision 272)
@@ -73,5 +73,5 @@
 
     // Creature AI reaction
-    if(c->isAggressive() && !c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+    if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
         if( c->AI() && c->IsWithinSightDist(pl) /*c->AI()->IsVisible(pl)*/ && !c->IsInEvadeMode() )
@@ -82,5 +82,5 @@
 inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2)
 {
-    if(c1->isAggressive() && !c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+    if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
         if( c1->AI() && c1->IsWithinSightDist(c2) /*c1->AI()->IsVisible(c2)*/ && !c1->IsInEvadeMode() )
@@ -88,5 +88,5 @@
     }
 
-    if(c2->isAggressive() && !c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
+    if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING))
     {
         if( c2->AI() && c1->IsWithinSightDist(c2) /*c2->AI()->IsVisible(c1)*/ && !c2->IsInEvadeMode() )
Index: /trunk/src/game/NPCHandler.cpp
===================================================================
--- /trunk/src/game/NPCHandler.cpp (revision 257)
+++ /trunk/src/game/NPCHandler.cpp (revision 272)
@@ -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
  */
 
@@ -223,5 +223,5 @@
     TrainerSpellData const* trainer_spells = unit->GetTrainerSpells();
     if(!trainer_spells)
-        return;
+        return; 
 
     // not found, cheat?
@@ -340,11 +340,13 @@
     if(!code.empty())
     {
+
         if (!Script->GossipSelectWithCode(_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction( option ), code.c_str()))
             unit->OnGossipSelect (_player, option);
     }
     else
+
     {
         if (!Script->GossipSelect (_player, unit, _player->PlayerTalkClass->GossipOptionSender (option), _player->PlayerTalkClass->GossipOptionAction (option)))
-           unit->OnGossipSelect (_player, option);
+            unit->OnGossipSelect (_player, option);
     }
 }
@@ -376,5 +378,5 @@
 void WorldSession::SendSpiritResurrect()
 {
-    _player->ResurrectPlayer(0.5f, true);
+    _player->ResurrectPlayer(0.5f,false, true);
 
     _player->DurabilityLossAll(0.25f,true);
Index: /trunk/src/game/Spell.cpp
===================================================================
--- /trunk/src/game/Spell.cpp (revision 248)
+++ /trunk/src/game/Spell.cpp (revision 272)
@@ -997,7 +997,4 @@
 
             unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL);
-            //TODO: find a better way to judge CC auras
-            if(m_spellInfo->Attributes & SPELL_ATTR_BREAKABLE_BY_DAMAGE)
-                unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC);
         }
         else
Index: /trunk/src/game/Pet.cpp
===================================================================
--- /trunk/src/game/Pet.cpp (revision 265)
+++ /trunk/src/game/Pet.cpp (revision 272)
@@ -287,9 +287,4 @@
             ++iter;
             m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str());
-
-            // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST
-            // so overwrite old state 
-            SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction);
-            if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET) m_charmInfo->GetActionBarEntry(index)->Type = ACT_CAST;
         }
 
@@ -1328,5 +1323,5 @@
         SetUInt32Value(i, 0);
 
-    QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
+    QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
 
     if(result)
@@ -1338,9 +1333,8 @@
             uint32 spellid = fields[1].GetUInt32();
             uint32 effindex = fields[2].GetUInt32();
-            uint32 stackcount= fields[3].GetUInt32();
-            int32 damage     = (int32)fields[4].GetUInt32();
-            int32 maxduration = (int32)fields[5].GetUInt32();
-            int32 remaintime = (int32)fields[6].GetUInt32();
-            int32 remaincharges = (int32)fields[7].GetUInt32();
+            int32 damage     = (int32)fields[3].GetUInt32();
+            int32 maxduration = (int32)fields[4].GetUInt32();
+            int32 remaintime = (int32)fields[5].GetUInt32();
+            int32 remaincharges = (int32)fields[6].GetUInt32();
 
             SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
@@ -1379,13 +1373,10 @@
                 continue;
 
-            for(uint32 i=0; i<stackcount; i++)
-            {
-                Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
-
-                if(!damage)
-                    damage = aura->GetModifier()->m_amount;
-                aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
-                AddAura(aura);
-            }
+            Aura* aura = CreateAura(spellproto, effindex, NULL, this, NULL);
+
+            if(!damage)
+                damage = aura->GetModifier()->m_amount;
+            aura->SetLoadedState(caster_guid,damage,maxduration,remaintime,remaincharges);
+            AddAura(aura);
         }
         while( result->NextRow() );
@@ -1400,50 +1391,28 @@
 
     AuraMap const& auras = GetAuras();
-    if (auras.empty())
-        return;
-
-    spellEffectPair lastEffectPair = auras.begin()->first;
-    uint32 stackCounter = 1;
-
-    for(AuraMap::const_iterator itr = auras.begin(); ; ++itr)
-    {
-        if(itr == auras.end() || lastEffectPair != itr->first)
-        {
-            AuraMap::const_iterator itr2 = itr;
-            // save previous spellEffectPair to db
-            itr2--;
-            SpellEntry const *spellInfo = itr2->second->GetSpellProto();
-            /// do not save single target auras (unless they were cast by the player)
-            if (!(itr2->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo)))
-            {
-                if(!itr2->second->IsPassive())
-                {
-                    // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras.
-                    uint8 i;
-                    for (i = 0; i < 3; i++)
-                        if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH ||
-                            spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER ||
-                            spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET )
-                            break;
-
-                    if (i == 3)
-                    {
-                        CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges) "
-                            "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d')",
-                            m_charmInfo->GetPetNumber(), itr2->second->GetCasterGUID(),(uint32)itr2->second->GetId(), (uint32)itr2->second->GetEffIndex(), stackCounter, itr2->second->GetModifier()->m_amount,int(itr2->second->GetAuraMaxDuration()),int(itr2->second->GetAuraDuration()),int(itr2->second->m_procCharges));
-                    }
-                }
-            }
-            if(itr == auras.end())
+    for(AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
+    {
+        // skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras.
+        SpellEntry const *spellInfo = itr->second->GetSpellProto();
+        uint8 i;
+        for (i = 0; i < 3; i++)
+            if (spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_STEALTH ||
+                spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_OWNER ||
+                spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_PET )
                 break;
-        }
-
-        if (lastEffectPair == itr->first)
-            stackCounter++;
-        else
-        {
-            lastEffectPair = itr->first;
-            stackCounter = 1;
-        }
+
+        if (i != 3)
+            continue;
+        
+        if(itr->second->IsPassive())
+            continue;
+
+        /// do not save single target auras (unless they were cast by the player)
+        if (itr->second->GetCasterGUID() != GetGUID() && IsSingleTargetSpell(spellInfo))
+            continue;
+
+        CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges) "
+            "VALUES ('%u', '" I64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d')",
+            m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(),(uint32)(*itr).second->GetId(), (uint32)(*itr).second->GetEffIndex(),(*itr).second->GetModifier()->m_amount,int((*itr).second->GetAuraMaxDuration()),int((*itr).second->GetAuraDuration()),int((*itr).second->m_procCharges));
     }
 }
@@ -1465,8 +1434,4 @@
         return false;
     }
-
-    // same spells don't have autocast option
-    if (spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET)
-        active = ACT_CAST;
 
     PetSpellMap::iterator itr = m_spells.find(spell_id);
@@ -1544,5 +1509,5 @@
         CastSpell(this, spell_id, true);
     else if(state == PETSPELL_NEW)
-        m_charmInfo->AddSpellToAB(oldspell_id, spell_id, (ActiveStates)active);
+        m_charmInfo->AddSpellToAB(oldspell_id, spell_id);
 
     if(newspell->active == ACT_ENABLED)
@@ -1694,8 +1659,8 @@
         return;
 
-    //if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid))
-    //    if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER
-    //        && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE)
-    //        return;    
+    if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid))
+        if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER
+            && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE)
+            return;    
 
     PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid);
Index: /trunk/src/game/WaypointManager.h
===================================================================
--- /trunk/src/game/WaypointManager.h (revision 263)
+++ /trunk/src/game/WaypointManager.h (revision 272)
@@ -26,10 +26,9 @@
 #include "Utilities/UnorderedMap.h"
 
-#define MAX_WAYPOINT_TEXT 5
 struct WaypointBehavior
 {
     uint32 emote;
     uint32 spell;
-    int32  textid[MAX_WAYPOINT_TEXT];
+    std::string text[5];
     uint32 model1;
     uint32 model2;
Index: /trunk/src/game/AuctionHouse.cpp
===================================================================
--- /trunk/src/game/AuctionHouse.cpp (revision 260)
+++ /trunk/src/game/AuctionHouse.cpp (revision 272)
@@ -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 << (uint32) auction->Id;
-    data << (uint32) pItem->GetEntry();
+    data << auction->Id;
+    data << pItem->GetUInt32Value(OBJECT_FIELD_ENTRY);
 
     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 equiped empty bag to auction)
+    // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
     if(!it)
     {
@@ -717,5 +717,5 @@
                                             if (il)
                                             {
-                                                if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
+                                                if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty())
                                                     name = il->Name[loc_idx];
                                             }
Index: /trunk/src/game/MapInstanced.cpp
===================================================================
--- /trunk/src/game/MapInstanced.cpp (revision 257)
+++ /trunk/src/game/MapInstanced.cpp (revision 272)
@@ -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,5 +27,5 @@
 #include "World.h"
 
-MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0)
+MapInstanced::MapInstanced(uint32 id, time_t expiry, uint32 aInstanceId) : Map(id, expiry, 0, 0)
 {
     // initialize instanced maps list
@@ -262,2 +262,3 @@
     m_InstancedMaps.erase(itr++);
 }
+
Index: /trunk/src/game/ObjectMgr.cpp
===================================================================
--- /trunk/src/game/ObjectMgr.cpp (revision 263)
+++ /trunk/src/game/ObjectMgr.cpp (revision 272)
@@ -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,5 +22,4 @@
 #include "Database/DatabaseEnv.h"
 #include "Database/SQLStorage.h"
-#include "Database/SQLStorageImpl.h"
 
 #include "Log.h"
@@ -118,10 +117,6 @@
     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);
@@ -421,5 +416,5 @@
 
         //prepare mail data... :
-        uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() );
+        uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() );
 
         // set owner to bidder (to prevent delete item with sender char deleting)
@@ -472,5 +467,5 @@
         sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
 
-        uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() );
+        uint32 itemTextId = this->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);
@@ -504,5 +499,5 @@
         sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
 
-        uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() );
+        uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() );
 
         uint32 profit = auction->bid + auction->deposit - auctionCut;
@@ -551,4 +546,5 @@
         // 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
@@ -568,6 +564,6 @@
 void ObjectMgr::LoadCreatureLocales()
 {
-    mCreatureLocaleMap.clear();                              // need for reload case
-
+    mCreatureLocaleMap.clear();
+    
     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");
 
@@ -628,5 +624,5 @@
     sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() );
 }
-   
+
 void ObjectMgr::LoadNpcOptionLocales()
 {
@@ -697,17 +693,7 @@
 }
 
-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()
 {
-    SQLCreatureLoader loader;
-    loader.Load(sCreatureStorage);
+    sCreatureStorage.Load();
 
     sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount );
@@ -1527,5 +1513,5 @@
         aItem->location = fields[11].GetUInt8();
         //check if sold item exists
-        if ( GetAItem( aItem->item_guidlow ) )
+        if ( this->GetAItem( aItem->item_guidlow ) )
         {
             GetAuctionsMap( aItem->location )->AddAuction(aItem);
@@ -1547,6 +1533,6 @@
 void ObjectMgr::LoadItemLocales()
 {
-    mItemLocaleMap.clear();                                 // need for reload case
-
+    mItemLocaleMap.clear();
+    
     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");
 
@@ -1609,17 +1595,7 @@
 }
 
-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()
 {
-    SQLItemLoader loader;
-    loader.Load(sItemStorage);
+    sItemStorage.Load ();
     sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount );
     sLog.outString();
@@ -2531,5 +2507,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)
@@ -3580,5 +3556,5 @@
 void ObjectMgr::LoadQuestLocales()
 {
-    mQuestLocaleMap.clear();                                // need for reload case
+    mQuestLocaleMap.clear();
 
     QueryResult *result = WorldDatabase.Query("SELECT entry,"
@@ -3774,5 +3750,5 @@
     scripts.clear();                                        // need for reload support
 
-    QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename );
+    QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,datatext, x, y, z, o FROM %s", tablename );
 
     uint32 count = 0;
@@ -3796,14 +3772,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.dataint   = fields[5].GetInt32();
-        tmp.x         = fields[6].GetFloat();
-        tmp.y         = fields[7].GetFloat();
-        tmp.z         = fields[8].GetFloat();
-        tmp.o         = fields[9].GetFloat();
+        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();
 
         // generic command args check
@@ -3817,16 +3793,4 @@
                     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;
             }
@@ -4193,6 +4157,6 @@
 void ObjectMgr::LoadPageTextLocales()
 {
-    mPageTextLocaleMap.clear();                             // need for reload case
-
+    mPageTextLocaleMap.clear();
+    
     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");
 
@@ -4243,17 +4207,7 @@
 }
 
-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()
 {
-    SQLInstanceLoader loader;
-    loader.Load(sInstanceTemplate);
+    sInstanceTemplate.Load();
 
     for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++)
@@ -4371,6 +4325,6 @@
 void ObjectMgr::LoadNpcTextLocales()
 {
-    mNpcTextLocaleMap.clear();                              // need for reload case
-
+    mNpcTextLocaleMap.clear();
+    
     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,"
@@ -4669,5 +4623,5 @@
 
         uint32 Trigger_ID      = fields[0].GetUInt32();
-        const char *scriptName = fields[1].GetString();
+        std::string scriptName = fields[1].GetCppString();
 
         AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
@@ -4677,5 +4631,5 @@
             continue;
         }
-        mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName);
+        mAreaTriggerScripts[Trigger_ID] = scriptName;
     } while( result->NextRow() );
 
@@ -4685,5 +4639,4 @@
     sLog.outString( ">> Loaded %u areatrigger scripts", count );
 }
-
 uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid )
 {
@@ -4744,9 +4697,9 @@
 uint16 ObjectMgr::GetTaxiMount( uint32 id, uint32 team )
 {
-    uint16 mount_entry = 0;
-    uint16 mount_id = 0;
+    uint32 mount_entry = 0;
+    uint32 mount_id = 0;
 
     TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
-    if(node)
+    if (node)
     {
         if (team == ALLIANCE) mount_entry = node->alliance_mount_type;
@@ -4987,4 +4940,5 @@
     }
 
+            // find now nearest graveyard at same map
     if(entryNear)
         return entryNear;
@@ -5227,4 +5181,5 @@
     {
         m_hiCharGuid = (*result)[0].GetUInt32()+1;
+
         delete result;
     }
@@ -5234,9 +5189,15 @@
     {
         m_hiCreatureGuid = (*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(id) FROM character_pet" );
+    if( result )
+    {
+        m_hiPetGuid = (*result)[0].GetUInt32()+1;
+
+        delete result;
+    }
 
     result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" );
@@ -5244,4 +5205,5 @@
     {
         m_hiItemGuid = (*result)[0].GetUInt32()+1;
+
         delete result;
     }
@@ -5257,4 +5219,5 @@
     {
         m_hiGoGuid = (*result)[0].GetUInt32()+1;
+
         delete result;
     }
@@ -5264,20 +5227,31 @@
     {
         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()+1;
+        m_ItemTextId = (*result)[0].GetUInt32();
+
         delete result;
     }
+    else
+        m_ItemTextId = 0;
 
     result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" );
@@ -5285,70 +5259,40 @@
     {
         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()
 {
-    if(m_auctionid>=0xFFFFFFFE)
+    ++m_auctionid;
+    if(m_auctionid>=0xFFFFFFFF)
     {
         sLog.outError("Auctions ids overflow!! Can't continue, shutting down server. ");
-        World::StopNow(ERROR_EXIT_CODE);
-    }
-    return m_auctionid++;
+        sWorld.m_stopEvent = true;
+    }
+    return m_auctionid;
 }
 
 uint32 ObjectMgr::GenerateMailID()
 {
-    if(m_mailid>=0xFFFFFFFE)
+    ++m_mailid;
+    if(m_mailid>=0xFFFFFFFF)
     {
         sLog.outError("Mail ids overflow!! Can't continue, shutting down server. ");
-        World::StopNow(ERROR_EXIT_CODE);
-    }
-    return m_mailid++;
+        sWorld.m_stopEvent = true;
+    }
+    return m_mailid;
 }
 
 uint32 ObjectMgr::GenerateItemTextID()
 {
-    if(m_ItemTextId>=0xFFFFFFFE)
+    ++m_ItemTextId;
+    if(m_ItemTextId>=0xFFFFFFFF)
     {
         sLog.outError("Item text ids overflow!! Can't continue, shutting down server. ");
-        World::StopNow(ERROR_EXIT_CODE);
-    }
-    return m_ItemTextId++;
+        sWorld.m_stopEvent = true;
+    }
+    return m_ItemTextId;
 }
 
@@ -5372,52 +5316,59 @@
     {
         case HIGHGUID_ITEM:
-            if(m_hiItemGuid>=0xFFFFFFFE)
+            ++m_hiItemGuid;
+            if(m_hiItemGuid>=0xFFFFFFFF)
             {
                 sLog.outError("Item guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiItemGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiItemGuid;
         case HIGHGUID_UNIT:
-            if(m_hiCreatureGuid>=0x00FFFFFE)
+            ++m_hiCreatureGuid;
+            if(m_hiCreatureGuid>=0x00FFFFFF)
             {
                 sLog.outError("Creature guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiCreatureGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiCreatureGuid;
         case HIGHGUID_PET:
-            if(m_hiPetGuid>=0x00FFFFFE)
+            ++m_hiPetGuid;
+            if(m_hiPetGuid>=0x00FFFFFF)
             {
                 sLog.outError("Pet guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiPetGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiPetGuid;
         case HIGHGUID_PLAYER:
-            if(m_hiCharGuid>=0xFFFFFFFE)
+            ++m_hiCharGuid;
+            if(m_hiCharGuid>=0xFFFFFFFF)
             {
                 sLog.outError("Players guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiCharGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiCharGuid;
         case HIGHGUID_GAMEOBJECT:
-            if(m_hiGoGuid>=0x00FFFFFE)
+            ++m_hiGoGuid;
+            if(m_hiGoGuid>=0x00FFFFFF)
             {
                 sLog.outError("Gameobject guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiGoGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiGoGuid;
         case HIGHGUID_CORPSE:
-            if(m_hiCorpseGuid>=0xFFFFFFFE)
+            ++m_hiCorpseGuid;
+            if(m_hiCorpseGuid>=0xFFFFFFFF)
             {
                 sLog.outError("Corpse guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiCorpseGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiCorpseGuid;
         case HIGHGUID_DYNAMICOBJECT:
-            if(m_hiDoGuid>=0xFFFFFFFE)
+            ++m_hiDoGuid;
+            if(m_hiDoGuid>=0xFFFFFFFF)
             {
                 sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. ");
-                World::StopNow(ERROR_EXIT_CODE);
-            }
-            return m_hiDoGuid++;
+                sWorld.m_stopEvent = true;
+            }
+            return m_hiDoGuid;
         default:
             ASSERT(0);
@@ -5430,6 +5381,6 @@
 void ObjectMgr::LoadGameObjectLocales()
 {
-    mGameObjectLocaleMap.clear();                           // need for reload case
-
+    mGameObjectLocaleMap.clear();
+    
     QueryResult *result = WorldDatabase.Query("SELECT entry,"
         "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8,"
@@ -5499,17 +5450,7 @@
 }
 
-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()
 {
-    SQLGameObjectLoader loader;
-    loader.Load(sGOStorage);
+    sGOStorage.Load();
 
     // some checks
@@ -6684,10 +6625,10 @@
 }
 
-uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)
-{
-    AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id);
+const char* ObjectMgr::GetAreaTriggerScriptName(uint32 id)
+{
+    AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(id);
     if(i!= mAreaTriggerScripts.end())
-        return i->second;
-    return 0;
+        return i->second.c_str();
+    return "";
 }
 
@@ -6734,8 +6675,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;
@@ -6858,28 +6799,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;
@@ -7011,5 +6952,5 @@
         if(itr->first > new_id)
             new_id = itr->first;
-
+    
     // use next
     ++new_id;
@@ -7051,5 +6992,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();
@@ -7142,5 +7083,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();
@@ -7249,5 +7190,4 @@
         "SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text "
         "FROM npc_option");
-
     if( !result )
     {
@@ -7402,82 +7342,8 @@
 }
 
-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
-uint32 GetAreaTriggerScriptId(uint32 trigger_id)
-{
-    return objmgr.GetAreaTriggerScriptId(trigger_id);
+const char* GetAreaTriggerScriptNameById(uint32 id)
+{
+    return objmgr.GetAreaTriggerScriptName(id);
 }
 
@@ -7494,12 +7360,2 @@
     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/game/SpellMgr.cpp
===================================================================
--- /trunk/src/game/SpellMgr.cpp (revision 265)
+++ /trunk/src/game/SpellMgr.cpp (revision 272)
@@ -100,5 +100,5 @@
 }
 
-/*bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2)
+bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2)
 {
     SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1);
@@ -114,5 +114,5 @@
 
     return true;
-}*/
+}
 
 int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2)
@@ -245,17 +245,4 @@
         case SPELL_CURSE:
         case SPELL_ASPECT:
-        case SPELL_POSITIVE_SHOUT:
-        case SPELL_JUDGEMENT:
-        case SPELL_WARLOCK_CORRUPTION:
-            return spellSpec1==spellSpec2;
-        default:
-            return false;
-    }
-}
-
-bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2)
-{
-    switch(spellSpec1)
-    {
         case SPELL_TRACKER:
         case SPELL_WARLOCK_ARMOR:
@@ -263,4 +250,7 @@
         case SPELL_ELEMENTAL_SHIELD:
         case SPELL_MAGE_POLYMORPH:
+        case SPELL_POSITIVE_SHOUT:
+        case SPELL_JUDGEMENT:
+        case SPELL_WARLOCK_CORRUPTION:
             return spellSpec1==spellSpec2;
         case SPELL_BATTLE_ELIXIR:
@@ -1041,8 +1031,8 @@
 }
 
-bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const
-{
-    //if(spellId_1 == spellId_2) // auras due to the same spell
-    //    return false;
+bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const
+{
+    if(spellId_1 == spellId_2) // auras due to the same spell
+        return false;
 
     SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1);
@@ -1052,16 +1042,8 @@
         return false;
 
-    SpellSpecific spellId_spec_1 = GetSpellSpecific(spellId_1);
-    SpellSpecific spellId_spec_2 = GetSpellSpecific(spellId_2);
-    if (spellId_spec_1 && spellId_spec_2)
-        if (IsSingleFromSpellSpecificPerTarget(spellId_spec_1, spellId_spec_2)
-            ||(IsSingleFromSpellSpecificPerCaster(spellId_spec_1, spellId_spec_2) && sameCaster))
-            return true;
-
     if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName)
         return false;
 
-    // generic spells
-    if(!spellInfo_1->SpellFamilyName)
+    if(!spellInfo_1->SpellFamilyName) // generic spells
     {
         if(!spellInfo_1->SpellIconID 
@@ -1069,46 +1051,11 @@
             return false;
     }
-
-    // if both elixirs are not battle/guardian/potions/flasks then always stack
-    else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION)
-    {
-        if(spellId_spec_1 || spellId_spec_2)
+    else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags)
+        return false;
+
+    for(uint32 i = 0; i < 3; ++i)
+        if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i]
+            || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i])
             return false;
-    }
-
-    // check for class spells
-    else
-    {
-        if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags)
-            return false;
-    }
-
-    for(uint32 i = 0; i < 3; ++i)
-    {
-        if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i]
-            || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]
-            || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) // paladin resist aura
-            return false; // need itemtype check? need an example to add that check
-
-        if(spellInfo_1->EffectApplyAuraName[i] // both spell has the same auras
-            && !sameCaster
-            && spellInfo_1->Effect[i] != SPELL_EFFECT_APPLY_AREA_AURA_PARTY) // not area auras (shaman totem)
-            // a better check may be effect == SPELL_EFFECT_APPLY_AURA
-        {
-            switch(spellInfo_1->EffectApplyAuraName[i])
-            {
-                // DOT or HOT from different casters will stack
-                case SPELL_AURA_PERIODIC_DAMAGE:
-                case SPELL_AURA_PERIODIC_HEAL:
-                case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
-                case SPELL_AURA_PERIODIC_ENERGIZE:
-                case SPELL_AURA_PERIODIC_MANA_LEECH:
-                case SPELL_AURA_PERIODIC_LEECH:
-                    return false;
-                default:
-                    break;
-            }
-        }
-    }
 
     return true;
Index: /trunk/src/game/ObjectAccessor.cpp
===================================================================
--- /trunk/src/game/ObjectAccessor.cpp (revision 268)
+++ /trunk/src/game/ObjectAccessor.cpp (revision 272)
@@ -143,13 +143,5 @@
 {
     Creature * ret = GetObjectInWorld(guid, (Creature*)NULL);
-    if(!ret)
-        return NULL;
-
-    if(ret->GetMapId() != u.GetMapId())
-        return NULL;
-
-    if(ret->GetInstanceId() != u.GetInstanceId())
-        return NULL;
-
+    if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL;
     return ret;
 }
@@ -257,4 +249,30 @@
 
 void
+ObjectAccessor::_update()
+{
+    UpdateDataMapType update_players;
+    {
+        Guard guard(i_updateGuard);
+        while(!i_objects.empty())
+        {
+            Object* obj = *i_objects.begin();
+            i_objects.erase(i_objects.begin());
+            if (!obj)
+                continue;
+            _buildUpdateObject(obj, update_players);
+            obj->ClearUpdateMask(false);
+        }
+    }
+
+    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
+    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
+    {
+        iter->second.BuildPacket(&packet);
+        iter->first->GetSession()->SendPacket(&packet);
+        packet.clear();                                     // clean the string
+    }
+}
+
+void
 ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer)
 {
@@ -344,5 +362,5 @@
     TypeContainerVisitor<WorldObjectChangeAccumulator, WorldTypeMapContainer > player_notifier(notifier);
     CellLock<GridReadGuard> cell_lock(cell, p);
-    cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap());
+    cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj));
 }
 
@@ -488,8 +506,19 @@
 
 void
+ObjectAccessor::AddActiveObject( WorldObject * obj )
+{
+    i_activeobjects.insert(obj);
+}
+
+void
+ObjectAccessor::RemoveActiveObject( WorldObject * obj )
+{
+    i_activeobjects.erase(obj);
+}
+
+void
 ObjectAccessor::Update(uint32 diff)
 {
-/*    {
-        //Player update now in MapManager -> UpdatePlayers
+    {
         // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects.
         HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer();
@@ -502,5 +531,4 @@
         }
 
-        // TODO: move this to Map::Update
         // clone the active object list, because update might remove from it
         std::set<WorldObject *> activeobjects(i_activeobjects);
@@ -561,36 +589,31 @@
             }
         }
-    }*/
-
-    UpdateDataMapType update_players;
-    {
-        Guard guard(i_updateGuard);
-        while(!i_objects.empty())
-        {
-            Object* obj = *i_objects.begin();
-            i_objects.erase(i_objects.begin());
-            if (!obj)
-                continue;
-            _buildUpdateObject(obj, update_players);
-            obj->ClearUpdateMask(false);
-        }
-    }
-
-    WorldPacket packet;                                     // here we allocate a std::vector with a size of 0x10000
-    for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
-    {
-        iter->second.BuildPacket(&packet);
-        iter->first->GetSession()->SendPacket(&packet);
-        packet.clear();                                     // clean the string
-    }
-}
-
-void
-ObjectAccessor::UpdatePlayers(uint32 diff)
-{
-    HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer();
-    for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter)
-        if(iter->second->IsInWorld())
-            iter->second->Update(diff);
+    }
+
+    _update();
+}
+
+bool
+ObjectAccessor::ActiveObjectsNearGrid(uint32 x, uint32 y, uint32 m_id, uint32 i_id) const
+{
+    CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS);
+    CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
+    cell_min << 2;
+    cell_min -= 2;
+    cell_max >> 2;
+    cell_max += 2;
+
+    for(std::set<WorldObject*>::const_iterator itr = i_activeobjects.begin(); itr != i_activeobjects.end(); ++itr)
+    {
+        if( m_id != (*itr)->GetMapId() || i_id != (*itr)->GetInstanceId() )
+            continue;
+
+        CellPair p = Trinity::ComputeCellPair((*itr)->GetPositionX(), (*itr)->GetPositionY());
+        if( (cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
+            (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord) )
+            return true;
+    }
+
+    return false;
 }
 
@@ -655,5 +678,5 @@
     Cell cell(p);
 
-    obj->GetMap()->UpdateObjectVisibility(obj,cell,p);
+    MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p);
 }
 
@@ -662,5 +685,5 @@
     CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY());
     Cell cell(p);
-    Map* m = player->GetMap();
+    Map* m = MapManager::Instance().GetMap(player->GetMapId(),player);
 
     m->UpdatePlayerVisibility(player,cell,p);
Index: /trunk/src/trinitycore/CliRunnable.cpp
===================================================================
--- /trunk/src/trinitycore/CliRunnable.cpp (revision 260)
+++ /trunk/src/trinitycore/CliRunnable.cpp (revision 272)
@@ -170,5 +170,5 @@
 {
     SendSysMessage(LANG_COMMAND_EXIT);
-    World::StopNow(SHUTDOWN_EXIT_CODE);
+    World::m_stopEvent = true;
     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::IsStopped())
+    while (!World::m_stopEvent)
     {
         fflush(stdout);
         #ifdef linux
-        while (!kb_hit_return() && !World::IsStopped())
+        while (!kb_hit_return() && !World::m_stopEvent)
             // With this, we limit CLI to 10commands/second
             usleep(100);
-        if (World::IsStopped())
+        if (World::m_stopEvent)
             break;
         #endif
@@ -349,5 +349,5 @@
         else if (feof(stdin))
         {
-            World::StopNow(SHUTDOWN_EXIT_CODE);
+            World::m_stopEvent = true;
         }
     }
Index: /trunk/src/trinitycore/WorldRunnable.cpp
===================================================================
--- /trunk/src/trinitycore/WorldRunnable.cpp (revision 260)
+++ /trunk/src/trinitycore/WorldRunnable.cpp (revision 272)
@@ -52,5 +52,5 @@
 
     ///- While we have not World::m_stopEvent, update the world
-    while (!World::IsStopped())
+    while (!World::m_stopEvent)
     {
         ++World::m_worldLoopCounter;
Index: /trunk/src/trinitycore/Master.cpp
===================================================================
--- /trunk/src/trinitycore/Master.cpp (revision 260)
+++ /trunk/src/trinitycore/Master.cpp (revision 272)
@@ -78,5 +78,5 @@
         m_lastchange = 0;
         w_lastchange = 0;
-        while(!World::IsStopped())
+        while(!World::m_stopEvent)
         {
             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::IsStopped())
+      while (!World::m_stopEvent)
         {
           h.Select (0, socketSelecttime);
@@ -179,5 +179,5 @@
         }
     else
-      while (!World::IsStopped())
+      while (!World::m_stopEvent)
         {
           ZThread::Thread::sleep (static_cast<unsigned long> (socketSelecttime / 1000));
@@ -324,5 +324,5 @@
     {
       sLog.outError ("Failed to start network");
-      World::StopNow(ERROR_EXIT_CODE);
+      World::m_stopEvent = true;
       // go down and shutdown the server
     }
@@ -395,6 +395,5 @@
     UnloadScriptingModule();
 
-    // Exit the process with specified return value
-    return World::GetExitCode();
+    return sWorld.GetShutdownMask() & SHUTDOWN_MASK_RESTART ? 2 : 0;
 }
 
@@ -479,4 +478,5 @@
 
 /// Handle termination signals
+/** Put the World::m_stopEvent to 'true' if a termination signal is caught **/
 void Master::_OnSignal(int s)
 {
@@ -484,11 +484,9 @@
     {
         case SIGINT:
-            World::StopNow(RESTART_EXIT_CODE);
-            break;
         case SIGTERM:
         #ifdef _WIN32
         case SIGBREAK:
         #endif
-            World::StopNow(SHUTDOWN_EXIT_CODE);
+            World::m_stopEvent = true;
             break;
     }
Index: /trunk/src/bindings/scripts/ScriptMgr.h
===================================================================
--- /trunk/src/bindings/scripts/ScriptMgr.h (revision 260)
+++ /trunk/src/bindings/scripts/ScriptMgr.h (revision 272)
@@ -25,5 +25,5 @@
 class WorldObject;
 
-#define MAX_SCRIPTS         5000                            //72 bytes each (approx 351kb)
+#define MAX_SCRIPTS         1000                            //72 bytes each (approx 71kb)
 #define VISIBLE_RANGE       (166.0f)                        //MAX visible range (size of grid)
 #define DEFAULT_TEXT        "<Trinity Script Text Entry Missing!>"
@@ -32,36 +32,37 @@
 {
     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;
 
-    //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& );
+// 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& );
 
-    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/include/sc_creature.cpp
===================================================================
--- /trunk/src/bindings/scripts/include/sc_creature.cpp (revision 267)
+++ /trunk/src/bindings/scripts/include/sc_creature.cpp (revision 272)
@@ -74,5 +74,15 @@
 void ScriptedAI::MoveInLineOfSight(Unit *who)
 {
-    if(!m_creature->getVictim() && m_creature->canStartAttack(who))
+    if(m_creature->getVictim() || !m_creature->IsHostileTo(who) || !who->isInAccessiblePlaceFor(m_creature))
+        return;
+
+    if(!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
+        return;
+
+    if(!m_creature->IsWithinDistInMap(who, m_creature->GetAttackDistance(who)) || !m_creature->IsWithinLOSInMap(who))
+        return;
+    
+    if(m_creature->canAttack(who))
+        //who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
         AttackStart(who);
 }
@@ -670,9 +680,11 @@
     }
 
-    Map::PlayerList const &PlayerList = map->GetPlayers();
-    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-        if (Player* i_pl = i->getSource())
-            if (!i_pl->isAlive())
-                pUnit->AddThreat(i_pl, 0.0f);
+    InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+    InstanceMap::PlayerList::const_iterator i;
+    for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
+    {
+        if((*i)->isAlive())
+            pUnit->AddThreat(*i, 0.0f);
+    }
 }
 
@@ -709,18 +721,4 @@
     ((Player*)pUnit)->TeleportTo(pUnit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
 }
-
-void ScriptedAI::DoTeleportAll(float x, float y, float z, float o)
-{
-    Map *map = m_creature->GetMap();
-    if (!map->IsDungeon())
-        return;
-
-    Map::PlayerList const &PlayerList = map->GetPlayers();
-    for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-        if (Player* i_pl = i->getSource())
-            if (!i_pl->isAlive())
-                i_pl->TeleportTo(m_creature->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT);
-}
-
 
 Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff)
Index: /trunk/src/bindings/scripts/include/sc_creature.h
===================================================================
--- /trunk/src/bindings/scripts/include/sc_creature.h (revision 257)
+++ /trunk/src/bindings/scripts/include/sc_creature.h (revision 272)
@@ -147,5 +147,4 @@
     //Teleports a player without dropping threat (only teleports to same map)
     void DoTeleportPlayer(Unit* pUnit, float x, float y, float z, float o);
-    void DoTeleportAll(float x, float y, float z, float o);
 
     //Returns friendly unit with the most amount of hp missing from max hp
Index: /trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/npc/npc_innkeeper.cpp (revision 272)
@@ -141,4 +141,4 @@
     newscript->pGossipHello = &GossipHello_npc_innkeeper;
     newscript->pGossipSelect = &GossipSelect_npc_innkeeper;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/npc/npcs_special.cpp (revision 272)
@@ -836,15 +836,15 @@
     newscript->pQuestAccept =   &QuestAccept_npc_chicken_cluck;
     newscript->pQuestComplete = &QuestComplete_npc_chicken_cluck;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_dancing_flames";
     newscript->pReceiveEmote =  &ReceiveEmote_npc_dancing_flames;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_injured_patient";
     newscript->GetAI = GetAI_npc_injured_patient;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -852,10 +852,10 @@
     newscript->GetAI = GetAI_npc_doctor;
     newscript->pQuestAccept = &QuestAccept_npc_doctor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_guardian";
     newscript->GetAI = GetAI_npc_guardian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -863,5 +863,5 @@
     newscript->pGossipHello =  &GossipHello_npc_mount_vendor;
     newscript->pGossipSelect = &GossipSelect_npc_mount_vendor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -869,5 +869,5 @@
     newscript->pGossipHello =  &GossipHello_npc_rogue_trainer;
     newscript->pGossipSelect = &GossipSelect_npc_rogue_trainer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -875,4 +875,4 @@
     newscript->pGossipHello = &GossipHello_npc_sayge;
     newscript->pGossipSelect = &GossipSelect_npc_sayge;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/npc/npc_professions.cpp (revision 272)
@@ -1178,5 +1178,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_alchemy;
     newscript->pGossipSelect = &GossipSelect_npc_prof_alchemy;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1184,5 +1184,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_blacksmith;
     newscript->pGossipSelect = &GossipSelect_npc_prof_blacksmith;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1190,5 +1190,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_leather;
     newscript->pGossipSelect = &GossipSelect_npc_prof_leather;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1196,5 +1196,5 @@
     newscript->pGossipHello =  &GossipHello_npc_prof_tailor;
     newscript->pGossipSelect = &GossipSelect_npc_prof_tailor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     /*newscript = new Script;
@@ -1202,4 +1202,4 @@
     newscript->pGOHello =  &GOHello_go_soothsaying_for_dummies;
     //newscript->pGossipSelect = &GossipSelect_go_soothsaying_for_dummies;
-    newscript->RegisterSelf();*/
-}
+    m_scripts[nrscripts++] = newscript;*/
+}
Index: /trunk/src/bindings/scripts/scripts/guard/guards.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/guard/guards.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/guard/guards.cpp (revision 272)
@@ -3981,5 +3981,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_azuremyst;
     newscript->GetAI = GetAI_guard_azuremyst;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -3988,10 +3988,10 @@
     newscript->pGossipSelect         = &GossipSelect_guard_bluffwatcher;
     newscript->GetAI = GetAI_guard_bluffwatcher;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="guard_contested";
     newscript->GetAI = GetAI_guard_contested;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4000,5 +4000,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_darnassus;
     newscript->GetAI = GetAI_guard_darnassus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4007,5 +4007,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_dunmorogh;
     newscript->GetAI = GetAI_guard_dunmorogh;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4014,5 +4014,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_durotar;
     newscript->GetAI = GetAI_guard_durotar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4021,5 +4021,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_elwynnforest;
     newscript->GetAI = GetAI_guard_elwynnforest;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4028,5 +4028,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_eversong;
     newscript->GetAI = GetAI_guard_eversong;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4035,5 +4035,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_exodar;
     newscript->GetAI = GetAI_guard_exodar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4042,5 +4042,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_ironforge;
     newscript->GetAI = GetAI_guard_ironforge;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4049,5 +4049,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_mulgore;
     newscript->GetAI = GetAI_guard_mulgore;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4057,5 +4057,5 @@
     newscript->pReceiveEmote         = &ReceiveEmote_guard_orgrimmar;
     newscript->GetAI = GetAI_guard_orgrimmar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4064,5 +4064,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath;
     newscript->GetAI = GetAI_guard_shattrath;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4071,5 +4071,5 @@
     newscript->pGossipHello          = &GossipHello_guard_shattrath_aldor;
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath_aldor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4078,5 +4078,5 @@
     newscript->pGossipHello          = &GossipHello_guard_shattrath_scryer;
     newscript->pGossipSelect         = &GossipSelect_guard_shattrath_scryer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4085,5 +4085,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_silvermoon;
     newscript->GetAI = GetAI_guard_silvermoon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4093,5 +4093,5 @@
     newscript->pReceiveEmote         = &ReceiveEmote_guard_stormwind;
     newscript->GetAI = GetAI_guard_stormwind;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4100,5 +4100,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_teldrassil;
     newscript->GetAI = GetAI_guard_teldrassil;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4107,5 +4107,5 @@
     newscript->pGossipSelect         = &GossipSelect_guard_tirisfal;
     newscript->GetAI = GetAI_guard_tirisfal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -4114,4 +4114,4 @@
     newscript->pGossipSelect         = &GossipSelect_guard_undercity;
     newscript->GetAI = GetAI_guard_undercity;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/go/go_scripts.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/go/go_scripts.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/go/go_scripts.cpp (revision 272)
@@ -166,44 +166,44 @@
     newscript->Name="go_northern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_northern_crystal_pylon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_eastern_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_eastern_crystal_pylon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_western_crystal_pylon";
     newscript->pGOHello =           &GOHello_go_western_crystal_pylon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_barov_journal";
     newscript->pGOHello =           &GOHello_go_barov_journal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_field_repair_bot_74A";
     newscript->pGOHello =           &GOHello_go_field_repair_bot_74A;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_orb_of_command";
     newscript->pGOHello =           &GOHello_go_orb_of_command;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_tablet_of_madness";
     newscript->pGOHello =           &GOHello_go_tablet_of_madness;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_tablet_of_the_seven";
     newscript->pGOHello =           &GOHello_go_tablet_of_the_seven;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_teleporter";
     newscript->pGOHello =           &GOHello_go_teleporter;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/boss/boss_taerar.cpp (revision 272)
@@ -298,9 +298,9 @@
     newscript->Name="boss_taerar";
     newscript->GetAI = GetAI_boss_taerar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_shade_of_taerar";
     newscript->GetAI = GetAI_boss_shadeoftaerar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/boss/boss_ysondre.cpp (revision 272)
@@ -238,9 +238,9 @@
     newscript->Name="boss_ysondre";
     newscript->GetAI = GetAI_boss_ysondre;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_dementeddruids";
     newscript->GetAI = GetAI_mob_dementeddruids;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/boss/boss_emeriss.cpp (revision 272)
@@ -153,4 +153,4 @@
     newscript->Name="boss_emeriss";
     newscript->GetAI = GetAI_boss_emeriss;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/creature/mob_generic_creature.cpp (revision 272)
@@ -169,4 +169,4 @@
     newscript->Name="generic_creature";
     newscript->GetAI = GetAI_generic_creature;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 269)
+++ /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.cpp (revision 272)
@@ -7,10 +7,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
  */
 
@@ -965,15 +965,4 @@
                 DoZoneInCombat();
             }
-            break;
-
-        // TRINITY ONLY
-        case ACTION_T_SET_ACTIVE:
-            m_creature->setActive(param1 ? true : false);
-            break;
-        case ACTION_T_SET_AGGRESSIVE:
-            m_creature->SetAggressive(param1 ? true : false);
-            break;
-        case ACTION_T_ATTACK_START_PULSE:
-            AttackStart(m_creature->SelectNearestTarget((float)param1));
             break;
         }
@@ -1204,10 +1193,22 @@
         }
 
-        // do we need this?
-        //if (m_creature->isCivilian() && m_creature->IsNeutralToAll())
-        //    return;
-
-        if(m_creature->canStartAttack(who))
-            AttackStart(who);
+        if (m_creature->isCivilian() && m_creature->IsNeutralToAll())
+            return;
+
+        if (m_creature->canAttack(who) && who->isInAccessiblePlaceFor(m_creature) && m_creature->IsHostileTo(who))
+        {
+            if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
+                return;
+
+            float attackRadius = m_creature->GetAttackDistance(who);
+            if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who))
+            {
+                //if(who->HasStealthAura())
+                //    who->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
+
+                //Begin melee attack if we are within range
+                AttackStart(who);
+            }
+        }
     }
 
@@ -1292,5 +1293,4 @@
                         if (!((*i).Event.event_inverse_phase_mask & (1 << Phase)))
                             (*i).Time -= EventDiff;
-
                         //Skip processing of events that have time remaining
                         continue;
@@ -1329,5 +1329,4 @@
         if (Combat && MeleeEnabled)
             DoMeleeAttackIfReady();
-
     }
 };
@@ -1402,4 +1401,4 @@
     newscript->Name="mob_eventai";
     newscript->GetAI = GetAI_Mob_EventAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.h
===================================================================
--- /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.h (revision 269)
+++ /trunk/src/bindings/scripts/scripts/creature/mob_event_ai.h (revision 272)
@@ -1,5 +1,5 @@
 /* Copyright (C) 2006 - 2008 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- * This program is free software licensed under GPL version 2
- * Please see the included DOCS/LICENSE.TXT for more information */
+* This program is free software licensed under GPL version 2
+* Please see the included DOCS/LICENSE.TXT for more information */
 
 #ifndef SC_EVENTAI_H
@@ -77,8 +77,4 @@
     ACTION_T_ZONE_COMBAT_PULSE      = 38,   //No Params
 
-    ACTION_T_SET_ACTIVE             = 101,  //Apply
-    ACTION_T_SET_AGGRESSIVE         = 102,  //Apply
-    ACTION_T_ATTACK_START_PULSE     = 103,  //Distance
-
     ACTION_T_END,
 };
Index: /trunk/src/bindings/scripts/scripts/custom/test.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/custom/test.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/custom/test.cpp (revision 272)
@@ -197,4 +197,4 @@
     newscript->pGossipHello          = &GossipHello_npc_test;
     newscript->pGossipSelect         = &GossipSelect_npc_test;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/custom/custom_gossip_codebox.cpp (revision 272)
@@ -78,4 +78,4 @@
     newscript->pGossipSelect =          &GossipSelect_custom_gossip_codebox;
     newscript->pGossipSelectWithCode =  &GossipSelectWithCode_custom_gossip_codebox;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/custom/custom_example.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/custom/custom_example.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/custom/custom_example.cpp (revision 272)
@@ -274,4 +274,4 @@
     newscript->pGossipSelect = &GossipSelect_custom_example;
     newscript->pReceiveEmote = &ReceiveEmote_custom_example;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hazzarah.cpp (revision 272)
@@ -97,4 +97,4 @@
     newscript->Name="boss_hazzarah";
     newscript->GetAI = GetAI_boss_hazzarah;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_thekal.cpp (revision 272)
@@ -532,14 +532,14 @@
     newscript->Name="boss_thekal";
     newscript->GetAI = GetAI_boss_thekal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_zealot_lorkhan";
     newscript->GetAI = GetAI_mob_zealot_lorkhan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_zealot_zath";
     newscript->GetAI = GetAI_mob_zealot_zath;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jeklik.cpp (revision 272)
@@ -289,9 +289,9 @@
     newscript->Name="boss_jeklik";
     newscript->GetAI = GetAI_boss_jeklik;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_batrider";
     newscript->GetAI = GetAI_mob_batrider;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_wushoolay.cpp (revision 272)
@@ -81,4 +81,4 @@
     newscript->Name="boss_wushoolay";
     newscript->GetAI = GetAI_boss_wushoolay;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_venoxis.cpp (revision 272)
@@ -197,4 +197,4 @@
     newscript->Name="boss_venoxis";
     newscript->GetAI = GetAI_boss_venoxis;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_grilek.cpp (revision 272)
@@ -89,4 +89,4 @@
     newscript->Name="boss_grilek";
     newscript->GetAI = GetAI_boss_grilek;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/instance_zulgurub.cpp (revision 272)
@@ -235,4 +235,4 @@
     newscript->Name = "instance_zulgurub";
     newscript->GetInstanceData = GetInstanceData_instance_zulgurub;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_renataki.cpp (revision 272)
@@ -148,4 +148,4 @@
     newscript->Name="boss_renataki";
     newscript->GetAI = GetAI_boss_renataki;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_hakkar.cpp (revision 272)
@@ -253,4 +253,4 @@
     newscript->Name="boss_hakkar";
     newscript->GetAI = GetAI_boss_hakkar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_arlokk.cpp (revision 272)
@@ -208,4 +208,4 @@
     newscript->Name="boss_arlokk";
     newscript->GetAI = GetAI_boss_arlokk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_jindo.cpp (revision 272)
@@ -259,14 +259,14 @@
     newscript->Name="boss_jindo";
     newscript->GetAI = GetAI_boss_jindo;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_healing_ward";
     newscript->GetAI = GetAI_mob_healing_ward;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_shade_of_jindo";
     newscript->GetAI = GetAI_mob_shade_of_jindo;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_mandokir.cpp (revision 272)
@@ -303,9 +303,9 @@
     newscript->Name="boss_mandokir";
     newscript->GetAI = GetAI_boss_mandokir;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_ohgan";
     newscript->GetAI = GetAI_mob_ohgan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_marli.cpp (revision 272)
@@ -245,9 +245,9 @@
     newscript->Name="boss_marli";
     newscript->GetAI = GetAI_boss_marli;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_spawn_of_marli";
     newscript->GetAI = GetAI_mob_spawn_of_marli;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulgurub/boss_gahzranka.cpp (revision 272)
@@ -89,4 +89,4 @@
     newscript->Name="boss_gahzranka";
     newscript->GetAI = GetAI_boss_gahzranka;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_broggok.cpp (revision 272)
@@ -124,9 +124,9 @@
     newscript->Name="boss_broggok";
     newscript->GetAI = GetAI_boss_broggokAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_broggok_poisoncloud";
     newscript->GetAI = GetAI_mob_broggok_poisoncloudAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_the_maker.cpp (revision 272)
@@ -128,4 +128,4 @@
     newscript->Name="boss_the_maker";
     newscript->GetAI = GetAI_boss_the_makerAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/blood_furnace/boss_kelidan_the_breaker.cpp (revision 272)
@@ -226,9 +226,9 @@
     newscript->Name="boss_kelidan_the_breaker";
     newscript->GetAI = GetAI_boss_kelidan_the_breaker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_shadowmoon_channeler";
     newscript->GetAI = GetAI_mob_shadowmoon_channeler;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_watchkeeper_gargolmar.cpp (revision 272)
@@ -165,4 +165,4 @@
     newscript->Name="boss_watchkeeper_gargolmar";
     newscript->GetAI = GetAI_boss_watchkeeper_gargolmarAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/hellfire_ramparts/boss_omor_the_unscarred.cpp (revision 272)
@@ -210,4 +210,4 @@
     newscript->Name="boss_omor_the_unscarred";
     newscript->GetAI = GetAI_boss_omor_the_unscarredAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_warbringer_omrogg.cpp (revision 272)
@@ -395,9 +395,9 @@
     newscript->Name="boss_warbringer_omrogg";
     newscript->GetAI = GetAI_boss_warbringer_omrogg;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_omrogg_heads";
     newscript->GetAI = GetAI_mob_omrogg_heads;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/boss_nethekurse.cpp (revision 272)
@@ -445,14 +445,14 @@
     newscript->Name="boss_grand_warlock_nethekurse";
     newscript->GetAI = GetAI_boss_grand_warlock_nethekurse;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_fel_orc_convert";
     newscript->GetAI = GetAI_mob_fel_orc_convert;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_lesser_shadow_fissure";
     newscript->GetAI = GetAI_mob_lesser_shadow_fissure;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/shattered_halls/instance_shattered_halls.cpp (revision 272)
@@ -111,4 +111,4 @@
     newscript->Name = "instance_shattered_halls";
     newscript->GetInstanceData = GetInstanceData_instance_shattered_halls;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/instance_magtheridons_lair.cpp (revision 272)
@@ -119,4 +119,7 @@
     void SetData(uint32 type, uint32 data)
     {
+        Player *player = GetPlayer();
+        if(!player) return;
+
         switch(type)
         {
@@ -127,5 +130,5 @@
             if(data != IN_PROGRESS)
             {
-                if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
+                if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
                     Door->SetGoState(0);
             }
@@ -140,5 +143,5 @@
                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
-                        if(Creature *Channeler = instance->GetCreatureInMap(*i))
+                        if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
                         {
                             if(Channeler->isAlive())
@@ -149,5 +152,5 @@
                     }
                     CageTimer = 0;
-                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
+                    if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
                         Door->SetGoState(0);
                 }break;
@@ -159,5 +162,5 @@
                     for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                     {
-                        Creature *Channeler = instance->GetCreatureInMap(*i);
+                        Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i);
                         if(Channeler && Channeler->isAlive())
                         {
@@ -168,5 +171,5 @@
                     }
                     // Release Magtheridon after two minutes.
-                    Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
+                    Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
                     if(Magtheridon && Magtheridon->isAlive())
                     {
@@ -174,5 +177,5 @@
                         CageTimer = 120000;
                     }
-                    if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
+                    if(GameObject *Door = GameObject::GetGameObject(*player, DoorGUID))
                         Door->SetGoState(1);
                 }break;
@@ -180,5 +183,5 @@
                 for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                 {
-                    Creature *Channeler = instance->GetCreatureInMap(*i);
+                    Unit *Channeler = Unit::GetUnit(*player, *i);
                     if(Channeler && Channeler->isAlive())
                     {
@@ -195,5 +198,5 @@
             for(std::set<uint64>::iterator i = ColumnGUID.begin(); i != ColumnGUID.end(); ++i)
             {
-                if(GameObject *Column = instance->GetGameObjectInMap(*i))
+                if(GameObject *Column = GameObject::GetGameObject(*player, *i))
                     Column->SetGoState(!data);
             }
@@ -211,4 +214,11 @@
     }
 
+    Player* GetPlayer()
+    {
+        if(((InstanceMap*)instance)->GetPlayers().size())
+            return ((InstanceMap*)instance)->GetPlayers().front();
+        return NULL;
+    }
+
     void AttackNearestTarget(Creature *creature)
     {
@@ -216,19 +226,16 @@
         float range;
         Player* target = NULL;
-        Map::PlayerList const &PlayerList = instance->GetPlayers();
-        Map::PlayerList::const_iterator i;
+        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)instance)->GetPlayers();
+        InstanceMap::PlayerList::const_iterator i;
         for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
         {
-            if(Player* i_pl = i->getSource())
-            {
-                if(i_pl->isTargetableForAttack())
-                {
-                    range = i_pl->GetDistance(creature);
-                    if(range < minRange)
-                    {
-                        minRange = range;
-                        target = i_pl;
-                    }                
-                }
+            if((*i)->isTargetableForAttack())
+            {
+                range = (*i)->GetDistance(creature);
+                if(range < minRange)
+                {
+                    minRange = range;
+                    target = *i;
+                }                
             }
         }
@@ -242,9 +249,12 @@
             if(CageTimer <= diff)
             {
-                Creature *Magtheridon = instance->GetCreatureInMap(MagtheridonGUID);
-                if(Magtheridon && Magtheridon->isAlive())
-                {
-                    Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
-                    AttackNearestTarget(Magtheridon);
+                if(Player *player = GetPlayer())
+                {
+                    Creature *Magtheridon = (Creature*)Unit::GetUnit(*player, MagtheridonGUID);
+                    if(Magtheridon && Magtheridon->isAlive())
+                    {
+                        Magtheridon->clearUnitState(UNIT_STAT_STUNNED);
+                        AttackNearestTarget(Magtheridon);
+                    }
                 }
                 CageTimer = 0;
@@ -256,12 +266,15 @@
             if(RespawnTimer <= diff)
             {
-                for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
-                {
-                    if(Creature *Channeler = instance->GetCreatureInMap(*i))
-                    {
-                        if(Channeler->isAlive())
-                            Channeler->AI()->EnterEvadeMode();
-                        else
-                            Channeler->Respawn();
+                if(Player *player = GetPlayer())
+                {
+                    for(std::set<uint64>::iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
+                    {
+                        if(Creature *Channeler = (Creature*)Unit::GetUnit(*player, *i))
+                        {
+                            if(Channeler->isAlive())
+                                Channeler->AI()->EnterEvadeMode();
+                            else
+                                Channeler->Respawn();
+                        }
                     }
                 }
@@ -283,4 +296,4 @@
     newscript->Name = "instance_magtheridons_lair";
     newscript->GetInstanceData = GetInstanceData_instance_magtheridons_lair;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_citadel/magtheridons_lair/boss_magtheridon.cpp (revision 272)
@@ -546,20 +546,20 @@
     newscript->Name="boss_magtheridon";
     newscript->GetAI = GetAI_boss_magtheridon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_hellfire_channeler";
     newscript->GetAI = GetAI_mob_hellfire_channeler;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="go_manticron_cube";
     newscript->pGOHello = &GOHello_go_Manticron_Cube;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_abyssal";
     newscript->GetAI = GetAI_mob_abyssalAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_teron_gorefiend.cpp (revision 272)
@@ -576,14 +576,14 @@
     newscript->Name = "mob_doom_blossom";
     newscript->GetAI = GetAI_mob_doom_blossom;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_shadowy_construct";
     newscript->GetAI = GetAI_mob_shadowy_construct;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_teron_gorefiend";
     newscript->GetAI = GetAI_boss_teron_gorefiend;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/black_temple.cpp (revision 272)
@@ -65,4 +65,4 @@
     newscript->pGossipHello = GossipHello_npc_spirit_of_olum;
     newscript->pGossipSelect = GossipSelect_npc_spirit_of_olum;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_illidan.cpp (revision 272)
@@ -2248,5 +2248,5 @@
     newscript->Name = "boss_illidan_stormrage";
     newscript->GetAI = GetAI_boss_illidan_stormrage;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -2255,44 +2255,44 @@
     newscript->pGossipHello = GossipHello_npc_akama_at_illidan;
     newscript->pGossipSelect = GossipSelect_npc_akama_at_illidan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "boss_maiev_shadowsong";
     newscript->GetAI = GetAI_boss_maiev;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_flame_of_azzinoth";
     newscript->GetAI = GetAI_mob_flame_of_azzinoth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_blade_of_azzinoth";
     newscript->GetAI = GetAI_blade_of_azzinoth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "gameobject_cage_trap";
     newscript->pGOHello = GOHello_cage_trap;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_cage_trap_trigger";
     newscript->GetAI = &GetAI_cage_trap_trigger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_shadow_demon";
     newscript->GetAI = GetAI_shadow_demon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_demon_fire";
     newscript->GetAI = GetAI_demonfire;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_parasitic_shadowfiend";
     newscript->GetAI = GetAI_parasitic_shadowfiend;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_mother_shahraz.cpp (revision 272)
@@ -358,4 +358,4 @@
     newscript->Name="boss_mother_shahraz";
     newscript->GetAI = GetAI_boss_shahraz;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/illidari_council.cpp (revision 272)
@@ -856,29 +856,29 @@
     newscript->Name="mob_illidari_council";
     newscript->GetAI = GetAI_mob_illidari_council;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_blood_elf_council_voice_trigger";
     newscript->GetAI = GetAI_mob_blood_elf_council_voice_trigger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_gathios_the_shatterer";
     newscript->GetAI = GetAI_boss_gathios_the_shatterer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lady_malande";
     newscript->GetAI = GetAI_boss_lady_malande;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_veras_darkshadow";
     newscript->GetAI = GetAI_boss_veras_darkshadow;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_high_nethermancer_zerevor";
     newscript->GetAI = GetAI_boss_high_nethermancer_zerevor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/instance_black_temple.cpp (revision 272)
@@ -333,4 +333,4 @@
     newscript->Name = "instance_black_temple";
     newscript->GetInstanceData = GetInstanceData_instance_black_temple;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_warlord_najentus.cpp (revision 272)
@@ -259,9 +259,9 @@
     newscript->Name="boss_najentus";
     newscript->GetAI = GetAI_boss_najentus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "go_najentus_spine";
     newscript->pGOHello = &GOHello_go_najentus_spine;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_shade_of_akama.cpp (revision 272)
@@ -797,15 +797,15 @@
     newscript->Name="boss_shade_of_akama";
     newscript->GetAI = GetAI_boss_shade_of_akama;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_ashtongue_channeler";
     newscript->GetAI = GetAI_mob_ashtongue_channeler;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_ashtongue_sorcerer";
     newscript->GetAI = GetAI_mob_ashtongue_sorcerer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -814,4 +814,4 @@
     newscript->pGossipHello = &GossipHello_npc_akama;
     newscript->pGossipSelect = &GossipSelect_npc_akama;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_supremus.cpp (revision 272)
@@ -237,9 +237,9 @@
     newscript->Name="boss_supremus";
     newscript->GetAI = GetAI_boss_supremus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="molten_flame";
     newscript->GetAI = GetAI_molten_flame;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_bloodboil.cpp (revision 272)
@@ -362,4 +362,4 @@
     newscript->Name="boss_gurtogg_bloodboil";
     newscript->GetAI = GetAI_boss_gurtogg_bloodboil;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/black_temple/boss_reliquary_of_souls.cpp (revision 272)
@@ -724,24 +724,24 @@
     newscript->Name="boss_reliquary_of_souls";
     newscript->GetAI = GetAI_boss_reliquary_of_souls;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_essence_of_suffering";
     newscript->GetAI = GetAI_boss_essence_of_suffering;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_essence_of_desire";
     newscript->GetAI = GetAI_boss_essence_of_desire;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_essence_of_anger";
     newscript->GetAI = GetAI_boss_essence_of_anger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_enslaved_soul";
     newscript->GetAI = GetAI_npc_enslaved_soul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stonetalon_mountains/stonetalon_mountains.cpp (revision 272)
@@ -77,4 +77,4 @@
     newscript->pGossipHello = &GossipHello_npc_braug_dimspirit;
     newscript->pGossipSelect = &GossipSelect_npc_braug_dimspirit;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_warp_splinter.cpp (revision 272)
@@ -294,9 +294,9 @@
     newscript->Name="boss_warp_splinter";
     newscript->GetAI = GetAI_boss_warp_splinter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_warp_splinter_treant";
     newscript->GetAI = GetAI_mob_treant;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_high_botanist_freywinn.cpp (revision 272)
@@ -212,4 +212,4 @@
     newscript->Name="boss_high_botanist_freywinn";
     newscript->GetAI = GetAI_boss_high_botanist_freywinn;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/botanica/boss_laj.cpp (revision 272)
@@ -195,4 +195,4 @@
     newscript->Name="boss_laj";
     newscript->GetAI = GetAI_boss_laj;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_kaelthas.cpp (revision 272)
@@ -1582,34 +1582,34 @@
     newscript->Name="boss_kaelthas";
     newscript->GetAI = GetAI_boss_kaelthas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_thaladred_the_darkener";
     newscript->GetAI = GetAI_boss_thaladred_the_darkener;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lord_sanguinar";
     newscript->GetAI = GetAI_boss_lord_sanguinar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_grand_astromancer_capernian";
     newscript->GetAI = GetAI_boss_grand_astromancer_capernian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_master_engineer_telonicus";
     newscript->GetAI = GetAI_boss_master_engineer_telonicus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name= "mob_kael_flamestrike";
     newscript->GetAI = GetAI_mob_kael_flamestrike;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_phoenix";
     newscript->GetAI = GetAI_mob_phoenix;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/the_eye.cpp (revision 272)
@@ -95,4 +95,4 @@
     newscript->Name="mob_crystalcore_devastator";
     newscript->GetAI = GetAI_mob_crystalcore_devastator;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_astromancer.cpp (revision 272)
@@ -537,9 +537,9 @@
     newscript->Name="boss_high_astromancer_solarian";
     newscript->GetAI = GetAI_boss_high_astromancer_solarian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_solarium_priest";
     newscript->GetAI = GetAI_mob_solarium_priest;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_alar.cpp (revision 272)
@@ -506,14 +506,14 @@
     newscript->Name="boss_alar";
     newscript->GetAI = GetAI_boss_alar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_ember_of_alar";
     newscript->GetAI = GetAI_mob_ember_of_alar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_flame_patch_alar";
     newscript->GetAI = GetAI_mob_flame_patch_alar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/instance_the_eye.cpp (revision 272)
@@ -173,4 +173,4 @@
     newscript->Name = "instance_the_eye";
     newscript->GetInstanceData = GetInstanceData_instance_the_eye;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_eye/boss_void_reaver.cpp (revision 272)
@@ -196,4 +196,4 @@
     newscript->Name="boss_void_reaver";
     newscript->GetAI = GetAI_boss_void_reaver;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/boss_harbinger_skyriss.cpp (revision 272)
@@ -368,9 +368,9 @@
     newscript->Name="boss_harbinger_skyriss";
     newscript->GetAI = GetAI_boss_harbinger_skyriss;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_harbinger_skyriss_illusion";
     newscript->GetAI = GetAI_boss_harbinger_skyriss_illusion;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/arcatraz.cpp (revision 272)
@@ -576,14 +576,14 @@
     newscript->Name="npc_millhouse_manastorm";
     newscript->GetAI = GetAI_npc_millhouse_manastorm;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_warden_mellichar";
     newscript->GetAI = GetAI_npc_warden_mellichar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_zerekethvoidzone";
     newscript->GetAI = GetAI_mob_zerekethvoidzoneAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/arcatraz/instance_arcatraz.cpp (revision 272)
@@ -221,4 +221,4 @@
     newscript->Name = "instance_arcatraz";
     newscript->GetInstanceData = GetInstanceData_instance_arcatraz;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_nethermancer_sepethrea.cpp (revision 272)
@@ -278,9 +278,9 @@
     newscript->Name="boss_nethermancer_sepethrea";    
     newscript->GetAI = GetAI_boss_nethermancer_sepethrea;    
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;    
     newscript->Name="mob_ragin_flames";    
     newscript->GetAI = GetAI_mob_ragin_flames;    
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 263)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/instance_mechanar.cpp (revision 272)
@@ -87,4 +87,4 @@
     newscript->Name = "instance_mechanar";
     newscript->GetInstanceData = GetInstanceData_instance_mechanar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_gatewatcher_ironhand.cpp (revision 272)
@@ -158,4 +158,4 @@
     newscript->Name="boss_gatewatcher_iron_hand";    
     newscript->GetAI = GetAI_boss_gatewatcher_iron_hand;    
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 263)
+++ /trunk/src/bindings/scripts/scripts/zone/tempest_keep/the_mechanar/boss_pathaleon_the_calculator.cpp (revision 272)
@@ -298,9 +298,9 @@
     newscript->Name="boss_pathaleon_the_calculator";    
     newscript->GetAI = GetAI_boss_pathaleon_the_calculator;    
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;    
     newscript->Name="mob_nether_wraith";    
     newscript->GetAI = GetAI_mob_nether_wraith;    
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stormwind/stormwind_city.cpp (revision 272)
@@ -246,5 +246,5 @@
     newscript->pGossipHello = &GossipHello_npc_archmage_malin;
     newscript->pGossipSelect = &GossipSelect_npc_archmage_malin;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -252,5 +252,5 @@
     newscript->GetAI = GetAI_npc_bartleby;
     newscript->pQuestAccept = &QuestAccept_npc_bartleby;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -258,10 +258,10 @@
     newscript->GetAI = GetAI_npc_dashel_stonefist;
     newscript->pQuestAccept = &QuestAccept_npc_dashel_stonefist;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "npc_general_marcus_jonathan";
     newscript->pReceiveEmote = &ReceiveEmote_npc_general_marcus_jonathan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -269,4 +269,4 @@
     newscript->pGossipHello = &GossipHello_npc_lady_katrana_prestor;
     newscript->pGossipSelect = &GossipSelect_npc_lady_katrana_prestor;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_bug_trio.cpp (revision 272)
@@ -335,14 +335,14 @@
     newscript->Name="boss_kri";
     newscript->GetAI = GetAI_boss_kri;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_vem";
     newscript->GetAI = GetAI_boss_vem;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_yauj";
     newscript->GetAI = GetAI_boss_yauj;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_huhuran.cpp (revision 272)
@@ -140,4 +140,4 @@
     newscript->Name="boss_huhuran";
     newscript->GetAI = GetAI_boss_huhuran;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_twinemperors.cpp (revision 272)
@@ -690,9 +690,9 @@
     newscript->Name="boss_veknilash";
     newscript->GetAI = GetAI_boss_veknilash;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_veklor";
     newscript->GetAI = GetAI_boss_veklor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_fankriss.cpp (revision 272)
@@ -187,4 +187,4 @@
     newscript->Name="boss_fankriss";
     newscript->GetAI = GetAI_boss_fankriss;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_cthun.cpp (revision 272)
@@ -578,21 +578,18 @@
                 if(!map->IsDungeon()) return;
 
-                Map::PlayerList const &PlayerList = map->GetPlayers();
-                for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-                {
-                    if (Player* i_pl = i->getSource())
+                InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+                for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+                {
+                    //Play random sound to the zone
+                    switch (rand()%8)
                     {
-                        //Play random sound to the zone
-                        switch (rand()%8)
-                        {
-                            case 0: i_pl->SendPlaySound(RND_WISPER_1, true); break;
-                            case 1: i_pl->SendPlaySound(RND_WISPER_2, true); break;
-                            case 2: i_pl->SendPlaySound(RND_WISPER_3, true); break;
-                            case 3: i_pl->SendPlaySound(RND_WISPER_4, true); break;
-                            case 4: i_pl->SendPlaySound(RND_WISPER_5, true); break;
-                            case 5: i_pl->SendPlaySound(RND_WISPER_6, true); break;
-                            case 6: i_pl->SendPlaySound(RND_WISPER_7, true); break;
-                            case 7: i_pl->SendPlaySound(RND_WISPER_8, true); break;
-                        }
+                        case 0: (*i)->SendPlaySound(RND_WISPER_1, true); break;
+                        case 1: (*i)->SendPlaySound(RND_WISPER_2, true); break;
+                        case 2: (*i)->SendPlaySound(RND_WISPER_3, true); break;
+                        case 3: (*i)->SendPlaySound(RND_WISPER_4, true); break;
+                        case 4: (*i)->SendPlaySound(RND_WISPER_5, true); break;
+                        case 5: (*i)->SendPlaySound(RND_WISPER_6, true); break;
+                        case 6: (*i)->SendPlaySound(RND_WISPER_7, true); break;
+                        case 7: (*i)->SendPlaySound(RND_WISPER_8, true); break;
                     }
                 }
@@ -1330,34 +1327,34 @@
     newscript->Name="boss_eye_of_cthun";
     newscript->GetAI = GetAI_eye_of_cthun;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_cthun";
     newscript->GetAI = GetAI_cthun;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_eye_tentacle";
     newscript->GetAI = GetAI_eye_tentacle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_claw_tentacle";
     newscript->GetAI = GetAI_claw_tentacle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_giant_claw_tentacle";
     newscript->GetAI = GetAI_giant_claw_tentacle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_giant_eye_tentacle";
     newscript->GetAI = GetAI_giant_eye_tentacle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_giant_flesh_tentacle";
     newscript->GetAI = GetAI_flesh_tentacle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_sartura.cpp (revision 272)
@@ -260,9 +260,9 @@
     newscript->Name="boss_sartura";
     newscript->GetAI = GetAI_boss_sartura;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_sartura_royal_guard";
     newscript->GetAI = GetAI_mob_sartura_royal_guard;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_skeram.cpp (revision 272)
@@ -311,4 +311,4 @@
     newscript->Name="boss_skeram";
     newscript->GetAI = GetAI_boss_skeram;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/boss_ouro.cpp (revision 272)
@@ -137,4 +137,4 @@
     newscript->Name="boss_ouro";
     newscript->GetAI = GetAI_boss_ouro;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/instance_temple_of_ahnqiraj.cpp (revision 272)
@@ -162,4 +162,4 @@
     newscript->Name = "instance_temple_of_ahnqiraj";
     newscript->GetInstanceData = GetInstanceData_instance_temple_of_ahnqiraj;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/temple_of_ahnqiraj/mob_anubisath_sentinel.cpp (revision 272)
@@ -310,5 +310,5 @@
     newscript->Name="mob_anubisath_sentinel";
     newscript->GetAI = GetAI_mob_anubisath_sentinelAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
 
Index: /trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/ironforge/ironforge.cpp (revision 272)
@@ -90,4 +90,4 @@
     newscript->pGossipHello =  &GossipHello_npc_royal_historian_archesonus;
     newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/boss_doomwalker.cpp (revision 272)
@@ -213,4 +213,4 @@
     newscript->Name="boss_doomwalker";
     newscript->GetAI = GetAI_boss_doomwalker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/shadowmoon_valley/shadowmoon_valley.cpp (revision 272)
@@ -1107,15 +1107,15 @@
     newscript->Name = "mob_mature_netherwing_drake";
     newscript->GetAI = GetAI_mob_mature_netherwing_drake;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_enslaved_netherwing_drake";
     newscript->GetAI = GetAI_mob_enslaved_netherwing_drake;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
 	newscript->Name = "mob_dragonmaw_peon";
 	newscript->GetAI = GetAI_mob_dragonmaw_peon;
-	newscript->RegisterSelf();
+	m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1123,10 +1123,10 @@
     newscript->pGossipHello =  &GossipHello_npc_drake_dealer_hurlunk;
     newscript->pGossipSelect = &GossipSelect_npc_drake_dealer_hurlunk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_invis_legion_teleporter";
     newscript->GetAI = GetAI_npc_invis_legion_teleporter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1134,5 +1134,5 @@
     newscript->pGossipHello =  &GossipHello_npcs_flanis_swiftwing_and_kagrosh;
     newscript->pGossipSelect = &GossipSelect_npcs_flanis_swiftwing_and_kagrosh;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1140,5 +1140,5 @@
     newscript->pGossipHello =  &GossipHello_npc_murkblood_overseer;
     newscript->pGossipSelect = &GossipSelect_npc_murkblood_overseer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1146,10 +1146,10 @@
     newscript->pGossipHello =  &GossipHello_npc_neltharaku;
     newscript->pGossipSelect = &GossipSelect_npc_neltharaku;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "npc_karynaku";
     newscript->pQuestAccept = &QuestAccept_npc_karynaku;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -1157,5 +1157,5 @@
     newscript->pGossipHello =  &GossipHello_npc_oronok_tornheart;
     newscript->pGossipSelect = &GossipSelect_npc_oronok_tornheart;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
@@ -1163,10 +1163,10 @@
 	newscript->GetAI = GetAI_Overlord_Morghor;
 	newscript->pQuestAccept = &QuestAccept_Overlord_Morghor;
-	newscript->RegisterSelf();
+	m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
 	newscript->Name = "npc_lord_illidan_stormrage";
 	newscript->GetAI = GetAI_Lord_Illidan;
-	newscript->RegisterSelf();
+	m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
@@ -1175,4 +1175,4 @@
 	newscript->pGossipHello = &GossipHello_npc_yarzill_fly;
 	newscript->pGossipSelect = &GossipSelect_npc_yarzill_fly;
-	newscript->RegisterSelf();
-}
+	m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_gyth.cpp (revision 272)
@@ -202,4 +202,4 @@
     newscript->Name="boss_gyth";
     newscript->GetAI = GetAI_boss_gyth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_warmaster_voone.cpp (revision 272)
@@ -118,4 +118,4 @@
     newscript->Name="boss_warmaster_voone";
     newscript->GetAI = GetAI_boss_warmastervoone;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_halycon.cpp (revision 272)
@@ -92,4 +92,4 @@
     newscript->Name="boss_halycon";
     newscript->GetAI = GetAI_boss_halycon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_the_beast.cpp (revision 272)
@@ -90,4 +90,4 @@
     newscript->Name="boss_the_beast";
     newscript->GetAI = GetAI_boss_thebeast;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_overlord_wyrmthalak.cpp (revision 272)
@@ -124,4 +124,4 @@
     newscript->Name="boss_overlord_wyrmthalak";
     newscript->GetAI = GetAI_boss_overlordwyrmthalak;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_rend_blackhand.cpp (revision 272)
@@ -88,4 +88,4 @@
     newscript->Name="boss_rend_blackhand";
     newscript->GetAI = GetAI_boss_rend_blackhand;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_highlord_omokk.cpp (revision 272)
@@ -128,4 +128,4 @@
     newscript->Name="boss_highlord_omokk";
     newscript->GetAI = GetAI_boss_highlordomokk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_mother_smolderweb.cpp (revision 272)
@@ -83,4 +83,4 @@
     newscript->Name="boss_mother_smolderweb";
     newscript->GetAI = GetAI_boss_mothersmolderweb;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_shadow_hunter_voshgajin.cpp (revision 272)
@@ -92,4 +92,4 @@
     newscript->Name="boss_shadow_hunter_voshgajin";
     newscript->GetAI = GetAI_boss_shadowvosh;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_drakkisath.cpp (revision 272)
@@ -98,4 +98,4 @@
     newscript->Name="boss_drakkisath";
     newscript->GetAI = GetAI_boss_drakkisath;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_pyroguard_emberseer.cpp (revision 272)
@@ -90,4 +90,4 @@
     newscript->Name="boss_pyroguard_emberseer";
     newscript->GetAI = GetAI_boss_pyroguard_emberseer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_spire/boss_quartermaster_zigris.cpp (revision 272)
@@ -82,4 +82,4 @@
     newscript->Name="quartermaster_zigris";
     newscript->GetAI = GetAI_boss_quatermasterzigris;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/elwynn_forest/elwynn_forest.cpp (revision 272)
@@ -95,4 +95,4 @@
     newscript->Name="npc_henze_faulk";
     newscript->GetAI = GetAI_npc_henze_faulk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blasted_lands/blasted_lands.cpp (revision 272)
@@ -150,5 +150,5 @@
     newscript->pGossipHello =  &GossipHello_npc_deathly_usher;
     newscript->pGossipSelect = &GossipSelect_npc_deathly_usher;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -156,4 +156,4 @@
     newscript->pGossipHello =  &GossipHello_npc_fallen_hero_of_horde;
     newscript->pGossipSelect = &GossipSelect_npc_fallen_hero_of_horde;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blasted_lands/boss_kruul.cpp (revision 272)
@@ -179,4 +179,4 @@
     newscript->Name="boss_kruul";
     newscript->GetAI = GetAI_boss_kruul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tanaris/tanaris.cpp (revision 272)
@@ -375,10 +375,10 @@
     newscript->Name="mob_aquementas";
     newscript->GetAI = GetAI_mob_aquementas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_custodian_of_time";
     newscript->GetAI = GetAI_npc_custodian_of_time;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -386,5 +386,5 @@
     newscript->pGossipHello =  &GossipHello_npc_marin_noggenfogger;
     newscript->pGossipSelect = &GossipSelect_npc_marin_noggenfogger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -393,5 +393,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_steward_of_time;
     newscript->pQuestAccept =  &QuestAccept_npc_steward_of_time;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -399,4 +399,4 @@
     newscript->pGossipHello =  &GossipHello_npc_stone_watcher_of_norgannon;
     newscript->pGossipSelect = &GossipSelect_npc_stone_watcher_of_norgannon;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/shattrath/shattrath_city.cpp (revision 272)
@@ -415,5 +415,5 @@
     newscript->pGossipHello =  &GossipHello_npc_raliq_the_drunk;
     newscript->pGossipSelect = &GossipSelect_npc_raliq_the_drunk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -421,5 +421,5 @@
     newscript->GetAI = GetAI_npc_salsalabim;
     newscript->pGossipHello =  &GossipHello_npc_salsalabim;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -427,5 +427,5 @@
     newscript->pGossipHello =  &GossipHello_npc_shattrathflaskvendors;
     newscript->pGossipSelect = &GossipSelect_npc_shattrathflaskvendors;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -433,9 +433,9 @@
     newscript->pGossipHello =  &GossipHello_npc_zephyr;
     newscript->pGossipSelect = &GossipSelect_npc_zephyr;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
        newscript = new Script;
     newscript->Name="npc_kservant";
     newscript->GetAI = GetAI_npc_kservantAI;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/eversong_woods/eversong_woods.cpp (revision 272)
@@ -153,5 +153,5 @@
     newscript->Name="mobs_mana_tapped";
     newscript->GetAI = GetAI_mobs_mana_tapped;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -160,4 +160,4 @@
     newscript->pGossipHello =  &GossipHello_npc_prospector_anvilward;
     newscript->pGossipSelect = &GossipSelect_npc_prospector_anvilward;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_kalecgos.cpp (revision 272)
@@ -369,10 +369,11 @@
         Map *map = m_creature->GetMap();
         if(!map->IsDungeon()) return;
-        Map::PlayerList const &PlayerList = map->GetPlayers();
-        Map::PlayerList::const_iterator i;
-        for(i = PlayerList.begin(); i != PlayerList.end(); ++i)
-            if(Player* i_pl = i->getSource())
-                if(i_pl->HasAura(AURA_SPECTRAL_REALM,0))
-                    i_pl->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
+        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+        InstanceMap::PlayerList::const_iterator i;
+        for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
+        {
+            if((*i)->HasAura(AURA_SPECTRAL_REALM,0))
+                (*i)->RemoveAurasDueToSpell(AURA_SPECTRAL_REALM);
+        }
     }
 
@@ -681,19 +682,19 @@
     newscript->Name="boss_kalecgos";
     newscript->GetAI = GetAI_boss_kalecgos;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_sathrovarr";
     newscript->GetAI = GetAI_boss_Sathrovarr;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_kalec";
     newscript->GetAI = GetAI_boss_kalec;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="kalocegos_teleporter";
     newscript->pGOHello = &GOkalocegos_teleporter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_brutallus.cpp (revision 272)
@@ -179,4 +179,4 @@
     newscript->Name="boss_brutallus";
     newscript->GetAI = GetAI_boss_brutallus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/instance_sunwell_plateau.cpp (revision 272)
@@ -193,4 +193,4 @@
     newscript->Name = "instance_sunwell_plateau";
     newscript->GetInstanceData = GetInstanceData_instance_sunwell_plateau;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_felmyst.cpp (revision 272)
@@ -296,5 +296,5 @@
             break;
         case 2:
-            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
+            if(Player* target = SelectRandomPlayer(150))
             {
                 Creature* Vapor = m_creature->SummonCreature(MOB_VAPOR, target->GetPositionX()-5+rand()%10, target->GetPositionY()-5+rand()%10, target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 9000);
@@ -312,5 +312,5 @@
             DespawnSummons(MOB_VAPOR_TRAIL);
             //m_creature->CastSpell(m_creature, SPELL_VAPOR_SELECT); need core support
-            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
+            if(Player* target = SelectRandomPlayer(150))
             {
                 //target->CastSpell(target, SPELL_VAPOR_SUMMON, true); need core support
@@ -331,5 +331,5 @@
             break;
         case 5:
-            if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
+            if(Player* target = SelectRandomPlayer(150))
             {
                 BreathX = target->GetPositionX();
@@ -434,5 +434,5 @@
                 break;
             case EVENT_ENCAPSULATE:
-                if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 150, true))
+                if(Unit* target = SelectRandomPlayer(150))
                 {
                     m_creature->CastSpell(target, SPELL_ENCAPSULATE_CHANNEL, false);
@@ -516,4 +516,24 @@
         }
     }
+
+    Player* SelectRandomPlayer(float range = 0.0f)
+    {
+        Map *map = m_creature->GetMap();
+        if (!map->IsDungeon()) return NULL;
+
+        InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
+        InstanceMap::PlayerList::iterator i;
+        while(PlayerList.size())
+        {
+            i = PlayerList.begin();
+            advance(i, rand()%PlayerList.size());
+            if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
+                && (*i)->isTargetableForAttack())
+                return *i;
+            else
+                PlayerList.erase(i);
+        }
+        return NULL;
+    }
 };
 
@@ -575,14 +595,14 @@
     newscript->Name="boss_felmyst";
     newscript->GetAI = GetAI_boss_felmyst;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_felmyst_vapor";
     newscript->GetAI = GetAI_mob_felmyst_vapor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_felmyst_trail";
     newscript->GetAI = GetAI_mob_felmyst_trail;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/sunwell_plateau/boss_eredar_twins.cpp (revision 272)
@@ -762,14 +762,14 @@
     newscript->Name="boss_sacrolash";
     newscript->GetAI = GetAI_boss_sacrolash;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_alythess";
     newscript->GetAI = GetAI_boss_alythess;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_shadow_image";
     newscript->GetAI = GetAI_mob_shadow_image;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/moonglade/moonglade.cpp (revision 272)
@@ -546,5 +546,5 @@
     newscript->pGossipHello =  &GossipHello_npc_bunthen_plainswind;
     newscript->pGossipSelect = &GossipSelect_npc_bunthen_plainswind;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -552,5 +552,5 @@
     newscript->pGossipHello =  &GossipHello_npc_great_bear_spirit;
     newscript->pGossipSelect = &GossipSelect_npc_great_bear_spirit;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -558,14 +558,14 @@
     newscript->pGossipHello =  &GossipHello_npc_silva_filnaveth;
     newscript->pGossipSelect = &GossipSelect_npc_silva_filnaveth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="npc_clintar_dreamwalker";
     newscript->pQuestAccept = &QuestAccept_npc_clintar_dreamwalker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_clintar_spirit";
     newscript->GetAI = GetAI_npc_clintar_spirit;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/undercity/undercity.cpp (revision 272)
@@ -246,10 +246,10 @@
     newscript->GetAI = GetAI_npc_lady_sylvanas_windrunner;
     newscript->pChooseReward = &ChooseReward_npc_lady_sylvanas_windrunner;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_highborne_lamenter";
     newscript->GetAI = GetAI_npc_highborne_lamenter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -257,4 +257,4 @@
     newscript->pGossipHello = &GossipHello_npc_parqual_fintallas;
     newscript->pGossipSelect = &GossipSelect_npc_parqual_fintallas;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_broodlord_lashlayer.cpp (revision 272)
@@ -125,4 +125,4 @@
     newscript->Name="boss_broodlord";
     newscript->GetAI = GetAI_boss_broodlord;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_firemaw.cpp (revision 272)
@@ -91,4 +91,4 @@
     newscript->Name="boss_firemaw";
     newscript->GetAI = GetAI_boss_firemaw;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_razorgore.cpp (revision 272)
@@ -128,4 +128,4 @@
     newscript->Name="boss_razorgore";
     newscript->GetAI = GetAI_boss_razorgore;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_flamegor.cpp (revision 272)
@@ -91,4 +91,4 @@
     newscript->Name="boss_flamegor";
     newscript->GetAI = GetAI_boss_flamegor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_chromaggus.cpp (revision 272)
@@ -311,4 +311,4 @@
     newscript->Name="boss_chromaggus";
     newscript->GetAI = GetAI_boss_chromaggus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_vaelastrasz.cpp (revision 272)
@@ -258,4 +258,4 @@
     newscript->pGossipHello = &GossipHello_boss_vael;
     newscript->pGossipSelect = &GossipSelect_boss_vael;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_victor_nefarius.cpp (revision 272)
@@ -391,4 +391,4 @@
     newscript->pGossipHello = &GossipHello_boss_victor_nefarius;
     newscript->pGossipSelect = &GossipSelect_boss_victor_nefarius;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_nefarian.cpp (revision 272)
@@ -224,4 +224,4 @@
     newscript->Name="boss_nefarian";
     newscript->GetAI = GetAI_boss_nefarian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackwing_lair/boss_ebonroc.cpp (revision 272)
@@ -100,4 +100,4 @@
     newscript->Name="boss_ebonroc";
     newscript->GetAI = GetAI_boss_ebonroc;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/searing_gorge/searing_gorge.cpp (revision 272)
@@ -144,5 +144,5 @@
     newscript->pGossipHello =  &GossipHello_npc_kalaran_windblade;
     newscript->pGossipSelect = &GossipSelect_npc_kalaran_windblade;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -150,5 +150,5 @@
     newscript->pGossipHello          = &GossipHello_npc_lothos_riftwaker;
     newscript->pGossipSelect         = &GossipSelect_npc_lothos_riftwaker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -156,4 +156,4 @@
     newscript->pGossipHello =  &GossipHello_npc_zamael_lunthistle;
     newscript->pGossipSelect = &GossipSelect_npc_zamael_lunthistle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blades_edge_mountains/blades_edge_mountains.cpp (revision 272)
@@ -407,15 +407,15 @@
     newscript->Name="mobs_bladespire_ogre";
     newscript->GetAI = GetAI_mobs_bladespire_ogre;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mobs_nether_drake";
     newscript->GetAI = GetAI_mobs_nether_drake;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_daranelle";
     newscript->GetAI = GetAI_npc_daranelle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -423,5 +423,5 @@
     newscript->pGossipHello = &GossipHello_npc_overseer_nuaar;
     newscript->pGossipSelect = &GossipSelect_npc_overseer_nuaar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -429,5 +429,5 @@
     newscript->pGossipHello = &GossipHello_npc_saikkal_the_elder;
     newscript->pGossipSelect = &GossipSelect_npc_saikkal_the_elder;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -435,4 +435,4 @@
     newscript->pGossipHello =  &GossipHello_npc_skyguard_handler_irena;
     newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_irena;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_nexusprince_shaffar.cpp (revision 272)
@@ -272,9 +272,9 @@
     newscript->Name="boss_nexusprince_shaffar";
     newscript->GetAI = GetAI_boss_nexusprince_shaffar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_ethereal_beacon";
     newscript->GetAI = GetAI_mob_ethereal_beacon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/mana_tombs/boss_pandemonius.cpp (revision 272)
@@ -135,4 +135,4 @@
     newscript->Name="boss_pandemonius";
     newscript->GetAI = GetAI_boss_pandemonius;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/auchenai_crypts/boss_exarch_maladaar.cpp (revision 272)
@@ -349,14 +349,14 @@
     newscript->Name="boss_exarch_maladaar";
     newscript->GetAI = GetAI_boss_exarch_maladaar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_avatar_of_martyred";
     newscript->GetAI = GetAI_mob_avatar_of_martyred;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_stolen_soul";
     newscript->GetAI = GetAI_mob_stolen_soul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/instance_sethekk_halls.cpp (revision 272)
@@ -71,4 +71,4 @@
     newscript->Name = "instance_sethekk_halls";
     newscript->GetInstanceData = GetInstanceData_instance_sethekk_halls;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_tailonking_ikiss.cpp (revision 272)
@@ -220,4 +220,4 @@
     newscript->Name="boss_talon_king_ikiss";
     newscript->GetAI = GetAI_boss_talon_king_ikiss;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/sethekk_halls/boss_darkweaver_syth.cpp (revision 272)
@@ -393,24 +393,24 @@
     newscript->Name="boss_darkweaver_syth";
     newscript->GetAI = GetAI_boss_darkweaver_syth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_syth_fire";
     newscript->GetAI = GetAI_mob_syth_arcane;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_syth_arcane";
     newscript->GetAI = GetAI_mob_syth_arcane;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_syth_frost";
     newscript->GetAI = GetAI_mob_syth_frost;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_syth_shadow";
     newscript->GetAI = GetAI_mob_syth_shadow;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_blackheart_the_inciter.cpp (revision 272)
@@ -174,4 +174,4 @@
     newscript->Name="boss_blackheart_the_inciter";
     newscript->GetAI = GetAI_boss_blackheart_the_inciter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/instance_shadow_labyrinth.cpp (revision 272)
@@ -175,4 +175,4 @@
     newscript->Name = "instance_shadow_labyrinth";
     newscript->GetInstanceData = GetInstanceData_instance_shadow_labyrinth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_grandmaster_vorpil.cpp (revision 272)
@@ -221,5 +221,16 @@
         if ( DrawnShadows_Timer < diff)
         {
-            DoTeleportAll(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
+            Map *map = m_creature->GetMap();
+            if(map->IsDungeon())
+            {
+                InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+                for (InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+                {
+                    if((*i)->isAlive())
+                    {
+                        (*i)->TeleportTo(555,VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
+                    }
+                }
+            }
             m_creature->Relocate(VorpilPosition[0][0],VorpilPosition[0][1],VorpilPosition[0][2],0);
             DoCast(m_creature,SPELL_DRAWN_SHADOWS,true);
@@ -364,9 +375,9 @@
     newscript->Name="boss_grandmaster_vorpil";
     newscript->GetAI = GetAI_boss_grandmaster_vorpil;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_voidtraveler";
     newscript->GetAI = GetAI_mob_voidtraveler;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_ambassador_hellmaw.cpp (revision 272)
@@ -195,4 +195,4 @@
     newscript->Name="boss_ambassador_hellmaw";
     newscript->GetAI = GetAI_boss_ambassador_hellmaw;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/aunchindoun/shadow_labyrinth/boss_murmur.cpp (revision 272)
@@ -149,4 +149,4 @@
     newscript->Name="boss_murmur";
     newscript->GetAI = GetAI_boss_murmur;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zangarmarsh/zangarmarsh.cpp (revision 272)
@@ -262,5 +262,5 @@
     newscript->pGossipHello =  &GossipHello_npcs_ashyen_and_keleth;
     newscript->pGossipSelect = &GossipSelect_npcs_ashyen_and_keleth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -268,5 +268,5 @@
     newscript->pGossipHello =  &GossipHello_npc_cooshcoosh;
     newscript->pGossipSelect = &GossipSelect_npc_cooshcoosh;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -274,5 +274,5 @@
     newscript->pGossipHello =  &GossipHello_npc_elder_kuruti;
     newscript->pGossipSelect = &GossipSelect_npc_elder_kuruti;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -280,4 +280,4 @@
     newscript->pGossipHello =  &GossipHello_npc_mortog_steamhead;
     newscript->pGossipSelect = &GossipSelect_npc_mortog_steamhead;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/thunder_bluff/thunder_bluff.cpp (revision 272)
@@ -133,4 +133,4 @@
     newscript->pGossipHello = &GossipHello_npc_cairne_bloodhoof;
     newscript->pGossipSelect = &GossipSelect_npc_cairne_bloodhoof;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_hydromancer_thespia.cpp (revision 272)
@@ -189,9 +189,9 @@
     newscript->Name="boss_hydromancer_thespia";
     newscript->GetAI = GetAI_boss_thespiaAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_coilfang_waterelemental";
     newscript->GetAI = GetAI_mob_coilfang_waterelementalAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_warlord_kalithresh.cpp (revision 272)
@@ -227,9 +227,9 @@
     newscript->Name="mob_naga_distiller";
     newscript->GetAI = GetAI_mob_naga_distiller;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_warlord_kalithresh";
     newscript->GetAI = GetAI_boss_warlord_kalithresh;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/boss_mekgineer_steamrigger.cpp (revision 272)
@@ -272,9 +272,9 @@
     newscript->Name="boss_mekgineer_steamrigger";
     newscript->GetAI = GetAI_boss_mekgineer_steamrigger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_steamrigger_mechanic";
     newscript->GetAI = GetAI_mob_steamrigger_mechanic;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/steam_vault/instance_steam_vault.cpp (revision 272)
@@ -167,4 +167,4 @@
     newscript->Name = "instance_steam_vault";
     newscript->GetInstanceData = GetInstanceData_instance_steam_vault;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/underbog/boss_hungarfen.cpp (revision 272)
@@ -148,9 +148,9 @@
     newscript->Name="boss_hungarfen";
     newscript->GetAI = GetAI_boss_hungarfen;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_underbog_mushroom";
     newscript->GetAI = GetAI_mob_underbog_mushroom;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_hydross_the_unstable.cpp (revision 272)
@@ -383,4 +383,4 @@
     newscript->Name="boss_hydross_the_unstable";
     newscript->GetAI = GetAI_boss_hydross_the_unstable;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lurker_below.cpp (revision 272)
@@ -168,15 +168,15 @@
     newscript->Name="boss_the_lurker_below";
     newscript->GetAI = GetAI_boss_the_lurker_below;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="mob_coilfang_guardian";
     newscript->GetAI = GetAI_mob_coilfang_guardian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="mob_coilfang_ambusher";
     newscript->GetAI = GetAI_mob_coilfang_ambusher;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
 
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_leotheras_the_blind.cpp (revision 272)
@@ -755,20 +755,17 @@
 		{
 			Map *map = m_creature->GetMap();
-			Map::PlayerList const &PlayerList = map->GetPlayers();
-			for(Map::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
+			InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+			for(InstanceMap::PlayerList::const_iterator itr = PlayerList.begin();itr != PlayerList.end(); ++itr)
             {
-                if (Player* i_pl = itr->getSource())
-                {
-				    bool isCasting = false;
-				    for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
-					    if(i_pl->m_currentSpells[i])
-						    isCasting = true;
-    				
-				    if(isCasting)
-				    {
-					    DoCast(i_pl, SPELL_EARTHSHOCK);
-					    break;
-				    }
-                }
+				bool isCasting = false;
+				for(uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
+					if((*itr)->m_currentSpells[i])
+						isCasting = true;
+				
+				if(isCasting)
+				{
+					DoCast((*itr), SPELL_EARTHSHOCK);
+					break;
+				}
 			}
 			Earthshock_Timer = 8000 + rand()%7000;
@@ -805,19 +802,19 @@
     newscript->Name="boss_leotheras_the_blind";
     newscript->GetAI = GetAI_boss_leotheras_the_blind;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_leotheras_the_blind_demonform";
     newscript->GetAI = GetAI_boss_leotheras_the_blind_demonform;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="mob_greyheart_spellbinder";
     newscript->GetAI = GetAI_mob_greyheart_spellbinder;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="mob_inner_demon";
     newscript->GetAI = GetAI_mob_inner_demon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_lady_vashj.cpp (revision 272)
@@ -251,10 +251,10 @@
 			//remove old tainted cores to prevent cheating in phase 2
 			Map *map = m_creature->GetMap();
-			Map::PlayerList const &PlayerList = map->GetPlayers();
-			for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
-            {
-                if(Player* i_pl = i->getSource())
+			InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+			for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
+            {
+                if((*i))
                 {
-                    i_pl->DestroyItemCount(31088, 1, true);
+                    (*i)->DestroyItemCount(31088, 1, true);
                 }
             }
@@ -1030,40 +1030,40 @@
     newscript->Name="boss_lady_vashj";
     newscript->GetAI = GetAI_boss_lady_vashj;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_enchanted_elemental";
     newscript->GetAI = GetAI_mob_enchanted_elemental;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_tainted_elemental";
     newscript->GetAI = GetAI_mob_tainted_elemental;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_toxic_sporebat";
     newscript->GetAI = GetAI_mob_toxic_sporebat;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_coilfang_elite";
     newscript->GetAI = GetAI_mob_coilfang_elite;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_coilfang_strider";
     newscript->GetAI = GetAI_mob_coilfang_strider;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_shield_generator_channel";
     newscript->GetAI = GetAI_mob_shield_generator_channel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_tainted_core";
     newscript->pItemUse = ItemUse_item_tainted_core;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
 
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp (revision 272)
@@ -745,19 +745,19 @@
     newscript->Name="boss_fathomlord_karathress";
     newscript->GetAI = GetAI_boss_fathomlord_karathress;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_sharkkis";
     newscript->GetAI = GetAI_boss_fathomguard_sharkkis;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_tidalvess";
     newscript->GetAI = GetAI_boss_fathomguard_tidalvess;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_fathomguard_caribdis";
     newscript->GetAI = GetAI_boss_fathomguard_caribdis;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_morogrim_tidewalker.cpp (revision 272)
@@ -351,9 +351,9 @@
     newscript->Name="boss_morogrim_tidewalker";
     newscript->GetAI = GetAI_boss_morogrim_tidewalker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_water_globule";
     newscript->GetAI = GetAI_mob_water_globule;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/instance_serpent_shrine.cpp (revision 272)
@@ -216,4 +216,4 @@
     newscript->Name = "instance_serpent_shrine";
     newscript->GetInstanceData = GetInstanceData_instance_serpentshrine_cavern;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_moam.cpp (revision 272)
@@ -114,4 +114,4 @@
     newscript->Name="boss_moam";
     newscript->GetAI = GetAI_boss_moam;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_ayamiss.cpp (revision 272)
@@ -104,4 +104,4 @@
     newscript->Name="boss_ayamiss";
     newscript->GetAI = GetAI_boss_ayamiss;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/ruins_of_ahnqiraj/boss_kurinnaxx.cpp (revision 272)
@@ -90,4 +90,4 @@
     newscript->Name="boss_kurinnaxx";
     newscript->GetAI = GetAI_boss_kurinnaxx;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/onyxias_lair/boss_onyxia.cpp (revision 272)
@@ -230,4 +230,4 @@
     newscript->Name="boss_onyxia";
     newscript->GetAI = GetAI_boss_onyxiaAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/dun_morogh/dun_morogh.cpp (revision 272)
@@ -95,4 +95,4 @@
     newscript->Name="npc_narm_faulk";
     newscript->GetAI = GetAI_npc_narm_faulk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_aeonus.cpp (revision 272)
@@ -118,4 +118,4 @@
     newscript->Name="boss_aeonus";
     newscript->GetAI = GetAI_boss_aeonus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_chrono_lord_deja.cpp (revision 272)
@@ -106,4 +106,4 @@
     newscript->Name="boss_chrono_lord_deja";
     newscript->GetAI = GetAI_boss_chrono_lord_deja;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/dark_portal/boss_temporus.cpp (revision 272)
@@ -140,4 +140,4 @@
     newscript->Name="boss_temporus";
     newscript->GetAI = GetAI_boss_temporus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/old_hillsbrad.cpp (revision 272)
@@ -894,5 +894,5 @@
     newscript->pGossipHello =   &GossipHello_npc_brazen;
     newscript->pGossipSelect =  &GossipSelect_npc_brazen;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -900,5 +900,5 @@
     newscript->pGossipHello =   &GossipHello_npc_erozion;
     newscript->pGossipSelect =  &GossipSelect_npc_erozion;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -907,5 +907,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_thrall_old_hillsbrad;
     newscript->GetAI = GetAI_npc_thrall_old_hillsbrad;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -913,4 +913,4 @@
     newscript->pGossipHello =   &GossipHello_npc_taretha;
     newscript->pGossipSelect =  &GossipSelect_npc_taretha;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_captain_skarloc.cpp (revision 272)
@@ -153,4 +153,4 @@
     newscript->Name="boss_captain_skarloc";
     newscript->GetAI = GetAI_boss_captain_skarloc;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/instance_old_hillsbrad.cpp (revision 272)
@@ -175,4 +175,4 @@
     newscript->Name = "instance_old_hillsbrad";
     newscript->GetInstanceData = GetInstanceData_instance_old_hillsbrad;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_epoch_hunter.cpp (revision 272)
@@ -147,4 +147,4 @@
     newscript->Name="boss_epoch_hunter";
     newscript->GetAI = GetAI_boss_epoch_hunter;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/old_hillsbrad/boss_leutenant_drake.cpp (revision 272)
@@ -195,9 +195,9 @@
     newscript->Name="go_barrel_old_hillsbrad";
     newscript->pGOHello = &GOHello_go_barrel_old_hillsbrad;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lieutenant_drake";
     newscript->GetAI = GetAI_boss_lieutenant_drake;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/boss_archimonde.cpp (revision 272)
@@ -770,19 +770,19 @@
     newscript->Name="boss_archimonde";
     newscript->GetAI = GetAI_boss_archimonde;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_doomfire";
     newscript->GetAI = GetAI_mob_doomfire;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_doomfire_targetting";
     newscript->GetAI = GetAI_mob_doomfire_targetting;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_ancient_wisp";
     newscript->GetAI = GetAI_mob_ancient_wisp;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp (revision 270)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjalAI.cpp (revision 272)
@@ -302,5 +302,5 @@
     data << value;
 
-    map->SendToPlayers(&data);
+    ((InstanceMap*)map)->SendToPlayers(&data);
 
     // TODO: Uncomment and remove everything above this line only when the core patch for this is accepted
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/hyjal.cpp (revision 272)
@@ -201,5 +201,5 @@
     newscript->pGossipHello = &GossipHello_npc_jaina_proudmoore;
     newscript->pGossipSelect = &GossipSelect_npc_jaina_proudmoore;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -208,5 +208,5 @@
     newscript->pGossipHello = &GossipHello_npc_thrall;
     newscript->pGossipSelect = &GossipSelect_npc_thrall;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -214,4 +214,4 @@
     newscript->pGossipHello = &GossipHello_npc_tyrande_whisperwind;
     newscript->pGossipSelect = &GossipSelect_npc_tyrande_whisperwind;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 270)
+++ /trunk/src/bindings/scripts/scripts/zone/caverns_of_time/hyjal/instance_hyjal.cpp (revision 272)
@@ -150,5 +150,5 @@
         data << value;
 
-        instance->SendToPlayers(&data);
+        ((InstanceMap*)instance)->SendToPlayers(&data);
     }
 
@@ -200,4 +200,4 @@
     newscript->Name = "instance_hyjal";
     newscript->GetInstanceData = GetInstanceData_instance_mount_hyjal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/burning_steppes/burning_steppes.cpp (revision 272)
@@ -148,4 +148,4 @@
     newscript->pGossipHello =  &GossipHello_npc_ragged_john;
     newscript->pGossipSelect = &GossipSelect_npc_ragged_john;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/alterac_mountains/alterac_mountains.cpp (revision 272)
@@ -59,4 +59,4 @@
     newscript->Name="npc_ravenholdt";
     newscript->GetAI = GetAI_npc_ravenholdt;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/nagrand/nagrand.cpp (revision 272)
@@ -632,5 +632,5 @@
     newscript->Name="mob_shattered_rumbler";
     newscript->GetAI = GetAI_mob_shattered_rumbler;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -639,10 +639,10 @@
     newscript->pGossipHello =  &GossipHello_mob_lump;
     newscript->pGossipSelect = &GossipSelect_mob_lump;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_sunspring_villager";
     newscript->GetAI = GetAI_mob_sunspring_villager;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -651,5 +651,5 @@
     newscript->pGossipSelect = &GossipSelect_npc_altruis_the_sufferer;
     newscript->pQuestAccept =  &QuestAccept_npc_altruis_the_sufferer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -657,5 +657,5 @@
     newscript->pGossipHello =  &GossipHello_npc_greatmother_geyah;
     newscript->pGossipSelect = &GossipSelect_npc_greatmother_geyah;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -663,14 +663,14 @@
     newscript->pGossipHello =  &GossipHello_npc_lantresor_of_the_blade;
     newscript->pGossipSelect = &GossipSelect_npc_lantresor_of_the_blade;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_creditmarker_visit_with_ancestors";
     newscript->GetAI = GetAI_npc_creditmarker_visit_with_ancestors;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_sparrowhawk";
     newscript->GetAI = GetAI_mob_sparrowhawk;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/eastern_plaguelands/eastern_plaguelands.cpp (revision 272)
@@ -159,5 +159,5 @@
     newscript->Name="mobs_ghoul_flayer";
     newscript->GetAI = GetAI_mobs_ghoul_flayer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -165,5 +165,5 @@
     newscript->pGossipHello = &GossipHello_npc_augustus_the_touched;
     newscript->pGossipSelect = &GossipSelect_npc_augustus_the_touched;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -171,5 +171,5 @@
     newscript->GetAI = GetAI_npc_darrowshire_spirit;
     newscript->pGossipHello = &GossipHello_npc_darrowshire_spirit;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -177,4 +177,4 @@
     newscript->pGossipHello =  &GossipHello_npc_tirion_fordring;
     newscript->pGossipSelect = &GossipSelect_npc_tirion_fordring;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/shadowfang_keep.cpp (revision 272)
@@ -114,4 +114,4 @@
     newscript->pGossipSelect = &GossipSelect_npc_shadowfang_prisoner;
     newscript->GetAI = GetAI_npc_shadowfang_prisoner;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/shadowfang_keep/instance_shadowfang_keep.cpp (revision 272)
@@ -149,4 +149,4 @@
     newscript->Name = "instance_shadowfang_keep";
     newscript->GetInstanceData = GetInstanceData_instance_shadowfang_keep;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_gruul.cpp (revision 272)
@@ -301,4 +301,4 @@
     newscript->Name="boss_gruul";
     newscript->GetAI = GetAI_boss_gruul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/gruuls_lair/boss_high_king_maulgar.cpp (revision 272)
@@ -818,24 +818,24 @@
     newscript->Name="boss_high_king_maulgar";
     newscript->GetAI = GetAI_boss_high_king_maulgar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_kiggler_the_crazed";
     newscript->GetAI = GetAI_boss_kiggler_the_crazed;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_blindeye_the_seer";
     newscript->GetAI = GetAI_boss_blindeye_the_seer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_olm_the_summoner";
     newscript->GetAI = GetAI_boss_olm_the_summoner;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_krosh_firehand";
     newscript->GetAI = GetAI_boss_krosh_firehand;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/gruuls_lair/instance_gruuls_lair.cpp (revision 272)
@@ -185,4 +185,4 @@
     newscript->Name = "instance_gruuls_lair";
     newscript->GetInstanceData = GetInstanceData_instance_gruuls_lair;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/bloodmyst_isle/bloodmyst_isle.cpp (revision 272)
@@ -132,5 +132,5 @@
     newscript->Name="mob_webbed_creature";
     newscript->GetAI = GetAI_mob_webbed_creature;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -138,4 +138,4 @@
     newscript->pGossipHello =  &GossipHello_npc_captured_sunhawk_agent;
     newscript->pGossipSelect = &GossipSelect_npc_captured_sunhawk_agent;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/winterspring/winterspring.cpp (revision 272)
@@ -142,5 +142,5 @@
     newscript->pGossipHello =  &GossipHello_npc_lorax;
     newscript->pGossipSelect = &GossipSelect_npc_lorax;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -148,5 +148,5 @@
     newscript->pGossipHello =  &GossipHello_npc_rivern_frostwind;
     newscript->pGossipSelect = &GossipSelect_npc_rivern_frostwind;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -154,4 +154,4 @@
     newscript->pGossipHello =  &GossipHello_npc_witch_doctor_mauari;
     newscript->pGossipSelect = &GossipSelect_npc_witch_doctor_mauari;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/barrens/the_barrens.cpp (revision 272)
@@ -370,5 +370,5 @@
     newscript->pGossipHello = &GossipHello_npc_beaten_corpse;
     newscript->pGossipSelect = &GossipSelect_npc_beaten_corpse;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -376,5 +376,5 @@
     newscript->pGossipHello = &GossipHello_npc_sputtervalve;
     newscript->pGossipSelect = &GossipSelect_npc_sputtervalve;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -382,9 +382,9 @@
     newscript->GetAI = GetAI_npc_taskmaster_fizzule;
     newscript->pReceiveEmote = &ReciveEmote_npc_taskmaster_fizzule;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_twiggy_flathead";
     newscript->GetAI = GetAI_npc_twiggy_flathead;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/tirisfal_glades/tirisfal_glades.cpp (revision 272)
@@ -85,4 +85,4 @@
     newscript->GetAI = GetAI_npc_calvin_montague;
     newscript->pQuestAccept = &QuestAccept_npc_calvin_montague;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/silvermoon/silvermoon_city.cpp (revision 272)
@@ -100,4 +100,4 @@
     newscript->Name="npc_blood_knight_stillblade";
     newscript->GetAI = GetAI_npc_blood_knight_stillblade;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_interrogator_vishas.cpp (revision 272)
@@ -110,4 +110,4 @@
     newscript->Name="boss_interrogator_vishas";
     newscript->GetAI = GetAI_boss_interrogator_vishas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_azshir_the_sleepless.cpp (revision 272)
@@ -94,4 +94,4 @@
     newscript->Name="boss_azshir_the_sleepless";
     newscript->GetAI = GetAI_boss_azshir_the_sleepless;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_houndmaster_loksey.cpp (revision 272)
@@ -75,4 +75,4 @@
     newscript->Name="boss_houndmaster_loksey";
     newscript->GetAI = GetAI_boss_houndmaster_loksey;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_bloodmage_thalnos.cpp (revision 272)
@@ -133,4 +133,4 @@
     newscript->Name="boss_bloodmage_thalnos";
     newscript->GetAI = GetAI_boss_bloodmage_thalnos;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_herod.cpp (revision 272)
@@ -194,4 +194,4 @@
     newscript->Name="boss_herod";
     newscript->GetAI = GetAI_boss_herod;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scarlet_commander_mograine.cpp (revision 272)
@@ -157,4 +157,4 @@
     newscript->Name="boss_scarlet_commander_mograine";
     newscript->GetAI = GetAI_boss_scarlet_commander_mograine;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_scorn.cpp (revision 272)
@@ -97,4 +97,4 @@
     newscript->Name="boss_scorn";
     newscript->GetAI = GetAI_boss_scorn;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_arcanist_doan.cpp (revision 272)
@@ -168,4 +168,4 @@
     newscript->Name="boss_arcanist_doan";
     newscript->GetAI = GetAI_boss_arcanist_doan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_fairbanks.cpp (revision 272)
@@ -129,4 +129,4 @@
     newscript->Name="boss_high_inquisitor_fairbanks";
     newscript->GetAI = GetAI_boss_high_inquisitor_fairbanks;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scarlet_monastery/boss_high_inquisitor_whitemane.cpp (revision 272)
@@ -174,4 +174,4 @@
     newscript->Name="boss_high_inquisitor_whitemane";
     newscript->GetAI = GetAI_boss_high_inquisitor_whitemane;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_shade_of_aran.cpp (revision 272)
@@ -655,19 +655,19 @@
     newscript->Name="boss_shade_of_aran";
     newscript->GetAI = GetAI_boss_aran;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_shadow_of_aran";
     newscript->GetAI = GetAI_shadow_of_aran;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_aran_elemental";
     newscript->GetAI = GetAI_water_elemental;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     //newscript = new Script;
     //newscript->Name="mob_aran_blizzard";
     //newscript->GetAI = GetAI_boss_aran;
-    //newscript->RegisterSelf();
+    //m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/karazhan.cpp (revision 272)
@@ -286,12 +286,12 @@
                     if(!map->IsDungeon()) return;
 
-                    Map::PlayerList const &PlayerList = map->GetPlayers();
-                    if(PlayerList.isEmpty())
+                    InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+                    if(PlayerList.empty())
                         return;
 
                     RaidWiped = true;
-                    for(Map::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
+                    for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin();i != PlayerList.end(); ++i)
                     {
-                        if (i->getSource()->isAlive() && !i->getSource()->isGameMaster())
+                        if((*i)->isAlive() && !(*i)->isGameMaster())
                         {
                             RaidWiped = false;
@@ -461,5 +461,5 @@
     newscript->pGossipHello = GossipHello_npc_barnes;
     newscript->pGossipSelect = GossipSelect_npc_barnes;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -467,4 +467,4 @@
     newscript->pGossipHello = GossipHello_npc_berthold;
     newscript->pGossipSelect = GossipSelect_npc_berthold;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_terestian_illhoof.cpp (revision 272)
@@ -437,19 +437,19 @@
     newscript->Name="boss_terestian_illhoof";
     newscript->GetAI = GetAI_boss_terestian_illhoof;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_karazhan_imp";
     newscript->GetAI = GetAI_mob_karazhan_imp;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_kilrek";
     newscript->GetAI = GetAI_mob_kilrek;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_demon_chain";
     newscript->GetAI = GetAI_mob_demon_chain;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/instance_karazhan.cpp (revision 272)
@@ -250,4 +250,4 @@
     newscript->Name = "instance_karazhan";
     newscript->GetInstanceData = GetInstanceData_instance_karazhan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/bosses_opera.cpp (revision 272)
@@ -1415,35 +1415,35 @@
     newscript->GetAI = GetAI_boss_dorothee;
     newscript->Name = "boss_dorothee";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_strawman;
     newscript->Name = "boss_strawman";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_tinhead;
     newscript->Name = "boss_tinhead";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_roar;
     newscript->Name = "boss_roar";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_crone;
     newscript->Name = "boss_crone";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_mob_tito;
     newscript->Name = "mob_tito";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_mob_cyclone;
     newscript->Name = "mob_cyclone";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     // Hood
@@ -1452,10 +1452,10 @@
     newscript->pGossipSelect = GossipSelect_npc_grandmother;
     newscript->Name = "npc_grandmother";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_bigbadwolf;
     newscript->Name = "boss_bigbadwolf";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     // Romeo And Juliet
@@ -1463,9 +1463,9 @@
     newscript->GetAI = GetAI_boss_julianne;
     newscript->Name = "boss_julianne";
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->GetAI = GetAI_boss_romulo;
     newscript->Name = "boss_romulo";
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_curator.cpp (revision 272)
@@ -197,4 +197,4 @@
     newscript->Name="boss_curator";
     newscript->GetAI = GetAI_boss_curator;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_maiden_of_virtue.cpp (revision 272)
@@ -180,4 +180,4 @@
     newscript->Name="boss_maiden_of_virtue";
     newscript->GetAI = GetAI_boss_maiden_of_virtue;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_midnight.cpp (revision 272)
@@ -363,9 +363,9 @@
     newscript->Name="boss_attumen";
     newscript->GetAI = GetAI_boss_attumen;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_midnight";
     newscript->GetAI = GetAI_boss_midnight;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_moroes.cpp (revision 272)
@@ -836,34 +836,34 @@
     newscript->Name="boss_moroes";
     newscript->GetAI = GetAI_boss_moroes;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_baroness_dorothea_millstipe";
     newscript->GetAI = GetAI_baroness_dorothea_millstipe;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_baron_rafe_dreuger";
     newscript->GetAI = GetAI_baron_rafe_dreuger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lady_catriona_von_indi";
     newscript->GetAI = GetAI_lady_catriona_von_indi;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lady_keira_berrybuck";
     newscript->GetAI = GetAI_lady_keira_berrybuck;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lord_robin_daris";
     newscript->GetAI = GetAI_lord_robin_daris;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lord_crispin_ference";
     newscript->GetAI = GetAI_lord_crispin_ference;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/karazhan/boss_prince_malchezaar.cpp (revision 272)
@@ -667,9 +667,9 @@
     newscript->Name="boss_malchezaar";
     newscript->GetAI = GetAI_boss_malchezaar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="netherspite_infernal";
     newscript->GetAI = GetAI_netherspite_infernal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/felwood/felwood.cpp (revision 272)
@@ -86,4 +86,4 @@
     newscript->pGossipHello = &GossipHello_npcs_riverbreeze_and_silversky;
     newscript->pGossipSelect = &GossipSelect_npcs_riverbreeze_and_silversky;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/dustwallow_marsh/dustwallow_marsh.cpp (revision 272)
@@ -205,10 +205,10 @@
     newscript->Name="mobs_risen_husk_spirit";
     newscript->GetAI = GetAI_mobs_risen_husk_spirit;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_restless_apparition";
     newscript->pGossipHello =   &GossipHello_npc_restless_apparition;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -216,5 +216,5 @@
     newscript->GetAI = GetAI_npc_deserter_agitator;
     newscript->pGossipHello = &GossipHello_npc_deserter_agitator;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -222,5 +222,5 @@
     newscript->pGossipHello = &GossipHello_npc_lady_jaina_proudmoore;
     newscript->pGossipSelect = &GossipSelect_npc_lady_jaina_proudmoore;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -228,4 +228,4 @@
     newscript->pGossipHello = &GossipHello_npc_nat_pagle;
     newscript->pGossipSelect = &GossipSelect_npc_nat_pagle;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/orgrimmar/orgrimmar.cpp (revision 272)
@@ -248,5 +248,5 @@
     newscript->pGossipHello =  &GossipHello_npc_neeru_fireblade;
     newscript->pGossipSelect = &GossipSelect_npc_neeru_fireblade;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -255,5 +255,5 @@
     newscript->pQuestAccept =  &QuestAccept_npc_shenthul;
     newscript->pReceiveEmote = &ReciveEmote_npc_shenthul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -262,4 +262,4 @@
     newscript->pGossipHello =  &GossipHello_npc_thrall_warchief;
     newscript->pGossipSelect = &GossipSelect_npc_thrall_warchief;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/razorfen_downs/boss_amnennar_the_coldbringer.cpp (revision 272)
@@ -137,4 +137,4 @@
     newscript->Name="boss_amnennar_the_coldbringer";
     newscript->GetAI = GetAI_boss_amnennar_the_coldbringer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulfarrak/zulfarrak.cpp (revision 272)
@@ -214,5 +214,5 @@
     newscript->pGossipHello =  &GossipHello_npc_sergeant_bly;
     newscript->pGossipSelect = &GossipSelect_npc_sergeant_bly;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -221,4 +221,4 @@
     newscript->pGossipHello =  &GossipHello_npc_weegli_blastfuse;
     newscript->pGossipSelect = &GossipSelect_npc_weegli_blastfuse;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stranglethorn_vale/stranglethorn_vale.cpp (revision 272)
@@ -104,4 +104,4 @@
     newscript->Name = "mob_yenniku";
     newscript->GetAI = GetAI_mob_yenniku;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_high_interrogator_gerstahn.cpp (revision 272)
@@ -102,4 +102,4 @@
     newscript->Name="boss_high_interrogator_gerstahn";
     newscript->GetAI = GetAI_boss_high_interrogator_gerstahn;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_seethrel.cpp (revision 272)
@@ -112,4 +112,4 @@
     newscript->Name="boss_seethrel";
     newscript->GetAI = GetAI_boss_seethrel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/blackrock_depths.cpp (revision 272)
@@ -222,5 +222,5 @@
     newscript->Name="phalanx";
     newscript->GetAI = GetAI_mob_phalanx;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -228,5 +228,5 @@
     newscript->pGossipHello =  &GossipHello_npc_kharan_mighthammer;
     newscript->pGossipSelect = &GossipSelect_npc_kharan_mighthammer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -234,4 +234,4 @@
     newscript->pGossipHello =  &GossipHello_npc_lokhtos_darkbargainer;
     newscript->pGossipSelect = &GossipSelect_npc_lokhtos_darkbargainer;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_general_angerforge.cpp (revision 272)
@@ -164,4 +164,4 @@
     newscript->Name="boss_general_angerforge";
     newscript->GetAI = GetAI_boss_general_angerforge;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gloomrel.cpp (revision 272)
@@ -139,4 +139,4 @@
     newscript->pGossipHello = &GossipHello_boss_gloomrel;
     newscript->pGossipSelect = &GossipSelect_boss_gloomrel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_haterel.cpp (revision 272)
@@ -102,4 +102,4 @@
     newscript->Name="boss_haterel";
     newscript->GetAI = GetAI_boss_haterel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_moira_bronzebeard.cpp (revision 272)
@@ -96,4 +96,4 @@
     newscript->Name="boss_moira_bronzebeard";
     newscript->GetAI = GetAI_boss_moira_bronzebeard;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_gorosh_the_dervish.cpp (revision 272)
@@ -78,4 +78,4 @@
     newscript->Name="boss_gorosh_the_dervish";
     newscript->GetAI = GetAI_boss_gorosh_the_dervish;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_emperor_dagran_thaurissan.cpp (revision 272)
@@ -101,4 +101,4 @@
     newscript->Name="boss_emperor_dagran_thaurissan";
     newscript->GetAI = GetAI_boss_draganthaurissan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_grizzle.cpp (revision 272)
@@ -83,4 +83,4 @@
     newscript->Name="boss_grizzle";
     newscript->GetAI = GetAI_boss_grizzle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_ambassador_flamelash.cpp (revision 272)
@@ -103,4 +103,4 @@
     newscript->Name="boss_ambassador_flamelash";
     newscript->GetAI = GetAI_boss_ambassador_flamelash;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_magmus.cpp (revision 272)
@@ -81,4 +81,4 @@
     newscript->Name="boss_magmus";
     newscript->GetAI = GetAI_boss_magmus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doperel.cpp (revision 272)
@@ -88,4 +88,4 @@
     newscript->Name="boss_doperel";
     newscript->GetAI = GetAI_boss_doperel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_angerrel.cpp (revision 272)
@@ -88,4 +88,4 @@
     newscript->Name="boss_angerrel";
     newscript->GetAI = GetAI_boss_angerrel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_doomrel.cpp (revision 272)
@@ -136,4 +136,4 @@
     newscript->Name="boss_doomrel";
     newscript->GetAI = GetAI_boss_doomrel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_anubshiah.cpp (revision 272)
@@ -112,4 +112,4 @@
     newscript->Name="boss_anubshiah";
     newscript->GetAI = GetAI_boss_anubshiah;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/blackrock_depths/boss_vilerel.cpp (revision 272)
@@ -98,4 +98,4 @@
     newscript->Name="boss_vilerel";
     newscript->GetAI = GetAI_boss_vilerel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/loch_modan/loch_modan.cpp (revision 272)
@@ -88,4 +88,4 @@
     newscript->pGossipHello =  &GossipHello_npc_mountaineer_pebblebitty;
     newscript->pGossipSelect = &GossipSelect_npc_mountaineer_pebblebitty;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/terokkar_forest/terokkar_forest.cpp (revision 272)
@@ -369,20 +369,20 @@
     newscript->Name="mob_unkor_the_ruthless";
     newscript->GetAI = GetAI_mob_unkor_the_ruthless;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_infested_root_walker";
     newscript->GetAI = GetAI_mob_infested_root_walker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_rotting_forest_rager";
     newscript->GetAI = GetAI_mob_rotting_forest_rager;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_netherweb_victim";
     newscript->GetAI = GetAI_mob_netherweb_victim;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -390,5 +390,5 @@
     newscript->pGossipHello =  &GossipHello_npc_floon;
     newscript->pGossipSelect = &GossipSelect_npc_floon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -396,4 +396,4 @@
     newscript->pGossipHello =  &GossipHello_npc_skyguard_handler_deesak;
     newscript->pGossipSelect = &GossipSelect_npc_skyguard_handler_deesak;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/western_plaguelands/western_plaguelands.cpp (revision 272)
@@ -168,9 +168,9 @@
     newscript->pGossipHello = &GossipHello_npcs_dithers_and_arbington;
     newscript->pGossipSelect = &GossipSelect_npcs_dithers_and_arbington;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_the_scourge_cauldron";
     newscript->GetAI = GetAI_npc_the_scourge_cauldron;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/ghostlands/ghostlands.cpp (revision 272)
@@ -134,5 +134,5 @@
     newscript->pGossipHello = &GossipHello_npc_blood_knight_dawnstar;
     newscript->pGossipSelect = &GossipSelect_npc_blood_knight_dawnstar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -140,5 +140,5 @@
     newscript->pGossipHello = &GossipHello_npc_budd_nedreck;
     newscript->pGossipSelect = &GossipSelect_npc_budd_nedreck;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -146,9 +146,9 @@
     newscript->pGossipHello = &GossipHello_npc_rathis_tomber;
     newscript->pGossipSelect = &GossipSelect_npc_rathis_tomber;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "go_gilded_brazier";
     newscript->pGOHello = &GOHello_gilded_brazier;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_gehennas.cpp (revision 272)
@@ -88,4 +88,4 @@
     newscript->Name="boss_gehennas";
     newscript->GetAI = GetAI_boss_gehennas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_magmadar.cpp (revision 272)
@@ -94,4 +94,4 @@
     newscript->Name="boss_magmadar";
     newscript->GetAI = GetAI_boss_magmadar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_shazzrah.cpp (revision 272)
@@ -118,4 +118,4 @@
     newscript->Name="boss_shazzrah";
     newscript->GetAI = GetAI_boss_shazzrah;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_garr.cpp (revision 272)
@@ -141,9 +141,9 @@
     newscript->Name="boss_garr";
     newscript->GetAI = GetAI_boss_garr;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_firesworn";
     newscript->GetAI = GetAI_mob_firesworn;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_majordomo_executus.cpp (revision 272)
@@ -130,4 +130,4 @@
     newscript->Name="boss_majordomo";
     newscript->GetAI = GetAI_boss_majordomo;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_ragnaros.cpp (revision 272)
@@ -314,4 +314,4 @@
     newscript->Name="boss_ragnaros";
     newscript->GetAI = GetAI_boss_ragnaros;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_sulfuron_harbinger.cpp (revision 272)
@@ -207,9 +207,9 @@
     newscript->Name="boss_sulfuron";
     newscript->GetAI = GetAI_boss_sulfuron;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_flamewaker_priest";
     newscript->GetAI = GetAI_mob_flamewaker_priest;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/molten_core.cpp (revision 272)
@@ -85,4 +85,4 @@
     newscript->Name="mob_ancient_core_hound";
     newscript->GetAI = GetAI_mob_ancient_core_hound;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_baron_geddon.cpp (revision 272)
@@ -102,4 +102,4 @@
     newscript->Name="boss_baron_geddon";
     newscript->GetAI = GetAI_boss_baron_geddon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_lucifron.cpp (revision 272)
@@ -87,4 +87,4 @@
     newscript->Name="boss_lucifron";
     newscript->GetAI = GetAI_boss_lucifron;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/boss_golemagg.cpp (revision 272)
@@ -193,9 +193,9 @@
     newscript->Name="boss_golemagg";
     newscript->GetAI = GetAI_boss_golemagg;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_core_rager";
     newscript->GetAI = GetAI_mob_core_rager;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/molten_core/instance_molten_core.cpp (revision 272)
@@ -254,4 +254,4 @@
     newscript->Name="instance_molten_core";
     newscript->GetInstanceData = &GetInstance_instance_molten_core;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp (revision 272)
@@ -630,14 +630,14 @@
     newscript->Name="boss_zuljin";
     newscript->GetAI = GetAI_boss_zuljin;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="do_nothing";
     newscript->GetAI = GetAI_do_nothing;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_zuljin_vortex";
     newscript->GetAI = GetAI_feather_vortexAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_janalai.cpp (revision 272)
@@ -398,10 +398,9 @@
             Map *map = m_creature->GetMap();
             if(!map->IsDungeon()) return;
-            Map::PlayerList const &PlayerList = map->GetPlayers();
-            for(Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
-            {
-                if (Player* i_pl = i->getSource())
-                    if(i_pl->isAlive())
-                        DoTeleportPlayer(i_pl, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
+            InstanceMap::PlayerList const &PlayerList =((InstanceMap*)map)->GetPlayers();
+            for(InstanceMap::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
+            {
+                if((*i)->isAlive())
+                    DoTeleportPlayer(*i, JanalainPos[0][0]-5+rand()%10, JanalainPos[0][1]-5+rand()%10, JanalainPos[0][2], 0);
             }
             //m_creature->CastSpell(Temp, SPELL_SUMMON_PLAYERS, true); // core bug, spell does not work if too far
@@ -707,24 +706,24 @@
     newscript->Name="boss_janalai";
     newscript->GetAI = GetAI_boss_janalaiAI;
-    newscript->RegisterSelf();  
+    m_scripts[nrscripts++] = newscript;  
 
     newscript = new Script;
     newscript->Name="mob_janalai_firebomb";
     newscript->GetAI = GetAI_mob_jandalai_firebombAI;
-    newscript->RegisterSelf();  
+    m_scripts[nrscripts++] = newscript;  
 
     newscript = new Script;
     newscript->Name="mob_janalai_hatcher";
     newscript->GetAI = GetAI_mob_amanishi_hatcherAI;
-    newscript->RegisterSelf(); 
+    m_scripts[nrscripts++] = newscript; 
 
     newscript = new Script;
     newscript->Name="mob_janalai_hatchling";
     newscript->GetAI = GetAI_mob_hatchlingAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_janalai_egg";
     newscript->GetAI = GetAI_mob_eggAI;
-    newscript->RegisterSelf(); 
+    m_scripts[nrscripts++] = newscript; 
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/zulaman.cpp (revision 272)
@@ -172,5 +172,5 @@
     newscript->Name="npc_forest_frog";
     newscript->GetAI = GetAI_npc_forest_frog;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -179,4 +179,4 @@
     newscript->pGossipHello = GossipHello_npc_zulaman_hostage;
     newscript->pGossipSelect = GossipSelect_npc_zulaman_hostage;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_halazzi.cpp (revision 272)
@@ -395,9 +395,9 @@
     newscript->Name="boss_halazzi";
     newscript->GetAI = GetAI_boss_halazziAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_halazzi_lynx";
     newscript->GetAI = GetAI_boss_spiritlynxAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_nalorakk.cpp (revision 272)
@@ -301,4 +301,4 @@
     newscript->Name="boss_nalorakk";
     newscript->GetAI = GetAI_boss_nalorakk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_hexlord.cpp (revision 272)
@@ -372,5 +372,5 @@
         if(SiphonSoul_Timer < diff)
         {
-            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0, 70, true);
+            Player* target = SelectRandomPlayer(50);
             Unit *trigger = DoSpawnCreature(MOB_TEMP_TRIGGER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
             if(!target || !trigger) EnterEvadeMode();
@@ -436,4 +436,24 @@
         m_creature->CastSpell(target, PlayerAbility[PlayerClass][random].spell, false);
     }
+
+    Player* SelectRandomPlayer(float range = 0.0f, bool alive = true)
+    {
+        Map *map = m_creature->GetMap();
+        if (!map->IsDungeon()) return NULL;
+
+        InstanceMap::PlayerList PlayerList = ((InstanceMap*)map)->GetPlayers();
+        InstanceMap::PlayerList::iterator i;
+        while(PlayerList.size())
+        {
+            i = PlayerList.begin();
+            advance(i, rand()%PlayerList.size());
+            if((range == 0.0f || m_creature->IsWithinDistInMap(*i, range))
+                && (!alive || (*i)->isAlive()))
+                return *i;
+            else
+                PlayerList.erase(i);
+        }
+        return NULL;
+    }
 };
 
@@ -869,44 +889,44 @@
     newscript->Name="boss_hexlord_malacrass";
     newscript->GetAI = GetAI_boss_hex_lord_malacrass;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_thurg";
     newscript->GetAI = GetAI_boss_thurg;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_gazakroth";
     newscript->GetAI = GetAI_boss_gazakroth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_lord_raadan";
     newscript->GetAI = GetAI_boss_lord_raadan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_darkheart";
     newscript->GetAI = GetAI_boss_darkheart;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_slither";
     newscript->GetAI = GetAI_boss_slither;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_fenstalker";
     newscript->GetAI = GetAI_boss_fenstalker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_koragg";
     newscript->GetAI = GetAI_boss_koragg;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_alyson_antille";
     newscript->GetAI = GetAI_boss_alyson_antille;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 270)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/instance_zulaman.cpp (revision 272)
@@ -140,26 +140,19 @@
     void OpenDoor(uint64 DoorGUID, bool open)
     {
-        if(GameObject *Door = instance->GetGameObjectInMap(DoorGUID))
-            Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
+        if(((InstanceMap*)instance)->GetPlayers().size())
+            if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
+                if(GameObject *Door = GameObject::GetGameObject(*first, DoorGUID))
+                    Door->SetUInt32Value(GAMEOBJECT_STATE, open ? 0 : 1);
     }
 
     void SummonHostage(uint8 num)
     {
-        if(!QuestMinute)
-            return;
-
-        Map::PlayerList const &PlayerList = instance->GetPlayers();
-        if (PlayerList.isEmpty())
-            return;
-
-        Map::PlayerList::const_iterator i = PlayerList.begin();
-        if(Player* i_pl = i->getSource())
-        {
-            if(Unit* Hostage = i_pl->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
-            {
-                Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-                Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
-            }
-        }
+        if(QuestMinute && ((InstanceMap*)instance)->GetPlayers().size())
+            if(Player* first = ((InstanceMap*)instance)->GetPlayers().front())
+                if(Unit* Hostage = first->SummonCreature(HostageInfo[num].npc, HostageInfo[num].x, HostageInfo[num].y, HostageInfo[num].z, HostageInfo[num].o, TEMPSUMMON_DEAD_DESPAWN, 0))
+                {
+                    Hostage->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+                    Hostage->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
+                }
     }
 
@@ -177,5 +170,5 @@
         WorldPacket data(SMSG_UPDATE_WORLD_STATE, 8);
         data << field << value;
-        instance->SendToPlayers(&data);
+        ((InstanceMap*)instance)->SendToPlayers(&data);
     }
 
@@ -329,4 +322,4 @@
     newscript->Name = "instance_zulaman";
     newscript->GetInstanceData = GetInstanceData_instance_zulaman;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp (revision 270)
+++ /trunk/src/bindings/scripts/scripts/zone/zulaman/boss_akilzon.cpp (revision 272)
@@ -170,5 +170,5 @@
         data << uint32(weather) << (float)grade << uint8(0);
 
-        map->SendToPlayers(&data);
+        ((InstanceMap*)map)->SendToPlayers(&data);
     }
 
@@ -462,9 +462,9 @@
     newscript->Name="boss_akilzon";
     newscript->GetAI = GetAI_boss_akilzon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_akilzon_eagle";
     newscript->GetAI = GetAI_mob_soaring_eagle;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp (revision 271)
+++ /trunk/src/bindings/scripts/scripts/zone/netherstorm/netherstorm.cpp (revision 272)
@@ -391,97 +391,4 @@
 
 /*######
-## mob_phase_hunter
-######*/
-
-#define SUMMONED_MOB        19595
-#define EMOTE_WEAK          "is very weak"
-
-// Spells
-#define SPELL_PHASE_SLIP    36574
-#define SPELL_MANA_BURN     13321
-
-struct TRINITY_DLL_DECL mob_phase_hunterAI : public ScriptedAI
-{
-
-    mob_phase_hunterAI(Creature *c) : ScriptedAI(c) {Reset();}
-    
-    bool Weak;
-    int WeakPercent;
-    uint32 PlayerGUID;
-    uint32 Health;
-    uint32 Level;
-    uint32 PhaseSlipVulnerabilityTimer;
-    uint32 ManaBurnTimer;
-
-    void Reset()
-    {
-        Weak = false;
-        WeakPercent = 25 + (rand()%16); // 25-40
-        PlayerGUID = 0;
-        ManaBurnTimer = 5000 + (rand()%3 * 1000); // 5-8 sec cd
-    }
-
-    void Aggro(Unit *who)
-    {
-        PlayerGUID = who->GetGUID();
-    }
-
-    void UpdateAI(const uint32 diff)
-    {
-
-        Player* target = NULL;
-        target = ((Player*)Unit::GetUnit((*m_creature), PlayerGUID));
-        
-        if(!target)
-            return;
-
-        if(m_creature->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || m_creature->hasUnitState(UNIT_STAT_ROOT)) // if the mob is rooted/slowed by spells eg.: Entangling Roots, Frost Nova, Hamstring, Crippling Poison, etc. => remove it
-            DoCast(m_creature, SPELL_PHASE_SLIP);
-        if(ManaBurnTimer < diff) // cast Mana Burn
-        {
-            if(target->GetCreateMana() > 0)
-            {
-                DoCast(target, SPELL_MANA_BURN);
-                ManaBurnTimer = 8000 + (rand()%10 * 1000); // 8-18 sec cd
-            }
-        }
-        else ManaBurnTimer -= diff;
-
-        if(!Weak && m_creature->GetHealth() < (m_creature->GetMaxHealth() / 100 * WeakPercent) && target->GetQuestStatus(10190) == QUEST_STATUS_INCOMPLETE) // start: support for quest 10190
-        {
-            DoTextEmote(EMOTE_WEAK, 0);
-            Weak = true;
-        }
-        if(Weak && m_creature->HasAura(34219, 0))
-        {
-            Health = m_creature->GetHealth(); // get the normal mob's data
-            Level = m_creature->getLevel();
-
-            m_creature->AttackStop(); // delete the normal mob
-            m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
-            m_creature->RemoveCorpse();
-            
-            Creature* DrainedPhaseHunter = NULL;
-            
-            if(!DrainedPhaseHunter)
-                DrainedPhaseHunter = m_creature->SummonCreature(SUMMONED_MOB, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000); // summon the mob
-            
-            if(DrainedPhaseHunter)
-            {
-                DrainedPhaseHunter->SetLevel(Level); // set the summoned mob's data
-                DrainedPhaseHunter->SetHealth(Health);
-                DrainedPhaseHunter->AI()->AttackStart(target);
-            }
-        } // end: support for quest 10190
-    }
-
-};
-
-CreatureAI* GetAI_mob_phase_hunter(Creature *_Creature)
-{
-    return new mob_phase_hunterAI (_Creature);
-}
-
-/*######
 ##
 ######*/
@@ -494,10 +401,10 @@
     newscript->Name="go_manaforge_control_console";
     newscript->pGOHello = &GOHello_go_manaforge_control_console;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_manaforge_control_console";
     newscript->GetAI = GetAI_npc_manaforge_control_console;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -505,5 +412,5 @@
     newscript->pGossipHello =   &GossipHello_npc_protectorate_nether_drake;
     newscript->pGossipSelect =  &GossipSelect_npc_protectorate_nether_drake;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -511,9 +418,4 @@
     newscript->pGossipHello =   &GossipHello_npc_veronia;
     newscript->pGossipSelect =  &GossipSelect_npc_veronia;
-    newscript->RegisterSelf();
-
-    newscript = new Script;
-    newscript->Name = "mob_phase_hunter";
-    newscript->GetAI = GetAI_mob_phase_hunter;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/isle_of_queldanas/isle_of_queldanas.cpp (revision 272)
@@ -141,10 +141,10 @@
     newscript->pGossipHello = &GossipHello_npc_ayren_cloudbreaker;
     newscript->pGossipSelect = &GossipSelect_npc_ayren_cloudbreaker;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_converted_sentry";
     newscript->GetAI = GetAI_npc_converted_sentry;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -152,4 +152,4 @@
     newscript->pGossipHello = &GossipHello_npc_unrestrained_dragonhawk;
     newscript->pGossipSelect = &GossipSelect_npc_unrestrained_dragonhawk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/azuremyst_isle/azuremyst_isle.cpp (revision 272)
@@ -351,5 +351,5 @@
     newscript->Name="npc_draenei_survivor";
     newscript->GetAI = GetAI_npc_draenei_survivor;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -358,10 +358,10 @@
     newscript->pGossipHello =  &GossipHello_npc_engineer_spark_overgrind;
     newscript->pGossipSelect = &GossipSelect_npc_engineer_spark_overgrind;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_injured_draenei";
     newscript->GetAI = GetAI_npc_injured_draenei;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -369,4 +369,4 @@
     newscript->pGossipHello =  &GossipHello_npc_susurrus;
     newscript->pGossipSelect = &GossipSelect_npc_susurrus;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/uldaman/uldaman.cpp (revision 272)
@@ -178,5 +178,5 @@
     newscript->Name="mob_jadespine_basilisk";
     newscript->GetAI = GetAI_mob_jadespine_basilisk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -184,4 +184,4 @@
     newscript->pGossipHello = &GossipHello_npc_lore_keeper_of_norgannon;
     newscript->pGossipSelect = &GossipSelect_npc_lore_keeper_of_norgannon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/uldaman/boss_ironaya.cpp (revision 272)
@@ -104,4 +104,4 @@
     newscript->Name="boss_ironaya";
     newscript->GetAI = GetAI_boss_ironaya;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_nerubenkan.cpp (revision 272)
@@ -135,4 +135,4 @@
     newscript->Name="boss_nerubenkan";
     newscript->GetAI = GetAI_boss_nerubenkan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_magistrate_barthilas.cpp (revision 272)
@@ -111,4 +111,4 @@
     newscript->Name="boss_magistrate_barthilas";
     newscript->GetAI = GetAI_boss_magistrate_barthilas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_timmy_the_cruel.cpp (revision 272)
@@ -97,4 +97,4 @@
     newscript->Name="boss_timmy_the_cruel";
     newscript->GetAI = GetAI_boss_timmy_the_cruel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_cannon_master_willey.cpp (revision 272)
@@ -218,4 +218,4 @@
     newscript->Name="boss_cannon_master_willey";
     newscript->GetAI = GetAI_boss_cannon_master_willey;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_dathrohan_balnazzar.cpp (revision 272)
@@ -313,4 +313,4 @@
     newscript->Name="boss_dathrohan_balnazzar";
     newscript->GetAI = GetAI_boss_dathrohan_balnazzar;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/stratholme.cpp (revision 272)
@@ -311,10 +311,10 @@
     newscript->Name="mob_freed_soul";
     newscript->GetAI = GetAI_mob_freed_soul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_restless_soul";
     newscript->GetAI = GetAI_mob_restless_soul;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -322,14 +322,14 @@
     newscript->GetAI = GetAI_mobs_spectral_ghostly_citizen;
     newscript->pReceiveEmote = &ReciveEmote_mobs_spectral_ghostly_citizen;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_mindless_skeleton";
     newscript->GetAI = GetAI_mob_mindless_skeleton;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_thuzadin_acolyte";
     newscript->GetAI = GetAI_mob_thuzadin_acolyte;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_order_of_silver_hand.cpp (revision 272)
@@ -158,4 +158,4 @@
     newscript->Name="boss_silver_hand_bosses";
     newscript->GetAI = GetAI_boss_silver_hand_bossesAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baroness_anastari.cpp (revision 272)
@@ -121,4 +121,4 @@
     newscript->Name="boss_baroness_anastari";
     newscript->GetAI = GetAI_boss_baroness_anastari;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_postmaster_malown.cpp (revision 272)
@@ -141,4 +141,4 @@
     newscript->Name="boss_postmaster_malown";
     newscript->GetAI = GetAI_boss_postmaster_malown;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_baron_rivendare.cpp (revision 272)
@@ -212,4 +212,4 @@
     newscript->Name="boss_baron_rivendare";
     newscript->GetAI = GetAI_boss_baron_rivendare;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/instance_stratholme.cpp (revision 272)
@@ -74,4 +74,4 @@
     newscript->Name = "instance_stratholme";
     newscript->GetInstanceData = GetInstanceData_instance_stratholme;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_maleki_the_pallid.cpp (revision 272)
@@ -116,4 +116,4 @@
     newscript->Name="boss_maleki_the_pallid";
     newscript->GetAI = GetAI_boss_maleki_the_pallid;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/stratholme/boss_ramstein_the_gorger.cpp (revision 272)
@@ -89,4 +89,4 @@
     newscript->Name="boss_ramstein_the_gorger";
     newscript->GetAI = GetAI_boss_ramstein_the_gorger;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/azshara/boss_azuregos.cpp (revision 272)
@@ -150,4 +150,4 @@
     newscript->Name="boss_azuregos";
     newscript->GetAI = GetAI_boss_azuregos;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/azshara/azshara.cpp (revision 272)
@@ -493,5 +493,5 @@
     newscript->Name="mobs_spitelashes";
     newscript->GetAI = GetAI_mobs_spitelashes;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -499,5 +499,5 @@
     newscript->pGossipHello =  &GossipHello_npc_loramus_thalipedes;
     newscript->pGossipSelect = &GossipSelect_npc_loramus_thalipedes;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
@@ -506,9 +506,9 @@
     newscript->pGossipHello =  &GossipHello_mob_rizzle_sprysprocket;
     newscript->pGossipSelect = &GossipSelect_mob_rizzle_sprysprocket;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_depth_charge";
     newscript->GetAI = GetAI_mob_depth_charge;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_doctor_theolen_krastinov.cpp (revision 272)
@@ -105,4 +105,4 @@
     newscript->Name="boss_doctor_theolen_krastinov";
     newscript->GetAI = GetAI_boss_theolenkrastinov;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_vectus.cpp (revision 272)
@@ -92,4 +92,4 @@
     newscript->Name="boss_vectus";
     newscript->GetAI = GetAI_boss_vectus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/instance_scholomance.cpp (revision 272)
@@ -99,4 +99,4 @@
     newscript->Name = "instance_scholomance";
     newscript->GetInstanceData = GetInstanceData_instance_scholomance;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_illucia_barov.cpp (revision 272)
@@ -113,4 +113,4 @@
     newscript->Name="boss_illucia_barov";
     newscript->GetAI = GetAI_boss_illuciabarov;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_instructor_malicia.cpp (revision 272)
@@ -149,4 +149,4 @@
     newscript->Name="boss_instructor_malicia";
     newscript->GetAI = GetAI_boss_instructormalicia;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_death_knight_darkreaver.cpp (revision 272)
@@ -56,4 +56,4 @@
     newscript->Name="boss_death_knight_darkreaver";
     newscript->GetAI = GetAI_boss_death_knight_darkreaver;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_darkmaster_gandling.cpp (revision 272)
@@ -189,4 +189,4 @@
     newscript->Name="boss_darkmaster_gandling";
     newscript->GetAI = GetAI_boss_darkmaster_gandling;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lord_alexei_barov.cpp (revision 272)
@@ -95,4 +95,4 @@
     newscript->Name="boss_lord_alexei_barov";
     newscript->GetAI = GetAI_boss_lordalexeibarov;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_kormok.cpp (revision 272)
@@ -152,4 +152,4 @@
     newscript->Name="boss_kormok";
     newscript->GetAI = GetAI_boss_kormok;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_the_ravenian.cpp (revision 272)
@@ -115,4 +115,4 @@
     newscript->Name="boss_the_ravenian";
     newscript->GetAI = GetAI_boss_theravenian;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_ras_frostwhisper.cpp (revision 272)
@@ -122,4 +122,4 @@
     newscript->Name="boss_boss_ras_frostwhisper";
     newscript->GetAI = GetAI_boss_rasfrost;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_jandice_barov.cpp (revision 272)
@@ -213,9 +213,9 @@
     newscript->Name="boss_jandice_barov";
     newscript->GetAI = GetAI_boss_jandicebarov;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_illusionofjandicebarov";
     newscript->GetAI = GetAI_mob_illusionofjandicebarov;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/scholomance/boss_lorekeeper_polkelt.cpp (revision 272)
@@ -110,4 +110,4 @@
     newscript->Name="boss_lorekeeper_polkelt";
     newscript->GetAI = GetAI_boss_lorekeeperpolkelt;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/silverpine_forest/silverpine_forest.cpp (revision 272)
@@ -97,4 +97,4 @@
     newscript->pGossipSelect = &GossipSelect_npc_astor_hadren;
     newscript->GetAI = GetAI_npc_astor_hadren;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_noth.cpp (revision 272)
@@ -177,4 +177,4 @@
     newscript->Name="boss_noth";
     newscript->GetAI = GetAI_boss_noth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_anubrekhan.cpp (revision 272)
@@ -209,4 +209,4 @@
     newscript->Name="boss_anubrekhan";
     newscript->GetAI = GetAI_boss_anubrekhan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_loatheb.cpp (revision 272)
@@ -213,4 +213,4 @@
     newscript->Name="boss_loatheb";
     newscript->GetAI = GetAI_boss_loatheb;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_faerlina.cpp (revision 272)
@@ -198,4 +198,4 @@
     newscript->Name="boss_faerlina";
     newscript->GetAI = GetAI_boss_faerlina;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_highlord_mograine.cpp (revision 272)
@@ -175,4 +175,4 @@
     newscript->Name="boss_highlord_mograine";
     newscript->GetAI = GetAI_boss_highlord_mograine;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_gluth.cpp (revision 272)
@@ -171,4 +171,4 @@
     newscript->Name="boss_gluth";
     newscript->GetAI = GetAI_boss_gluth;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_patchwerk.cpp (revision 272)
@@ -157,4 +157,4 @@
     newscript->Name="boss_patchwerk";
     newscript->GetAI = GetAI_boss_patchwerk;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_thane_korthazz.cpp (revision 272)
@@ -144,4 +144,4 @@
     newscript->Name="boss_thane_korthazz";
     newscript->GetAI = GetAI_boss_thane_korthazz;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_kelthuzad.cpp (revision 272)
@@ -538,5 +538,5 @@
     newscript->Name="boss_kelthuzad";
     newscript->GetAI = GetAI_boss_kelthuzadAI;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
     */
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_lady_blaumeux.cpp (revision 272)
@@ -144,4 +144,4 @@
     newscript->Name="boss_lady_blaumeux";
     newscript->GetAI = GetAI_boss_lady_blaumeux;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sir_zeliek.cpp (revision 272)
@@ -143,4 +143,4 @@
     newscript->Name="boss_sir_zeliek";
     newscript->GetAI = GetAI_boss_sir_zeliek;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_maexxna.cpp (revision 272)
@@ -238,9 +238,9 @@
     newscript->Name="boss_maexxna";
     newscript->GetAI = GetAI_boss_maexxna;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_webwrap";
     newscript->GetAI = GetAI_mob_webwrap;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_sapphiron.cpp (revision 272)
@@ -196,4 +196,4 @@
     newscript->Name="boss_sapphiron";
     newscript->GetAI = GetAI_boss_sapphiron;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/naxxramas/boss_razuvious.cpp (revision 272)
@@ -164,4 +164,4 @@
     newscript->Name="boss_razuvious";
     newscript->GetAI = GetAI_boss_razuvious;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/instance_magisters_terrace.cpp (revision 272)
@@ -250,4 +250,4 @@
     newscript->Name = "instance_magisters_terrace";
     newscript->GetInstanceData = GetInstanceData_instance_magisters_terrace;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_felblood_kaelthas.cpp (revision 272)
@@ -232,15 +232,15 @@
         m_creature->Relocate(KaelLocations[0][0], KaelLocations[0][1], LOCATION_Z, 0);
 		Map *map = m_creature->GetMap();
-        Map::PlayerList const &PlayerList = map->GetPlayers();
-		Map::PlayerList::const_iterator i;
+        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+		InstanceMap::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
 		{
-			if (Player* i_pl = i->getSource())
-			    if(i_pl->isAlive())
-			    {
-				    i_pl->CastSpell(i_pl, SPELL_TELEPORT_CENTER, true);
-				    m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
-				    i_pl->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,i_pl->GetOrientation());
-			    }
+			//if(!(*i)->isGameMaster())
+			if((*i) && (*i)->isAlive())
+			{
+				(*i)->CastSpell((*i), SPELL_TELEPORT_CENTER, true);
+				m_creature->GetNearPoint(m_creature,x,y,z,5,5,0);
+				(*i)->TeleportTo(m_creature->GetMapId(),x,y,LOCATION_Z,(*i)->GetOrientation());
+			}
         }
         DoCast(m_creature, SPELL_TELEPORT_CENTER, true);
@@ -250,12 +250,11 @@
     {
 		Map *map = m_creature->GetMap();
-        Map::PlayerList const &PlayerList = map->GetPlayers();
-		Map::PlayerList::const_iterator i;
+        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+		InstanceMap::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-		{
-            if (Player* i_pl = i->getSource())
-			    if(i_pl->isAlive())
+		{            
+			if((*i) && (*i)->isAlive())
                 // Knockback into the air
-                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
+                (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_DOT, true, 0, 0, m_creature->GetGUID());
         }
     }
@@ -264,22 +263,19 @@
     {
 		Map *map = m_creature->GetMap();
-		Map::PlayerList const &PlayerList = map->GetPlayers();
-		Map::PlayerList::const_iterator i;
+		InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+		InstanceMap::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
-		{
-            if (Player* i_pl = i->getSource())
+		{ 
+			if((*i) && (*i)->isAlive())
             {
-			    if(i_pl->isAlive())
-                {
-                    // Also needs an exception in spell system.
-                    i_pl->CastSpell(i_pl, SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
-                    // Use packet hack
-                    WorldPacket data(12);
-                    data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
-                    data.append(i_pl->GetPackGUID());
-                    data << uint32(0);
-                    i_pl->SendMessageToSet(&data, true);
-				    i_pl->SetSpeed(MOVE_FLY, 2.0f);
-                }
+                // Also needs an exception in spell system.
+                (*i)->CastSpell((*i), SPELL_GRAVITY_LAPSE_FLY, true, 0, 0, m_creature->GetGUID());
+                // Use packet hack
+                WorldPacket data(12);
+                data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
+                data.append((*i)->GetPackGUID());
+                data << uint32(0);
+                (*i)->SendMessageToSet(&data, true);
+				(*i)->SetSpeed(MOVE_FLY, 2.0f);
             }
         }
@@ -289,17 +285,17 @@
     {
 		Map *map = m_creature->GetMap();
-        Map::PlayerList const &PlayerList = map->GetPlayers();
-		Map::PlayerList::const_iterator i;
+        InstanceMap::PlayerList const &PlayerList = ((InstanceMap*)map)->GetPlayers();
+		InstanceMap::PlayerList::const_iterator i;
 		for (i = PlayerList.begin(); i != PlayerList.end(); ++i)
 		{ 
-            if(Player* i_pl = i->getSource())
+            if((*i))
             {
-                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
-                i_pl->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
+                (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_FLY);
+                (*i)->RemoveAurasDueToSpell(SPELL_GRAVITY_LAPSE_DOT);
                 WorldPacket data(12);
                 data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
-                data.append(i_pl->GetPackGUID());
+                data.append((*i)->GetPackGUID());
                 data << uint32(0);
-                i_pl->SendMessageToSet(&data, true);
+                (*i)->SendMessageToSet(&data, true);
             }
         }
@@ -762,34 +758,34 @@
     newscript->Name = "boss_felblood_kaelthas";
     newscript->GetAI = GetAI_boss_felblood_kaelthas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name = "mob_arcane_sphere";
     newscript->GetAI = GetAI_mob_arcane_sphere;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_felkael_phoenix";
     newscript->GetAI = GetAI_mob_felkael_phoenix;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_felkael_phoenix_egg";
     newscript->GetAI = GetAI_mob_felkael_phoenix_egg;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_felkael_flamestrike";
     newscript->GetAI = GetAI_mob_felkael_flamestrike;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="go_kael_orb";
     newscript->pGOHello = &GOHello_go_kael_orb;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
 	newscript = new Script;
     newscript->Name="go_movie_orb";
     newscript->pGOHello = &GOHello_go_movie_orb;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_selin_fireheart.cpp (revision 272)
@@ -404,9 +404,9 @@
     newscript->Name="boss_selin_fireheart";
     newscript->GetAI = GetAI_boss_selin_fireheart;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_fel_crystal";
     newscript->GetAI = GetAI_mob_fel_crystal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_vexallus.cpp (revision 272)
@@ -239,9 +239,9 @@
     newscript->Name="boss_vexallus";
     newscript->GetAI = GetAI_boss_vexallus;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="mob_pure_energy";
     newscript->GetAI = GetAI_mob_pure_energy;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/magisters_terrace/boss_priestess_delrissa.cpp (revision 272)
@@ -1356,59 +1356,59 @@
     newscript->Name="boss_priestess_delrissa";
     newscript->GetAI = GetAI_boss_priestess_delrissa;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_kagani_nightstrike";
     newscript->GetAI = GetAI_boss_kagani_nightstrike;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_ellris_duskhallow";
     newscript->GetAI = GetAI_ellris_duskhallow;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_eramas_brightblaze";
     newscript->GetAI = GetAI_eramas_brightblaze;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_yazzai";
     newscript->GetAI = GetAI_yazzai;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_warlord_salaris";
     newscript->GetAI = GetAI_warlord_salaris;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_garaxxas";
     newscript->GetAI = GetAI_garaxxas;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_apoko";
     newscript->GetAI = GetAI_apoko;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="boss_zelfan";
     newscript->GetAI = GetAI_zelfan;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     /*newscript = new Script;
     newscript->Name="mob_high_explosive_sheep";
     newscript->GetAI = GetAI_mob_high_explosive_sheep;
-    newscript->RegisterSelf();*/
+    m_scripts[nrscripts++] = newscript;*/
 
     /*newscript = new Script;
     newscript->Name="mob_fizzle";
     newscript->GetAI = GetAI_mob_fizzle;
-    newscript->RegisterSelf();*/
+    m_scripts[nrscripts++] = newscript;*/
 
     /*newscript = new Script;
     newscript->Name="mob_sliver";
     newscript->GetAI = GetAI_mob_sliver;
-    newscript->RegisterSelf();*/
+    m_scripts[nrscripts++] = newscript;*/
 }
Index: /trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/silithus/silithus.cpp (revision 272)
@@ -146,4 +146,4 @@
     newscript->pGossipHello =   &GossipHello_npcs_rutgar_and_frankal;
     newscript->pGossipSelect =  &GossipSelect_npcs_rutgar_and_frankal;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_landslide.cpp (revision 272)
@@ -91,4 +91,4 @@
     newscript->Name="boss_landslide";
     newscript->GetAI = GetAI_boss_landslide;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_noxxion.cpp (revision 272)
@@ -146,4 +146,4 @@
     newscript->Name="boss_noxxion";
     newscript->GetAI = GetAI_boss_noxxion;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_princess_theradras.cpp (revision 272)
@@ -105,4 +105,4 @@
     newscript->Name="boss_princess_theradras";
     newscript->GetAI = GetAI_boss_ptheradras;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/maraudon/boss_celebras_the_cursed.cpp (revision 272)
@@ -94,4 +94,4 @@
     newscript->Name="celebras_the_cursed";
     newscript->GetAI = GetAI_celebras_the_cursed;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
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 260)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/boss_doomlord_kazzak.cpp (revision 272)
@@ -138,4 +138,4 @@
     newscript->Name="boss_doomlord_kazzak";
     newscript->GetAI = GetAI_boss_doomlordkazzak;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp (revision 271)
+++ /trunk/src/bindings/scripts/scripts/zone/hellfire_peninsula/hellfire_peninsula.cpp (revision 272)
@@ -18,5 +18,5 @@
 SDName: Hellfire_Peninsula
 SD%Complete: 100
-SDComment: Quest support: 9375, 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths)
+SDComment: Quest support: 10129, 10146, 10162, 10163, 10340, 10346, 10347, 10382 (Special flight paths)
 SDCategory: Hellfire Peninsula
 EndScriptData */
@@ -26,9 +26,7 @@
 npc_gryphoneer_windbellow
 npc_wing_commander_brack
-npc_wounded_blood_elf
 EndContentData */
 
 #include "precompiled.h"
-#include "../../npc/npc_escortAI.h"
 
 /*######
@@ -163,149 +161,4 @@
 
 /*######
-## npc_wounded_blood_elf
-######*/
-
-#define QUEST_THE_ROAD_TO_FALCON_WATCH 9375
-#define SAY1      "Thank you for agreeing to help. Now, let's get out of here $N."
-#define SAY2      "Over there! They're following us!"
-#define SAY3      "Allow me a moment to rest. The journey taxes what little strength I have."
-#define SAY4      "Did you hear something?"
-#define SAY5      "Falcon Watch, at last! Now, where's my... Oh no! My pack, it's missing! Where has -"
-#define SAYAGGRO  "You won't keep me from getting to Falcon Watch!"
-
-struct TRINITY_DLL_DECL npc_wounded_blood_elfAI : public npc_escortAI
-{
-    npc_wounded_blood_elfAI(Creature *c) : npc_escortAI(c) {Reset();}
-
-    void WaypointReached(uint32 i)
-    {
-        Unit* player = Unit::GetUnit((*m_creature), PlayerGUID);
-
-        if (!player)
-            return;
-
-        switch (i)
-        {
-
-        case 0:
-            DoSay(SAY1, LANG_UNIVERSAL, player);
-            // Change faction, so mobs can attack
-            m_creature->setFaction(1610);
-            break;
-
-        case 9:
-            DoSay(SAY2, LANG_UNIVERSAL, player);
-            // Spawn two Haal'eshi Talonguard
-            {
-                Creature* temp1 = m_creature->SummonCreature(16967, m_creature->GetPositionX()-15, m_creature->GetPositionY()-15, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
-                if (temp1) temp1->AI()->AttackStart(m_creature);
-                Creature* temp2 = m_creature->SummonCreature(16967, m_creature->GetPositionX()-17, m_creature->GetPositionY()-17, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
-                if (temp2) temp2->AI()->AttackStart(m_creature);
-            }
-            break;
-
-        case 13:
-            DoSay(SAY3, LANG_UNIVERSAL, player);
-            // NPC "should" kneel
-            m_creature->HandleEmoteCommand(EMOTE_STATE_KNEEL);
-            break;
-
-        case 14:
-            DoSay(SAY4, LANG_UNIVERSAL, player);
-            // Spawn two Haal'eshi Windwalker
-            {
-                Creature* temp3 = m_creature->SummonCreature(16966, m_creature->GetPositionX()-15, m_creature->GetPositionY()-15, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
-                if (temp3) temp3->AI()->AttackStart(m_creature);
-                Creature* temp4 = m_creature->SummonCreature(16966, m_creature->GetPositionX()-17, m_creature->GetPositionY()-17, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 3000);
-                if (temp4) temp4->AI()->AttackStart(m_creature);
-            }
-            break;
-
-        case 27:
-            DoSay(SAY5, LANG_UNIVERSAL, player);
-            // Set faction back to normal
-            m_creature->setFaction(1604);
-            // Award quest credit
-            if( PlayerGUID )
-            {
-                Unit* player = Unit::GetUnit((*m_creature), PlayerGUID);
-                if( player && player->GetTypeId() == TYPEID_PLAYER )
-                    ((Player*)player)->GroupEventHappens(9375,m_creature);
-            }
-            break;
-        }
-    }
-
-    void Aggro(Unit* who)
-    {
-        DoSay(SAYAGGRO, LANG_UNIVERSAL, who);
-    }
-
-    void Reset() { }
-
-    void JustDied(Unit* killer)
-        // If NPC dies, Quest fail
-    {
-        if (PlayerGUID)
-        {
-            Unit* player = Unit::GetUnit((*m_creature), PlayerGUID);
-            if (player)
-                ((Player*)player)->FailQuest(QUEST_THE_ROAD_TO_FALCON_WATCH);
-        }
-    }
-
-    void UpdateAI(const uint32 diff)
-    {
-        npc_escortAI::UpdateAI(diff);
-    }
-};
-
-bool QuestAccept_wounded_blood_elf(Player* player, Creature* creature, Quest const* quest)
-// Begin the escort quest
-{
-    if (quest->GetQuestId() == QUEST_THE_ROAD_TO_FALCON_WATCH)
-    {
-        ((npc_escortAI*)(creature->AI()))->Start(true, true, false, player->GetGUID());
-    }
-    return true;
-}
-
-CreatureAI* GetAI_npc_wounded_blood_elf(Creature *_Creature)
-{
-    npc_wounded_blood_elfAI* thisAI = new npc_wounded_blood_elfAI(_Creature);
-
-    thisAI->AddWaypoint(0, -1137.72, 4272.10, 14.04, 3000);
-    thisAI->AddWaypoint(1, -1141.34, 4232.42, 14.63);
-    thisAI->AddWaypoint(2, -1133.47, 4220.88, 11.78);
-    thisAI->AddWaypoint(3, -1126.18, 4213.26, 13.51);
-    thisAI->AddWaypoint(4, -1100.12, 4204.32, 16.41);
-    thisAI->AddWaypoint(5, -1063.68, 4197.92, 15.51);
-    thisAI->AddWaypoint(6, -1027.28, 4194.36, 15.52);
-    thisAI->AddWaypoint(7, -995.68, 4189.59, 19.84);
-    thisAI->AddWaypoint(8, -970.90, 4188.60, 24.61);
-    thisAI->AddWaypoint(9, -961.93, 4193.34, 26.11, 80000); // Summon 1
-    thisAI->AddWaypoint(10, -935.52, 4210.99, 31.98);
-    thisAI->AddWaypoint(11, -913.42, 4218.27, 37.29);
-    thisAI->AddWaypoint(12, -896.53, 4207.73, 43.23);
-    thisAI->AddWaypoint(13, -868.49, 4194.77, 46.75, 17000); // Kneel and Rest Here
-    thisAI->AddWaypoint(14, -852.83, 4198.29, 47.28, 80000); // Summon 2
-    thisAI->AddWaypoint(15, -819.85, 4200.50, 46.37);
-    thisAI->AddWaypoint(16, -791.92, 4201.96, 44.19);
-    thisAI->AddWaypoint(17, -774.42, 4202.46, 47.41);
-    thisAI->AddWaypoint(18, -762.90, 4202.17, 48.81);
-    thisAI->AddWaypoint(19, -728.25, 4195.35, 50.68);
-    thisAI->AddWaypoint(20, -713.58, 4192.07, 53.98);
-    thisAI->AddWaypoint(21, -703.09, 4189.74, 56.96);
-    thisAI->AddWaypoint(22, -693.70, 4185.43, 57.06);
-    thisAI->AddWaypoint(23, -686.38, 4159.81, 60.26);
-    thisAI->AddWaypoint(24, -679.88, 4147.04, 64.20);
-    thisAI->AddWaypoint(25, -656.74, 4147.72, 64.11);
-    thisAI->AddWaypoint(26, -652.22, 4137.50, 64.58);
-    thisAI->AddWaypoint(27, -649.99, 4136.38, 64.63, 20000); // Award Quest Credit
-
-    return (CreatureAI*)thisAI;
-}
-
-/*######
 ##
 ######*/
@@ -319,5 +172,5 @@
     newscript->pGossipHello =   &GossipHello_npc_wing_commander_dabiree;
     newscript->pGossipSelect =  &GossipSelect_npc_wing_commander_dabiree;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -325,5 +178,5 @@
     newscript->pGossipHello =   &GossipHello_npc_gryphoneer_windbellow;
     newscript->pGossipSelect =  &GossipSelect_npc_gryphoneer_windbellow;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
@@ -331,10 +184,4 @@
     newscript->pGossipHello =   &GossipHello_npc_wing_commander_brack;
     newscript->pGossipSelect =  &GossipSelect_npc_wing_commander_brack;
-    newscript->RegisterSelf();
-	
-    newscript = new Script;
-    newscript->Name="npc_wounded_blood_elf";
-    newscript->GetAI = &GetAI_npc_wounded_blood_elf;
-    newscript->pQuestAccept = &QuestAccept_wounded_blood_elf;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/mulgore/mulgore.cpp (revision 272)
@@ -61,4 +61,4 @@
     newscript->pGossipHello          = &GossipHello_npc_skorn_whitecloud;
     newscript->pGossipSelect         = &GossipSelect_npc_skorn_whitecloud;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/zone/feralas/feralas.cpp (revision 272)
@@ -77,9 +77,9 @@
     newscript->pGossipHello = &GossipHello_npc_gregan_brewspewer;
     newscript->pGossipSelect = &GossipSelect_npc_gregan_brewspewer;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="npc_screecher_spirit";
     newscript->pGossipHello = &GossipHello_npc_screecher_spirit;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/areatrigger/areatrigger_scripts.cpp (revision 272)
@@ -41,4 +41,4 @@
     newscript->Name="at_test";
     newscript->pAreaTrigger = ATtest;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/scripts/item/item_scripts.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/item/item_scripts.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/item/item_scripts.cpp (revision 272)
@@ -456,94 +456,94 @@
     newscript->Name="item_area_52_special";
     newscript->pItemUse = ItemUse_item_area_52_special;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_arcane_charges";
     newscript->pItemUse = ItemUse_item_arcane_charges;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_attuned_crystal_cores";
     newscript->pItemUse = ItemUse_item_attuned_crystal_cores;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_blackwhelp_net";
     newscript->pItemUse = ItemUse_item_blackwhelp_net;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_disciplinary_rod";
     newscript->pItemUse = ItemUse_item_disciplinary_rod;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_draenei_fishing_net";
     newscript->pItemUse = ItemUse_item_draenei_fishing_net;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_nether_wraith_beacon";
     newscript->pItemUse = ItemUse_item_nether_wraith_beacon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_flying_machine";
     newscript->pItemUse = ItemUse_item_flying_machine;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_gor_dreks_ointment";
     newscript->pItemUse = ItemUse_item_gor_dreks_ointment;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_muiseks_vessel";
     newscript->pItemUse = ItemUse_item_muiseks_vessel;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_razorthorn_flayer_gland";
     newscript->pItemUse = ItemUse_item_razorthorn_flayer_gland;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_tame_beast_rods";
     newscript->pItemUse = ItemUse_item_tame_beast_rods;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_protovoltaic_magneto_collector";
     newscript->pItemUse = ItemUse_item_protovoltaic_magneto_collector;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_soul_cannon";
     newscript->pItemUse = ItemUse_item_soul_cannon;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_sparrowhawk_net";
     newscript->pItemUse = ItemUse_item_sparrowhawk_net;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_voodoo_charm";
     newscript->pItemUse = ItemUse_item_voodoo_charm;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_vorenthals_presence";
     newscript->pItemUse = ItemUse_item_vorenthals_presence;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_yehkinyas_bramble";
     newscript->pItemUse = ItemUse_item_yehkinyas_bramble;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 
     newscript = new Script;
     newscript->Name="item_zezzaks_shard";
     newscript->pItemUse = ItemUse_item_zezzak_shard;
-    newscript->RegisterSelf();
-}
+    m_scripts[nrscripts++] = newscript;
+}
Index: /trunk/src/bindings/scripts/scripts/item/item_test.cpp
===================================================================
--- /trunk/src/bindings/scripts/scripts/item/item_test.cpp (revision 260)
+++ /trunk/src/bindings/scripts/scripts/item/item_test.cpp (revision 272)
@@ -39,4 +39,4 @@
     newscript->Name="item_test";
     newscript->pItemUse = ItemUse_item_test;
-    newscript->RegisterSelf();
+    m_scripts[nrscripts++] = newscript;
 }
Index: /trunk/src/bindings/scripts/ScriptMgr.cpp
===================================================================
--- /trunk/src/bindings/scripts/ScriptMgr.cpp (revision 260)
+++ /trunk/src/bindings/scripts/ScriptMgr.cpp (revision 272)
@@ -18,6 +18,5 @@
 
 //*** Global data ***
-int num_db_scripts;
-int num_sc_scripts;
+int nrscripts;
 Script *m_scripts[MAX_SCRIPTS];
 
@@ -48,4 +47,5 @@
 // Text Maps
 UNORDERED_MAP<int32, StringTextData> TextMap;
+
 
 //*** End Global data ***
@@ -1181,14 +1181,13 @@
 TRINITY_DLL_EXPORT
 void ScriptsFree()
-{
+{   
     // Free Spell Summary
     delete []SpellSummary;
 
     // Free resources before library unload
-    for(int i=0;i<num_db_scripts;i++)
+    for(int i=0;i<nrscripts;i++)
         delete m_scripts[i];
 
-    num_db_scripts = 0;
-    num_sc_scripts = 0;
+    nrscripts = 0;
 }
 
@@ -1241,6 +1240,4 @@
         LoadDatabase();
 
-    num_db_scripts = GetScriptNames().size();
-
     outstring_log("TSCR: Loading C++ scripts");
     barGoLink bar(1);
@@ -1248,4 +1245,5 @@
     outstring_log("");
 
+    nrscripts = 0;
     for(int i=0;i<MAX_SCRIPTS;i++)
         m_scripts[i]=NULL;
@@ -1778,5 +1776,6 @@
     // -------------------
 
-    outstring_log(">> Loaded %i C++ Scripts (of %i ScriptNames defined in Mangos database)", num_sc_scripts, num_db_scripts);
+    outstring_log("TSCR: Loaded %u C++ Scripts", nrscripts);
+    outstring_log("");
 }
 
@@ -1850,13 +1849,21 @@
 //*** Functions used internally ***
 
-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());
+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;
 }
 
@@ -1865,12 +1872,7 @@
 
 TRINITY_DLL_EXPORT
-char const* ScriptsVersion()
-{
-	return "Default Trinity scripting library";
-}
-TRINITY_DLL_EXPORT
 bool GossipHello ( Player * player, Creature *_Creature )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pGossipHello) return false;
 
@@ -1884,5 +1886,5 @@
     debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action);
 
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pGossipSelect) return false;
 
@@ -1896,5 +1898,5 @@
     debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action);
 
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false;
 
@@ -1906,5 +1908,5 @@
 bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pQuestAccept) return false;
 
@@ -1916,5 +1918,5 @@
 bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pQuestSelect) return false;
 
@@ -1926,5 +1928,5 @@
 bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pQuestComplete) return false;
 
@@ -1936,5 +1938,5 @@
 bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pChooseReward) return false;
 
@@ -1946,5 +1948,5 @@
 uint32 NPCDialogStatus( Player *player, Creature *_Creature )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100;
 
@@ -1956,6 +1958,6 @@
 uint32 GODialogStatus( Player *player, GameObject *_GO )
 {
-    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
-    if (!tmpscript || !tmpscript->pGODialogStatus) return 100;
+    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
+    if(!tmpscript || !tmpscript->pGODialogStatus) return 100;
 
     player->PlayerTalkClass->ClearMenus();
@@ -1966,5 +1968,5 @@
 bool ItemHello( Player *player, Item *_Item, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
     if (!tmpscript || !tmpscript->pItemHello) return false;
 
@@ -1976,5 +1978,5 @@
 bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
     if (!tmpscript || !tmpscript->pItemQuestAccept) return false;
 
@@ -1986,5 +1988,5 @@
 bool GOHello( Player *player, GameObject *_GO )
 {
-    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
     if (!tmpscript || !tmpscript->pGOHello) return false;
 
@@ -1996,5 +1998,5 @@
 bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest )
 {
-    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
     if (!tmpscript || !tmpscript->pGOQuestAccept) return false;
 
@@ -2006,5 +2008,5 @@
 bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt )
 {
-    Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+    Script *tmpscript = GetScriptByName(_GO->GetGOInfo()->ScriptName);
     if (!tmpscript || !tmpscript->pGOChooseReward) return false;
 
@@ -2016,5 +2018,7 @@
 bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry)
 {
-    Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
+    Script *tmpscript = NULL;
+
+    tmpscript = GetScriptByName(GetAreaTriggerScriptNameById(atEntry->id));
     if (!tmpscript || !tmpscript->pAreaTrigger) return false;
 
@@ -2025,7 +2029,7 @@
 CreatureAI* GetAI(Creature *_Creature)
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
+
     if (!tmpscript || !tmpscript->GetAI) return NULL;
-
     return tmpscript->GetAI(_Creature);
 }
@@ -2034,5 +2038,5 @@
 bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
 {
-    Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+    Script *tmpscript = GetScriptByName(_Item->GetProto()->ScriptName);
     if (!tmpscript || !tmpscript->pItemUse) return false;
 
@@ -2043,5 +2047,5 @@
 bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote )
 {
-    Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+    Script *tmpscript = GetScriptByName(_Creature->GetScriptName());
     if (!tmpscript || !tmpscript->pReceiveEmote) return false;
 
@@ -2052,8 +2056,10 @@
 InstanceData* CreateInstanceData(Map *map)
 {
-    if (!map->IsDungeon()) return NULL;
-
-    Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()];
-    if (!tmpscript || !tmpscript->GetInstanceData) return NULL;
+    Script *tmpscript = NULL;
+
+    if (!map->IsDungeon()) return false;
+
+    tmpscript = GetScriptByName(((InstanceMap*)map)->GetScript());
+    if (!tmpscript || !tmpscript->GetInstanceData) return false;
 
     return tmpscript->GetInstanceData(map);
Index: /trunk/src/framework/Utilities/LinkedReference/Reference.h
===================================================================
--- /trunk/src/framework/Utilities/LinkedReference/Reference.h (revision 257)
+++ /trunk/src/framework/Utilities/LinkedReference/Reference.h (revision 272)
@@ -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
  */
 
@@ -75,5 +75,4 @@
 
         Reference<TO,FROM>* next() { return((Reference<TO,FROM>*)LinkedListElement::next()); }
-        Reference<TO,FROM>const* next() const { return((Reference<TO,FROM> const*)LinkedListElement::next()); }
         Reference<TO,FROM>* prev() { return((Reference<TO,FROM>*)LinkedListElement::prev()); }
 
Index: /trunk/src/framework/Utilities/LinkedReference/RefManager.h
===================================================================
--- /trunk/src/framework/Utilities/LinkedReference/RefManager.h (revision 257)
+++ /trunk/src/framework/Utilities/LinkedReference/RefManager.h (revision 272)
@@ -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
  */
 
@@ -34,7 +34,5 @@
 
         Reference<TO, FROM>* getFirst() { return ((Reference<TO, FROM>*) LinkedListHead::getFirst()); }
-        Reference<TO, FROM> const* getFirst() const { return ((Reference<TO, FROM> const*) LinkedListHead::getFirst()); }
         Reference<TO, FROM>* getLast() { return ((Reference<TO, FROM>*) LinkedListHead::getLast()); }
-        Reference<TO, FROM> const* getLast() const { return ((Reference<TO, FROM> const*) LinkedListHead::getLast()); }
 
         iterator begin() { return iterator(getFirst()); }
Index: /trunk/win/VC71/game.vcproj
===================================================================
--- /trunk/win/VC71/game.vcproj (revision 257)
+++ /trunk/win/VC71/game.vcproj (revision 272)
@@ -338,10 +338,4 @@
 			</File>
 			<File
-				RelativePath="..\..\src\game\MapReference.h">
-			</File>
-			<File
-				RelativePath="..\..\src\game\MapRefManager.h">
-			</File>				
-			<File
 				RelativePath="..\..\src\game\MiscHandler.cpp">
 			</File>
Index: /trunk/win/VC80/game.vcproj
===================================================================
--- /trunk/win/VC80/game.vcproj (revision 257)
+++ /trunk/win/VC80/game.vcproj (revision 272)
@@ -628,12 +628,4 @@
 			</File>
 			<File
-				RelativePath="..\..\src\game\MapReference.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\game\MapRefManager.h"
-				>
-			</File>				
-			<File
 				RelativePath="..\..\src\game\MiscHandler.cpp"
 				>
Index: /trunk/win/VC90/game.vcproj
===================================================================
--- /trunk/win/VC90/game.vcproj (revision 257)
+++ /trunk/win/VC90/game.vcproj (revision 272)
@@ -633,12 +633,4 @@
 			</File>
 			<File
-				RelativePath="..\..\src\game\MapReference.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\game\MapRefManager.h"
-				>
-			</File>			
-			<File
 				RelativePath="..\..\src\game\MiscHandler.cpp"
 				>
Index: /trunk/sql/characters.sql
===================================================================
--- /trunk/sql/characters.sql (revision 256)
+++ /trunk/sql/characters.sql (revision 272)
@@ -1,5 +1,5 @@
 -- MySQL dump 10.11
 --
--- Host: localhost    Database: char_temp
+-- Host: localhost    Database: characters
 -- ------------------------------------------------------
 -- Server version	5.0.34-log
@@ -615,5 +615,4 @@
   `death_expire_time` bigint(20) unsigned NOT NULL default '0',
   `taxi_path` text,
-  `latency` int(11) unsigned NOT NULL default '0',
   PRIMARY KEY  (`guid`),
   KEY `idx_account` (`account`),
@@ -1303,3 +1302,3 @@
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 
--- Dump completed on 2008-11-18 11:24:11
+-- Dump completed on 2008-10-14 13:27:52
