Changeset 44 for trunk/src/game/World.cpp
- Timestamp:
- 11/19/08 13:27:40 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/World.cpp
r42 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 … … 46 48 #include "Policies/SingletonImp.h" 47 49 #include "BattleGroundMgr.h" 50 #include "OutdoorPvPMgr.h" 48 51 #include "TemporarySummon.h" 49 52 #include "WaypointMovementGenerator.h" … … 57 60 #include "WaypointManager.h" 58 61 #include "Util.h" 59 #include "IRCClient.h"60 62 #include "Language.h" 61 63 … … 65 67 volatile uint32 World::m_worldLoopCounter = 0; 66 68 67 float World::m_PlayerStartGold = 0; // starting gold68 69 float World::m_MaxVisibleDistanceForCreature = DEFAULT_VISIBILITY_DISTANCE; 69 70 float World::m_MaxVisibleDistanceForPlayer = DEFAULT_VISIBILITY_DISTANCE; … … 524 525 uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT); 525 526 if(val!=m_configs[CONFIG_PORT_WORLD]) 526 sLog.outError("WorldServerPort option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]);527 sLog.outError("WorldServerPort option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_PORT_WORLD]); 527 528 } 528 529 else … … 533 534 uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME); 534 535 if(val!=m_configs[CONFIG_SOCKET_SELECTTIME]) 535 sLog.outError("SocketSelectTime option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[DEFAULT_SOCKET_SELECT_TIME]);536 sLog.outError("SocketSelectTime option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[DEFAULT_SOCKET_SELECT_TIME]); 536 537 } 537 538 else … … 541 542 m_configs[CONFIG_TCP_NO_DELAY] = sConfig.GetBoolDefault("TcpNoDelay", false); 542 543 m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74); 543 /// \todo Add MonsterSight and GuarderSight (with meaning) in mangosd.conf or put them as define544 /// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define 544 545 m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50); 545 546 m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50); … … 549 550 uint32 val = sConfig.GetIntDefault("GameType", 0); 550 551 if(val!=m_configs[CONFIG_GAME_TYPE]) 551 sLog.outError("GameType option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]);552 sLog.outError("GameType option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_GAME_TYPE]); 552 553 } 553 554 else … … 558 559 uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT); 559 560 if(val!=m_configs[CONFIG_REALM_ZONE]) 560 sLog.outError("RealmZone option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]);561 sLog.outError("RealmZone option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_REALM_ZONE]); 561 562 } 562 563 else … … 725 726 uint32 val = sConfig.GetIntDefault("Expansion",1); 726 727 if(val!=m_configs[CONFIG_EXPANSION]) 727 sLog.outError("Expansion option can't be changed at mangosd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]);728 sLog.outError("Expansion option can't be changed at Trinityd.conf reload, using current value (%u).",m_configs[CONFIG_EXPANSION]); 728 729 } 729 730 else … … 774 775 m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300); 775 776 776 m_PlayerStartGold = sConfig.GetFloatDefault("PlayerStart.Gold", 0); 777 if(m_PlayerStartGold < 0) 778 m_PlayerStartGold = 0; 779 780 if(m_PlayerStartGold > MAX_MONEY_AMOUNT) 781 m_PlayerStartGold = MAX_MONEY_AMOUNT; 782 783 m_configs[CONFIG_PLAYER_START_HONOR] = sConfig.GetIntDefault("PlayerStart.HonorPoints", 0); 784 if(m_configs[CONFIG_PLAYER_START_HONOR] < 0) 785 m_configs[CONFIG_PLAYER_START_HONOR] = 0; 786 787 m_configs[CONFIG_PLAYER_START_ARENAPTS] = sConfig.GetIntDefault("PlayerStart.ArenaPoints", 0); 788 if(m_configs[CONFIG_PLAYER_START_ARENAPTS] < 0) 789 m_configs[CONFIG_PLAYER_START_ARENAPTS] = 0; 790 791 m_configs[CONFIG_GM_START_LEVEL] = sConfig.GetIntDefault("GamemasterStartLevel", 70); 792 if(m_configs[CONFIG_GM_START_LEVEL] < 1) 793 m_configs[CONFIG_GM_START_LEVEL] = 1; 794 795 m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetBoolDefault("PlayerInstantLogout", false); 796 m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); 797 m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); 798 // Leaving GM queue option out for now, it's not 100% functional with the ACE patch 799 //m_configs[CONFIG_QUEUE_FOR_GM] = sConfig.GetBoolDefault("EnableQueueForGMs", false); 800 m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); 801 if(m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) 802 m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; 803 m_configs[CONFIG_KICK_FROM_GMISLAND] = sConfig.GetBoolDefault("AntiCheat.GMIsland", false); 804 m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); 805 m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetBoolDefault("DisableWaterBreath", false); 806 m_configs[CONFIG_DISABLE_RES_SICKNESS] = sConfig.GetBoolDefault("DisableResurrectSickness", false); 807 m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); 808 m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false); 809 m_configs[CONFIG_START_ALL_TAXI] = sConfig.GetBoolDefault("PlayerStart.AllFlightPaths", false); 810 m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false); 811 m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); 812 m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); 813 m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); 814 if(m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) 815 m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; 816 m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false); 777 m_configs[CONFIG_PLAYER_START_GOLD] = sConfig.GetFloatDefault("PlayerStart.Gold", 0); 778 if(m_configs[CONFIG_PLAYER_START_GOLD] < 0) 779 m_configs[CONFIG_PLAYER_START_GOLD] = 0; 780 781 if(m_configs[CONFIG_PLAYER_START_GOLD] > MAX_MONEY_AMOUNT) 782 m_configs[CONFIG_PLAYER_START_GOLD] = MAX_MONEY_AMOUNT; 783 784 m_configs[CONFIG_PLAYER_START_HONOR] = sConfig.GetIntDefault("PlayerStart.HonorPoints", 0); 785 if(m_configs[CONFIG_PLAYER_START_HONOR] < 0) 786 m_configs[CONFIG_PLAYER_START_HONOR] = 0; 787 788 m_configs[CONFIG_PLAYER_START_ARENAPTS] = sConfig.GetIntDefault("PlayerStart.ArenaPoints", 0); 789 if(m_configs[CONFIG_PLAYER_START_ARENAPTS] < 0) 790 m_configs[CONFIG_PLAYER_START_ARENAPTS] = 0; 791 792 m_configs[CONFIG_GM_START_LEVEL] = sConfig.GetIntDefault("GamemasterStartLevel", 70); 793 if(m_configs[CONFIG_GM_START_LEVEL] < 1) 794 m_configs[CONFIG_GM_START_LEVEL] = 1; 795 796 m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetBoolDefault("PlayerInstantLogout", false); 797 m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false); 798 m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false); 799 m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0); 800 if(m_configs[CONFIG_HONOR_AFTER_DUEL] < 0) 801 m_configs[CONFIG_HONOR_AFTER_DUEL]= 0; 802 m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false); 803 m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetBoolDefault("DisableWaterBreath", false); 804 m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false); 805 m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false); 806 m_configs[CONFIG_START_ALL_TAXI] = sConfig.GetBoolDefault("PlayerStart.AllFlightPaths", false); 807 m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false); 808 m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4); 809 m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434); 810 m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1); 811 if(m_configs[CONFIG_PVP_TOKEN_COUNT] < 1) 812 m_configs[CONFIG_PVP_TOKEN_COUNT] = 1; 813 m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false); 817 814 818 815 m_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = sConfig.GetIntDefault("Arena.MaxRatingDifference", 0); … … 884 881 { 885 882 if(dataPath!=m_dataPath) 886 sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).",m_dataPath.c_str());883 sLog.outError("DataDir option can't be changed at Trinityd.conf reload, using current value (%s).",m_dataPath.c_str()); 887 884 } 888 885 else … … 891 888 sLog.outString("Using DataDir %s",m_dataPath.c_str()); 892 889 } 890 891 std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", ""); 892 char * forbiddenMaps = new char[forbiddenmaps.length() + 1]; 893 forbiddenMaps[forbiddenmaps.length()] = 0; 894 strncpy(forbiddenMaps, forbiddenmaps.c_str(), forbiddenmaps.length()); 895 const char * delim = ","; 896 char * token = strtok(forbiddenMaps, delim); 897 while(token != NULL) 898 { 899 int32 mapid = strtol(token, NULL, 10); 900 m_forbiddenMapIds.insert(mapid); 901 token = strtok(NULL,delim); 902 } 903 delete[] forbiddenMaps; 893 904 894 905 bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); … … 928 939 !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f) ) ) 929 940 { 930 sLog.outError("Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str(),m_dataPath.c_str());941 sLog.outError("Correct *.map files not found in path '%smaps' or *.vmap/*vmdir files in '%svmaps'. Please place *.map/*.vmap/*.vmdir files in appropriate directories or correct the DataDir value in the Trinityd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); 931 942 exit(1); 932 943 } … … 934 945 ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output. 935 946 sLog.outString( "" ); 936 sLog.outString( "Loading MaNGOSstrings..." );937 if (!objmgr.Load MangosStrings())947 sLog.outString( "Loading Trinity strings..." ); 948 if (!objmgr.LoadTrinityStrings()) 938 949 exit(1); // Error message displayed in function already 939 950 … … 1181 1192 WorldDatabase.PExecute("INSERT INTO uptime (startstring, starttime, uptime) VALUES('%s', %ld, 0)", isoDate, m_startTime ); 1182 1193 1183 static uint32 autoanc = 1;1184 autoanc = sIRC.autoanc;1185 1186 1194 m_timers[WUPDATE_OBJECTS].SetInterval(0); 1187 1195 m_timers[WUPDATE_SESSIONS].SetInterval(0); … … 1192 1200 m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*1000); //erase corpses every 20 minutes 1193 1201 1194 m_timers[WUPDATE_AUTOANC].SetInterval(autoanc*MINUTE*1000);1195 1196 1202 //to set mailtimer to return mails every day between 4 and 5 am 1197 1203 //mailtimer is increased when updating auctions … … 1215 1221 sBattleGroundMgr.CreateInitialBattleGrounds(); 1216 1222 sBattleGroundMgr.InitAutomaticArenaPointDistribution(); 1223 1224 ///- Initialize outdoor pvp 1225 sLog.outString( "Starting Outdoor PvP System" ); 1226 sOutdoorPvPMgr.InitOutdoorPvP(); 1217 1227 1218 1228 //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager … … 1408 1418 1409 1419 sBattleGroundMgr.Update(diff); 1420 1421 sOutdoorPvPMgr.Update(diff); 1410 1422 } 1411 1423 … … 1430 1442 } 1431 1443 1432 if (m_timers[WUPDATE_AUTOANC].Passed())1433 {1434 m_timers[WUPDATE_AUTOANC].Reset(); /// </ul>1435 SendRNDBroadcast();1436 }1437 1444 MapManager::Instance().DoDelayedMovesAndRemoves(); ///- Move all creatures with "delayed move" and remove and delete all objects with "delayed remove" 1438 1445 … … 1442 1449 // And last, but not least handle the issued cli commands 1443 1450 ProcessCliCommands(); 1451 } 1452 1453 void World::ForceGameEventUpdate() 1454 { 1455 m_timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed 1456 uint32 nextGameEvent = gameeventmgr.Update(); 1457 m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); 1458 m_timers[WUPDATE_EVENTS].Reset(); 1444 1459 } 1445 1460 … … 1783 1798 int32 time_to_despawn = step.script->datalong2<5 ? 5 : (int32)step.script->datalong2; 1784 1799 1785 CellPair p( MaNGOS::ComputeCellPair(summoner->GetPositionX(), summoner->GetPositionY()));1800 CellPair p(Trinity::ComputeCellPair(summoner->GetPositionX(), summoner->GetPositionY())); 1786 1801 Cell cell(p); 1787 1802 cell.data.Part.reserved = ALL_DISTRICT; 1788 1803 1789 MaNGOS::GameObjectWithDbGUIDCheck go_check(*summoner,step.script->datalong);1790 MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(go,go_check);1791 1792 TypeContainerVisitor< MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);1804 Trinity::GameObjectWithDbGUIDCheck go_check(*summoner,step.script->datalong); 1805 Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(go,go_check); 1806 1807 TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); 1793 1808 CellLock<GridReadGuard> cell_lock(cell, p); 1794 1809 cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(summoner->GetMapId(), summoner)); … … 1844 1859 int32 time_to_close = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; 1845 1860 1846 CellPair p( MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));1861 CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); 1847 1862 Cell cell(p); 1848 1863 cell.data.Part.reserved = ALL_DISTRICT; 1849 1864 1850 MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong);1851 MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(door,go_check);1852 1853 TypeContainerVisitor< MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);1865 Trinity::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); 1866 Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(door,go_check); 1867 1868 TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); 1854 1869 CellLock<GridReadGuard> cell_lock(cell, p); 1855 1870 cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); … … 1900 1915 int32 time_to_open = step.script->datalong2 < 15 ? 15 : (int32)step.script->datalong2; 1901 1916 1902 CellPair p( MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));1917 CellPair p(Trinity::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY())); 1903 1918 Cell cell(p); 1904 1919 cell.data.Part.reserved = ALL_DISTRICT; 1905 1920 1906 MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong);1907 MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(door,go_check);1908 1909 TypeContainerVisitor< MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker);1921 Trinity::GameObjectWithDbGUIDCheck go_check(*caster,step.script->datalong); 1922 Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck> checker(door,go_check); 1923 1924 TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectWithDbGUIDCheck>, GridTypeMapContainer > object_checker(checker); 1910 1925 CellLock<GridReadGuard> cell_lock(cell, p); 1911 1926 cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); … … 2131 2146 data_list = &data_cache[cache_idx]; 2132 2147 2133 char const* text = objmgr.Get MangosString(string_id,loc_idx);2148 char const* text = objmgr.GetTrinityString(string_id,loc_idx); 2134 2149 2135 2150 char buf[1000]; … … 2510 2525 } 2511 2526 2512 void World::SendRNDBroadcast()2513 {2514 std::string msg;2515 QueryResult *result = WorldDatabase.PQuery("SELECT `message` FROM `IRC_AutoAnnounce` ORDER BY RAND() LIMIT 1");2516 if(!result)2517 return;2518 msg = result->Fetch()[0].GetString();2519 delete result;2520 std::string str = "|cffff0000[Automatic]:|r";2521 str += msg;2522 sWorld.SendWorldText(LANG_AUTO_ANN);2523 std::string ircchan = "#";2524 ircchan += sIRC._irc_chan[sIRC.anchn].c_str();2525 sIRC.Send_IRC_Channel(ircchan, sIRC.MakeMsg("\00304,08\037/!\\\037\017\00304 Automatic System Message \00304,08\037/!\\\037\017 %s", "%s", msg.c_str()), true);2526 }2527 2528 2527 void World::InitResultQueue() 2529 2528 {