Show
Ignore:
Timestamp:
11/21/08 08:47:55 (17 years ago)
Author:
yumileroy
Message:

*DB script table stucture change. Source Mangos. Also fix some bugs. Hopefully this rev will make program usable again.

Original author: megamage
Date: 2008-11-20 10:43:20-06:00

Files:
1 modified

Legend:

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

    r230 r260  
    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; 
     69uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 
    6970volatile uint32 World::m_worldLoopCounter = 0; 
    7071 
     
    543544        m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 
    544545 
    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  
    609608    if(reload) 
    610609    { 
     
    770769    m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 
    771770 
    772     // always use declined names in the Russian client 
    773     m_configs[CONFIG_DECLINED_NAMES_USED] =  
     771    // always use declined names in the russian client 
     772    m_configs[CONFIG_DECLINED_NAMES_USED] = 
    774773        (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 
    775774 
     
    966965    DetectDBCLang(); 
    967966 
     967    sLog.outString( "Loading Script Names..."); 
     968    objmgr.LoadScriptNames(); 
     969 
    968970    sLog.outString( "Loading InstanceTemplate" ); 
    969971    objmgr.LoadInstanceTemplate(); 
     
    10811083    sLog.outString( "Loading Tavern Area Triggers..." ); 
    10821084    objmgr.LoadTavernAreaTriggers(); 
    1083      
     1085 
    10841086    sLog.outString( "Loading AreaTrigger script names..." ); 
    10851087    objmgr.LoadAreaTriggerScripts(); 
    1086  
    10871088 
    10881089    sLog.outString( "Loading Graveyard-zone links..."); 
     
    11651166    sLog.outString( "Loading Npc Text Id..." ); 
    11661167    objmgr.LoadNpcTextId();                                 // must be after load Creature and NpcText 
    1167      
     1168 
    11681169    sLog.outString( "Loading Npc Options..." ); 
    11691170    objmgr.LoadNpcOptions(); 
     
    11931194    objmgr.LoadEventScripts();                              // must be after load Creature/Gameobject(Template/Data) 
    11941195 
     1196    sLog.outString( "Loading Scripts text locales..." );    // must be after Load*Scripts calls 
     1197    objmgr.LoadDbScriptStrings(); 
     1198 
    11951199    sLog.outString( "Initializing Scripts..." ); 
    11961200    if(!LoadScriptingModule()) 
     
    12631267    sLog.outString( "WORLD: World initialized" ); 
    12641268} 
     1269 
    12651270void World::DetectDBCLang() 
    12661271{ 
     
    14631468    } 
    14641469 
    1465     MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 
     1470    /// </ul> 
     1471    ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 
     1472    MapManager::Instance().DoDelayedMovesAndRemoves(); 
    14661473 
    14671474    // update the instance reset times 
     
    15831590        } 
    15841591 
     1592        //if(source && !source->IsInWorld()) source = NULL; 
     1593 
    15851594        Object* target = NULL; 
    15861595 
     
    16101619        } 
    16111620 
     1621        //if(target && !target->IsInWorld()) target = NULL; 
     1622 
    16121623        switch (step.script->command) 
    16131624        { 
     
    16371648                { 
    16381649                    case 0:                                 // Say 
    1639                         ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 
     1650                        ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); 
    16401651                        break; 
    16411652                    case 1:                                 // Whisper 
     
    16451656                            break; 
    16461657                        } 
    1647                         ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); 
     1658                        ((Creature *)source)->Whisper(step.script->dataint,unit_target); 
    16481659                        break; 
    16491660                    case 2:                                 // Yell 
    1650                         ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 
     1661                        ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); 
    16511662                        break; 
    16521663                    case 3:                                 // Emote text 
    1653                         ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); 
     1664                        ((Creature *)source)->TextEmote(step.script->dataint, unit_target); 
    16541665                        break; 
    16551666                    default: 
     
    17021713                } 
    17031714                ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); 
    1704                 MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 
     1715                ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); 
    17051716                break; 
    17061717            case SCRIPT_COMMAND_FLAG_SET: 
     
    18521863                go->SetRespawnTime(time_to_despawn);        //despawn object in ? seconds 
    18531864 
    1854                 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); 
     1865                go->GetMap()->Add(go); 
    18551866                break; 
    18561867            } 
     
    23742385 
    23752386    ///- if there is a shutdown timer 
    2376     if(m_ShutdownTimer > 0 && elapsed > 0) 
     2387    if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) 
    23772388    { 
    23782389        ///- ... and it is overdue, stop the world (set m_stopEvent) 
     
    23802391        { 
    23812392            if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 
    2382                 m_stopEvent = true; 
     2393                m_stopEvent = true;                         // exist code already set 
    23832394            else 
    23842395                m_ShutdownTimer = 1;                        // minimum timer value to wait idle state 
     
    23952406 
    23962407/// Shutdown the server 
    2397 void World::ShutdownServ(uint32 time, uint32 options) 
    2398 { 
     2408void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) 
     2409{ 
     2410    // ignore if server shutdown at next tick 
     2411    if(m_stopEvent) 
     2412        return; 
     2413 
    23992414    m_ShutdownMask = options; 
     2415    m_ExitCode = exitcode; 
    24002416 
    24012417    ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) 
     
    24032419    { 
    24042420        if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 
    2405             m_stopEvent = true; 
     2421            m_stopEvent = true;                             // exist code already set 
    24062422        else 
    24072423            m_ShutdownTimer = 1;                            //So that the session count is re-evaluated at next world tick 
     
    24482464void World::ShutdownCancel() 
    24492465{ 
    2450     if(!m_ShutdownTimer) 
     2466    // nothing cancel or too later 
     2467    if(!m_ShutdownTimer || m_stopEvent) 
    24512468        return; 
    24522469 
     
    24552472    m_ShutdownMask = 0; 
    24562473    m_ShutdownTimer = 0; 
     2474    m_ExitCode = SHUTDOWN_EXIT_CODE;                       // to default value 
    24572475    SendServerMessage(msgid); 
    24582476 
    2459     DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 
     2477    DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 
    24602478} 
    24612479 
     
    25022520        if(!itr->second->Update(diff))                      // As interval = 0 
    25032521        { 
     2522            RemoveQueuedPlayer (itr->second); 
    25042523            delete itr->second; 
    25052524            m_sessions.erase(itr);