Changeset 272 for trunk/src/game/World.cpp
- Timestamp:
- 11/22/08 00:35:41 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/World.cpp
r260 r272 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. 13 * 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;70 69 volatile uint32 World::m_worldLoopCounter = 0; 71 70 … … 544 543 m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 545 544 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 608 609 if(reload) 609 610 { … … 769 770 m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 100); 770 771 771 // always use declined names in the russian client772 m_configs[CONFIG_DECLINED_NAMES_USED] = 772 // always use declined names in the Russian client 773 m_configs[CONFIG_DECLINED_NAMES_USED] = 773 774 (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false); 774 775 … … 965 966 DetectDBCLang(); 966 967 967 sLog.outString( "Loading Script Names...");968 objmgr.LoadScriptNames();969 970 968 sLog.outString( "Loading InstanceTemplate" ); 971 969 objmgr.LoadInstanceTemplate(); … … 1083 1081 sLog.outString( "Loading Tavern Area Triggers..." ); 1084 1082 objmgr.LoadTavernAreaTriggers(); 1085 1083 1086 1084 sLog.outString( "Loading AreaTrigger script names..." ); 1087 1085 objmgr.LoadAreaTriggerScripts(); 1086 1088 1087 1089 1088 sLog.outString( "Loading Graveyard-zone links..."); … … 1166 1165 sLog.outString( "Loading Npc Text Id..." ); 1167 1166 objmgr.LoadNpcTextId(); // must be after load Creature and NpcText 1168 1167 1169 1168 sLog.outString( "Loading Npc Options..." ); 1170 1169 objmgr.LoadNpcOptions(); … … 1194 1193 objmgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data) 1195 1194 1196 sLog.outString( "Loading Scripts text locales..." ); // must be after Load*Scripts calls1197 objmgr.LoadDbScriptStrings();1198 1199 1195 sLog.outString( "Initializing Scripts..." ); 1200 1196 if(!LoadScriptingModule()) … … 1267 1263 sLog.outString( "WORLD: World initialized" ); 1268 1264 } 1269 1270 1265 void World::DetectDBCLang() 1271 1266 { … … 1468 1463 } 1469 1464 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" 1473 1466 1474 1467 // update the instance reset times … … 1590 1583 } 1591 1584 1592 //if(source && !source->IsInWorld()) source = NULL;1593 1594 1585 Object* target = NULL; 1595 1586 … … 1619 1610 } 1620 1611 1621 //if(target && !target->IsInWorld()) target = NULL;1622 1623 1612 switch (step.script->command) 1624 1613 { … … 1648 1637 { 1649 1638 case 0: // Say 1650 ((Creature *)source)->Say(step.script->data int, LANG_UNIVERSAL, unit_target);1639 ((Creature *)source)->Say(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 1651 1640 break; 1652 1641 case 1: // Whisper … … 1656 1645 break; 1657 1646 } 1658 ((Creature *)source)->Whisper(step.script->data int,unit_target);1647 ((Creature *)source)->Whisper(step.script->datatext.c_str(),unit_target); 1659 1648 break; 1660 1649 case 2: // Yell 1661 ((Creature *)source)->Yell(step.script->data int, LANG_UNIVERSAL, unit_target);1650 ((Creature *)source)->Yell(step.script->datatext.c_str(), LANG_UNIVERSAL, unit_target); 1662 1651 break; 1663 1652 case 3: // Emote text 1664 ((Creature *)source)->TextEmote(step.script->data int, unit_target);1653 ((Creature *)source)->TextEmote(step.script->datatext.c_str(), unit_target); 1665 1654 break; 1666 1655 default: … … 1713 1702 } 1714 1703 ((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); 1716 1705 break; 1717 1706 case SCRIPT_COMMAND_FLAG_SET: … … 1863 1852 go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds 1864 1853 1865 go->GetMap()->Add(go);1854 MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); 1866 1855 break; 1867 1856 } … … 2385 2374 2386 2375 ///- if there is a shutdown timer 2387 if( !m_stopEvent &&m_ShutdownTimer > 0 && elapsed > 0)2376 if(m_ShutdownTimer > 0 && elapsed > 0) 2388 2377 { 2389 2378 ///- ... and it is overdue, stop the world (set m_stopEvent) … … 2391 2380 { 2392 2381 if(!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2393 m_stopEvent = true; // exist code already set2382 m_stopEvent = true; 2394 2383 else 2395 2384 m_ShutdownTimer = 1; // minimum timer value to wait idle state … … 2406 2395 2407 2396 /// 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 2397 void World::ShutdownServ(uint32 time, uint32 options) 2398 { 2414 2399 m_ShutdownMask = options; 2415 m_ExitCode = exitcode;2416 2400 2417 2401 ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) … … 2419 2403 { 2420 2404 if(!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) 2421 m_stopEvent = true; // exist code already set2405 m_stopEvent = true; 2422 2406 else 2423 2407 m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick … … 2464 2448 void World::ShutdownCancel() 2465 2449 { 2466 // nothing cancel or too later 2467 if(!m_ShutdownTimer || m_stopEvent) 2450 if(!m_ShutdownTimer) 2468 2451 return; 2469 2452 … … 2472 2455 m_ShutdownMask = 0; 2473 2456 m_ShutdownTimer = 0; 2474 m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value2475 2457 SendServerMessage(msgid); 2476 2458 2477 DEBUG_LOG("Server %s cancel led.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));2459 DEBUG_LOG("Server %s canceled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown")); 2478 2460 } 2479 2461 … … 2520 2502 if(!itr->second->Update(diff)) // As interval = 0 2521 2503 { 2522 RemoveQueuedPlayer (itr->second);2523 2504 delete itr->second; 2524 2505 m_sessions.erase(itr);