Changeset 260 for trunk/src/game/World.cpp
- Timestamp:
- 11/21/08 08:47:55 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/World.cpp
r230 r260 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 67 67 68 68 volatile bool World::m_stopEvent = false; 69 uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE; 69 70 volatile uint32 World::m_worldLoopCounter = 0; 70 71 … … 543 544 m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 544 545 545 546 546 m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); 547 547 /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define … … 606 606 } 607 607 608 609 608 if(reload) 610 609 { … … 770 769 m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 771 770 772 // always use declined names in the Russian client773 m_configs[CONFIG_DECLINED_NAMES_USED] = 771 // always use declined names in the russian client 772 m_configs[CONFIG_DECLINED_NAMES_USED] = 774 773 (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 775 774 … … 966 965 DetectDBCLang(); 967 966 967 sLog.outString( "Loading Script Names..."); 968 objmgr.LoadScriptNames(); 969 968 970 sLog.outString( "Loading InstanceTemplate" ); 969 971 objmgr.LoadInstanceTemplate(); … … 1081 1083 sLog.outString( "Loading Tavern Area Triggers..." ); 1082 1084 objmgr.LoadTavernAreaTriggers(); 1083 1085 1084 1086 sLog.outString( "Loading AreaTrigger script names..." ); 1085 1087 objmgr.LoadAreaTriggerScripts(); 1086 1087 1088 1088 1089 sLog.outString( "Loading Graveyard-zone links..."); … … 1165 1166 sLog.outString( "Loading Npc Text Id..." ); 1166 1167 objmgr.LoadNpcTextId(); // must be after load Creature and NpcText 1167 1168 1168 1169 sLog.outString( "Loading Npc Options..." ); 1169 1170 objmgr.LoadNpcOptions(); … … 1193 1194 objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) 1194 1195 1196 sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls 1197 objmgr.LoadDbScriptStrings(); 1198 1195 1199 sLog.outString( "Initializing Scripts..." ); 1196 1200 if(!LoadScriptingModule()) … … 1263 1267 sLog.outString( "WORLD: World initialized" ); 1264 1268 } 1269 1265 1270 void World::DetectDBCLang() 1266 1271 { … … 1463 1468 } 1464 1469 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(); 1466 1473 1467 1474 // update the instance reset times … … 1583 1590 } 1584 1591 1592 //if(source && !source->IsInWorld()) source = NULL; 1593 1585 1594 Object* target = NULL; 1586 1595 … … 1610 1619 } 1611 1620 1621 //if(target && !target->IsInWorld()) target = NULL; 1622 1612 1623 switch (step.script->command) 1613 1624 { … … 1637 1648 { 1638 1649 case 0: // Say 1639 ((Creature *)source)->Say(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1650 ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); 1640 1651 break; 1641 1652 case 1: // Whisper … … 1645 1656 break; 1646 1657 } 1647 ((Creature *)source)->Whisper(step.script->data text.c_str(),unit_target);1658 ((Creature *)source)->Whisper(step.script->dataint,unit_target); 1648 1659 break; 1649 1660 case 2: // Yell 1650 ((Creature *)source)->Yell(step.script->data text.c_str(), LANG_UNIVERSAL, unit_target);1661 ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); 1651 1662 break; 1652 1663 case 3: // Emote text 1653 ((Creature *)source)->TextEmote(step.script->data text.c_str(), unit_target);1664 ((Creature *)source)->TextEmote(step.script->dataint, unit_target); 1654 1665 break; 1655 1666 default: … … 1702 1713 } 1703 1714 ((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); 1705 1716 break; 1706 1717 case SCRIPT_COMMAND_FLAG_SET: … … 1852 1863 go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds 1853 1864 1854 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go);1865 go->GetMap()->Add(go); 1855 1866 break; 1856 1867 } … … 2374 2385 2375 2386 ///- if there is a shutdown timer 2376 if( m_ShutdownTimer > 0 && elapsed > 0)2387 if(!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0) 2377 2388 { 2378 2389 ///- ... and it is overdue, stop the world (set m_stopEvent) … … 2380 2391 { 2381 2392 if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2382 m_stopEvent = true; 2393 m_stopEvent = true; // exist code already set 2383 2394 else 2384 2395 m_ShutdownTimer = 1; // minimum timer value to wait idle state … … 2395 2406 2396 2407 /// Shutdown the server 2397 void World::ShutdownServ(uint32 time, uint32 options) 2398 { 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 2399 2414 m_ShutdownMask = options; 2415 m_ExitCode = exitcode; 2400 2416 2401 2417 ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) … … 2403 2419 { 2404 2420 if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2405 m_stopEvent = true; 2421 m_stopEvent = true; // exist code already set 2406 2422 else 2407 2423 m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick … … 2448 2464 void World::ShutdownCancel() 2449 2465 { 2450 if(!m_ShutdownTimer) 2466 // nothing cancel or too later 2467 if(!m_ShutdownTimer || m_stopEvent) 2451 2468 return; 2452 2469 … … 2455 2472 m_ShutdownMask = 0; 2456 2473 m_ShutdownTimer = 0; 2474 m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value 2457 2475 SendServerMessage(msgid); 2458 2476 2459 DEBUG_LOG("Server %s cancel ed.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));2477 DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 2460 2478 } 2461 2479 … … 2502 2520 if(!itr->second->Update(diff)) // As interval = 0 2503 2521 { 2522 RemoveQueuedPlayer (itr->second); 2504 2523 delete itr->second; 2505 2524 m_sessions.erase(itr);