Changeset 3158

Show
Ignore:
Timestamp:
02/07/2010 02:33:38 PM (7 months ago)
Author:
jackpoz
Message:

FIXED: CreatureAIScript::Destroy() is called by MapCell::RemoveObjects?(), too.

Location:
trunk/src/arcemu-world
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/arcemu-world/Creature.cpp

    r3148 r3158  
    749749} 
    750750 
     751void Creature::RemoveFromWorld(bool free_guid) 
     752{ 
     753        PrepareForDeletion(); 
     754        Unit::RemoveFromWorld(free_guid); 
     755} 
     756 
    751757void Creature::EnslaveExpire() 
    752758{ 
     
    18341840        } 
    18351841 
    1836         //remove ai stuff 
    1837         sEventMgr.RemoveEvents( this, EVENT_CREATURE_AISPELL ); 
    1838  
    1839         if( GetScript() != NULL ) 
    1840         { 
    1841                 GetScript()->Destroy(); 
    1842                 _myScriptClass = NULL; 
    1843         } 
    1844  
    1845         RemoveAllAuras(); 
    1846          
    1847         // If we have a summons then let's remove them 
    1848         RemoveAllGuardians(); 
    1849          
    1850         // remove our reference from owner 
    1851         if( m_owner != NULL ) 
    1852         { 
    1853                 m_owner->RemoveGuardianRef( this ); 
    1854                 m_owner = NULL; 
    1855         } 
     1842        PrepareForDeletion(); 
    18561843 
    18571844        if(!IsInWorld()) 
    18581845                return; 
    1859  
    1860         if(GetMapMgr() && GetMapMgr()->GetMapInfo() && GetMapMgr()->GetMapInfo()->type == INSTANCE_RAID) 
    1861         { 
    1862                 if(GetCreatureInfo() && GetCreatureInfo()->Rank == 3) 
    1863                 { 
    1864                         GetMapMgr()->RemoveCombatInProgress(GetGUID()); 
    1865                 } 
    1866         } 
    18671846 
    18681847        if( IsPet() ) 
     
    21162095                (*itr)->RemoveSanctuaryFlag(); 
    21172096} 
     2097 
     2098void Creature::PrepareForDeletion() 
     2099{ 
     2100        //remove ai stuff 
     2101        sEventMgr.RemoveEvents( this, EVENT_CREATURE_AISPELL ); 
     2102 
     2103        if( GetScript() != NULL ) 
     2104        { 
     2105                GetScript()->Destroy(); 
     2106                _myScriptClass = NULL; 
     2107        } 
     2108 
     2109        RemoveAllAuras(); 
     2110         
     2111        // If we have a summons then let's remove them 
     2112        RemoveAllGuardians(); 
     2113         
     2114        // remove our reference from owner 
     2115        if( m_owner != NULL ) 
     2116        { 
     2117                m_owner->RemoveGuardianRef( this ); 
     2118                m_owner = NULL; 
     2119        } 
     2120 
     2121        if(!IsInWorld()) 
     2122                return; 
     2123 
     2124        if(GetMapMgr() && GetMapMgr()->GetMapInfo() && GetMapMgr()->GetMapInfo()->type == INSTANCE_RAID) 
     2125        { 
     2126                if(GetCreatureInfo() && GetCreatureInfo()->Rank == 3) 
     2127                { 
     2128                        GetMapMgr()->RemoveCombatInProgress(GetGUID()); 
     2129                } 
     2130        } 
     2131} 
  • trunk/src/arcemu-world/Creature.h

    r3131 r3158  
    300300        void AddToWorld(MapMgr * pMapMgr); 
    301301        void RemoveFromWorld(bool addrespawnevent, bool free_guid); 
     302        void RemoveFromWorld(bool free_guid); 
     303 
     304        void PrepareForDeletion();//remove auras, guardians, scripts 
    302305 
    303306        /// Creation