Show
Ignore:
Timestamp:
11/22/08 00:35:41 (17 years ago)
Author:
yumileroy
Message:

Delete possessed AI only on creature delete.

Original author: gvcoman
Date: 2008-11-16 14:38:02-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/World.cpp

    r260 r272  
    1111 * This program is distributed in the hope that it will be useful, 
    1212 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1414 * GNU General Public License for more details. 
    1515 * 
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1919 */ 
    2020 
     
    6767 
    6868volatile bool World::m_stopEvent = false; 
    69 uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 
    7069volatile uint32 World::m_worldLoopCounter = 0; 
    7170 
     
    544543        m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 
    545544 
     545 
    546546    m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); 
    547547    /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define 
     
    606606    } 
    607607 
     608 
    608609    if(reload) 
    609610    { 
     
    769770    m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 
    770771 
    771     // always use declined names in the russian client 
    772     m_configs[CONFIG_DECLINED_NAMES_USED] = 
     772    // always use declined names in the Russian client 
     773    m_configs[CONFIG_DECLINED_NAMES_USED] =  
    773774        (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 
    774775 
     
    965966    DetectDBCLang(); 
    966967 
    967     sLog.outString( "Loading Script Names..."); 
    968     objmgr.LoadScriptNames(); 
    969  
    970968    sLog.outString( "Loading InstanceTemplate" ); 
    971969    objmgr.LoadInstanceTemplate(); 
     
    10831081    sLog.outString( "Loading Tavern Area Triggers..." ); 
    10841082    objmgr.LoadTavernAreaTriggers(); 
    1085  
     1083     
    10861084    sLog.outString( "Loading AreaTrigger script names..." ); 
    10871085    objmgr.LoadAreaTriggerScripts(); 
     1086 
    10881087 
    10891088    sLog.outString( "Loading Graveyard-zone links..."); 
     
    11661165    sLog.outString( "Loading Npc Text Id..." ); 
    11671166    objmgr.LoadNpcTextId();                                 // must be after load Creature and NpcText 
    1168  
     1167     
    11691168    sLog.outString( "Loading Npc Options..." ); 
    11701169    objmgr.LoadNpcOptions(); 
     
    11941193    objmgr.LoadEventScripts();                              // must be after load Creature/Gameobject(Template/Data) 
    11951194 
    1196     sLog.outString( "Loading Scripts text locales..." );    // must be after Load*Scripts calls 
    1197     objmgr.LoadDbScriptStrings(); 
    1198  
    11991195    sLog.outString( "Initializing Scripts..." ); 
    12001196    if(!LoadScriptingModule()) 
     
    12671263    sLog.outString( "WORLD: World initialized" ); 
    12681264} 
    1269  
    12701265void World::DetectDBCLang() 
    12711266{ 
     
    14681463    } 
    14691464 
    1470     /// </ul> 
    1471     ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 
    1472     MapManager::Instance().DoDelayedMovesAndRemoves(); 
     1465    MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 
    14731466 
    14741467    // update the instance reset times 
     
    15901583        } 
    15911584 
    1592         //if(source && !source->IsInWorld()) source = NULL; 
    1593  
    15941585        Object* target = NULL; 
    15951586 
     
    16191610        } 
    16201611 
    1621         //if(target && !target->IsInWorld()) target = NULL; 
    1622  
    16231612        switch (step.script->command) 
    16241613        { 
     
    16481637                { 
    16491638                    case 0:                                 // Say 
    1650                         ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); 
     1639                        ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 
    16511640                        break; 
    16521641                    case 1:                                 // Whisper 
     
    16561645                            break; 
    16571646                        } 
    1658                         ((Creature *)source)->Whisper(step.script->dataint,unit_target); 
     1647                        ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); 
    16591648                        break; 
    16601649                    case 2:                                 // Yell 
    1661                         ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); 
     1650                        ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 
    16621651                        break; 
    16631652                    case 3:                                 // Emote text 
    1664                         ((Creature *)source)->TextEmote(step.script->dataint, unit_target); 
     1653                        ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); 
    16651654                        break; 
    16661655                    default: 
     
    17131702                } 
    17141703                ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); 
    1715                 ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 
     1704                MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 
    17161705                break; 
    17171706            case SCRIPT_COMMAND_FLAG_SET: 
     
    18631852                go->SetRespawnTime(time_to_despawn);        //despawn object in ? seconds 
    18641853 
    1865                 go->GetMap()->Add(go); 
     1854                MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); 
    18661855                break; 
    18671856            } 
     
    23852374 
    23862375    ///- if there is a shutdown timer 
    2387     if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) 
     2376    if(m_ShutdownTimer > 0 && elapsed > 0) 
    23882377    { 
    23892378        ///- ... and it is overdue, stop the world (set m_stopEvent) 
     
    23912380        { 
    23922381            if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 
    2393                 m_stopEvent = true;                         // exist code already set 
     2382                m_stopEvent = true; 
    23942383            else 
    23952384                m_ShutdownTimer = 1;                        // minimum timer value to wait idle state 
     
    24062395 
    24072396/// Shutdown the server 
    2408 void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) 
    2409 { 
    2410     // ignore if server shutdown at next tick 
    2411     if(m_stopEvent) 
    2412         return; 
    2413  
     2397void World::ShutdownServ(uint32 time, uint32 options) 
     2398{ 
    24142399    m_ShutdownMask = options; 
    2415     m_ExitCode = exitcode; 
    24162400 
    24172401    ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) 
     
    24192403    { 
    24202404        if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 
    2421             m_stopEvent = true;                             // exist code already set 
     2405            m_stopEvent = true; 
    24222406        else 
    24232407            m_ShutdownTimer = 1;                            //So that the session count is re-evaluated at next world tick 
     
    24642448void World::ShutdownCancel() 
    24652449{ 
    2466     // nothing cancel or too later 
    2467     if(!m_ShutdownTimer || m_stopEvent) 
     2450    if(!m_ShutdownTimer) 
    24682451        return; 
    24692452 
     
    24722455    m_ShutdownMask = 0; 
    24732456    m_ShutdownTimer = 0; 
    2474     m_ExitCode = SHUTDOWN_EXIT_CODE;                       // to default value 
    24752457    SendServerMessage(msgid); 
    24762458 
    2477     DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 
     2459    DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 
    24782460} 
    24792461 
     
    25202502        if(!itr->second->Update(diff))                      // As interval = 0 
    25212503        { 
    2522             RemoveQueuedPlayer (itr->second); 
    25232504            delete itr->second; 
    25242505            m_sessions.erase(itr);