2008-10-11 14:16:25 -05:00
/*
2009-02-04 12:42:26 +01:00
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
2008-10-14 11:57:03 -05:00
*
2010-01-16 20:19:18 +03:00
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
2008-10-11 14:16:25 -05:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2008-11-20 16:16:57 -06:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2008-10-11 14:16:25 -05:00
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2008-11-20 16:16:57 -06:00
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2008-10-11 14:16:25 -05:00
*/
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/** \file
\ingroup world
*/
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Config/ConfigEnv.h"
#include "SystemConfig.h"
#include "Log.h"
#include "Opcodes.h"
#include "WorldSession.h"
#include "WorldPacket.h"
#include "Weather.h"
#include "Player.h"
2009-03-09 17:06:13 -06:00
#include "Vehicle.h"
2008-10-11 14:16:25 -05:00
#include "SkillExtraItems.h"
#include "SkillDiscovery.h"
#include "World.h"
2008-10-21 19:07:16 -05:00
#include "AccountMgr.h"
2009-01-06 13:55:14 -06:00
#include "AchievementMgr.h"
2009-02-13 19:50:20 -06:00
#include "AuctionHouseMgr.h"
2008-10-11 14:16:25 -05:00
#include "ObjectMgr.h"
2009-04-07 19:38:09 -05:00
#include "CreatureEventAIMgr.h"
2008-10-11 14:16:25 -05:00
#include "SpellMgr.h"
#include "Chat.h"
2009-03-27 09:58:20 -06:00
#include "DBCStores.h"
2008-10-11 14:16:25 -05:00
#include "LootMgr.h"
#include "ItemEnchantmentMgr.h"
#include "MapManager.h"
#include "CreatureAIRegistry.h"
#include "Policies/SingletonImp.h"
#include "BattleGroundMgr.h"
2008-10-14 11:57:03 -05:00
#include "OutdoorPvPMgr.h"
2008-10-11 14:16:25 -05:00
#include "TemporarySummon.h"
2009-01-20 16:44:05 -06:00
#include "AuctionHouseBot.h"
2008-10-11 14:16:25 -05:00
#include "WaypointMovementGenerator.h"
#include "VMapFactory.h"
#include "GlobalEvents.h"
2009-03-06 19:36:47 -06:00
#include "GameEventMgr.h"
2009-02-19 18:44:20 -06:00
#include "PoolHandler.h"
2008-10-11 14:16:25 -05:00
#include "Database/DatabaseImpl.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "InstanceSaveMgr.h"
#include "Util.h"
2008-10-12 14:03:38 -05:00
#include "Language.h"
2008-12-15 00:07:21 +02:00
#include "CreatureGroups.h"
2009-01-03 07:26:39 +02:00
#include "Transports.h"
2009-08-10 17:03:11 +02:00
#include "ProgressBar.h"
2010-01-19 11:36:05 +01:00
#include "ScriptMgr.h"
2010-01-20 16:24:52 +01:00
#include "AddonMgr.h"
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
INSTANTIATE_SINGLETON_1 ( World );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
volatile bool World :: m_stopEvent = false ;
2008-11-20 16:16:57 -06:00
uint8 World :: m_ExitCode = SHUTDOWN_EXIT_CODE ;
2008-10-11 14:16:25 -05:00
volatile uint32 World :: m_worldLoopCounter = 0 ;
2009-10-17 15:51:44 -07:00
2009-09-27 02:24:25 -07:00
float World :: m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE ;
float World :: m_MaxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE ;
float World :: m_MaxVisibleDistanceInBGArenas = DEFAULT_VISIBILITY_BGARENAS ;
2008-10-11 14:16:25 -05:00
float World :: m_MaxVisibleDistanceForObject = DEFAULT_VISIBILITY_DISTANCE ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
float World :: m_MaxVisibleDistanceInFlight = DEFAULT_VISIBILITY_DISTANCE ;
float World :: m_VisibleUnitGreyDistance = 0 ;
float World :: m_VisibleObjectGreyDistance = 0 ;
2009-10-17 15:51:44 -07:00
2009-12-19 10:12:40 +01:00
int32 World :: m_visibility_notify_periodOnContinents = DEFAULT_VISIBILITY_NOTIFY_PERIOD ;
int32 World :: m_visibility_notify_periodInInstances = DEFAULT_VISIBILITY_NOTIFY_PERIOD ;
int32 World :: m_visibility_notify_periodInBGArenas = DEFAULT_VISIBILITY_NOTIFY_PERIOD ;
2008-10-11 14:16:25 -05:00
/// World constructor
World :: World ()
{
m_playerLimit = 0 ;
2009-08-29 05:17:55 -04:00
m_allowedSecurityLevel = SEC_PLAYER ;
2008-10-11 14:16:25 -05:00
m_allowMovement = true ;
m_ShutdownMask = 0 ;
m_ShutdownTimer = 0 ;
2009-12-24 10:20:15 +01:00
m_gameTime = time ( NULL );
2008-10-11 14:16:25 -05:00
m_startTime = m_gameTime ;
m_maxActiveSessionCount = 0 ;
m_maxQueuedSessionCount = 0 ;
2009-07-12 00:16:56 +02:00
m_PlayerCount = 0 ;
m_MaxPlayerCount = 0 ;
2008-10-11 14:16:25 -05:00
m_resultQueue = NULL ;
m_NextDailyQuestReset = 0 ;
2009-07-31 10:48:34 +08:00
m_scheduledScripts = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_defaultDbcLocale = LOCALE_enUS ;
m_availableDbcLocaleMask = 0 ;
2009-10-17 15:51:44 -07:00
2008-12-30 18:03:26 -06:00
m_updateTimeSum = 0 ;
m_updateTimeCount = 0 ;
2009-10-17 15:51:44 -07:00
2009-03-21 13:51:28 +01:00
m_isClosed = false ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// World destructor
World ::~ World ()
{
///- Empty the kicked session set
2008-11-30 12:47:26 -06:00
while ( ! m_sessions . empty ())
{
// not remove from queue, prevent loading new sessions
delete m_sessions . begin () -> second ;
m_sessions . erase ( m_sessions . begin ());
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Empty the WeatherMap
2009-04-29 00:26:07 -05:00
for ( WeatherMap :: const_iterator itr = m_weathers . begin (); itr != m_weathers . end (); ++ itr )
2008-10-11 14:16:25 -05:00
delete itr -> second ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_weathers . clear ();
2009-10-17 15:51:44 -07:00
2009-09-11 13:42:39 -07:00
CliCommandHolder * command ;
while ( cliCmdQueue . next ( command ))
delete command ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
VMAP :: VMapFactory :: clear ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( m_resultQueue ) delete m_resultQueue ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//TODO free addSessQueue
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Find a player in a specified zone
Player * World :: FindPlayerInZone ( uint32 zone )
{
///- circle through active sessions and return the first player found in the zone
2009-04-29 00:26:07 -05:00
SessionMap :: const_iterator itr ;
2008-10-11 14:16:25 -05:00
for ( itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
{
2009-09-22 20:40:34 -04:00
if ( ! itr -> second )
2008-10-11 14:16:25 -05:00
continue ;
Player * player = itr -> second -> GetPlayer ();
2009-09-22 20:40:34 -04:00
if ( ! player )
2008-10-11 14:16:25 -05:00
continue ;
2009-09-22 20:40:34 -04:00
if ( player -> IsInWorld () && player -> GetZoneId () == zone )
2008-10-11 14:16:25 -05:00
{
// Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone.
return player ;
}
}
return NULL ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Find a session by its id
WorldSession * World :: FindSession ( uint32 id ) const
{
SessionMap :: const_iterator itr = m_sessions . find ( id );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( itr != m_sessions . end ())
2008-10-11 14:16:25 -05:00
return itr -> second ; // also can return NULL for kicked session
else
return NULL ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Remove a given session
bool World :: RemoveSession ( uint32 id )
{
///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation
2009-04-29 00:26:07 -05:00
SessionMap :: const_iterator itr = m_sessions . find ( id );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( itr != m_sessions . end () && itr -> second )
2008-10-11 14:16:25 -05:00
{
if ( itr -> second -> PlayerLoading ())
return false ;
itr -> second -> KickPlayer ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: AddSession ( WorldSession * s )
{
2008-11-06 16:10:28 -06:00
addSessQueue . add ( s );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void
World :: AddSession_ ( WorldSession * s )
{
2008-11-06 16:10:28 -06:00
ASSERT ( s );
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
//NOTE - Still there is race condition in WorldSession* being used in the Sockets
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
///- kick already loaded player with same account (if any) and remove session
///- if player is in loading and want to load again, return
if ( ! RemoveSession ( s -> GetAccountId ()))
2008-10-11 14:16:25 -05:00
{
2008-11-06 16:10:28 -06:00
s -> KickPlayer ();
2008-11-30 12:47:26 -06:00
delete s ; // session not added yet in session list, so not listed in queue
2008-11-06 16:10:28 -06:00
return ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
// decrease session counts only at not reconnection case
bool decrease_session = true ;
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
// if session already exist, prepare to it deleting at next world update
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
2008-11-14 17:03:03 -06:00
{
2008-11-30 12:47:26 -06:00
SessionMap :: const_iterator old = m_sessions . find ( s -> GetAccountId ());
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( old != m_sessions . end ())
2008-11-30 12:47:26 -06:00
{
// prevent decrease sessions count if session queued
2009-09-22 20:40:34 -04:00
if ( RemoveQueuedPlayer ( old -> second ))
2008-11-30 12:47:26 -06:00
decrease_session = false ;
// not remove replaced session form queue if listed
delete old -> second ;
}
2008-11-14 17:03:03 -06:00
}
2009-10-17 15:51:44 -07:00
2008-11-14 17:03:03 -06:00
m_sessions [ s -> GetAccountId ()] = s ;
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
uint32 Sessions = GetActiveAndQueuedSessionCount ();
uint32 pLimit = GetPlayerAmountLimit ();
2008-12-24 09:58:26 -06:00
uint32 QueueSize = GetQueueSize (); //number of players in the queue
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
//so we don't count the user trying to
//login as a session and queue the socket that we are using
2009-09-22 20:40:34 -04:00
if ( decrease_session )
2008-11-30 12:47:26 -06:00
-- Sessions ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( pLimit > 0 && Sessions >= pLimit && s -> GetSecurity () == SEC_PLAYER && ! HasRecentlyDisconnected ( s ))
2008-10-11 14:16:25 -05:00
{
2008-11-06 16:10:28 -06:00
AddQueuedPlayer ( s );
UpdateMaxSessionCounters ();
sLog . outDetail ( "PlayerQueue: Account id %u is in Queue Position (%u)." , s -> GetAccountId (), ++ QueueSize );
return ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
WorldPacket packet ( SMSG_AUTH_RESPONSE , 1 + 4 + 1 + 4 + 1 );
packet << uint8 ( AUTH_OK );
2008-12-24 09:58:26 -06:00
packet << uint32 ( 0 ); // BillingTimeRemaining
packet << uint8 ( 0 ); // BillingPlanFlags
packet << uint32 ( 0 ); // BillingTimeRested
2009-12-13 03:47:59 +01:00
packet << uint8 ( s -> Expansion ()); // 0 - normal, 1 - TBC, 2 - WOTLK, must be set in database manually for each account
2008-11-06 16:10:28 -06:00
s -> SendPacket ( & packet );
2009-10-17 15:51:44 -07:00
2009-03-21 14:39:04 -06:00
s -> SendAddonsInfo ();
2009-10-17 15:51:44 -07:00
2009-08-14 14:34:46 -05:00
WorldPacket pkt ( SMSG_CLIENTCACHE_VERSION , 4 );
pkt << uint32 ( sWorld . getConfig ( CONFIG_CLIENTCACHE_VERSION ));
s -> SendPacket ( & pkt );
2009-10-17 15:51:44 -07:00
2009-06-11 00:45:59 -05:00
s -> SendTutorialsData ();
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
UpdateMaxSessionCounters ();
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
// Updates the population
if ( pLimit > 0 )
2008-10-11 14:16:25 -05:00
{
2009-09-01 16:47:49 -05:00
float popu = GetActiveSessionCount (); // updated number of users on the server
2008-11-06 16:10:28 -06:00
popu /= pLimit ;
popu *= 2 ;
sLog . outDetail ( "Server Population (%f)." , popu );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2009-02-21 18:31:26 +01:00
bool World :: HasRecentlyDisconnected ( WorldSession * session )
{
2009-09-22 20:40:34 -04:00
if ( ! session ) return false ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( uint32 tolerance = getConfig ( CONFIG_INTERVAL_DISCONNECT_TOLERANCE ))
2009-02-28 17:42:29 -05:00
{
2009-11-20 19:11:28 -08:00
for ( DisconnectMap :: iterator i = m_disconnects . begin (); i != m_disconnects . end ();)
2009-02-21 18:31:26 +01:00
{
2009-12-24 10:20:15 +01:00
if ( difftime ( i -> second , time ( NULL )) < tolerance )
2009-02-21 18:31:26 +01:00
{
2009-09-22 20:40:34 -04:00
if ( i -> first == session -> GetAccountId ())
2009-02-21 18:31:26 +01:00
return true ;
2009-03-28 10:55:14 +01:00
++ i ;
2009-02-21 18:31:26 +01:00
}
else
m_disconnects . erase ( i );
}
}
return false ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
int32 World :: GetQueuePos ( WorldSession * sess )
{
uint32 position = 1 ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
for ( Queue :: const_iterator iter = m_QueuedPlayer . begin (); iter != m_QueuedPlayer . end (); ++ iter , ++ position )
if (( * iter ) == sess )
2008-10-11 14:16:25 -05:00
return position ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
return 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: AddQueuedPlayer ( WorldSession * sess )
{
2008-11-30 12:47:26 -06:00
sess -> SetInQueue ( true );
2008-10-11 14:16:25 -05:00
m_QueuedPlayer . push_back ( sess );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
WorldPacket packet ( SMSG_AUTH_RESPONSE , 1 + 4 + 1 + 4 + 1 );
packet << uint8 ( AUTH_WAIT_QUEUE );
2008-12-24 09:58:26 -06:00
packet << uint32 ( 0 ); // BillingTimeRemaining
packet << uint8 ( 0 ); // BillingPlanFlags
packet << uint32 ( 0 ); // BillingTimeRested
2009-12-13 03:47:59 +01:00
packet << uint8 ( sess -> Expansion ()); // 0 - normal, 1 - TBC, 2 - WOTLK, must be set in database manually for each account
2008-10-11 14:16:25 -05:00
packet << uint32 ( GetQueuePos ( sess ));
sess -> SendPacket ( & packet );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//sess->SendAuthWaitQue (GetQueuePos (sess));
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
bool World :: RemoveQueuedPlayer ( WorldSession * sess )
2008-10-11 14:16:25 -05:00
{
// sessions count including queued to remove (if removed_session set)
uint32 sessions = GetActiveSessionCount ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 position = 1 ;
Queue :: iterator iter = m_QueuedPlayer . begin ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// search to remove and count skipped positions
2008-11-30 12:47:26 -06:00
bool found = false ;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
for (; iter != m_QueuedPlayer . end (); ++ iter , ++ position )
2008-10-11 14:16:25 -05:00
{
2010-04-07 23:25:02 +02:00
if ( * iter == sess )
2008-10-11 14:16:25 -05:00
{
2008-11-30 12:47:26 -06:00
sess -> SetInQueue ( false );
2008-11-14 17:03:03 -06:00
iter = m_QueuedPlayer . erase ( iter );
2008-11-30 12:47:26 -06:00
found = true ; // removing queued session
2008-10-11 14:16:25 -05:00
break ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// iter point to next socked after removed or end()
// position store position of removed socket and then new position next socket after removed
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
// if session not queued then we need decrease sessions count
2009-09-22 20:40:34 -04:00
if ( ! found && sessions )
2008-10-11 14:16:25 -05:00
-- sessions ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// accept first in queue
2009-09-22 20:40:34 -04:00
if (( ! m_playerLimit || sessions < m_playerLimit ) && ! m_QueuedPlayer . empty ())
2008-10-11 14:16:25 -05:00
{
2008-11-30 12:47:26 -06:00
WorldSession * pop_sess = m_QueuedPlayer . front ();
pop_sess -> SetInQueue ( false );
pop_sess -> SendAuthWaitQue ( 0 );
2009-12-13 03:08:21 +01:00
pop_sess -> SendAddonsInfo ();
WorldPacket pkt ( SMSG_CLIENTCACHE_VERSION , 4 );
pkt << uint32 ( sWorld . getConfig ( CONFIG_CLIENTCACHE_VERSION ));
pop_sess -> SendPacket ( & pkt );
2009-12-17 12:36:55 +01:00
pop_sess -> SendAccountDataTimes ( GLOBAL_CACHE_MASK );
2009-12-13 03:08:21 +01:00
pop_sess -> SendTutorialsData ();
2008-10-11 14:16:25 -05:00
m_QueuedPlayer . pop_front ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// update iter to point first queued socket or end() if queue is empty now
iter = m_QueuedPlayer . begin ();
position = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// update position from iter to end()
// iter point to first not updated socket, position store new position
2009-09-22 20:40:34 -04:00
for (; iter != m_QueuedPlayer . end (); ++ iter , ++ position )
2008-10-11 14:16:25 -05:00
( * iter ) -> SendAuthWaitQue ( position );
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
return found ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Find a Weather object by the given zoneid
Weather * World :: FindWeather ( uint32 id ) const
{
WeatherMap :: const_iterator itr = m_weathers . find ( id );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( itr != m_weathers . end ())
2008-10-11 14:16:25 -05:00
return itr -> second ;
else
return 0 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Remove a Weather object for the given zoneid
void World :: RemoveWeather ( uint32 id )
{
// not called at the moment. Kept for completeness
WeatherMap :: iterator itr = m_weathers . find ( id );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( itr != m_weathers . end ())
2008-10-11 14:16:25 -05:00
{
delete itr -> second ;
m_weathers . erase ( itr );
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Add a Weather object to the list
Weather * World :: AddWeather ( uint32 zone_id )
{
WeatherZoneChances const * weatherChances = objmgr . GetWeatherChances ( zone_id );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// zone not have weather, ignore
2009-09-22 20:40:34 -04:00
if ( ! weatherChances )
2008-10-11 14:16:25 -05:00
return NULL ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
Weather * w = new Weather ( zone_id , weatherChances );
m_weathers [ w -> GetZone ()] = w ;
w -> ReGenerate ();
w -> UpdateWeather ();
return w ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Initialize config values
void World :: LoadConfigSettings ( bool reload )
{
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
2009-09-22 20:40:34 -04:00
if ( ! sConfig . Reload ())
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "World settings reload fail: can't read settings from %s." , sConfig . GetFilename (). c_str ());
return ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Read the player limit and the Message of the day from the config file
2009-09-22 20:40:34 -04:00
SetPlayerLimit ( sConfig . GetIntDefault ( "PlayerLimit" , DEFAULT_PLAYER_LIMIT ), true );
SetMotd ( sConfig . GetStringDefault ( "Motd" , "Welcome to a Trinity Core Server." ));
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
///- Get string for new logins (newly created characters)
2008-12-31 11:06:52 +01:00
SetNewCharString ( sConfig . GetStringDefault ( "PlayerStart.String" , "" ));
2009-10-17 15:51:44 -07:00
2008-12-31 11:06:52 +01:00
///- Send server info on login?
m_configs [ CONFIG_ENABLE_SINFO_LOGIN ] = sConfig . GetIntDefault ( "Server.LoginInfo" , 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Read all rates from the config file
rate_values [ RATE_HEALTH ] = sConfig . GetFloatDefault ( "Rate.Health" , 1 );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_HEALTH ] < 0 )
2008-10-11 14:16:25 -05:00
{
2008-12-24 09:58:26 -06:00
sLog . outError ( "Rate.Health (%f) must be > 0. Using 1 instead." , rate_values [ RATE_HEALTH ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_HEALTH ] = 1 ;
}
rate_values [ RATE_POWER_MANA ] = sConfig . GetFloatDefault ( "Rate.Mana" , 1 );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_POWER_MANA ] < 0 )
2008-10-11 14:16:25 -05:00
{
2008-12-24 09:58:26 -06:00
sLog . outError ( "Rate.Mana (%f) must be > 0. Using 1 instead." , rate_values [ RATE_POWER_MANA ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_POWER_MANA ] = 1 ;
}
rate_values [ RATE_POWER_RAGE_INCOME ] = sConfig . GetFloatDefault ( "Rate.Rage.Income" , 1 );
rate_values [ RATE_POWER_RAGE_LOSS ] = sConfig . GetFloatDefault ( "Rate.Rage.Loss" , 1 );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_POWER_RAGE_LOSS ] < 0 )
2008-10-11 14:16:25 -05:00
{
2008-12-24 09:58:26 -06:00
sLog . outError ( "Rate.Rage.Loss (%f) must be > 0. Using 1 instead." , rate_values [ RATE_POWER_RAGE_LOSS ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_POWER_RAGE_LOSS ] = 1 ;
}
2008-12-24 09:58:26 -06:00
rate_values [ RATE_POWER_RUNICPOWER_INCOME ] = sConfig . GetFloatDefault ( "Rate.RunicPower.Income" , 1 );
rate_values [ RATE_POWER_RUNICPOWER_LOSS ] = sConfig . GetFloatDefault ( "Rate.RunicPower.Loss" , 1 );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_POWER_RUNICPOWER_LOSS ] < 0 )
2008-12-24 09:58:26 -06:00
{
sLog . outError ( "Rate.RunicPower.Loss (%f) must be > 0. Using 1 instead." , rate_values [ RATE_POWER_RUNICPOWER_LOSS ]);
rate_values [ RATE_POWER_RUNICPOWER_LOSS ] = 1 ;
}
2008-10-11 14:16:25 -05:00
rate_values [ RATE_POWER_FOCUS ] = sConfig . GetFloatDefault ( "Rate.Focus" , 1.0f );
rate_values [ RATE_SKILL_DISCOVERY ] = sConfig . GetFloatDefault ( "Rate.Skill.Discovery" , 1.0f );
rate_values [ RATE_DROP_ITEM_POOR ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Poor" , 1.0f );
rate_values [ RATE_DROP_ITEM_NORMAL ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Normal" , 1.0f );
rate_values [ RATE_DROP_ITEM_UNCOMMON ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Uncommon" , 1.0f );
rate_values [ RATE_DROP_ITEM_RARE ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Rare" , 1.0f );
rate_values [ RATE_DROP_ITEM_EPIC ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Epic" , 1.0f );
rate_values [ RATE_DROP_ITEM_LEGENDARY ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Legendary" , 1.0f );
rate_values [ RATE_DROP_ITEM_ARTIFACT ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Artifact" , 1.0f );
rate_values [ RATE_DROP_ITEM_REFERENCED ] = sConfig . GetFloatDefault ( "Rate.Drop.Item.Referenced" , 1.0f );
rate_values [ RATE_DROP_MONEY ] = sConfig . GetFloatDefault ( "Rate.Drop.Money" , 1.0f );
rate_values [ RATE_XP_KILL ] = sConfig . GetFloatDefault ( "Rate.XP.Kill" , 1.0f );
rate_values [ RATE_XP_QUEST ] = sConfig . GetFloatDefault ( "Rate.XP.Quest" , 1.0f );
rate_values [ RATE_XP_EXPLORE ] = sConfig . GetFloatDefault ( "Rate.XP.Explore" , 1.0f );
2009-08-07 12:12:42 -07:00
rate_values [ RATE_REPAIRCOST ] = sConfig . GetFloatDefault ( "Rate.RepairCost" , 1.0f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_REPAIRCOST ] < 0.0f )
2009-08-07 12:12:42 -07:00
{
sLog . outError ( "Rate.RepairCost (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_REPAIRCOST ]);
rate_values [ RATE_REPAIRCOST ] = 0.0f ;
}
2008-10-11 14:16:25 -05:00
rate_values [ RATE_REPUTATION_GAIN ] = sConfig . GetFloatDefault ( "Rate.Reputation.Gain" , 1.0f );
2009-03-22 19:29:09 -06:00
rate_values [ RATE_REPUTATION_LOWLEVEL_KILL ] = sConfig . GetFloatDefault ( "Rate.Reputation.LowLevel.Kill" , 1.0f );
rate_values [ RATE_REPUTATION_LOWLEVEL_QUEST ] = sConfig . GetFloatDefault ( "Rate.Reputation.LowLevel.Quest" , 1.0f );
2008-10-11 14:16:25 -05:00
rate_values [ RATE_CREATURE_NORMAL_DAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Normal.Damage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_ELITE_DAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.Elite.Damage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RAREELITE_DAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RAREELITE.Damage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.WORLDBOSS.Damage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RARE_DAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RARE.Damage" , 1.0f );
rate_values [ RATE_CREATURE_NORMAL_HP ] = sConfig . GetFloatDefault ( "Rate.Creature.Normal.HP" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_ELITE_HP ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.Elite.HP" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RAREELITE_HP ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RAREELITE.HP" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_WORLDBOSS_HP ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.WORLDBOSS.HP" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RARE_HP ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RARE.HP" , 1.0f );
rate_values [ RATE_CREATURE_NORMAL_SPELLDAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Normal.SpellDamage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.Elite.SpellDamage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RAREELITE.SpellDamage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.WORLDBOSS.SpellDamage" , 1.0f );
rate_values [ RATE_CREATURE_ELITE_RARE_SPELLDAMAGE ] = sConfig . GetFloatDefault ( "Rate.Creature.Elite.RARE.SpellDamage" , 1.0f );
rate_values [ RATE_CREATURE_AGGRO ] = sConfig . GetFloatDefault ( "Rate.Creature.Aggro" , 1.0f );
rate_values [ RATE_REST_INGAME ] = sConfig . GetFloatDefault ( "Rate.Rest.InGame" , 1.0f );
rate_values [ RATE_REST_OFFLINE_IN_TAVERN_OR_CITY ] = sConfig . GetFloatDefault ( "Rate.Rest.Offline.InTavernOrCity" , 1.0f );
rate_values [ RATE_REST_OFFLINE_IN_WILDERNESS ] = sConfig . GetFloatDefault ( "Rate.Rest.Offline.InWilderness" , 1.0f );
rate_values [ RATE_DAMAGE_FALL ] = sConfig . GetFloatDefault ( "Rate.Damage.Fall" , 1.0f );
rate_values [ RATE_AUCTION_TIME ] = sConfig . GetFloatDefault ( "Rate.Auction.Time" , 1.0f );
rate_values [ RATE_AUCTION_DEPOSIT ] = sConfig . GetFloatDefault ( "Rate.Auction.Deposit" , 1.0f );
rate_values [ RATE_AUCTION_CUT ] = sConfig . GetFloatDefault ( "Rate.Auction.Cut" , 1.0f );
rate_values [ RATE_HONOR ] = sConfig . GetFloatDefault ( "Rate.Honor" , 1.0f );
rate_values [ RATE_MINING_AMOUNT ] = sConfig . GetFloatDefault ( "Rate.Mining.Amount" , 1.0f );
rate_values [ RATE_MINING_NEXT ] = sConfig . GetFloatDefault ( "Rate.Mining.Next" , 1.0f );
rate_values [ RATE_INSTANCE_RESET_TIME ] = sConfig . GetFloatDefault ( "Rate.InstanceResetTime" , 1.0f );
rate_values [ RATE_TALENT ] = sConfig . GetFloatDefault ( "Rate.Talent" , 1.0f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_TALENT ] < 0.0f )
2008-10-11 14:16:25 -05:00
{
2009-08-30 19:00:19 -07:00
sLog . outError ( "Rate.Talent (%f) must be > 0. Using 1 instead." , rate_values [ RATE_TALENT ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_TALENT ] = 1.0f ;
}
2009-08-30 19:00:19 -07:00
rate_values [ RATE_MOVESPEED ] = sConfig . GetFloatDefault ( "Rate.MoveSpeed" , 1.0f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_MOVESPEED ] < 0 )
2009-08-30 19:00:19 -07:00
{
sLog . outError ( "Rate.MoveSpeed (%f) must be > 0. Using 1 instead." , rate_values [ RATE_MOVESPEED ]);
rate_values [ RATE_MOVESPEED ] = 1.0f ;
}
2009-09-22 20:40:34 -04:00
for ( uint8 i = 0 ; i < MAX_MOVE_TYPE ; ++ i ) playerBaseMoveSpeed [ i ] = baseMoveSpeed [ i ] * rate_values [ RATE_MOVESPEED ];
2009-01-01 18:21:38 +01:00
rate_values [ RATE_CORPSE_DECAY_LOOTED ] = sConfig . GetFloatDefault ( "Rate.Corpse.Decay.Looted" , 0.5f );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ] = sConfig . GetFloatDefault ( "TargetPosRecalculateRange" , 1.5f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ] < CONTACT_DISTANCE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "TargetPosRecalculateRange (%f) must be >= %f. Using %f instead." , rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ], CONTACT_DISTANCE , CONTACT_DISTANCE );
rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ] = CONTACT_DISTANCE ;
}
2009-09-22 20:40:34 -04:00
else if ( rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ] > NOMINAL_MELEE_RANGE )
2008-10-11 14:16:25 -05:00
{
2008-11-10 09:04:23 -06:00
sLog . outError ( "TargetPosRecalculateRange (%f) must be <= %f. Using %f instead." ,
2008-12-05 18:39:31 -06:00
rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ], NOMINAL_MELEE_RANGE , NOMINAL_MELEE_RANGE );
rate_values [ RATE_TARGET_POS_RECALCULATION_RANGE ] = NOMINAL_MELEE_RANGE ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-08-07 12:12:42 -07:00
rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] = sConfig . GetFloatDefault ( "DurabilityLoss.OnDeath" , 10.0f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] < 0.0f )
2009-08-07 12:12:42 -07:00
{
2009-12-17 12:36:55 +01:00
sLog . outError ( "DurabilityLoss.OnDeath (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ]);
2009-08-07 12:12:42 -07:00
rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] = 0.0f ;
}
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] > 100.0f )
2009-08-07 12:12:42 -07:00
{
2010-04-07 23:56:35 +02:00
sLog . outError ( "DurabilityLoss.OnDeath (%f) must be <= 100. Using 100.0 instead." , rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ]);
2009-12-17 12:36:55 +01:00
rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] = 0.0f ;
2009-08-07 12:12:42 -07:00
}
rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] = rate_values [ RATE_DURABILITY_LOSS_ON_DEATH ] / 100.0f ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
rate_values [ RATE_DURABILITY_LOSS_DAMAGE ] = sConfig . GetFloatDefault ( "DurabilityLossChance.Damage" , 0.5f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_DAMAGE ] < 0.0f )
2008-10-11 14:16:25 -05:00
{
2009-12-17 12:36:55 +01:00
sLog . outError ( "DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_DURABILITY_LOSS_DAMAGE ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_DURABILITY_LOSS_DAMAGE ] = 0.0f ;
}
rate_values [ RATE_DURABILITY_LOSS_ABSORB ] = sConfig . GetFloatDefault ( "DurabilityLossChance.Absorb" , 0.5f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_ABSORB ] < 0.0f )
2008-10-11 14:16:25 -05:00
{
2009-12-17 12:36:55 +01:00
sLog . outError ( "DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_DURABILITY_LOSS_ABSORB ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_DURABILITY_LOSS_ABSORB ] = 0.0f ;
}
rate_values [ RATE_DURABILITY_LOSS_PARRY ] = sConfig . GetFloatDefault ( "DurabilityLossChance.Parry" , 0.05f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_PARRY ] < 0.0f )
2008-10-11 14:16:25 -05:00
{
2009-12-17 12:36:55 +01:00
sLog . outError ( "DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_DURABILITY_LOSS_PARRY ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_DURABILITY_LOSS_PARRY ] = 0.0f ;
}
rate_values [ RATE_DURABILITY_LOSS_BLOCK ] = sConfig . GetFloatDefault ( "DurabilityLossChance.Block" , 0.05f );
2009-09-22 20:40:34 -04:00
if ( rate_values [ RATE_DURABILITY_LOSS_BLOCK ] < 0.0f )
2008-10-11 14:16:25 -05:00
{
2009-12-17 12:36:55 +01:00
sLog . outError ( "DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead." , rate_values [ RATE_DURABILITY_LOSS_BLOCK ]);
2008-10-11 14:16:25 -05:00
rate_values [ RATE_DURABILITY_LOSS_BLOCK ] = 0.0f ;
}
///- Read other configuration items from the config file
2009-10-17 15:51:44 -07:00
2009-08-07 12:12:42 -07:00
m_configs [ CONFIG_DURABILITY_LOSS_IN_PVP ] = sConfig . GetBoolDefault ( "DurabilityLoss.InPvP" , false );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_COMPRESSION ] = sConfig . GetIntDefault ( "Compression" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_COMPRESSION ] < 1 || m_configs [ CONFIG_COMPRESSION ] > 9 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Compression level (%i) must be in range 1..9. Using default compression level (1)." , m_configs [ CONFIG_COMPRESSION ]);
m_configs [ CONFIG_COMPRESSION ] = 1 ;
}
m_configs [ CONFIG_ADDON_CHANNEL ] = sConfig . GetBoolDefault ( "AddonChannel" , true );
2010-03-09 12:58:48 +01:00
m_configs [ CONFIG_CHAT_CHANNEL_LEVEL_REQ ] = sConfig . GetIntDefault ( "ChatLevelReq.Channel" , 1 );
m_configs [ CONFIG_CHAT_WHISPER_LEVEL_REQ ] = sConfig . GetIntDefault ( "ChatLevelReq.Whisper" , 1 );
m_configs [ CONFIG_CHAT_SAY_LEVEL_REQ ] = sConfig . GetIntDefault ( "ChatLevelReq.Say" , 1 );
m_configs [ CONFIG_TRADE_LEVEL_REQ ] = sConfig . GetIntDefault ( "LevelReq.Trade" , 1 );
m_configs [ CONFIG_TICKET_LEVEL_REQ ] = sConfig . GetIntDefault ( "LevelReq.Ticket" , 1 );
m_configs [ CONFIG_AUCTION_LEVEL_REQ ] = sConfig . GetIntDefault ( "LevelReq.Auction" , 1 );
m_configs [ CONFIG_MAIL_LEVEL_REQ ] = sConfig . GetIntDefault ( "LevelReq.Mail" , 1 );
2009-12-27 16:10:15 +01:00
m_configs [ CONFIG_ALLOW_PLAYER_COMMANDS ] = sConfig . GetBoolDefault ( "AllowPlayerCommands" , 1 );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_GRID_UNLOAD ] = sConfig . GetBoolDefault ( "GridUnload" , true );
2009-03-05 19:02:08 -06:00
m_configs [ CONFIG_INTERVAL_SAVE ] = sConfig . GetIntDefault ( "PlayerSaveInterval" , 15 * MINUTE * IN_MILISECONDS );
2009-02-21 18:31:26 +01:00
m_configs [ CONFIG_INTERVAL_DISCONNECT_TOLERANCE ] = sConfig . GetIntDefault ( "DisconnectToleranceInterval" , 0 );
2009-10-17 15:51:44 -07:00
2009-03-05 19:02:08 -06:00
m_configs [ CONFIG_INTERVAL_GRIDCLEAN ] = sConfig . GetIntDefault ( "GridCleanUpDelay" , 5 * MINUTE * IN_MILISECONDS );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_INTERVAL_GRIDCLEAN ] < MIN_GRID_DELAY )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "GridCleanUpDelay (%i) must be greater %u. Use this minimal value." , m_configs [ CONFIG_INTERVAL_GRIDCLEAN ], MIN_GRID_DELAY );
m_configs [ CONFIG_INTERVAL_GRIDCLEAN ] = MIN_GRID_DELAY ;
}
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
MapManager :: Instance (). SetGridCleanUpDelay ( m_configs [ CONFIG_INTERVAL_GRIDCLEAN ]);
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_INTERVAL_MAPUPDATE ] = sConfig . GetIntDefault ( "MapUpdateInterval" , 100 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_INTERVAL_MAPUPDATE ] < MIN_MAP_UPDATE_DELAY )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "MapUpdateInterval (%i) must be greater %u. Use this minimal value." , m_configs [ CONFIG_INTERVAL_MAPUPDATE ], MIN_MAP_UPDATE_DELAY );
m_configs [ CONFIG_INTERVAL_MAPUPDATE ] = MIN_MAP_UPDATE_DELAY ;
}
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
MapManager :: Instance (). SetMapUpdateInterval ( m_configs [ CONFIG_INTERVAL_MAPUPDATE ]);
2009-10-17 15:51:44 -07:00
2009-03-05 19:02:08 -06:00
m_configs [ CONFIG_INTERVAL_CHANGEWEATHER ] = sConfig . GetIntDefault ( "ChangeWeatherInterval" , 10 * MINUTE * IN_MILISECONDS );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
uint32 val = sConfig . GetIntDefault ( "WorldServerPort" , DEFAULT_WORLDSERVER_PORT );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_PORT_WORLD ])
2008-10-14 11:57:03 -05:00
sLog . outError ( "WorldServerPort option can't be changed at Trinityd.conf reload, using current value (%u)." , m_configs [ CONFIG_PORT_WORLD ]);
2008-10-11 14:16:25 -05:00
}
else
m_configs [ CONFIG_PORT_WORLD ] = sConfig . GetIntDefault ( "WorldServerPort" , DEFAULT_WORLDSERVER_PORT );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
uint32 val = sConfig . GetIntDefault ( "SocketSelectTime" , DEFAULT_SOCKET_SELECT_TIME );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_SOCKET_SELECTTIME ])
2009-02-24 11:55:56 -06:00
sLog . outError ( "SocketSelectTime option can't be changed at Trinityd.conf reload, using current value (%u)." , m_configs [ CONFIG_SOCKET_SELECTTIME ]);
2008-10-11 14:16:25 -05:00
}
else
m_configs [ CONFIG_SOCKET_SELECTTIME ] = sConfig . GetIntDefault ( "SocketSelectTime" , DEFAULT_SOCKET_SELECT_TIME );
2009-10-17 15:51:44 -07:00
2010-02-12 19:59:44 +01:00
m_configs [ CONFIG_SOCKET_TIMEOUTTIME ] = sConfig . GetIntDefault ( "SocketTimeOutTime" , 900000 );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_GROUP_XP_DISTANCE ] = sConfig . GetIntDefault ( "MaxGroupXPDistance" , 74 );
2008-10-14 11:57:03 -05:00
/// \todo Add MonsterSight and GuarderSight (with meaning) in Trinityd.conf or put them as define
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SIGHT_MONSTER ] = sConfig . GetIntDefault ( "MonsterSight" , 50 );
m_configs [ CONFIG_SIGHT_GUARDER ] = sConfig . GetIntDefault ( "GuarderSight" , 50 );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
uint32 val = sConfig . GetIntDefault ( "GameType" , 0 );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_GAME_TYPE ])
2008-10-14 11:57:03 -05:00
sLog . outError ( "GameType option can't be changed at Trinityd.conf reload, using current value (%u)." , m_configs [ CONFIG_GAME_TYPE ]);
2008-10-11 14:16:25 -05:00
}
else
m_configs [ CONFIG_GAME_TYPE ] = sConfig . GetIntDefault ( "GameType" , 0 );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
uint32 val = sConfig . GetIntDefault ( "RealmZone" , REALM_ZONE_DEVELOPMENT );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_REALM_ZONE ])
2008-10-14 11:57:03 -05:00
sLog . outError ( "RealmZone option can't be changed at Trinityd.conf reload, using current value (%u)." , m_configs [ CONFIG_REALM_ZONE ]);
2008-10-11 14:16:25 -05:00
}
else
m_configs [ CONFIG_REALM_ZONE ] = sConfig . GetIntDefault ( "RealmZone" , REALM_ZONE_DEVELOPMENT );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_ALLOW_TWO_SIDE_ACCOUNTS ] = sConfig . GetBoolDefault ( "AllowTwoSide.Accounts" , false );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Chat" , false );
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Channel" , false );
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Group" , false );
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Guild" , false );
2009-02-13 19:50:20 -06:00
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Auction" , false );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL ] = sConfig . GetBoolDefault ( "AllowTwoSide.Interaction.Mail" , false );
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_ALLOW_TWO_SIDE_WHO_LIST ] = sConfig . GetBoolDefault ( "AllowTwoSide.WhoList" , false );
m_configs [ CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND ] = sConfig . GetBoolDefault ( "AllowTwoSide.AddFriend" , false );
m_configs [ CONFIG_ALLOW_TWO_SIDE_TRADE ] = sConfig . GetBoolDefault ( "AllowTwoSide.trade" , false );
m_configs [ CONFIG_STRICT_PLAYER_NAMES ] = sConfig . GetIntDefault ( "StrictPlayerNames" , 0 );
m_configs [ CONFIG_STRICT_CHARTER_NAMES ] = sConfig . GetIntDefault ( "StrictCharterNames" , 0 );
m_configs [ CONFIG_STRICT_PET_NAMES ] = sConfig . GetIntDefault ( "StrictPetNames" , 0 );
2009-10-17 15:51:44 -07:00
2009-07-10 08:25:33 +08:00
m_configs [ CONFIG_MIN_PLAYER_NAME ] = sConfig . GetIntDefault ( "MinPlayerName" , 2 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MIN_PLAYER_NAME ] < 1 || m_configs [ CONFIG_MIN_PLAYER_NAME ] > MAX_PLAYER_NAME )
2009-07-10 08:25:33 +08:00
{
sLog . outError ( "MinPlayerName (%i) must be in range 1..%u. Set to 2." , m_configs [ CONFIG_MIN_PLAYER_NAME ], MAX_PLAYER_NAME );
m_configs [ CONFIG_MIN_PLAYER_NAME ] = 2 ;
}
2009-10-17 15:51:44 -07:00
2009-07-10 08:25:33 +08:00
m_configs [ CONFIG_MIN_CHARTER_NAME ] = sConfig . GetIntDefault ( "MinCharterName" , 2 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MIN_CHARTER_NAME ] < 1 || m_configs [ CONFIG_MIN_CHARTER_NAME ] > MAX_CHARTER_NAME )
2009-07-10 08:25:33 +08:00
{
sLog . outError ( "MinCharterName (%i) must be in range 1..%u. Set to 2." , m_configs [ CONFIG_MIN_CHARTER_NAME ], MAX_CHARTER_NAME );
m_configs [ CONFIG_MIN_CHARTER_NAME ] = 2 ;
}
2009-10-17 15:51:44 -07:00
2009-07-10 08:25:33 +08:00
m_configs [ CONFIG_MIN_PET_NAME ] = sConfig . GetIntDefault ( "MinPetName" , 2 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MIN_PET_NAME ] < 1 || m_configs [ CONFIG_MIN_PET_NAME ] > MAX_PET_NAME )
2009-07-10 08:25:33 +08:00
{
sLog . outError ( "MinPetName (%i) must be in range 1..%u. Set to 2." , m_configs [ CONFIG_MIN_PET_NAME ], MAX_PET_NAME );
m_configs [ CONFIG_MIN_PET_NAME ] = 2 ;
}
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_CHARACTERS_CREATING_DISABLED ] = sConfig . GetIntDefault ( "CharactersCreatingDisabled" , 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_CHARACTERS_PER_REALM ] = sConfig . GetIntDefault ( "CharactersPerRealm" , 10 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_CHARACTERS_PER_REALM ] < 1 || m_configs [ CONFIG_CHARACTERS_PER_REALM ] > 10 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "CharactersPerRealm (%i) must be in range 1..10. Set to 10." , m_configs [ CONFIG_CHARACTERS_PER_REALM ]);
m_configs [ CONFIG_CHARACTERS_PER_REALM ] = 10 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// must be after CONFIG_CHARACTERS_PER_REALM
m_configs [ CONFIG_CHARACTERS_PER_ACCOUNT ] = sConfig . GetIntDefault ( "CharactersPerAccount" , 50 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_CHARACTERS_PER_ACCOUNT ] < m_configs [ CONFIG_CHARACTERS_PER_REALM ])
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i)." , m_configs [ CONFIG_CHARACTERS_PER_ACCOUNT ], m_configs [ CONFIG_CHARACTERS_PER_REALM ]);
m_configs [ CONFIG_CHARACTERS_PER_ACCOUNT ] = m_configs [ CONFIG_CHARACTERS_PER_REALM ];
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_HEROIC_CHARACTERS_PER_REALM ] = sConfig . GetIntDefault ( "HeroicCharactersPerRealm" , 1 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_HEROIC_CHARACTERS_PER_REALM ]) < 0 || m_configs [ CONFIG_HEROIC_CHARACTERS_PER_REALM ] > 10 )
2008-12-24 09:58:26 -06:00
{
sLog . outError ( "HeroicCharactersPerRealm (%i) must be in range 0..10. Set to 1." , m_configs [ CONFIG_HEROIC_CHARACTERS_PER_REALM ]);
m_configs [ CONFIG_HEROIC_CHARACTERS_PER_REALM ] = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_MIN_LEVEL_FOR_HEROIC_CHARACTER_CREATING ] = sConfig . GetIntDefault ( "MinLevelForHeroicCharacterCreating" , 55 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKIP_CINEMATICS ] = sConfig . GetIntDefault ( "SkipCinematics" , 0 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_SKIP_CINEMATICS ]) < 0 || m_configs [ CONFIG_SKIP_CINEMATICS ] > 2 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "SkipCinematics (%i) must be in range 0..2. Set to 0." , m_configs [ CONFIG_SKIP_CINEMATICS ]);
m_configs [ CONFIG_SKIP_CINEMATICS ] = 0 ;
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
2009-08-12 20:30:17 -05:00
uint32 val = sConfig . GetIntDefault ( "MaxPlayerLevel" , DEFAULT_MAX_LEVEL );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_MAX_PLAYER_LEVEL ])
2008-10-12 17:35:16 -05:00
sLog . outError ( "MaxPlayerLevel option can't be changed at config reload, using current value (%u)." , m_configs [ CONFIG_MAX_PLAYER_LEVEL ]);
2008-10-11 14:16:25 -05:00
}
else
2009-08-12 20:30:17 -05:00
m_configs [ CONFIG_MAX_PLAYER_LEVEL ] = sConfig . GetIntDefault ( "MaxPlayerLevel" , DEFAULT_MAX_LEVEL );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MAX_PLAYER_LEVEL ] > MAX_LEVEL )
2008-10-11 14:16:25 -05:00
{
2008-12-19 16:05:13 -06:00
sLog . outError ( "MaxPlayerLevel (%i) must be in range 1..%u. Set to %u." , m_configs [ CONFIG_MAX_PLAYER_LEVEL ], MAX_LEVEL , MAX_LEVEL );
m_configs [ CONFIG_MAX_PLAYER_LEVEL ] = MAX_LEVEL ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-08-15 13:39:40 -07:00
m_configs [ CONFIG_MIN_DUALSPEC_LEVEL ] = sConfig . GetIntDefault ( "MinDualSpecLevel" , 40 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_START_PLAYER_LEVEL ] = sConfig . GetIntDefault ( "StartPlayerLevel" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_START_PLAYER_LEVEL ] < 1 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 1." , m_configs [ CONFIG_START_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ]);
m_configs [ CONFIG_START_PLAYER_LEVEL ] = 1 ;
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_PLAYER_LEVEL ] > m_configs [ CONFIG_MAX_PLAYER_LEVEL ])
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "StartPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u." , m_configs [ CONFIG_START_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ]);
m_configs [ CONFIG_START_PLAYER_LEVEL ] = m_configs [ CONFIG_MAX_PLAYER_LEVEL ];
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ] = sConfig . GetIntDefault ( "StartHeroicPlayerLevel" , 55 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ] < 1 )
2008-12-24 09:58:26 -06:00
{
sLog . outError ( "StartHeroicPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to 55." ,
m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ]);
m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ] = 55 ;
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ] > m_configs [ CONFIG_MAX_PLAYER_LEVEL ])
2008-12-24 09:58:26 -06:00
{
sLog . outError ( "StartHeroicPlayerLevel (%i) must be in range 1..MaxPlayerLevel(%u). Set to %u." ,
m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ], m_configs [ CONFIG_MAX_PLAYER_LEVEL ]);
m_configs [ CONFIG_START_HEROIC_PLAYER_LEVEL ] = m_configs [ CONFIG_MAX_PLAYER_LEVEL ];
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_START_PLAYER_MONEY ] = sConfig . GetIntDefault ( "StartPlayerMoney" , 0 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_START_PLAYER_MONEY ]) < 0 )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartPlayerMoney (%i) must be in range 0..%u. Set to %u." , m_configs [ CONFIG_START_PLAYER_MONEY ], MAX_MONEY_AMOUNT , 0 );
m_configs [ CONFIG_START_PLAYER_MONEY ] = 0 ;
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_PLAYER_MONEY ] > MAX_MONEY_AMOUNT )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartPlayerMoney (%i) must be in range 0..%u. Set to %u." ,
m_configs [ CONFIG_START_PLAYER_MONEY ], MAX_MONEY_AMOUNT , MAX_MONEY_AMOUNT );
m_configs [ CONFIG_START_PLAYER_MONEY ] = MAX_MONEY_AMOUNT ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAX_HONOR_POINTS ] = sConfig . GetIntDefault ( "MaxHonorPoints" , 75000 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_MAX_HONOR_POINTS ]) < 0 )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "MaxHonorPoints (%i) can't be negative. Set to 0." , m_configs [ CONFIG_MAX_HONOR_POINTS ]);
m_configs [ CONFIG_MAX_HONOR_POINTS ] = 0 ;
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_START_HONOR_POINTS ] = sConfig . GetIntDefault ( "StartHonorPoints" , 0 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_START_HONOR_POINTS ]) < 0 )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u." ,
m_configs [ CONFIG_START_HONOR_POINTS ], m_configs [ CONFIG_MAX_HONOR_POINTS ], 0 );
2009-04-11 15:35:50 -05:00
m_configs [ CONFIG_START_HONOR_POINTS ] = 0 ;
2008-11-30 12:47:26 -06:00
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_HONOR_POINTS ] > m_configs [ CONFIG_MAX_HONOR_POINTS ])
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u." ,
m_configs [ CONFIG_START_HONOR_POINTS ], m_configs [ CONFIG_MAX_HONOR_POINTS ], m_configs [ CONFIG_MAX_HONOR_POINTS ]);
m_configs [ CONFIG_START_HONOR_POINTS ] = m_configs [ CONFIG_MAX_HONOR_POINTS ];
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAX_ARENA_POINTS ] = sConfig . GetIntDefault ( "MaxArenaPoints" , 5000 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_MAX_ARENA_POINTS ]) < 0 )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "MaxArenaPoints (%i) can't be negative. Set to 0." , m_configs [ CONFIG_MAX_ARENA_POINTS ]);
m_configs [ CONFIG_MAX_ARENA_POINTS ] = 0 ;
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_START_ARENA_POINTS ] = sConfig . GetIntDefault ( "StartArenaPoints" , 0 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_START_ARENA_POINTS ]) < 0 )
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u." ,
m_configs [ CONFIG_START_ARENA_POINTS ], m_configs [ CONFIG_MAX_ARENA_POINTS ], 0 );
2009-01-14 00:34:08 -06:00
m_configs [ CONFIG_START_ARENA_POINTS ] = 0 ;
2008-11-30 12:47:26 -06:00
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_ARENA_POINTS ] > m_configs [ CONFIG_MAX_ARENA_POINTS ])
2008-11-30 12:47:26 -06:00
{
sLog . outError ( "StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u." ,
m_configs [ CONFIG_START_ARENA_POINTS ], m_configs [ CONFIG_MAX_ARENA_POINTS ], m_configs [ CONFIG_MAX_ARENA_POINTS ]);
m_configs [ CONFIG_START_ARENA_POINTS ] = m_configs [ CONFIG_MAX_ARENA_POINTS ];
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_ALL_TAXI_PATHS ] = sConfig . GetBoolDefault ( "AllFlightPaths" , false );
2009-09-10 09:59:16 -07:00
m_configs [ CONFIG_INSTANT_TAXI ] = sConfig . GetBoolDefault ( "InstantFlightPaths" , false );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_INSTANCE_IGNORE_LEVEL ] = sConfig . GetBoolDefault ( "Instance.IgnoreLevel" , false );
m_configs [ CONFIG_INSTANCE_IGNORE_RAID ] = sConfig . GetBoolDefault ( "Instance.IgnoreRaid" , false );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_CAST_UNSTUCK ] = sConfig . GetBoolDefault ( "CastUnstuck" , true );
m_configs [ CONFIG_INSTANCE_RESET_TIME_HOUR ] = sConfig . GetIntDefault ( "Instance.ResetTimeHour" , 4 );
2009-03-05 19:02:08 -06:00
m_configs [ CONFIG_INSTANCE_UNLOAD_DELAY ] = sConfig . GetIntDefault ( "Instance.UnloadDelay" , 30 * MINUTE * IN_MILISECONDS );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAX_PRIMARY_TRADE_SKILL ] = sConfig . GetIntDefault ( "MaxPrimaryTradeSkill" , 2 );
m_configs [ CONFIG_MIN_PETITION_SIGNS ] = sConfig . GetIntDefault ( "MinPetitionSigns" , 9 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MIN_PETITION_SIGNS ] > 9 )
2008-10-11 14:16:25 -05:00
{
2008-12-24 09:58:26 -06:00
sLog . outError ( "MinPetitionSigns (%i) must be in range 0..9. Set to 9." , m_configs [ CONFIG_MIN_PETITION_SIGNS ]);
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MIN_PETITION_SIGNS ] = 9 ;
}
2009-10-17 15:51:44 -07:00
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_GM_LOGIN_STATE ] = sConfig . GetIntDefault ( "GM.LoginState" , 2 );
2009-01-25 16:35:14 -06:00
m_configs [ CONFIG_GM_VISIBLE_STATE ] = sConfig . GetIntDefault ( "GM.Visible" , 2 );
//m_configs[CONFIG_GM_ACCEPT_TICKETS] = sConfig.GetIntDefault("GM.AcceptTickets", 2);
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_GM_CHAT ] = sConfig . GetIntDefault ( "GM.Chat" , 2 );
m_configs [ CONFIG_GM_WISPERING_TO ] = sConfig . GetIntDefault ( "GM.WhisperingTo" , 2 );
2009-10-17 15:51:44 -07:00
2009-07-20 11:51:20 +08:00
m_configs [ CONFIG_GM_LEVEL_IN_GM_LIST ] = sConfig . GetIntDefault ( "GM.InGMList.Level" , SEC_ADMINISTRATOR );
m_configs [ CONFIG_GM_LEVEL_IN_WHO_LIST ] = sConfig . GetIntDefault ( "GM.InWhoList.Level" , SEC_ADMINISTRATOR );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_GM_LOG_TRADE ] = sConfig . GetBoolDefault ( "GM.LogTrade" , false );
2009-05-14 23:07:17 +02:00
m_configs [ CONFIG_START_GM_LEVEL ] = sConfig . GetIntDefault ( "GM.StartLevel" , 1 );
m_configs [ CONFIG_ALLOW_GM_GROUP ] = sConfig . GetBoolDefault ( "GM.AllowInvite" , false );
m_configs [ CONFIG_ALLOW_GM_FRIEND ] = sConfig . GetBoolDefault ( "GM.AllowFriend" , false );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_START_GM_LEVEL ] < m_configs [ CONFIG_START_PLAYER_LEVEL ])
2008-11-30 12:47:26 -06:00
{
2008-12-19 16:05:13 -06:00
sLog . outError ( "GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u." ,
m_configs [ CONFIG_START_GM_LEVEL ], m_configs [ CONFIG_START_PLAYER_LEVEL ], MAX_LEVEL , m_configs [ CONFIG_START_PLAYER_LEVEL ]);
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_START_GM_LEVEL ] = m_configs [ CONFIG_START_PLAYER_LEVEL ];
}
2009-09-22 20:40:34 -04:00
else if ( m_configs [ CONFIG_START_GM_LEVEL ] > MAX_LEVEL )
2008-11-30 12:47:26 -06:00
{
2008-12-19 16:05:13 -06:00
sLog . outError ( "GM.StartLevel (%i) must be in range 1..%u. Set to %u." , m_configs [ CONFIG_START_GM_LEVEL ], MAX_LEVEL , MAX_LEVEL );
m_configs [ CONFIG_START_GM_LEVEL ] = MAX_LEVEL ;
2008-11-30 12:47:26 -06:00
}
2008-12-29 17:27:50 -06:00
m_configs [ CONFIG_GM_LOWER_SECURITY ] = sConfig . GetBoolDefault ( "GM.LowerSecurity" , false );
2009-01-25 16:35:14 -06:00
m_configs [ CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS ] = sConfig . GetBoolDefault ( "GM.AllowAchievementGain" , true );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_GROUP_VISIBILITY ] = sConfig . GetIntDefault ( "Visibility.GroupMode" , 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAIL_DELIVERY_DELAY ] = sConfig . GetIntDefault ( "MailDeliveryDelay" , HOUR );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_UPTIME_UPDATE ] = sConfig . GetIntDefault ( "UpdateUptimeInterval" , 10 );
2010-04-07 23:56:35 +02:00
if ( int32 ( m_configs [ CONFIG_UPTIME_UPDATE ]) <= 0 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "UpdateUptimeInterval (%i) must be > 0, set to default 10." , m_configs [ CONFIG_UPTIME_UPDATE ]);
m_configs [ CONFIG_UPTIME_UPDATE ] = 10 ;
}
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
2009-03-02 16:53:50 -06:00
m_timers [ WUPDATE_UPTIME ]. SetInterval ( m_configs [ CONFIG_UPTIME_UPDATE ] * MINUTE * IN_MILISECONDS );
2008-10-11 14:16:25 -05:00
m_timers [ WUPDATE_UPTIME ]. Reset ();
}
2009-10-17 15:51:44 -07:00
2009-03-25 15:21:32 +01:00
// log db cleanup interval
2009-03-26 15:56:00 +01:00
m_configs [ CONFIG_LOGDB_CLEARINTERVAL ] = sConfig . GetIntDefault ( "LogDB.Opt.ClearInterval" , 10 );
2009-09-22 20:40:34 -04:00
if ( int32 ( m_configs [ CONFIG_LOGDB_CLEARINTERVAL ]) <= 0 )
2009-03-25 15:21:32 +01:00
{
2009-03-26 16:12:17 +01:00
sLog . outError ( "LogDB.Opt.ClearInterval (%i) must be > 0, set to default 10." , m_configs [ CONFIG_LOGDB_CLEARINTERVAL ]);
2009-03-25 15:21:32 +01:00
m_configs [ CONFIG_LOGDB_CLEARINTERVAL ] = 10 ;
}
2009-09-22 20:40:34 -04:00
if ( reload )
2009-03-25 15:21:32 +01:00
{
m_timers [ WUPDATE_CLEANDB ]. SetInterval ( m_configs [ CONFIG_LOGDB_CLEARINTERVAL ] * MINUTE * IN_MILISECONDS );
m_timers [ WUPDATE_CLEANDB ]. Reset ();
}
m_configs [ CONFIG_LOGDB_CLEARTIME ] = sConfig . GetIntDefault ( "LogDB.Opt.ClearTime" , 1209600 ); // 14 days default
2009-03-26 15:56:00 +01:00
sLog . outString ( "Will clear `logs` table of entries older than %i seconds every %u minutes." ,
2009-03-25 15:21:32 +01:00
m_configs [ CONFIG_LOGDB_CLEARTIME ], m_configs [ CONFIG_LOGDB_CLEARINTERVAL ]);
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_CHANCE_ORANGE ] = sConfig . GetIntDefault ( "SkillChance.Orange" , 100 );
m_configs [ CONFIG_SKILL_CHANCE_YELLOW ] = sConfig . GetIntDefault ( "SkillChance.Yellow" , 75 );
m_configs [ CONFIG_SKILL_CHANCE_GREEN ] = sConfig . GetIntDefault ( "SkillChance.Green" , 25 );
m_configs [ CONFIG_SKILL_CHANCE_GREY ] = sConfig . GetIntDefault ( "SkillChance.Grey" , 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_CHANCE_MINING_STEPS ] = sConfig . GetIntDefault ( "SkillChance.MiningSteps" , 75 );
m_configs [ CONFIG_SKILL_CHANCE_SKINNING_STEPS ] = sConfig . GetIntDefault ( "SkillChance.SkinningSteps" , 75 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_PROSPECTING ] = sConfig . GetBoolDefault ( "SkillChance.Prospecting" , false );
2008-12-24 09:58:26 -06:00
m_configs [ CONFIG_SKILL_MILLING ] = sConfig . GetBoolDefault ( "SkillChance.Milling" , false );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_GAIN_CRAFTING ] = sConfig . GetIntDefault ( "SkillGain.Crafting" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_SKILL_GAIN_CRAFTING ] < 0 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "SkillGain.Crafting (%i) can't be negative. Set to 1." , m_configs [ CONFIG_SKILL_GAIN_CRAFTING ]);
m_configs [ CONFIG_SKILL_GAIN_CRAFTING ] = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_GAIN_DEFENSE ] = sConfig . GetIntDefault ( "SkillGain.Defense" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_SKILL_GAIN_DEFENSE ] < 0 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "SkillGain.Defense (%i) can't be negative. Set to 1." , m_configs [ CONFIG_SKILL_GAIN_DEFENSE ]);
m_configs [ CONFIG_SKILL_GAIN_DEFENSE ] = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_GAIN_GATHERING ] = sConfig . GetIntDefault ( "SkillGain.Gathering" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_SKILL_GAIN_GATHERING ] < 0 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "SkillGain.Gathering (%i) can't be negative. Set to 1." , m_configs [ CONFIG_SKILL_GAIN_GATHERING ]);
m_configs [ CONFIG_SKILL_GAIN_GATHERING ] = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SKILL_GAIN_WEAPON ] = sConfig . GetIntDefault ( "SkillGain.Weapon" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_SKILL_GAIN_WEAPON ] < 0 )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "SkillGain.Weapon (%i) can't be negative. Set to 1." , m_configs [ CONFIG_SKILL_GAIN_WEAPON ]);
m_configs [ CONFIG_SKILL_GAIN_WEAPON ] = 1 ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAX_OVERSPEED_PINGS ] = sConfig . GetIntDefault ( "MaxOverspeedPings" , 2 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_MAX_OVERSPEED_PINGS ] != 0 && m_configs [ CONFIG_MAX_OVERSPEED_PINGS ] < 2 )
2008-10-11 14:16:25 -05:00
{
2009-08-14 14:34:46 -05:00
sLog . outError ( "MaxOverspeedPings (%i) must be in range 2..infinity (or 0 to disable check). Set to 2." , m_configs [ CONFIG_MAX_OVERSPEED_PINGS ]);
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_MAX_OVERSPEED_PINGS ] = 2 ;
}
2009-10-17 15:51:44 -07:00
2008-11-14 16:28:45 -06:00
m_configs [ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY ] = sConfig . GetBoolDefault ( "SaveRespawnTimeImmediately" , true );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_WEATHER ] = sConfig . GetBoolDefault ( "ActivateWeather" , true );
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_DISABLE_BREATHING ] = sConfig . GetIntDefault ( "DisableWaterBreath" , SEC_CONSOLE );
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL ] = sConfig . GetBoolDefault ( "AlwaysMaxSkillForLevel" , false );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
uint32 val = sConfig . GetIntDefault ( "Expansion" , 1 );
2010-04-08 08:20:08 +02:00
if ( val != m_configs [ CONFIG_EXPANSION ])
2008-10-14 11:57:03 -05:00
sLog . outError ( "Expansion option can't be changed at Trinityd.conf reload, using current value (%u)." , m_configs [ CONFIG_EXPANSION ]);
2008-10-11 14:16:25 -05:00
}
else
m_configs [ CONFIG_EXPANSION ] = sConfig . GetIntDefault ( "Expansion" , 1 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_CHATFLOOD_MESSAGE_COUNT ] = sConfig . GetIntDefault ( "ChatFlood.MessageCount" , 10 );
m_configs [ CONFIG_CHATFLOOD_MESSAGE_DELAY ] = sConfig . GetIntDefault ( "ChatFlood.MessageDelay" , 1 );
m_configs [ CONFIG_CHATFLOOD_MUTE_TIME ] = sConfig . GetIntDefault ( "ChatFlood.MuteTime" , 10 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_EVENT_ANNOUNCE ] = sConfig . GetIntDefault ( "Event.Announce" , 0 );
2009-10-17 15:51:44 -07:00
2009-05-21 10:48:00 -05:00
m_configs [ CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS ] = sConfig . GetIntDefault ( "CreatureFamilyFleeAssistanceRadius" , 30 );
2008-11-25 16:36:50 -06:00
m_configs [ CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS ] = sConfig . GetIntDefault ( "CreatureFamilyAssistanceRadius" , 10 );
m_configs [ CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY ] = sConfig . GetIntDefault ( "CreatureFamilyAssistanceDelay" , 1500 );
2009-05-21 10:48:00 -05:00
m_configs [ CONFIG_CREATURE_FAMILY_FLEE_DELAY ] = sConfig . GetIntDefault ( "CreatureFamilyFleeDelay" , 7000 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_WORLD_BOSS_LEVEL_DIFF ] = sConfig . GetIntDefault ( "WorldBossLevelDiff" , 3 );
2009-10-17 15:51:44 -07:00
2008-12-19 16:05:13 -06:00
// note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100)
m_configs [ CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF ] = sConfig . GetIntDefault ( "Quests.LowLevelHideDiff" , 4 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF ] > MAX_LEVEL )
2008-12-19 16:05:13 -06:00
m_configs [ CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF ] = MAX_LEVEL ;
m_configs [ CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF ] = sConfig . GetIntDefault ( "Quests.HighLevelHideDiff" , 7 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF ] > MAX_LEVEL )
2008-12-19 16:05:13 -06:00
m_configs [ CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF ] = MAX_LEVEL ;
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_DETECT_POS_COLLISION ] = sConfig . GetBoolDefault ( "DetectPosCollision" , true );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_RESTRICTED_LFG_CHANNEL ] = sConfig . GetBoolDefault ( "Channel.RestrictedLfg" , true );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL ] = sConfig . GetBoolDefault ( "Channel.SilentlyGMJoin" , false );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_TALENTS_INSPECTING ] = sConfig . GetBoolDefault ( "TalentsInspecting" , true );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_CHAT_FAKE_MESSAGE_PREVENTING ] = sConfig . GetBoolDefault ( "ChatFakeMessagePreventing" , false );
2009-08-27 19:57:35 -05:00
m_configs [ CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY ] = sConfig . GetIntDefault ( "ChatStrictLinkChecking.Severity" , 0 );
m_configs [ CONFIG_CHAT_STRICT_LINK_CHECKING_KICK ] = sConfig . GetIntDefault ( "ChatStrictLinkChecking.Kick" , 0 );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_CORPSE_DECAY_NORMAL ] = sConfig . GetIntDefault ( "Corpse.Decay.NORMAL" , 60 );
m_configs [ CONFIG_CORPSE_DECAY_RARE ] = sConfig . GetIntDefault ( "Corpse.Decay.RARE" , 300 );
m_configs [ CONFIG_CORPSE_DECAY_ELITE ] = sConfig . GetIntDefault ( "Corpse.Decay.ELITE" , 300 );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_CORPSE_DECAY_RAREELITE ] = sConfig . GetIntDefault ( "Corpse.Decay.RAREELITE" , 300 );
m_configs [ CONFIG_CORPSE_DECAY_WORLDBOSS ] = sConfig . GetIntDefault ( "Corpse.Decay.WORLDBOSS" , 3600 );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_DEATH_SICKNESS_LEVEL ] = sConfig . GetIntDefault ( "Death.SicknessLevel" , 11 );
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP ] = sConfig . GetBoolDefault ( "Death.CorpseReclaimDelay.PvP" , true );
m_configs [ CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE ] = sConfig . GetBoolDefault ( "Death.CorpseReclaimDelay.PvE" , true );
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_DEATH_BONES_WORLD ] = sConfig . GetBoolDefault ( "Death.Bones.World" , true );
m_configs [ CONFIG_DEATH_BONES_BG_OR_ARENA ] = sConfig . GetBoolDefault ( "Death.Bones.BattlegroundOrArena" , true );
2009-10-17 15:51:44 -07:00
2009-08-20 13:22:07 -07:00
m_configs [ CONFIG_DIE_COMMAND_MODE ] = sConfig . GetBoolDefault ( "Die.Command.Mode" , true );
2009-10-17 15:51:44 -07:00
2009-01-01 18:21:38 +01:00
m_configs [ CONFIG_THREAT_RADIUS ] = sConfig . GetIntDefault ( "ThreatRadius" , 60 );
2009-10-17 15:51:44 -07:00
2008-11-20 16:16:57 -06:00
// always use declined names in the russian client
m_configs [ CONFIG_DECLINED_NAMES_USED ] =
2008-10-11 14:16:25 -05:00
( m_configs [ CONFIG_REALM_ZONE ] == REALM_ZONE_RUSSIAN ) ? true : sConfig . GetBoolDefault ( "DeclinedNames" , false );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_configs [ CONFIG_LISTEN_RANGE_SAY ] = sConfig . GetIntDefault ( "ListenRange.Say" , 25 );
m_configs [ CONFIG_LISTEN_RANGE_TEXTEMOTE ] = sConfig . GetIntDefault ( "ListenRange.TextEmote" , 25 );
m_configs [ CONFIG_LISTEN_RANGE_YELL ] = sConfig . GetIntDefault ( "ListenRange.Yell" , 300 );
2009-10-17 15:51:44 -07:00
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_BATTLEGROUND_CAST_DESERTER ] = sConfig . GetBoolDefault ( "Battleground.CastDeserter" , true );
m_configs [ CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE ] = sConfig . GetBoolDefault ( "Battleground.QueueAnnouncer.Enable" , false );
m_configs [ CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY ] = sConfig . GetBoolDefault ( "Battleground.QueueAnnouncer.PlayerOnly" , false );
m_configs [ CONFIG_BATTLEGROUND_INVITATION_TYPE ] = sConfig . GetIntDefault ( "Battleground.InvitationType" , 0 );
m_configs [ CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER ] = sConfig . GetIntDefault ( "BattleGround.PrematureFinishTimer" , 5 * MINUTE * IN_MILISECONDS );
m_configs [ CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH ] = sConfig . GetIntDefault ( "BattleGround.PremadeGroupWaitForMatch" , 30 * MINUTE * IN_MILISECONDS );
2009-03-05 19:02:08 -06:00
m_configs [ CONFIG_ARENA_MAX_RATING_DIFFERENCE ] = sConfig . GetIntDefault ( "Arena.MaxRatingDifference" , 150 );
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_ARENA_RATING_DISCARD_TIMER ] = sConfig . GetIntDefault ( "Arena.RatingDiscardTimer" , 10 * MINUTE * IN_MILISECONDS );
m_configs [ CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS ] = sConfig . GetBoolDefault ( "Arena.AutoDistributePoints" , false );
m_configs [ CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS ] = sConfig . GetIntDefault ( "Arena.AutoDistributeInterval" , 7 );
m_configs [ CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE ] = sConfig . GetBoolDefault ( "Arena.QueueAnnouncer.Enable" , false );
2009-06-19 19:30:32 -05:00
m_configs [ CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY ] = sConfig . GetBoolDefault ( "Arena.QueueAnnouncer.PlayerOnly" , false );
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_ARENA_SEASON_ID ] = sConfig . GetIntDefault ( "Arena.ArenaSeason.ID" , 1 );
2010-02-14 19:13:14 -07:00
m_configs [ CONFIG_ARENA_START_RATING ] = sConfig . GetIntDefault ( "Arena.ArenaStartRating" , 0 );
m_configs [ CONFIG_ARENA_START_PERSONAL_RATING ] = sConfig . GetIntDefault ( "Arena.ArenaStartPersonalRating" , 0 );
2009-02-27 12:13:59 -06:00
m_configs [ CONFIG_ARENA_SEASON_IN_PROGRESS ] = sConfig . GetBoolDefault ( "Arena.ArenaSeason.InProgress" , true );
2009-10-17 15:51:44 -07:00
2009-08-17 03:17:14 +02:00
m_configs [ CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN ] = sConfig . GetBoolDefault ( "OffhandCheckAtSpellUnlearn" , false );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( int clientCacheId = sConfig . GetIntDefault ( "ClientCacheVersion" , 0 ))
2009-08-14 14:34:46 -05:00
{
// overwrite DB/old value
2009-09-22 20:40:34 -04:00
if ( clientCacheId > 0 )
2009-08-14 14:36:11 -05:00
{
2009-08-14 14:34:46 -05:00
m_configs [ CONFIG_CLIENTCACHE_VERSION ] = clientCacheId ;
2009-08-14 14:36:11 -05:00
sLog . outString ( "Client cache version set to: %u" , clientCacheId );
}
2009-08-14 14:34:46 -05:00
else
sLog . outError ( "ClientCacheVersion can't be negative %d, ignored." , clientCacheId );
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_INSTANT_LOGOUT ] = sConfig . GetIntDefault ( "InstantLogout" , SEC_MODERATOR );
2009-10-17 15:51:44 -07:00
2009-08-24 19:23:31 -05:00
m_configs [ CONFIG_GUILD_EVENT_LOG_COUNT ] = sConfig . GetIntDefault ( "Guild.EventLogRecordsCount" , GUILD_EVENTLOG_MAX_RECORDS );
if ( m_configs [ CONFIG_GUILD_EVENT_LOG_COUNT ] < GUILD_EVENTLOG_MAX_RECORDS )
m_configs [ CONFIG_GUILD_EVENT_LOG_COUNT ] = GUILD_EVENTLOG_MAX_RECORDS ;
m_configs [ CONFIG_GUILD_BANK_EVENT_LOG_COUNT ] = sConfig . GetIntDefault ( "Guild.BankEventLogRecordsCount" , GUILD_BANK_MAX_LOGS );
if ( m_configs [ CONFIG_GUILD_BANK_EVENT_LOG_COUNT ] < GUILD_BANK_MAX_LOGS )
m_configs [ CONFIG_GUILD_BANK_EVENT_LOG_COUNT ] = GUILD_BANK_MAX_LOGS ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_VisibleUnitGreyDistance = sConfig . GetFloatDefault ( "Visibility.Distance.Grey.Unit" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Visibility.Distance.Grey.Unit can't be greater %f" , MAX_VISIBILITY_DISTANCE );
m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE ;
}
m_VisibleObjectGreyDistance = sConfig . GetFloatDefault ( "Visibility.Distance.Grey.Object" , 10 );
2009-09-22 20:40:34 -04:00
if ( m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Visibility.Distance.Grey.Object can't be greater %f" , MAX_VISIBILITY_DISTANCE );
m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE ;
}
2009-10-17 15:51:44 -07:00
2009-09-27 02:24:25 -07:00
//visibility on continents
m_MaxVisibleDistanceOnContinents = sConfig . GetFloatDefault ( "Visibility.Distance.Continents" , DEFAULT_VISIBILITY_DISTANCE );
2010-04-07 19:14:10 +02:00
if ( m_MaxVisibleDistanceOnContinents < 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ))
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.Continents can't be less max aggro radius %f" , 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ));
m_MaxVisibleDistanceOnContinents = 45 * sWorld . getRate ( RATE_CREATURE_AGGRO );
2008-10-11 14:16:25 -05:00
}
2010-04-07 19:14:10 +02:00
else if ( m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.Continents can't be greater %f" , MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance );
m_MaxVisibleDistanceOnContinents = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 16:20:24 -07:00
2009-09-27 02:24:25 -07:00
//visibility in instances
m_MaxVisibleDistanceInInstances = sConfig . GetFloatDefault ( "Visibility.Distance.Instances" , DEFAULT_VISIBILITY_INSTANCE );
2010-04-07 19:14:10 +02:00
if ( m_MaxVisibleDistanceInInstances < 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ))
2009-09-27 02:24:25 -07:00
{
sLog . outError ( "Visibility.Distance.Instances can't be less max aggro radius %f" , 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ));
m_MaxVisibleDistanceInInstances = 45 * sWorld . getRate ( RATE_CREATURE_AGGRO );
}
2010-04-07 19:14:10 +02:00
else if ( m_MaxVisibleDistanceInInstances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.Instances can't be greater %f" , MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance );
m_MaxVisibleDistanceInInstances = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 16:20:24 -07:00
2009-09-27 02:24:25 -07:00
//visibility in BG/Arenas
m_MaxVisibleDistanceInBGArenas = sConfig . GetFloatDefault ( "Visibility.Distance.BGArenas" , DEFAULT_VISIBILITY_BGARENAS );
2010-04-07 19:14:10 +02:00
if ( m_MaxVisibleDistanceInBGArenas < 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ))
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.BGArenas can't be less max aggro radius %f" , 45 * sWorld . getRate ( RATE_CREATURE_AGGRO ));
m_MaxVisibleDistanceInBGArenas = 45 * sWorld . getRate ( RATE_CREATURE_AGGRO );
}
2010-04-07 19:14:10 +02:00
else if ( m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE )
2009-09-27 02:24:25 -07:00
{
sLog . outError ( "Visibility.Distance.BGArenas can't be greater %f" , MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance );
m_MaxVisibleDistanceInBGArenas = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-09-27 02:24:25 -07:00
m_MaxVisibleDistanceForObject = sConfig . GetFloatDefault ( "Visibility.Distance.Object" , DEFAULT_VISIBILITY_DISTANCE );
2010-04-07 19:14:10 +02:00
if ( m_MaxVisibleDistanceForObject < INTERACTION_DISTANCE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Visibility.Distance.Object can't be less max aggro radius %f" , float ( INTERACTION_DISTANCE ));
m_MaxVisibleDistanceForObject = INTERACTION_DISTANCE ;
}
2010-04-07 19:14:10 +02:00
else if ( m_MaxVisibleDistanceForObject + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.Object can't be greater %f" , MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance );
2008-10-11 14:16:25 -05:00
m_MaxVisibleDistanceForObject = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance ;
}
2009-09-27 02:24:25 -07:00
m_MaxVisibleDistanceInFlight = sConfig . GetFloatDefault ( "Visibility.Distance.InFlight" , DEFAULT_VISIBILITY_DISTANCE );
2010-04-07 19:14:10 +02:00
if ( m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE )
2008-10-11 14:16:25 -05:00
{
2009-09-27 02:24:25 -07:00
sLog . outError ( "Visibility.Distance.InFlight can't be greater %f" , MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance );
2008-10-11 14:16:25 -05:00
m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance ;
}
2009-10-17 15:51:44 -07:00
2009-12-19 10:12:40 +01:00
m_visibility_notify_periodOnContinents = sConfig . GetIntDefault ( "Visibility.Notify.Period.OnContinents" , DEFAULT_VISIBILITY_NOTIFY_PERIOD );
m_visibility_notify_periodInInstances = sConfig . GetIntDefault ( "Visibility.Notify.Period.InInstances" , DEFAULT_VISIBILITY_NOTIFY_PERIOD );
2010-04-07 18:09:10 +02:00
m_visibility_notify_periodInBGArenas = sConfig . GetIntDefault ( "Visibility.Notify.Period.InBGArenas" , DEFAULT_VISIBILITY_NOTIFY_PERIOD );
2009-12-19 10:12:40 +01:00
2008-10-11 14:16:25 -05:00
///- Read the "Data" directory from the config file
std :: string dataPath = sConfig . GetStringDefault ( "DataDir" , "./" );
2010-04-08 08:20:08 +02:00
if ( dataPath . at ( dataPath . length () - 1 ) != '/' && dataPath . at ( dataPath . length () - 1 ) != '\\' )
2008-10-11 14:16:25 -05:00
dataPath . append ( "/" );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( reload )
2008-10-11 14:16:25 -05:00
{
2010-04-08 08:20:08 +02:00
if ( dataPath != m_dataPath )
2008-10-14 11:57:03 -05:00
sLog . outError ( "DataDir option can't be changed at Trinityd.conf reload, using current value (%s)." , m_dataPath . c_str ());
2008-10-11 14:16:25 -05:00
}
else
{
m_dataPath = dataPath ;
sLog . outString ( "Using DataDir %s" , m_dataPath . c_str ());
}
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
bool enableLOS = sConfig . GetBoolDefault ( "vmap.enableLOS" , false );
bool enableHeight = sConfig . GetBoolDefault ( "vmap.enableHeight" , false );
std :: string ignoreMapIds = sConfig . GetStringDefault ( "vmap.ignoreMapIds" , "" );
std :: string ignoreSpellIds = sConfig . GetStringDefault ( "vmap.ignoreSpellIds" , "" );
VMAP :: VMapFactory :: createOrGetVMapManager () -> setEnableLineOfSightCalc ( enableLOS );
VMAP :: VMapFactory :: createOrGetVMapManager () -> setEnableHeightCalc ( enableHeight );
VMAP :: VMapFactory :: createOrGetVMapManager () -> preventMapsFromBeingUsed ( ignoreMapIds . c_str ());
VMAP :: VMapFactory :: preventSpellsFromBeingTestedForLoS ( ignoreSpellIds . c_str ());
2009-09-22 20:40:34 -04:00
sLog . outString ( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i" , enableLOS , enableHeight );
sLog . outString ( "WORLD: VMap data directory is: %svmaps" , m_dataPath . c_str ());
sLog . outString ( "WORLD: VMap config keys are: vmap.enableLOS, vmap.enableHeight, vmap.ignoreMapIds, vmap.ignoreSpellIds" );
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_MAX_WHO ] = sConfig . GetIntDefault ( "MaxWhoListReturns" , 49 );
2009-05-21 23:17:52 +02:00
m_configs [ CONFIG_PET_LOS ] = sConfig . GetBoolDefault ( "vmap.petLOS" , false );
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_BG_START_MUSIC ] = sConfig . GetBoolDefault ( "MusicInBattleground" , false );
m_configs [ CONFIG_START_ALL_SPELLS ] = sConfig . GetBoolDefault ( "PlayerStart.AllSpells" , false );
m_configs [ CONFIG_HONOR_AFTER_DUEL ] = sConfig . GetIntDefault ( "HonorPointsAfterDuel" , 0 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_HONOR_AFTER_DUEL ] < 0 )
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_HONOR_AFTER_DUEL ] = 0 ;
m_configs [ CONFIG_START_ALL_EXPLORED ] = sConfig . GetBoolDefault ( "PlayerStart.MapsExplored" , false );
m_configs [ CONFIG_START_ALL_REP ] = sConfig . GetBoolDefault ( "PlayerStart.AllReputation" , false );
m_configs [ CONFIG_ALWAYS_MAXSKILL ] = sConfig . GetBoolDefault ( "AlwaysMaxWeaponSkill" , false );
m_configs [ CONFIG_PVP_TOKEN_ENABLE ] = sConfig . GetBoolDefault ( "PvPToken.Enable" , false );
m_configs [ CONFIG_PVP_TOKEN_MAP_TYPE ] = sConfig . GetIntDefault ( "PvPToken.MapAllowType" , 4 );
m_configs [ CONFIG_PVP_TOKEN_ID ] = sConfig . GetIntDefault ( "PvPToken.ItemID" , 29434 );
m_configs [ CONFIG_PVP_TOKEN_COUNT ] = sConfig . GetIntDefault ( "PvPToken.ItemCount" , 1 );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_PVP_TOKEN_COUNT ] < 1 )
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_PVP_TOKEN_COUNT ] = 1 ;
2009-10-17 15:51:44 -07:00
2008-11-30 12:47:26 -06:00
m_configs [ CONFIG_NO_RESET_TALENT_COST ] = sConfig . GetBoolDefault ( "NoResetTalentsCost" , false );
2008-12-27 00:24:48 +01:00
m_configs [ CONFIG_SHOW_KICK_IN_WORLD ] = sConfig . GetBoolDefault ( "ShowKickInWorld" , false );
2008-12-30 18:03:26 -06:00
m_configs [ CONFIG_INTERVAL_LOG_UPDATE ] = sConfig . GetIntDefault ( "RecordUpdateTimeDiffInterval" , 60000 );
2009-01-08 14:57:46 -06:00
m_configs [ CONFIG_MIN_LOG_UPDATE ] = sConfig . GetIntDefault ( "MinRecordUpdateTimeDiff" , 10 );
2009-12-17 12:36:55 +01:00
m_configs [ CONFIG_NUMTHREADS ] = sConfig . GetIntDefault ( "MapUpdate.Threads" , 1 );
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
std :: string forbiddenmaps = sConfig . GetStringDefault ( "ForbiddenMaps" , "" );
char * forbiddenMaps = new char [ forbiddenmaps . length () + 1 ];
forbiddenMaps [ forbiddenmaps . length ()] = 0 ;
strncpy ( forbiddenMaps , forbiddenmaps . c_str (), forbiddenmaps . length ());
const char * delim = "," ;
char * token = strtok ( forbiddenMaps , delim );
2010-04-07 19:13:19 +02:00
while ( token != NULL )
2008-10-14 11:57:03 -05:00
{
int32 mapid = strtol ( token , NULL , 10 );
m_forbiddenMapIds . insert ( mapid );
token = strtok ( NULL , delim );
}
delete [] forbiddenMaps ;
2009-10-17 15:51:44 -07:00
2009-03-25 14:25:15 +01:00
// chat logging
m_configs [ CONFIG_CHATLOG_CHANNEL ] = sConfig . GetBoolDefault ( "ChatLogs.Channel" , false );
m_configs [ CONFIG_CHATLOG_WHISPER ] = sConfig . GetBoolDefault ( "ChatLogs.Whisper" , false );
m_configs [ CONFIG_CHATLOG_SYSCHAN ] = sConfig . GetBoolDefault ( "ChatLogs.SysChan" , false );
m_configs [ CONFIG_CHATLOG_PARTY ] = sConfig . GetBoolDefault ( "ChatLogs.Party" , false );
m_configs [ CONFIG_CHATLOG_RAID ] = sConfig . GetBoolDefault ( "ChatLogs.Raid" , false );
m_configs [ CONFIG_CHATLOG_GUILD ] = sConfig . GetBoolDefault ( "ChatLogs.Guild" , false );
m_configs [ CONFIG_CHATLOG_PUBLIC ] = sConfig . GetBoolDefault ( "ChatLogs.Public" , false );
m_configs [ CONFIG_CHATLOG_ADDON ] = sConfig . GetBoolDefault ( "ChatLogs.Addon" , false );
2009-03-26 16:12:17 +01:00
m_configs [ CONFIG_CHATLOG_BGROUND ] = sConfig . GetBoolDefault ( "ChatLogs.BattleGround" , false );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Initialize the World
void World :: SetInitialWorldSettings ()
{
///- Initialize the random number generator
2009-12-24 10:20:15 +01:00
srand (( unsigned int ) time ( NULL ));
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Initialize config settings
LoadConfigSettings ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Init highest guids before any table loading to prevent using not initialized guids in some code.
objmgr . SetHighestGuids ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Check the existence of the map files for all races' startup areas.
2009-09-22 20:40:34 -04:00
if ( ! MapManager :: ExistMapAndVMap ( 0 , - 6240.32f , 331.033f )
2008-10-11 14:16:25 -05:00
||! MapManager :: ExistMapAndVMap ( 0 , - 8949.95f , - 132.493f )
||! MapManager :: ExistMapAndVMap ( 0 , - 8949.95f , - 132.493f )
||! MapManager :: ExistMapAndVMap ( 1 , - 618.518f , - 4251.67f )
||! MapManager :: ExistMapAndVMap ( 0 , 1676.35f , 1677.45f )
||! MapManager :: ExistMapAndVMap ( 1 , 10311.3f , 832.463f )
||! MapManager :: ExistMapAndVMap ( 1 , - 2917.58f , - 257.98f )
|| m_configs [ CONFIG_EXPANSION ] && (
2009-09-22 20:40:34 -04:00
! MapManager :: ExistMapAndVMap ( 530 , 10349.6f , - 6357.29f ) || ! MapManager :: ExistMapAndVMap ( 530 , - 3961.64f , - 13931.2f )))
2008-10-11 14:16:25 -05:00
{
2008-10-14 11:57:03 -05:00
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 ());
2008-10-11 14:16:25 -05:00
exit ( 1 );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Loading strings. Getting no records means core load has to be canceled because no error message can be output.
2009-04-03 16:36:20 -06:00
sLog . outString ();
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Trinity strings..." );
2008-10-14 11:57:03 -05:00
if ( ! objmgr . LoadTrinityStrings ())
2008-10-11 14:16:25 -05:00
exit ( 1 ); // Error message displayed in function already
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Update the realm entry in the database with the realm type from the config file
//No SQL injection as values are treated as integers
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// not send custom type REALM_FFA_PVP to realm list
uint32 server_type = IsFFAPvPRealm () ? REALM_TYPE_PVP : getConfig ( CONFIG_GAME_TYPE );
uint32 realm_zone = getConfig ( CONFIG_REALM_ZONE );
2009-07-31 11:29:28 +08:00
loginDatabase . PExecute ( "UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'" , server_type , realm_zone , realmID );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Remove the bones after a restart
CharacterDatabase . PExecute ( "DELETE FROM corpse WHERE corpse_type = '0'" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Load the DBC files
sLog . outString ( "Initialize data stores..." );
LoadDBCStores ( m_dataPath );
DetectDBCLang ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Script Names..." );
2008-11-20 16:16:57 -06:00
objmgr . LoadScriptNames ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Instance Template..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadInstanceTemplate ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading SkillLineAbilityMultiMap Data..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSkillLineAbilityMap ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Clean up and pack instances
2009-09-22 20:40:34 -04:00
sLog . outString ( "Cleaning up instances..." );
2008-12-24 09:58:26 -06:00
sInstanceSaveManager . CleanupInstances (); // must be called before `creature_respawn`/`gameobject_respawn` tables
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Packing instances..." );
2008-10-11 14:16:25 -05:00
sInstanceSaveManager . PackInstances ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Localization strings..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatureLocales ();
objmgr . LoadGameObjectLocales ();
objmgr . LoadItemLocales ();
objmgr . LoadQuestLocales ();
objmgr . LoadNpcTextLocales ();
objmgr . LoadPageTextLocales ();
2008-11-05 09:22:56 -06:00
objmgr . LoadNpcOptionLocales ();
2009-02-17 17:40:03 -06:00
objmgr . LoadPointOfInterestLocales ();
2008-10-11 14:16:25 -05:00
objmgr . SetDBCLocaleIndex ( GetDefaultDbcLocale ()); // Get once for all the locale index of DBC language (console/broadcasts)
2009-09-22 20:40:34 -04:00
sLog . outString ( ">>> Localization strings loaded" );
2009-04-03 16:36:20 -06:00
sLog . outString ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Page Texts..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadPageTexts ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Game Object Templates..." ); // must be after LoadPageTexts
2008-10-11 14:16:25 -05:00
objmgr . LoadGameobjectInfo ();
2009-10-17 15:51:44 -07:00
2010-01-29 17:54:29 +01:00
sLog . outString ( "Loading Spell Rank Data..." );
spellmgr . LoadSpellRanks ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell Required Data..." );
2008-12-22 02:11:11 +01:00
spellmgr . LoadSpellRequired ();
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
sLog . outString ( "Loading Spell Group types..." );
2010-02-01 19:22:32 +01:00
spellmgr . LoadSpellGroups ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell Learn Skills..." );
2010-01-29 17:54:29 +01:00
spellmgr . LoadSpellLearnSkills (); // must be after LoadSpellRanks
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell Learn Spells..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellLearnSpells ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell Proc Event conditions..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellProcEvents ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell Bonus Data..." );
2009-01-29 19:33:39 -06:00
spellmgr . LoadSpellBonusess ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Aggro Spells Definitions..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellThreats ();
2009-10-17 15:51:44 -07:00
2010-02-02 22:35:01 +01:00
sLog . outString ( "Loading Spell Group Stack Rules..." );
spellmgr . LoadSpellGroupStackRules ();
2010-01-23 17:05:20 +01:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading NPC Texts..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGossipText ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Enchant Spells Proc datas..." );
2009-07-30 11:44:23 +02:00
spellmgr . LoadSpellEnchantProcData ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Item Random Enchantments Table..." );
2008-10-11 14:16:25 -05:00
LoadRandomEnchantmentsTable ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Items..." ); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
2008-10-11 14:16:25 -05:00
objmgr . LoadItemPrototypes ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Item Texts..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadItemTexts ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Model Based Info Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatureModelInfo ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Equipment templates..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadEquipmentTemplates ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature templates..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatureTemplates ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading SpellsScriptTarget..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellScriptTarget (); // must be after LoadCreatureTemplates and LoadGameobjectInfo
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading ItemRequiredTarget..." );
2009-06-08 17:25:02 -05:00
objmgr . LoadItemRequiredTarget ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Reputation OnKill Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadReputationOnKill ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Points Of Interest Data..." );
2009-02-17 17:40:03 -06:00
objmgr . LoadPointsOfInterest ();
2009-10-17 15:51:44 -07:00
2009-12-20 20:23:18 -07:00
sLog . outString ( "Loading Creature Base Stats..." );
objmgr . LoadCreatureClassLevelStats ();
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatures ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Linked Respawn..." );
2009-04-14 14:33:48 +02:00
objmgr . LoadCreatureLinkedRespawn (); // must be after LoadCreatures()
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading pet levelup spells..." );
2009-05-24 12:16:12 -05:00
spellmgr . LoadPetLevelupSpellMap ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading pet default spell additional to levelup spells..." );
2009-05-24 12:16:12 -05:00
spellmgr . LoadPetDefaultSpells ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Creature Template Addon Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatureAddons (); // must be after LoadCreatureTemplates() and LoadCreatures()
2009-10-17 15:51:44 -07:00
2010-03-12 18:19:50 +01:00
sLog . outString ( "Loading Vehicle Accessories..." );
objmgr . LoadVehicleAccessories (); // must be after LoadCreatureTemplates()
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Respawn Data..." ); // must be after PackInstances()
2008-10-11 14:16:25 -05:00
objmgr . LoadCreatureRespawnTimes ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Gameobject Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGameobjects ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Gameobject Respawn Data..." ); // must be after PackInstances()
2008-10-11 14:16:25 -05:00
objmgr . LoadGameobjectRespawnTimes ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Objects Pooling Data..." );
2009-02-19 18:44:20 -06:00
poolhandler . LoadFromDB ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Game Event Data..." );
2008-10-11 14:16:25 -05:00
gameeventmgr . LoadFromDB ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Weather Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadWeatherZoneChances ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Quests..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadQuests (); // must be loaded after DBCs, creature_template, item_template, gameobject tables
2010-02-14 19:13:14 -07:00
2010-04-07 22:59:46 +02:00
sLog . outString ( "Loading Quest POI" );
2010-02-14 19:13:14 -07:00
objmgr . LoadQuestPOI ();
sLog . outString ( "Loading Quests Relations..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadQuestRelations (); // must be after quest load
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading UNIT_NPC_FLAG_SPELLCLICK Data..." );
2009-05-05 16:56:15 -05:00
objmgr . LoadNPCSpellClickSpells ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading SpellArea Data..." ); // must be after quest load
2009-02-27 12:53:27 -06:00
spellmgr . LoadSpellAreas ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading AreaTrigger definitions..." );
2009-03-05 21:02:33 +01:00
objmgr . LoadAreaTriggerTeleports ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Access Requirements..." );
2009-03-05 21:02:33 +01:00
objmgr . LoadAccessRequirements (); // must be after item template load
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Quest Area Triggers..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadQuestAreaTriggers (); // must be after LoadQuests
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Tavern Area Triggers..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadTavernAreaTriggers ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading AreaTrigger script names..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadAreaTriggerScripts ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Graveyard-zone links..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGraveyardZones ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Spell target coordinates..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellTargetPositions ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading spell pet auras..." );
2008-10-11 14:16:25 -05:00
spellmgr . LoadSpellPetAuras ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading spell extra attributes..." );
2008-11-08 11:26:44 -06:00
spellmgr . LoadSpellCustomAttr ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading enchant custom attributes..." );
2009-05-24 22:54:13 +02:00
spellmgr . LoadEnchantCustomAttr ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading linked spells..." );
2008-10-30 11:32:10 -05:00
spellmgr . LoadSpellLinked ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Player Create Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadPlayerInfo ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Exploration BaseXP Data..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadExplorationBaseXP ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Pet Name Parts..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadPetNames ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading the max pet number..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadPetNumber ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading pet level stats..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadPetLevelInfo ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Player Corpses..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadCorpses ();
2009-10-17 15:51:44 -07:00
2010-04-07 22:59:46 +02:00
sLog . outString ( "Loading Player level dependent mail rewards..." );
2009-12-17 13:07:38 +01:00
objmgr . LoadMailLevelRewards ();
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Disabled Spells..." );
2008-10-21 03:58:38 -05:00
objmgr . LoadSpellDisabledEntrys ();
2009-10-17 15:51:44 -07:00
2010-01-01 14:19:29 -06:00
// Loot tables
2008-10-11 14:16:25 -05:00
LoadLootTables ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Skill Discovery Table..." );
2008-10-11 14:16:25 -05:00
LoadSkillDiscoveryTable ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Skill Extra Item Table..." );
2008-10-11 14:16:25 -05:00
LoadSkillExtraItemTable ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Skill Fishing base level requirements..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadFishingBaseSkillLevel ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Achievements..." );
2009-04-03 16:36:20 -06:00
achievementmgr . LoadAchievementReferenceList ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Achievement Criteria Lists..." );
2009-01-06 13:55:14 -06:00
achievementmgr . LoadAchievementCriteriaList ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Achievement Criteria Data..." );
2009-04-08 16:24:34 -05:00
achievementmgr . LoadAchievementCriteriaData ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Achievement Rewards..." );
2009-01-06 13:55:14 -06:00
achievementmgr . LoadRewards ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Achievement Reward Locales..." );
2009-01-06 13:55:14 -06:00
achievementmgr . LoadRewardLocales ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Completed Achievements..." );
2009-01-06 13:55:14 -06:00
achievementmgr . LoadCompletedAchievements ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Load dynamic data tables from the database
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Item Auctions..." );
2009-02-13 19:50:20 -06:00
auctionmgr . LoadAuctionItems ();
2010-01-01 14:19:29 -06:00
sLog . outString ( "Loading Auctions..." );
2009-02-13 19:50:20 -06:00
auctionmgr . LoadAuctions ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Guilds..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGuilds ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading ArenaTeams..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadArenaTeams ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Groups..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGroups ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading ReservedNames..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadReservedPlayersNames ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading GameObjects for quests..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGameObjectForQuests ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading BattleMasters..." );
2009-02-09 22:08:06 -06:00
sBattleGroundMgr . LoadBattleMastersEntry ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading GameTeleports..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadGameTele ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Npc Text Id..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadNpcTextId (); // must be after load Creature and NpcText
2009-10-17 15:51:44 -07:00
2009-12-20 13:35:08 +02:00
objmgr . LoadGossipScripts (); // must be before gossip menu options
sLog . outString ( "Loading Gossip menu..." );
objmgr . LoadGossipMenu ();
sLog . outString ( "Loading Gossip menu options..." );
objmgr . LoadGossipMenuItems ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Vendors..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadVendors (); // must be after load CreatureTemplate and ItemTemplate
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Trainers..." );
2008-10-11 14:16:25 -05:00
objmgr . LoadTrainerSpell (); // must be after load CreatureTemplate
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Waypoints..." );
2008-10-11 14:16:25 -05:00
WaypointMgr . Load ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Creature Formations..." );
2009-02-09 08:16:34 -05:00
formation_mgr . LoadCreatureFormations ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading GM tickets..." );
2009-06-15 23:58:29 +02:00
objmgr . LoadGMTickets ();
2009-10-17 15:51:44 -07:00
2010-01-29 11:56:48 +01:00
sLog . outString ( "Loading client addons..." );
sAddonMgr . LoadFromDB ();
2008-10-11 14:16:25 -05:00
///- Handle outdated emails (delete/return)
2009-09-22 20:40:34 -04:00
sLog . outString ( "Returning old mails..." );
2008-10-11 14:16:25 -05:00
objmgr . ReturnOrDeleteOldMails ( false );
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ( "Loading Autobroadcasts..." );
LoadAutobroadcasts ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Load and initialize scripts
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Scripts..." );
2009-04-03 16:36:20 -06:00
sLog . outString ();
2008-10-11 14:16:25 -05:00
objmgr . LoadQuestStartScripts (); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
objmgr . LoadQuestEndScripts (); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
objmgr . LoadSpellScripts (); // must be after load Creature/Gameobject(Template/Data)
objmgr . LoadGameObjectScripts (); // must be after load Creature/Gameobject(Template/Data)
objmgr . LoadEventScripts (); // must be after load Creature/Gameobject(Template/Data)
2009-02-09 08:16:34 -05:00
objmgr . LoadWaypointScripts ();
2009-09-22 20:40:34 -04:00
sLog . outString ( ">>> Scripts loaded" );
2009-04-03 16:36:20 -06:00
sLog . outString ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Scripts text locales..." ); // must be after Load*Scripts calls
2008-11-20 16:16:57 -06:00
objmgr . LoadDbScriptStrings ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading CreatureEventAI Texts..." );
2009-04-07 19:38:09 -05:00
CreatureEAI_Mgr . LoadCreatureEventAI_Texts ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading CreatureEventAI Summons..." );
2009-04-07 19:38:09 -05:00
CreatureEAI_Mgr . LoadCreatureEventAI_Summons ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading CreatureEventAI Scripts..." );
2009-04-07 19:38:09 -05:00
CreatureEAI_Mgr . LoadCreatureEventAI_Scripts ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Initializing Scripts..." );
2010-02-05 13:01:32 +01:00
sScriptMgr . ScriptsInit ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Initialize game time and timers
2009-09-22 20:40:34 -04:00
sLog . outDebug ( "DEBUG:: Initialize game time and timers" );
2009-12-24 10:20:15 +01:00
m_gameTime = time ( NULL );
2008-10-11 14:16:25 -05:00
m_startTime = m_gameTime ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
tm local ;
time_t curr ;
time ( & curr );
local =* ( localtime ( & curr )); // dereference and assign
char isoDate [ 128 ];
2009-09-22 20:40:34 -04:00
sprintf ( isoDate , "%04d-%02d-%02d %02d:%02d:%02d" ,
2008-10-11 14:16:25 -05:00
local . tm_year + 1900 , local . tm_mon + 1 , local . tm_mday , local . tm_hour , local . tm_min , local . tm_sec );
2009-10-17 15:51:44 -07:00
2009-09-15 01:09:36 -04:00
loginDatabase . PExecute ( "INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')" ,
2009-12-24 10:20:15 +01:00
realmID , uint64 ( m_startTime ), isoDate , _FULLVERSION );
2009-10-17 15:51:44 -07:00
2009-08-08 15:05:21 -07:00
static uint32 abtimer = 0 ;
abtimer = sConfig . GetIntDefault ( "AutoBroadcast.Timer" , 60000 );
2009-06-09 19:54:46 -05:00
m_timers [ WUPDATE_OBJECTS ]. SetInterval ( IN_MILISECONDS / 2 );
2008-10-11 14:16:25 -05:00
m_timers [ WUPDATE_SESSIONS ]. SetInterval ( 0 );
2009-03-02 16:53:50 -06:00
m_timers [ WUPDATE_WEATHERS ]. SetInterval ( 1 * IN_MILISECONDS );
m_timers [ WUPDATE_AUCTIONS ]. SetInterval ( MINUTE * IN_MILISECONDS );
m_timers [ WUPDATE_UPTIME ]. SetInterval ( m_configs [ CONFIG_UPTIME_UPDATE ] * MINUTE * IN_MILISECONDS );
2008-10-11 14:16:25 -05:00
//Update "uptime" table based on configuration entry in minutes.
2009-03-02 16:53:50 -06:00
m_timers [ WUPDATE_CORPSES ]. SetInterval ( 20 * MINUTE * IN_MILISECONDS );
//erase corpses every 20 minutes
2009-03-25 15:21:32 +01:00
m_timers [ WUPDATE_CLEANDB ]. SetInterval ( m_configs [ CONFIG_LOGDB_CLEARINTERVAL ] * MINUTE * IN_MILISECONDS );
// clean logs table every 14 days by default
2009-08-08 15:05:21 -07:00
m_timers [ WUPDATE_AUTOBROADCAST ]. SetInterval ( abtimer );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
//one second is 1000 -(tested on win system)
2009-12-24 10:20:15 +01:00
mail_timer = (((( localtime ( & m_gameTime ) -> tm_hour + 20 ) % 24 ) * HOUR * IN_MILISECONDS ) / m_timers [ WUPDATE_AUCTIONS ]. GetInterval ());
2008-10-11 14:16:25 -05:00
//1440
2009-09-22 20:40:34 -04:00
mail_timer_expires = (( DAY * IN_MILISECONDS ) / ( m_timers [ WUPDATE_AUCTIONS ]. GetInterval ()));
2008-10-11 14:16:25 -05:00
sLog . outDebug ( "Mail timer set to: %u, mail return is called every %u minutes" , mail_timer , mail_timer_expires );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Initilize static helper structures
AIRegistry :: Initialize ();
Player :: InitVisibleBits ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Initialize MapManager
2009-09-22 20:40:34 -04:00
sLog . outString ( "Starting Map System" );
2008-10-11 14:16:25 -05:00
MapManager :: Instance (). Initialize ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Starting Game Event system..." );
2009-05-30 14:48:13 -05:00
uint32 nextGameEvent = gameeventmgr . Initialize ();
m_timers [ WUPDATE_EVENTS ]. SetInterval ( nextGameEvent ); //depend on next event
2009-10-17 15:51:44 -07:00
2010-03-26 16:48:33 +01:00
sLog . outString ( "Loading World States..." ); // must be loaded before battleground and outdoor PvP
LoadWorldStates ();
2008-10-11 14:16:25 -05:00
///- Initialize Battlegrounds
2009-09-22 20:40:34 -04:00
sLog . outString ( "Starting BattleGround System" );
2008-10-11 14:16:25 -05:00
sBattleGroundMgr . CreateInitialBattleGrounds ();
sBattleGroundMgr . InitAutomaticArenaPointDistribution ();
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
///- Initialize outdoor pvp
2009-09-22 20:40:34 -04:00
sLog . outString ( "Starting Outdoor PvP System" );
2008-10-14 11:57:03 -05:00
sOutdoorPvPMgr . InitOutdoorPvP ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Transports..." );
2008-10-11 14:16:25 -05:00
MapManager :: Instance (). LoadTransports ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Loading Transports Events..." );
2009-02-09 08:16:34 -05:00
objmgr . LoadTransportEvents ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Deleting expired bans..." );
2010-04-07 23:56:35 +02:00
loginDatabase . Execute ( "DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate" );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Calculate next daily quest reset time..." );
2008-10-11 14:16:25 -05:00
InitDailyQuestResetTime ();
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
sLog . outString ( "Starting objects Pooling system..." );
2009-02-19 18:44:20 -06:00
poolhandler . Initialize ();
2009-10-17 15:51:44 -07:00
2009-01-20 16:44:05 -06:00
sLog . outString ( "Initialize AuctionHouseBot..." );
2009-08-06 03:00:45 -04:00
auctionbot . Initialize ();
2009-10-17 15:51:44 -07:00
2009-04-07 10:51:45 +02:00
// possibly enable db logging; avoid massive startup spam by doing it here.
if ( sLog . GetLogDBLater ())
{
sLog . outString ( "Enabling database logging..." );
sLog . SetLogDBLater ( false );
sLog . SetLogDB ( true );
}
else
{
2009-04-07 18:42:20 +02:00
sLog . SetLogDB ( false );
2009-04-07 10:51:45 +02:00
sLog . SetLogDBLater ( false );
}
2010-01-19 11:36:05 +01:00
sScriptMgr . OnServerStartup ();
2009-09-22 20:40:34 -04:00
sLog . outString ( "WORLD: World initialized" );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: DetectDBCLang ()
{
uint32 m_lang_confid = sConfig . GetIntDefault ( "DBC.Locale" , 255 );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)" , MAX_LOCALE );
m_lang_confid = LOCALE_enUS ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
ChrRacesEntry const * race = sChrRacesStore . LookupEntry ( 1 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
std :: string availableLocalsStr ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
int default_locale = MAX_LOCALE ;
for ( int i = MAX_LOCALE - 1 ; i >= 0 ; -- i )
{
2009-09-22 20:40:34 -04:00
if ( strlen ( race -> name [ i ]) > 0 ) // check by race names
2008-10-11 14:16:25 -05:00
{
default_locale = i ;
m_availableDbcLocaleMask |= ( 1 << i );
availableLocalsStr += localeNames [ i ];
availableLocalsStr += " " ;
}
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE &&
( m_availableDbcLocaleMask & ( 1 << m_lang_confid )))
2008-10-11 14:16:25 -05:00
{
default_locale = m_lang_confid ;
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( default_locale >= MAX_LOCALE )
2008-10-11 14:16:25 -05:00
{
sLog . outError ( "Unable to determine your DBC Locale! (corrupt DBC?)" );
exit ( 1 );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_defaultDbcLocale = LocaleConstant ( default_locale );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
sLog . outString ( "Using %s DBC Locale as default. All available DBC locales: %s" , localeNames [ m_defaultDbcLocale ], availableLocalsStr . empty () ? "<none>" : availableLocalsStr . c_str ());
2009-04-03 16:36:20 -06:00
sLog . outString ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-01-07 10:49:13 -06:00
void World :: RecordTimeDiff ( const char * text , ...)
2009-01-05 16:39:03 -06:00
{
2009-09-22 20:40:34 -04:00
if ( m_updateTimeCount != 1 )
2009-01-05 16:39:03 -06:00
return ;
2009-09-22 20:40:34 -04:00
if ( ! text )
2009-01-06 15:48:42 -06:00
{
m_currentTime = getMSTime ();
return ;
}
2009-10-17 15:51:44 -07:00
2009-01-08 14:57:46 -06:00
uint32 thisTime = getMSTime ();
uint32 diff = getMSTimeDiff ( m_currentTime , thisTime );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( diff > m_configs [ CONFIG_MIN_LOG_UPDATE ])
2009-01-08 14:57:46 -06:00
{
va_list ap ;
char str [ 256 ];
va_start ( ap , text );
2009-09-22 20:40:34 -04:00
vsnprintf ( str , 256 , text , ap );
2009-01-08 14:57:46 -06:00
va_end ( ap );
sLog . outDetail ( "Difftime %s: %u." , str , diff );
}
2009-10-17 15:51:44 -07:00
2009-01-05 16:39:03 -06:00
m_currentTime = thisTime ;
}
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
void World :: LoadAutobroadcasts ()
{
m_Autobroadcasts . clear ();
2009-10-17 15:51:44 -07:00
2010-01-23 14:45:58 +01:00
QueryResult_AutoPtr result = WorldDatabase . Query ( "SELECT text FROM autobroadcast" );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( ! result )
2009-08-10 17:03:11 +02:00
{
barGoLink bar ( 1 );
bar . step ();
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ();
2009-09-22 20:40:34 -04:00
sLog . outString ( ">> Loaded 0 autobroadcasts definitions" );
2009-08-10 17:03:11 +02:00
return ;
}
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
barGoLink bar ( result -> GetRowCount ());
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
uint32 count = 0 ;
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
do
{
bar . step ();
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
std :: string message = fields [ 0 ]. GetCppString ();
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
m_Autobroadcasts . push_back ( message );
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
count ++ ;
2010-04-07 19:13:19 +02:00
} while ( result -> NextRow ());
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ();
2009-09-22 20:40:34 -04:00
sLog . outString ( ">> Loaded %u autobroadcasts definitions" , count );
2009-08-10 17:03:11 +02:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Update the World !
2009-01-21 16:18:57 -06:00
void World :: Update ( uint32 diff )
2008-10-11 14:16:25 -05:00
{
2008-12-30 18:03:26 -06:00
m_updateTime = uint32 ( diff );
2009-09-22 20:40:34 -04:00
if ( m_configs [ CONFIG_INTERVAL_LOG_UPDATE ])
2008-12-30 18:03:26 -06:00
{
2009-09-22 20:40:34 -04:00
if ( m_updateTimeSum > m_configs [ CONFIG_INTERVAL_LOG_UPDATE ])
2008-12-30 18:03:26 -06:00
{
2009-01-15 22:01:47 -05:00
sLog . outBasic ( "Update time diff: %u. Players online: %u." , m_updateTimeSum / m_updateTimeCount , GetActiveSessionCount ());
2008-12-30 18:03:26 -06:00
m_updateTimeSum = m_updateTime ;
m_updateTimeCount = 1 ;
}
else
{
m_updateTimeSum += m_updateTime ;
++ m_updateTimeCount ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Update the different timers
2009-09-22 20:40:34 -04:00
for ( int i = 0 ; i < WUPDATE_COUNT ; ++ i )
2010-04-07 23:56:35 +02:00
if ( m_timers [ i ]. GetCurrent () >= 0 )
2008-10-11 14:16:25 -05:00
m_timers [ i ]. Update ( diff );
else m_timers [ i ]. SetCurrent ( 0 );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Update the game time and check for shutdown time
_UpdateGameTime ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Handle daily quests reset time
2009-12-24 10:20:15 +01:00
if ( m_gameTime > m_NextDailyQuestReset )
2008-10-11 14:16:25 -05:00
{
ResetDailyQuests ();
m_NextDailyQuestReset += DAY ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// <ul><li> Handle auctions when the timer has passed
if ( m_timers [ WUPDATE_AUCTIONS ]. Passed ())
{
2009-08-06 03:00:45 -04:00
auctionbot . Update ();
2009-02-28 17:42:29 -05:00
m_timers [ WUPDATE_AUCTIONS ]. Reset ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Update mails (return old mails with item, or delete them)
//(tested... works on win)
if ( ++ mail_timer > mail_timer_expires )
{
mail_timer = 0 ;
objmgr . ReturnOrDeleteOldMails ( true );
}
2009-10-17 15:51:44 -07:00
2009-02-13 19:50:20 -06:00
///- Handle expired auctions
auctionmgr . Update ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// <li> Handle session updates when the timer has passed
2009-06-09 19:54:46 -05:00
RecordTimeDiff ( NULL );
UpdateSessions ( diff );
2009-01-05 16:39:03 -06:00
RecordTimeDiff ( "UpdateSessions" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// <li> Handle weather updates when the timer has passed
if ( m_timers [ WUPDATE_WEATHERS ]. Passed ())
{
m_timers [ WUPDATE_WEATHERS ]. Reset ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Send an update signal to Weather objects
WeatherMap :: iterator itr , next ;
for ( itr = m_weathers . begin (); itr != m_weathers . end (); itr = next )
{
next = itr ;
++ next ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- and remove Weather objects for zones with no player
//As interval > WorldTick
2009-09-22 20:40:34 -04:00
if ( ! itr -> second -> Update ( m_timers [ WUPDATE_WEATHERS ]. GetInterval ()))
2008-10-11 14:16:25 -05:00
{
delete itr -> second ;
m_weathers . erase ( itr );
}
}
}
/// <li> Update uptime table
if ( m_timers [ WUPDATE_UPTIME ]. Passed ())
{
uint32 tmpDiff = ( m_gameTime - m_startTime );
2009-03-26 14:02:11 -06:00
uint32 maxClientsNum = GetMaxActiveSessionCount ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_timers [ WUPDATE_UPTIME ]. Reset ();
2009-12-24 10:20:15 +01:00
loginDatabase . PExecute ( "UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD , tmpDiff , maxClientsNum , realmID , uint64 ( m_startTime ));
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-03-25 15:21:32 +01:00
/// <li> Clean logs table
2009-09-22 20:40:34 -04:00
if ( sWorld . getConfig ( CONFIG_LOGDB_CLEARTIME ) > 0 ) // if not enabled, ignore the timer
2009-03-25 15:21:32 +01:00
{
if ( m_timers [ WUPDATE_CLEANDB ]. Passed ())
{
2009-12-23 09:05:17 +01:00
uint32 tmpDiff = ( m_gameTime - m_startTime );
2009-03-25 15:21:32 +01:00
uint32 maxClientsNum = sWorld . GetMaxActiveSessionCount ();
2009-10-17 15:51:44 -07:00
2009-03-25 15:21:32 +01:00
m_timers [ WUPDATE_CLEANDB ]. Reset ();
2009-07-31 11:29:28 +08:00
loginDatabase . PExecute ( "DELETE FROM logs WHERE (time + %u) < " UI64FMTD ";" ,
2009-03-25 15:21:32 +01:00
sWorld . getConfig ( CONFIG_LOGDB_CLEARTIME ), uint64 ( time ( 0 )));
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// <li> Handle all other objects
2009-06-09 19:54:46 -05:00
///- Update objects when the timer has passed (maps, transport, creatures,...)
MapManager :: Instance (). Update ( diff ); // As interval = 0
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
/*if (m_timers[WUPDATE_OBJECTS].Passed())
2008-10-11 14:16:25 -05:00
{
m_timers[WUPDATE_OBJECTS].Reset();
2009-06-09 19:54:46 -05:00
MapManager::Instance().DoDelayedMovesAndRemoves();
2009-06-10 16:33:09 -05:00
}*/
2009-10-17 15:51:44 -07:00
2009-08-08 15:05:21 -07:00
static uint32 autobroadcaston = 0 ;
autobroadcaston = sConfig . GetIntDefault ( "AutoBroadcast.On" , 0 );
2009-09-22 20:40:34 -04:00
if ( autobroadcaston == 1 )
2009-08-08 15:05:21 -07:00
{
if ( m_timers [ WUPDATE_AUTOBROADCAST ]. Passed ())
{
m_timers [ WUPDATE_AUTOBROADCAST ]. Reset ();
SendRNDBroadcast ();
}
}
2009-10-17 15:51:44 -07:00
2009-06-09 19:54:46 -05:00
sBattleGroundMgr . Update ( diff );
RecordTimeDiff ( "UpdateBattleGroundMgr" );
2008-10-14 11:57:03 -05:00
2009-06-09 19:54:46 -05:00
sOutdoorPvPMgr . Update ( diff );
RecordTimeDiff ( "UpdateOutdoorPvPMgr" );
2008-10-11 14:16:25 -05:00
// execute callbacks from sql queries that were queued recently
UpdateResultQueue ();
2009-01-05 16:39:03 -06:00
RecordTimeDiff ( "UpdateResultQueue" );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Erase corpses once every 20 minutes
if ( m_timers [ WUPDATE_CORPSES ]. Passed ())
{
m_timers [ WUPDATE_CORPSES ]. Reset ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
CorpsesErase ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Process Game events when necessary
if ( m_timers [ WUPDATE_EVENTS ]. Passed ())
{
m_timers [ WUPDATE_EVENTS ]. Reset (); // to give time for Update() to be processed
uint32 nextGameEvent = gameeventmgr . Update ();
m_timers [ WUPDATE_EVENTS ]. SetInterval ( nextGameEvent );
m_timers [ WUPDATE_EVENTS ]. Reset ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// update the instance reset times
sInstanceSaveManager . Update ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// And last, but not least handle the issued cli commands
ProcessCliCommands ();
}
2009-10-17 15:51:44 -07:00
2008-10-14 11:57:03 -05:00
void World :: ForceGameEventUpdate ()
{
m_timers [ WUPDATE_EVENTS ]. Reset (); // to give time for Update() to be processed
uint32 nextGameEvent = gameeventmgr . Update ();
m_timers [ WUPDATE_EVENTS ]. SetInterval ( nextGameEvent );
m_timers [ WUPDATE_EVENTS ]. Reset ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Send a packet to all players (except self if mentioned)
void World :: SendGlobalMessage ( WorldPacket * packet , WorldSession * self , uint32 team )
{
2009-04-29 00:26:07 -05:00
SessionMap :: const_iterator itr ;
2008-12-19 16:05:13 -06:00
for ( itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2008-10-11 14:16:25 -05:00
{
if ( itr -> second &&
itr -> second -> GetPlayer () &&
itr -> second -> GetPlayer () -> IsInWorld () &&
itr -> second != self &&
2009-09-22 20:40:34 -04:00
( team == 0 || itr -> second -> GetPlayer () -> GetTeam () == team ))
2008-10-11 14:16:25 -05:00
{
itr -> second -> SendPacket ( packet );
}
}
}
2009-10-17 15:51:44 -07:00
2009-03-09 19:17:12 -06:00
/// Send a packet to all GMs (except self if mentioned)
void World :: SendGlobalGMMessage ( WorldPacket * packet , WorldSession * self , uint32 team )
{
SessionMap :: iterator itr ;
for ( itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
{
if ( itr -> second &&
itr -> second -> GetPlayer () &&
itr -> second -> GetPlayer () -> IsInWorld () &&
itr -> second != self &&
2009-06-08 16:25:07 +02:00
itr -> second -> GetSecurity () > SEC_PLAYER &&
2009-09-22 20:40:34 -04:00
( team == 0 || itr -> second -> GetPlayer () -> GetTeam () == team ))
2009-03-09 19:17:12 -06:00
{
itr -> second -> SendPacket ( packet );
}
}
}
2009-10-17 15:51:44 -07:00
2009-12-20 15:20:04 +01:00
namespace Trinity
2008-12-22 21:56:16 +01:00
{
2009-03-09 17:00:31 -06:00
class WorldWorldTextBuilder
2008-12-22 21:56:16 +01:00
{
2009-03-09 17:00:31 -06:00
public :
typedef std :: vector < WorldPacket *> WorldPacketList ;
explicit WorldWorldTextBuilder ( int32 textId , va_list * args = NULL ) : i_textId ( textId ), i_args ( args ) {}
void operator ()( WorldPacketList & data_list , int32 loc_idx )
{
2009-12-20 15:20:04 +01:00
char const * text = objmgr . GetTrinityString ( i_textId , loc_idx );
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( i_args )
2009-03-09 17:00:31 -06:00
{
// we need copy va_list before use or original va_list will corrupted
va_list ap ;
va_copy ( ap , * i_args );
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
char str [ 2048 ];
2009-09-22 20:40:34 -04:00
vsnprintf ( str , 2048 , text , ap );
2009-03-09 17:00:31 -06:00
va_end ( ap );
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
do_helper ( data_list , & str [ 0 ]);
}
else
do_helper ( data_list ,( char * ) text );
}
private :
char * lineFromMessage ( char *& pos ) { char * start = strtok ( pos , " \n " ); pos = NULL ; return start ; }
void do_helper ( WorldPacketList & data_list , char * text )
{
char * pos = text ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:13:19 +02:00
while ( char * line = lineFromMessage ( pos ))
2009-03-09 17:00:31 -06:00
{
WorldPacket * data = new WorldPacket ();
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
uint32 lineLength = ( line ? strlen ( line ) : 0 ) + 1 ;
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
data -> Initialize ( SMSG_MESSAGECHAT , 100 ); // guess size
* data << uint8 ( CHAT_MSG_SYSTEM );
* data << uint32 ( LANG_UNIVERSAL );
* data << uint64 ( 0 );
* data << uint32 ( 0 ); // can be chat msg group or something
* data << uint64 ( 0 );
* data << uint32 ( lineLength );
* data << line ;
* data << uint8 ( 0 );
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
data_list . push_back ( data );
}
}
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
int32 i_textId ;
va_list * i_args ;
};
2009-12-20 15:20:04 +01:00
} // namespace Trinity
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
/// Send a System Message to all players (except self if mentioned)
void World :: SendWorldText ( int32 string_id , ...)
{
va_list ap ;
va_start ( ap , string_id );
2009-10-17 15:51:44 -07:00
2009-12-20 15:20:04 +01:00
Trinity :: WorldWorldTextBuilder wt_builder ( string_id , & ap );
Trinity :: LocalizedPacketListDo < Trinity :: WorldWorldTextBuilder > wt_do ( wt_builder );
2009-09-22 20:40:34 -04:00
for ( SessionMap :: const_iterator itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2009-03-09 17:00:31 -06:00
{
2009-09-22 20:40:34 -04:00
if ( ! itr -> second || ! itr -> second -> GetPlayer () || ! itr -> second -> GetPlayer () -> IsInWorld ())
2009-03-09 17:00:31 -06:00
continue ;
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
wt_do ( itr -> second -> GetPlayer ());
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
va_end ( ap );
2008-12-22 21:56:16 +01:00
}
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
/// Send a System Message to all GMs (except self if mentioned)
2008-12-22 21:56:16 +01:00
void World :: SendGMText ( int32 string_id , ...)
{
2009-03-09 17:00:31 -06:00
va_list ap ;
va_start ( ap , string_id );
2009-10-17 15:51:44 -07:00
2009-12-20 15:20:04 +01:00
Trinity :: WorldWorldTextBuilder wt_builder ( string_id , & ap );
Trinity :: LocalizedPacketListDo < Trinity :: WorldWorldTextBuilder > wt_do ( wt_builder );
2009-09-22 20:40:34 -04:00
for ( SessionMap :: iterator itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2008-12-22 21:56:16 +01:00
{
2009-09-22 20:40:34 -04:00
if ( ! itr -> second || ! itr -> second -> GetPlayer () || ! itr -> second -> GetPlayer () -> IsInWorld ())
2008-12-22 21:56:16 +01:00
continue ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( itr -> second -> GetSecurity () < SEC_MODERATOR )
2009-03-09 17:00:31 -06:00
continue ;
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
wt_do ( itr -> second -> GetPlayer ());
2008-12-22 21:56:16 +01:00
}
2009-10-17 15:51:44 -07:00
2009-03-09 17:00:31 -06:00
va_end ( ap );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-02-10 00:59:10 -06:00
/// DEPRICATED, only for debug purpose. Send a System Message to all players (except self if mentioned)
2008-12-19 16:05:13 -06:00
void World :: SendGlobalText ( const char * text , WorldSession * self )
{
WorldPacket data ;
2009-10-17 15:51:44 -07:00
2008-12-19 16:05:13 -06:00
// need copy to prevent corruption by strtok call in LineFromMessage original string
char * buf = strdup ( text );
char * pos = buf ;
2009-10-17 15:51:44 -07:00
2010-04-07 19:13:19 +02:00
while ( char * line = ChatHandler :: LineFromMessage ( pos ))
2008-12-19 16:05:13 -06:00
{
ChatHandler :: FillMessageData ( & data , NULL , CHAT_MSG_SYSTEM , LANG_UNIVERSAL , NULL , 0 , line , NULL );
SendGlobalMessage ( & data , self );
}
2009-10-17 15:51:44 -07:00
2008-12-19 16:05:13 -06:00
free ( buf );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
void World :: SendZoneMessage ( uint32 zone , WorldPacket * packet , WorldSession * self , uint32 team )
{
2009-04-29 00:26:07 -05:00
SessionMap :: const_iterator itr ;
2008-12-19 16:05:13 -06:00
for ( itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2008-10-11 14:16:25 -05:00
{
if ( itr -> second &&
itr -> second -> GetPlayer () &&
itr -> second -> GetPlayer () -> IsInWorld () &&
itr -> second -> GetPlayer () -> GetZoneId () == zone &&
itr -> second != self &&
2009-09-22 20:40:34 -04:00
( team == 0 || itr -> second -> GetPlayer () -> GetTeam () == team ))
2008-10-11 14:16:25 -05:00
{
itr -> second -> SendPacket ( packet );
}
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Send a System Message to all players in the zone (except self if mentioned)
void World :: SendZoneText ( uint32 zone , const char * text , WorldSession * self , uint32 team )
{
WorldPacket data ;
ChatHandler :: FillMessageData ( & data , NULL , CHAT_MSG_SYSTEM , LANG_UNIVERSAL , NULL , 0 , text , NULL );
SendZoneMessage ( zone , & data , self , team );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Kick (and save) all players
void World :: KickAll ()
{
2008-11-30 12:47:26 -06:00
m_QueuedPlayer . clear (); // prevent send queue update packet and login queued sessions
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// session not removed at kick and will removed in next update tick
2009-04-29 00:26:07 -05:00
for ( SessionMap :: const_iterator itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2008-10-11 14:16:25 -05:00
itr -> second -> KickPlayer ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Kick (and save) all players with security level less `sec`
void World :: KickAllLess ( AccountTypes sec )
{
// session not removed at kick and will removed in next update tick
2009-04-29 00:26:07 -05:00
for ( SessionMap :: const_iterator itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
2009-09-22 20:40:34 -04:00
if ( itr -> second -> GetSecurity () < sec )
2008-10-11 14:16:25 -05:00
itr -> second -> KickPlayer ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
2008-10-26 13:32:42 -05:00
BanReturn World :: BanAccount ( BanMode mode , std :: string nameOrIP , std :: string duration , std :: string reason , std :: string author )
2008-10-11 14:16:25 -05:00
{
2009-07-31 11:29:28 +08:00
loginDatabase . escape_string ( nameOrIP );
loginDatabase . escape_string ( reason );
2008-10-11 14:16:25 -05:00
std :: string safe_author = author ;
2009-07-31 11:29:28 +08:00
loginDatabase . escape_string ( safe_author );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
uint32 duration_secs = TimeStringToSecs ( duration );
2010-01-23 14:45:58 +01:00
QueryResult_AutoPtr resultAccounts = QueryResult_AutoPtr ( NULL ); //used for kicking
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Update the database with ban information
2008-11-06 16:10:28 -06:00
switch ( mode )
2008-10-26 13:32:42 -05:00
{
case BAN_IP :
2008-11-06 16:10:28 -06:00
//No SQL injection as strings are escaped
2009-07-31 11:29:28 +08:00
resultAccounts = loginDatabase . PQuery ( "SELECT id FROM account WHERE last_ip = '%s'" , nameOrIP . c_str ());
loginDatabase . PExecute ( "INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')" , nameOrIP . c_str (), duration_secs , safe_author . c_str (), reason . c_str ());
2008-11-06 16:10:28 -06:00
break ;
case BAN_ACCOUNT :
//No SQL injection as string is escaped
2009-07-31 11:29:28 +08:00
resultAccounts = loginDatabase . PQuery ( "SELECT id FROM account WHERE username = '%s'" , nameOrIP . c_str ());
2008-11-06 16:10:28 -06:00
break ;
case BAN_CHARACTER :
//No SQL injection as string is escaped
resultAccounts = CharacterDatabase . PQuery ( "SELECT account FROM characters WHERE name = '%s'" , nameOrIP . c_str ());
break ;
default :
return BAN_SYNTAX_ERROR ;
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( ! resultAccounts )
2008-11-06 16:10:28 -06:00
{
2010-04-07 23:25:02 +02:00
if ( mode == BAN_IP )
2008-11-06 16:10:28 -06:00
return BAN_SUCCESS ; // ip correctly banned but nobody affected (yet)
else
return BAN_NOTFOUND ; // Nobody to ban
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Disconnect all affected players (for IP it can be several)
do
{
Field * fieldsAccount = resultAccounts -> Fetch ();
uint32 account = fieldsAccount -> GetUInt32 ();
2009-10-17 15:51:44 -07:00
2010-04-08 08:20:08 +02:00
if ( mode != BAN_IP )
2008-11-06 16:10:28 -06:00
{
2008-10-11 14:16:25 -05:00
//No SQL injection as strings are escaped
2009-07-31 11:29:28 +08:00
loginDatabase . PExecute ( "INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')" ,
2008-10-11 14:16:25 -05:00
account , duration_secs , safe_author . c_str (), reason . c_str ());
2008-11-06 16:10:28 -06:00
}
2009-10-17 15:51:44 -07:00
2008-10-26 13:32:42 -05:00
if ( WorldSession * sess = FindSession ( account ))
2009-09-22 20:40:34 -04:00
if ( std :: string ( sess -> GetPlayerName ()) != author )
2008-10-11 14:16:25 -05:00
sess -> KickPlayer ();
}
2010-04-07 19:13:19 +02:00
while ( resultAccounts -> NextRow ());
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
return BAN_SUCCESS ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Remove a ban from an account or IP address
2008-10-26 13:32:42 -05:00
bool World :: RemoveBanAccount ( BanMode mode , std :: string nameOrIP )
2008-10-11 14:16:25 -05:00
{
2008-10-26 13:32:42 -05:00
if ( mode == BAN_IP )
2008-10-11 14:16:25 -05:00
{
2009-07-31 11:29:28 +08:00
loginDatabase . escape_string ( nameOrIP );
loginDatabase . PExecute ( "DELETE FROM ip_banned WHERE ip = '%s'" , nameOrIP . c_str ());
2008-10-11 14:16:25 -05:00
}
else
{
2008-11-06 16:10:28 -06:00
uint32 account = 0 ;
2008-10-26 13:32:42 -05:00
if ( mode == BAN_ACCOUNT )
2008-10-21 19:07:16 -05:00
account = accmgr . GetId ( nameOrIP );
2008-10-26 13:32:42 -05:00
else if ( mode == BAN_CHARACTER )
2008-10-21 19:07:16 -05:00
account = objmgr . GetPlayerAccountIdByPlayerName ( nameOrIP );
2009-10-17 15:51:44 -07:00
2008-11-06 16:10:28 -06:00
if ( ! account )
2008-10-11 14:16:25 -05:00
return false ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
//NO SQL injection as account is uint32
2009-07-31 11:29:28 +08:00
loginDatabase . PExecute ( "UPDATE account_banned SET active = '0' WHERE id = '%u'" , account );
2008-10-11 14:16:25 -05:00
}
return true ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Update the game time
void World :: _UpdateGameTime ()
{
///- update the time
2009-12-24 10:20:15 +01:00
time_t thisTime = time ( NULL );
uint32 elapsed = uint32 ( thisTime - m_gameTime );
m_gameTime = thisTime ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- if there is a shutdown timer
2009-09-22 20:40:34 -04:00
if ( ! m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0 )
2008-10-11 14:16:25 -05:00
{
///- ... and it is overdue, stop the world (set m_stopEvent)
2009-09-22 20:40:34 -04:00
if ( m_ShutdownTimer <= elapsed )
2008-10-11 14:16:25 -05:00
{
2010-04-07 23:25:02 +02:00
if ( ! ( m_ShutdownMask & SHUTDOWN_MASK_IDLE ) || GetActiveAndQueuedSessionCount () == 0 )
2008-11-20 16:16:57 -06:00
m_stopEvent = true ; // exist code already set
2008-10-11 14:16:25 -05:00
else
m_ShutdownTimer = 1 ; // minimum timer value to wait idle state
}
///- ... else decrease it and if necessary display a shutdown countdown to the users
else
{
m_ShutdownTimer -= elapsed ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
ShutdownMsg ();
}
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Shutdown the server
2008-11-20 16:16:57 -06:00
void World :: ShutdownServ ( uint32 time , uint32 options , uint8 exitcode )
2008-10-11 14:16:25 -05:00
{
2008-11-20 16:16:57 -06:00
// ignore if server shutdown at next tick
2009-09-22 20:40:34 -04:00
if ( m_stopEvent )
2008-11-20 16:16:57 -06:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_ShutdownMask = options ;
2008-11-20 16:16:57 -06:00
m_ExitCode = exitcode ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
2010-04-07 23:25:02 +02:00
if ( time == 0 )
2008-10-11 14:16:25 -05:00
{
2010-04-07 23:25:02 +02:00
if ( ! ( options & SHUTDOWN_MASK_IDLE ) || GetActiveAndQueuedSessionCount () == 0 )
2008-11-20 16:16:57 -06:00
m_stopEvent = true ; // exist code already set
2008-10-11 14:16:25 -05:00
else
m_ShutdownTimer = 1 ; //So that the session count is re-evaluated at next world tick
}
///- Else set the shutdown timer and warn users
else
{
m_ShutdownTimer = time ;
ShutdownMsg ( true );
}
2009-10-17 15:51:44 -07:00
2010-01-19 11:36:05 +01:00
sScriptMgr . OnServerShutdown ();
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Display a shutdown message to the user(s)
void World :: ShutdownMsg ( bool show , Player * player )
{
// not show messages for idle shutdown mode
2009-09-22 20:40:34 -04:00
if ( m_ShutdownMask & SHUTDOWN_MASK_IDLE )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Display a message every 12 hours, hours, 5 minutes, minute, 5 seconds and finally seconds
2009-09-22 20:40:34 -04:00
if ( show ||
2008-10-11 14:16:25 -05:00
( m_ShutdownTimer < 10 ) ||
// < 30 sec; every 5 sec
2010-04-07 23:25:02 +02:00
( m_ShutdownTimer < 30 && ( m_ShutdownTimer % 5 ) == 0 ) ||
2008-10-11 14:16:25 -05:00
// < 5 min ; every 1 min
2010-04-07 23:25:02 +02:00
( m_ShutdownTimer < 5 * MINUTE && ( m_ShutdownTimer % MINUTE ) == 0 ) ||
2008-10-11 14:16:25 -05:00
// < 30 min ; every 5 min
2010-04-07 23:25:02 +02:00
( m_ShutdownTimer < 30 * MINUTE && ( m_ShutdownTimer % ( 5 * MINUTE )) == 0 ) ||
2008-10-11 14:16:25 -05:00
// < 12 h ; every 1 h
2010-04-07 23:25:02 +02:00
( m_ShutdownTimer < 12 * HOUR && ( m_ShutdownTimer % HOUR ) == 0 ) ||
2008-10-11 14:16:25 -05:00
// > 12 h ; every 12 h
2010-04-07 23:25:02 +02:00
( m_ShutdownTimer > 12 * HOUR && ( m_ShutdownTimer % ( 12 * HOUR )) == 0 ))
2008-10-11 14:16:25 -05:00
{
std :: string str = secsToTimeString ( m_ShutdownTimer );
2009-10-17 15:51:44 -07:00
2009-03-28 17:56:15 -06:00
ServerMessageType msgid = ( m_ShutdownMask & SHUTDOWN_MASK_RESTART ) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
SendServerMessage ( msgid , str . c_str (), player );
2008-11-06 16:10:28 -06:00
DEBUG_LOG ( "Server is %s in %s" ,( m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown" ), str . c_str ());
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Cancel a planned server shutdown
void World :: ShutdownCancel ()
{
2008-11-20 16:16:57 -06:00
// nothing cancel or too later
2009-09-22 20:40:34 -04:00
if ( ! m_ShutdownTimer || m_stopEvent )
2008-10-11 14:16:25 -05:00
return ;
2009-10-17 15:51:44 -07:00
2009-03-28 17:56:15 -06:00
ServerMessageType msgid = ( m_ShutdownMask & SHUTDOWN_MASK_RESTART ) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
m_ShutdownMask = 0 ;
m_ShutdownTimer = 0 ;
2008-11-20 16:16:57 -06:00
m_ExitCode = SHUTDOWN_EXIT_CODE ; // to default value
2008-10-11 14:16:25 -05:00
SendServerMessage ( msgid );
2009-10-17 15:51:44 -07:00
2008-11-20 16:16:57 -06:00
DEBUG_LOG ( "Server %s cancelled." ,( m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown" ));
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
/// Send a server message to the user(s)
2009-03-28 17:56:15 -06:00
void World :: SendServerMessage ( ServerMessageType type , const char * text , Player * player )
2008-10-11 14:16:25 -05:00
{
WorldPacket data ( SMSG_SERVER_MESSAGE , 50 ); // guess size
data << uint32 ( type );
2009-09-22 20:40:34 -04:00
if ( type <= SERVER_MSG_STRING )
2008-10-11 14:16:25 -05:00
data << text ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( player )
2008-10-11 14:16:25 -05:00
player -> GetSession () -> SendPacket ( & data );
else
2009-09-22 20:40:34 -04:00
SendGlobalMessage ( & data );
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
void World :: UpdateSessions ( uint32 diff )
2008-10-11 14:16:25 -05:00
{
2008-11-30 12:47:26 -06:00
///- Add new sessions
2009-09-11 13:42:39 -07:00
WorldSession * sess ;
2010-04-07 19:13:19 +02:00
while ( addSessQueue . next ( sess ))
2008-11-30 12:47:26 -06:00
AddSession_ ( sess );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- Then send an update signal to remaining ones
for ( SessionMap :: iterator itr = m_sessions . begin (), next ; itr != m_sessions . end (); itr = next )
{
next = itr ;
++ next ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
///- and remove not active sessions from the list
2009-09-22 20:40:34 -04:00
if ( ! itr -> second -> Update ( diff )) // As interval = 0
2008-10-11 14:16:25 -05:00
{
2009-09-22 20:40:34 -04:00
if ( ! RemoveQueuedPlayer ( itr -> second ) && itr -> second && getConfig ( CONFIG_INTERVAL_DISCONNECT_TOLERANCE ))
2009-12-24 10:20:15 +01:00
m_disconnects [ itr -> second -> GetAccountId ()] = time ( NULL );
2008-10-11 14:16:25 -05:00
delete itr -> second ;
m_sessions . erase ( itr );
}
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// This handles the issued and queued CLI commands
void World :: ProcessCliCommands ()
{
2009-09-11 13:42:39 -07:00
CliCommandHolder :: Print * zprint = NULL ;
2009-10-17 15:51:44 -07:00
2009-09-11 13:42:39 -07:00
CliCommandHolder * command ;
while ( cliCmdQueue . next ( command ))
2008-10-11 14:16:25 -05:00
{
sLog . outDebug ( "CLI command under processing..." );
2008-11-06 16:10:28 -06:00
zprint = command -> m_print ;
CliHandler ( zprint ). ParseCommands ( command -> m_command );
2008-10-11 14:16:25 -05:00
delete command ;
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// print the console message here so it looks right
2009-09-11 13:42:39 -07:00
if ( zprint )
zprint ( "TC> " );
2008-10-12 14:03:38 -05:00
}
2009-10-17 15:51:44 -07:00
2009-08-08 15:05:21 -07:00
void World :: SendRNDBroadcast ()
{
2009-09-22 20:40:34 -04:00
if ( m_Autobroadcasts . empty ())
2009-08-10 17:03:11 +02:00
return ;
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
std :: string msg ;
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
std :: list < std :: string >:: const_iterator itr = m_Autobroadcasts . begin ();
std :: advance ( itr , rand () % m_Autobroadcasts . size ());
msg = * itr ;
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
static uint32 abcenter = 0 ;
2009-08-08 15:05:21 -07:00
abcenter = sConfig . GetIntDefault ( "AutoBroadcast.Center" , 0 );
2009-09-22 20:40:34 -04:00
if ( abcenter == 0 )
2009-08-08 15:05:21 -07:00
{
2009-08-10 17:03:11 +02:00
sWorld . SendWorldText ( LANG_AUTO_BROADCAST , msg . c_str ());
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ( "AutoBroadcast: '%s'" , msg . c_str ());
}
2009-09-22 20:40:34 -04:00
if ( abcenter == 1 )
2009-08-10 17:03:11 +02:00
{
WorldPacket data ( SMSG_NOTIFICATION , ( msg . size () + 1 ));
data << msg ;
sWorld . SendGlobalMessage ( & data );
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ( "AutoBroadcast: '%s'" , msg . c_str ());
}
2009-09-22 20:40:34 -04:00
if ( abcenter == 2 )
2009-08-10 17:03:11 +02:00
{
sWorld . SendWorldText ( LANG_AUTO_BROADCAST , msg . c_str ());
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
WorldPacket data ( SMSG_NOTIFICATION , ( msg . size () + 1 ));
data << msg ;
sWorld . SendGlobalMessage ( & data );
2009-10-17 15:51:44 -07:00
2009-08-10 17:03:11 +02:00
sLog . outString ( "AutoBroadcast: '%s'" , msg . c_str ());
}
2009-08-08 15:05:21 -07:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: InitResultQueue ()
{
m_resultQueue = new SqlResultQueue ;
CharacterDatabase . SetResultQueue ( m_resultQueue );
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: UpdateResultQueue ()
{
m_resultQueue -> Update ();
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: UpdateRealmCharCount ( uint32 accountId )
{
CharacterDatabase . AsyncPQuery ( this , & World :: _UpdateRealmCharCount , accountId ,
"SELECT COUNT(guid) FROM characters WHERE account = '%u'" , accountId );
}
2009-10-17 15:51:44 -07:00
2010-01-23 14:45:58 +01:00
void World :: _UpdateRealmCharCount ( QueryResult_AutoPtr resultCharCount , uint32 accountId )
2008-10-11 14:16:25 -05:00
{
if ( resultCharCount )
{
Field * fields = resultCharCount -> Fetch ();
uint32 charCount = fields [ 0 ]. GetUInt32 ();
2010-01-23 14:45:58 +01:00
2009-07-31 11:29:28 +08:00
loginDatabase . PExecute ( "DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'" , accountId , realmID );
loginDatabase . PExecute ( "INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)" , charCount , accountId , realmID );
2008-10-11 14:16:25 -05:00
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: InitDailyQuestResetTime ()
{
time_t mostRecentQuestTime ;
2009-10-17 15:51:44 -07:00
2010-01-23 14:45:58 +01:00
QueryResult_AutoPtr result = CharacterDatabase . Query ( "SELECT MAX(time) FROM character_queststatus_daily" );
2009-09-22 20:40:34 -04:00
if ( result )
2008-10-11 14:16:25 -05:00
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
mostRecentQuestTime = ( time_t ) fields [ 0 ]. GetUInt64 ();
}
else
mostRecentQuestTime = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// client built-in time for reset is 6:00 AM
// FIX ME: client not show day start time
2009-12-24 10:20:15 +01:00
time_t curTime = time ( NULL );
2008-10-11 14:16:25 -05:00
tm localTm = * localtime ( & curTime );
localTm . tm_hour = 6 ;
localTm . tm_min = 0 ;
localTm . tm_sec = 0 ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// current day reset time
time_t curDayResetTime = mktime ( & localTm );
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// last reset time before current moment
time_t resetTime = ( curTime < curDayResetTime ) ? curDayResetTime - DAY : curDayResetTime ;
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
// need reset (if we have quest time before last reset time (not processed by some reason)
2009-09-22 20:40:34 -04:00
if ( mostRecentQuestTime && mostRecentQuestTime <= resetTime )
2008-10-11 14:16:25 -05:00
m_NextDailyQuestReset = mostRecentQuestTime ;
else
{
// plan next reset time
m_NextDailyQuestReset = ( curTime >= curDayResetTime ) ? curDayResetTime + DAY : curDayResetTime ;
}
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: ResetDailyQuests ()
{
sLog . outDetail ( "Daily quests reset for all characters." );
CharacterDatabase . Execute ( "DELETE FROM character_queststatus_daily" );
2009-09-22 20:40:34 -04:00
for ( SessionMap :: const_iterator itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
if ( itr -> second -> GetPlayer ())
2008-10-11 14:16:25 -05:00
itr -> second -> GetPlayer () -> ResetDailyQuestStatus ();
}
2009-10-17 15:51:44 -07:00
2009-08-29 08:51:24 -04:00
void World :: UpdateAllowedSecurity ()
2008-10-11 14:16:25 -05:00
{
2010-01-23 14:45:58 +01:00
QueryResult_AutoPtr result = loginDatabase . PQuery ( "SELECT allowedSecurityLevel from realmlist WHERE id = '%d'" , realmID );
2009-08-29 05:17:55 -04:00
if ( result )
{
2009-08-29 08:51:24 -04:00
m_allowedSecurityLevel = AccountTypes ( result -> Fetch () -> GetUInt16 ());
sLog . outDebug ( "Allowed Level: %u Result %u" , m_allowedSecurityLevel , result -> Fetch () -> GetUInt16 ());
2009-08-29 05:17:55 -04:00
}
2009-08-29 08:51:24 -04:00
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
void World :: SetPlayerLimit ( int32 limit , bool needUpdate )
2009-08-29 08:51:24 -04:00
{
m_playerLimit = limit ;
2008-10-11 14:16:25 -05:00
}
2009-10-17 15:51:44 -07:00
2008-10-11 14:16:25 -05:00
void World :: UpdateMaxSessionCounters ()
{
m_maxActiveSessionCount = std :: max ( m_maxActiveSessionCount , uint32 ( m_sessions . size () - m_QueuedPlayer . size ()));
m_maxQueuedSessionCount = std :: max ( m_maxQueuedSessionCount , uint32 ( m_QueuedPlayer . size ()));
}
2009-10-17 15:51:44 -07:00
2008-11-02 16:53:46 -06:00
void World :: LoadDBVersion ()
{
2010-01-23 14:45:58 +01:00
QueryResult_AutoPtr result = WorldDatabase . Query ( "SELECT db_version, script_version, cache_id FROM version LIMIT 1" );
2009-08-14 14:34:46 -05:00
//QueryResult* result = WorldDatabase.Query("SELECT version, creature_ai_version, cache_id FROM db_version LIMIT 1");
2009-09-22 20:40:34 -04:00
if ( result )
2008-11-06 16:10:28 -06:00
{
Field * fields = result -> Fetch ();
2009-10-17 15:51:44 -07:00
2009-04-09 17:57:57 -05:00
m_DBVersion = fields [ 0 ]. GetCppString ();
2009-07-09 11:14:43 +02:00
m_CreatureEventAIVersion = fields [ 1 ]. GetCppString ();
2009-10-17 15:51:44 -07:00
2009-08-14 14:34:46 -05:00
// will be overwrite by config values if different and non-0
m_configs [ CONFIG_CLIENTCACHE_VERSION ] = fields [ 2 ]. GetUInt32 ();
2008-11-06 16:10:28 -06:00
}
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( m_DBVersion . empty ())
2009-04-09 17:57:57 -05:00
m_DBVersion = "Unknown world database." ;
2009-10-17 15:51:44 -07:00
2009-09-22 20:40:34 -04:00
if ( m_CreatureEventAIVersion . empty ())
2009-04-09 17:57:57 -05:00
m_CreatureEventAIVersion = "Unknown creature EventAI." ;
2008-11-02 16:53:46 -06:00
}
2009-11-27 03:16:49 +01:00
2009-12-17 12:36:55 +01:00
void World :: ProcessStartEvent ()
2009-11-27 03:16:49 +01:00
{
2009-12-18 13:41:30 -08:00
isEventKillStart = true ;
2009-12-17 12:36:55 +01:00
}
void World :: ProcessStopEvent ()
{
2009-12-18 13:41:30 -08:00
isEventKillStart = false ;
2009-11-27 03:16:49 +01:00
}
2009-12-17 14:06:20 +01:00
void World :: UpdateAreaDependentAuras ()
{
SessionMap :: const_iterator itr ;
for ( itr = m_sessions . begin (); itr != m_sessions . end (); ++ itr )
if ( itr -> second && itr -> second -> GetPlayer () && itr -> second -> GetPlayer () -> IsInWorld ())
{
itr -> second -> GetPlayer () -> UpdateAreaDependentAuras ( itr -> second -> GetPlayer () -> GetAreaId ());
itr -> second -> GetPlayer () -> UpdateZoneDependentAuras ( itr -> second -> GetPlayer () -> GetZoneId ());
}
}
2010-03-26 16:48:33 +01:00
void World :: LoadWorldStates ()
2010-04-07 18:09:10 +02:00
{
2010-03-26 16:48:33 +01:00
QueryResult_AutoPtr result = CharacterDatabase . Query ( "SELECT entry, value FROM worldstates" );
if ( ! result )
{
barGoLink bar ( 1 );
bar . step ();
sLog . outString ();
sLog . outString ( ">> Loaded 0 world states." );
return ;
}
barGoLink bar ( result -> GetRowCount ());
uint32 counter = 0 ;
do
{
Field * fields = result -> Fetch ();
m_worldstates [ fields [ 0 ]. GetUInt32 ()] = fields [ 1 ]. GetUInt64 ();
bar . step ();
++ counter ;
}
while ( result -> NextRow ());
sLog . outString ();
2010-04-07 22:59:46 +02:00
sLog . outString ( ">> Loaded %u world states." , counter );
2010-03-26 16:48:33 +01:00
}
// Setting a worldstate will save it to DB
void World :: setWorldState ( uint32 index , uint64 value )
{
WorldStatesMap :: const_iterator it = m_worldstates . find ( index );
if ( it != m_worldstates . end ())
CharacterDatabase . PExecute ( "UPDATE worldstates SET value=" UI64FMTD " where entry=%u" , value , index );
else
CharacterDatabase . PExecute ( "INSERT INTO worldstates (entry, value) VALUES (%u," UI64FMTD ")" , index , value );
m_worldstates [ index ] = value ;
}
uint64 World :: getWorldState ( uint32 index ) const
{
WorldStatesMap :: const_iterator it = m_worldstates . find ( index );
return it != m_worldstates . end () ? it -> second : 0 ;
}