OregonCore  revision 3611e8a-git
Your Favourite TBC server
World Class Reference

#include <World.h>

Public Types

typedef std::list< WorldSession * > Queue
 

Public Member Functions

 World ()
 
 ~World ()
 
WorldSessionFindSession (uint32 id) const
 
void AddSession (WorldSession *s)
 
void SendAutoBroadcast ()
 
bool RemoveSession (uint32 id)
 
void UpdateMaxSessionCounters ()
 
const SessionMapGetAllSessions () const
 
uint32 GetActiveAndQueuedSessionCount () const
 
uint32 GetActiveSessionCount () const
 
uint32 GetQueuedSessionCount () const
 
uint32 GetMaxQueuedSessionCount () const
 
uint32 GetMaxActiveSessionCount () const
 
PlayerFindPlayerInZone (uint32 zone)
 
WeatherFindWeather (uint32 id) const
 
WeatherAddWeather (uint32 zone_id)
 
void RemoveWeather (uint32 zone_id)
 
uint32 GetPlayerAmountLimit () const
 
AccountTypes GetPlayerSecurityLimit () const
 
void SetPlayerSecurityLimit (AccountTypes sec)
 
void SetPlayerLimit (int32 limit, bool needUpdate=false)
 
void AddQueuedPlayer (WorldSession *)
 
bool RemoveQueuedPlayer (WorldSession *session)
 
int32 GetQueuePos (WorldSession *)
 
bool HasRecentlyDisconnected (WorldSession *)
 
uint32 GetQueueSize () const
 
bool getAllowMovement () const
 
void SetAllowMovement (bool allow)
 
void SetMotd (std::string motd)
 
const char * GetMotd () const
 
void SetNewCharString (std::string str)
 
const std::string & GetNewCharString () const
 
uint32 GetDefaultDbcLocale () const
 
std::string GetDataPath () const
 
time_t const & GetStartTime () const
 
time_t const & GetGameTime () const
 
uint32 GetUptime () const
 
uint32 GetUpdateTime () const
 
void SetRecordDiffInterval (int32 t)
 
uint16 GetConfigMaxSkillValue () const
 
void SetInitialWorldSettings ()
 
void LoadConfigSettings (bool reload=false)
 
void SendWorldText (int32 string_id,...)
 
void SendGlobalText (const char *text, WorldSession *self)
 
void SendGMText (int32 string_id,...)
 
void SendGlobalMessage (WorldPacket *packet, WorldSession *self=0, uint32 team=0)
 
void SendGlobalGMMessage (WorldPacket *packet, WorldSession *self=0, uint32 team=0)
 
bool SendZoneMessage (uint32 zone, WorldPacket *packet, WorldSession *self=0, uint32 team=0)
 
void SendZoneText (uint32 zone, const char *text, WorldSession *self=0, uint32 team=0)
 
void SendServerMessage (ServerMessageType type, const char *text="", Player *player=NULL)
 
bool IsShuttingDown () const
 
uint32 GetShutDownTimeLeft ()
 
void ShutdownServ (uint32 time, uint32 options, uint8 exitcode)
 
void ShutdownCancel ()
 
void ShutdownMsg (bool show=false, Player *player=NULL)
 
void Update (uint32 diff)
 
void UpdateSessions (time_t diff)
 
void setRate (Rates rate, float value)
 
float getRate (Rates rate) const
 
void setConfig (uint32 index, uint32 value)
 
uint32 getConfig (uint32 index) const
 
bool IsPvPRealm ()
 
bool IsFFAPvPRealm ()
 
bool KickPlayer (const std::string &playerName)
 
void KickAll ()
 
void KickAllLess (AccountTypes sec)
 
BanReturn BanAccount (BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
 
bool RemoveBanAccount (BanMode mode, std::string nameOrIP)
 
uint32 IncreaseScheduledScriptsCount ()
 
uint32 DecreaseScheduledScriptCount ()
 
uint32 DecreaseScheduledScriptCount (size_t count)
 
bool IsScriptScheduled () const
 
void ProcessCliCommands ()
 
void QueueCliCommand (CliCommandHolder *commandHolder)
 
void UpdateResultQueue ()
 
void InitResultQueue ()
 
void ForceGameEventUpdate ()
 
void UpdateRealmCharCount (uint32 accid)
 
void UpdateAllowedSecurity ()
 
LocaleConstant GetAvailableDbcLocale (LocaleConstant locale) const
 
void LoadDBVersion ()
 
char const * GetDBVersion ()
 
void SetScriptsVersion (char const *version)
 
char const * GetScriptsVersion ()
 
void RecordTimeDiff (const char *text,...)
 
void LoadAutobroadcasts ()
 
void LoadIp2nation ()
 
void LoadOpcodeProtection ()
 
void LoadSQLUpdates ()
 
ProtectedOpcodeProperties const & GetProtectedOpcodeProperties (uint32 opcode)
 

Static Public Member Functions

static uint8 GetExitCode ()
 
static void StopNow (uint8 exitcode)
 
static bool IsStopped ()
 
static float GetMaxVisibleDistanceOnContinents ()
 
static float GetMaxVisibleDistanceInInstances ()
 
static float GetMaxVisibleDistanceInBGArenas ()
 
static int32 GetVisibilityNotifyPeriodOnContinents ()
 
static int32 GetVisibilityNotifyPeriodInInstances ()
 
static int32 GetVisibilityNotifyPeriodInBGArenas ()
 

Static Public Attributes

static volatile uint32 m_worldLoopCounter = 0
 

Protected Member Functions

void _UpdateGameTime ()
 
void _UpdateRealmCharCount (QueryResult_AutoPtr resultCharCount, uint32 accountId)
 
void InitDailyQuestResetTime ()
 
void ResetDailyQuests ()
 

Private Types

typedef UNORDERED_MAP< uint32, Weather * > WeatherMap
 
typedef UNORDERED_MAP< uint32, time_t > DisconnectMap
 

Private Member Functions

void DetectDBCLang ()
 
void AddSession_ (WorldSession *s)
 

Private Attributes

uint32 m_ShutdownTimer
 
uint32 m_ShutdownMask
 
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
 
time_t m_startTime
 
time_t m_gameTime
 
IntervalTimer m_timers [WUPDATE_COUNT]
 
IntervalTimer extmail_timer
 
uint32 mail_timer
 
uint32 mail_timer_expires
 
uint32 m_updateTime
 
uint32 m_updateTimeSum
 
uint32 m_updateTimeCount
 
uint32 m_currentTime
 
WeatherMap m_weathers
 
SessionMap m_sessions
 
DisconnectMap m_disconnects
 
uint32 m_maxActiveSessionCount
 
uint32 m_maxQueuedSessionCount
 
std::string m_newCharString
 
float rate_values [MAX_RATES]
 
uint32 m_configs [CONFIG_VALUE_COUNT]
 
int32 m_playerLimit
 
AccountTypes m_allowedSecurityLevel
 
LocaleConstant m_defaultDbcLocale
 
uint32 m_availableDbcLocaleMask
 
bool m_allowMovement
 
std::string m_motd
 
std::string m_dataPath
 
ACE_Based::LockedQueue< CliCommandHolder *, ACE_Thread_Mutex > cliCmdQueue
 
SqlResultQueuem_resultQueue
 
time_t m_NextDailyQuestReset
 
Queue m_QueuedPlayer
 
ACE_Based::LockedQueue< WorldSession *, ACE_Thread_Mutex > addSessQueue
 
std::string m_DBVersion
 
std::string m_ScriptsVersion
 
std::list< std::string > m_Autobroadcasts
 
std::string m_SQLUpdatesPath
 
UNORDERED_MAP< uint32, ProtectedOpcodeProperties_protectedOpcodesProperties
 

Static Private Attributes

static volatile bool m_stopEvent = false
 
static uint8 m_ExitCode = SHUTDOWN_EXIT_CODE
 
static float m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE
 
static float m_MaxVisibleDistanceInInstances = DEFAULT_VISIBILITY_INSTANCE
 
static float m_MaxVisibleDistanceInBGArenas = DEFAULT_VISIBILITY_BGARENAS
 
static int32 m_visibility_notify_periodOnContinents = DEFAULT_VISIBILITY_NOTIFY_PERIOD
 
static int32 m_visibility_notify_periodInInstances = DEFAULT_VISIBILITY_NOTIFY_PERIOD
 
static int32 m_visibility_notify_periodInBGArenas = DEFAULT_VISIBILITY_NOTIFY_PERIOD
 

Detailed Description

Definition at line 457 of file World.h.

Member Typedef Documentation

typedef UNORDERED_MAP<uint32, time_t> World::DisconnectMap
private

Definition at line 808 of file World.h.

typedef std::list<WorldSession*> World::Queue

Definition at line 517 of file World.h.

Definition at line 804 of file World.h.

Constructor & Destructor Documentation

World::World ( )

Definition at line 87 of file World.cpp.

References LOCALE_enUS, m_allowedSecurityLevel, m_allowMovement, m_availableDbcLocaleMask, m_defaultDbcLocale, m_gameTime, m_maxActiveSessionCount, m_maxQueuedSessionCount, m_NextDailyQuestReset, m_playerLimit, m_resultQueue, m_scheduledScripts, m_ShutdownMask, m_ShutdownTimer, m_startTime, m_updateTimeCount, m_updateTimeSum, and SEC_PLAYER.

88 {
89  m_playerLimit = 0;
91  m_allowMovement = true;
92  m_ShutdownMask = 0;
93  m_ShutdownTimer = 0;
94  m_gameTime = time(NULL);
98  m_resultQueue = NULL;
100  m_scheduledScripts = 0;
101 
104 
105  m_updateTimeSum = 0;
106  m_updateTimeCount = 0;
107 }
time_t m_NextDailyQuestReset
Definition: World.h:840
uint32 m_updateTimeCount
Definition: World.h:801
SqlResultQueue * m_resultQueue
Definition: World.h:837
AccountTypes m_allowedSecurityLevel
Definition: World.h:818
time_t m_gameTime
Definition: World.h:795
uint32 m_maxActiveSessionCount
Definition: World.h:810
uint32 m_availableDbcLocaleMask
Definition: World.h:820
time_t m_startTime
Definition: World.h:794
uint32 m_ShutdownMask
Definition: World.h:789
uint32 m_maxQueuedSessionCount
Definition: World.h:811
uint32 m_updateTimeSum
Definition: World.h:800
LocaleConstant m_defaultDbcLocale
Definition: World.h:819
bool m_allowMovement
Definition: World.h:822
uint32 m_ShutdownTimer
Definition: World.h:788
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
Definition: World.h:792
int32 m_playerLimit
Definition: World.h:817
World::~World ( )

Definition at line 110 of file World.cpp.

References VMAP::VMapFactory::clear(), MMAP::MMapFactory::clear(), cliCmdQueue, m_resultQueue, m_sessions, m_weathers, and ACE_Based::LockedQueue< T, LockType, StorageType >::next().

111 {
112  // Empty the kicked session set
113  while (!m_sessions.empty())
114  {
115  // not remove from queue, prevent loading new sessions
116  delete m_sessions.begin()->second;
117  m_sessions.erase(m_sessions.begin());
118  }
119 
120  // Empty the WeatherMap
121  for (WeatherMap::iterator itr = m_weathers.begin(); itr != m_weathers.end(); ++itr)
122  delete itr->second;
123 
124  m_weathers.clear();
125 
126  CliCommandHolder* command = NULL;
127  while (cliCmdQueue.next(command))
128  delete command;
129 
132 
133  delete m_resultQueue;
134 
135  //TODO free addSessQueue
136 }
ACE_Based::LockedQueue< CliCommandHolder *, ACE_Thread_Mutex > cliCmdQueue
Definition: World.h:836
SqlResultQueue * m_resultQueue
Definition: World.h:837
SessionMap m_sessions
Definition: World.h:807
static void clear()
Definition: MoveMap.cpp:67
bool next(T &result)
Definition: LockedQueue.h:68
WeatherMap m_weathers
Definition: World.h:805
static void clear()

Member Function Documentation

void World::_UpdateGameTime ( )
protected

Definition at line 2289 of file World.cpp.

References GetActiveAndQueuedSessionCount(), Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), m_gameTime, m_ShutdownMask, m_ShutdownTimer, m_stopEvent, ObjectAccessor::SaveAllPlayers(), SHUTDOWN_MASK_IDLE, and ShutdownMsg().

Referenced by Update().

2290 {
2291  // update the time
2292  time_t thisTime = time(NULL);
2293  uint32 elapsed = uint32(thisTime - m_gameTime);
2294  m_gameTime = thisTime;
2295 
2296  // if there is a shutdown timer
2297  if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0)
2298  {
2299  // ... and it is overdue, stop the world (set m_stopEvent)
2300  if (m_ShutdownTimer <= elapsed)
2301  {
2303  {
2305  m_stopEvent = true; // exist code already set
2306  }
2307  else
2308  m_ShutdownTimer = 1; // minimum timer value to wait idle state
2309  }
2310  // ... else decrease it and if necessary display a shutdown countdown to the users
2311  else
2312  {
2313  m_ShutdownTimer -= elapsed;
2314 
2315  ShutdownMsg();
2316  }
2317  }
2318 }
uint32 GetActiveAndQueuedSessionCount() const
Definition: World.h:472
time_t m_gameTime
Definition: World.h:795
void ShutdownMsg(bool show=false, Player *player=NULL)
Definition: World.cpp:2347
uint32 m_ShutdownMask
Definition: World.h:789
static volatile bool m_stopEvent
Definition: World.h:786
uint32 m_ShutdownTimer
Definition: World.h:788
ACE_UINT32 uint32
Definition: Define.h:71
void World::_UpdateRealmCharCount ( QueryResult_AutoPtr  resultCharCount,
uint32  accountId 
)
protected

Definition at line 2502 of file World.cpp.

References LoginDatabase, Database::PExecute(), and realmID.

Referenced by UpdateRealmCharCount().

2503 {
2504  if (resultCharCount)
2505  {
2506  Field* fields = resultCharCount->Fetch();
2507  uint32 charCount = fields[0].GetUInt32();
2508 
2509  LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID);
2510  LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID);
2511  }
2512 }
Definition: Field.h:24
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
uint32 realmID
Id of the realm.
Definition: Main.cpp:57
ACE_UINT32 uint32
Definition: Define.h:71
void World::AddQueuedPlayer ( WorldSession sess)

Definition at line 294 of file World.cpp.

References AUTH_WAIT_QUEUE, WorldSession::Expansion(), GetQueuePos(), m_QueuedPlayer, WorldSession::SendPacket(), WorldSession::SetInQueue(), and SMSG_AUTH_RESPONSE.

Referenced by AddSession_().

295 {
296  sess->SetInQueue(true);
297  m_QueuedPlayer.push_back(sess);
298 
299  // The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
300  WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
301  packet << uint8(AUTH_WAIT_QUEUE);
302  packet << uint32(0); // BillingTimeRemaining
303  packet << uint8(0); // BillingPlanFlags
304  packet << uint32(0); // BillingTimeRested
305  packet << uint8(sess->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
306  packet << uint32(GetQueuePos(sess)); // Queue position
307  sess->SendPacket(&packet);
308 
309  //sess->SendAuthWaitQue (GetQueuePos (sess));
310 }
uint8 Expansion() const
Definition: WorldSession.h:121
void SetInQueue(bool state)
Definition: WorldSession.h:129
void SendPacket(WorldPacket const *packet)
Queue m_QueuedPlayer
Definition: World.h:843
ACE_UINT8 uint8
Definition: Define.h:73
int32 GetQueuePos(WorldSession *)
Definition: World.cpp:283
ACE_UINT32 uint32
Definition: Define.h:71
void World::AddSession ( WorldSession s)

Definition at line 183 of file World.cpp.

References ACE_Based::LockedQueue< T, LockType, StorageType >::add(), and addSessQueue.

184 {
185  addSessQueue.add(s);
186 }
void add(const T &item)
Definition: LockedQueue.h:55
ACE_Based::LockedQueue< WorldSession *, ACE_Thread_Mutex > addSessQueue
Definition: World.h:847
void World::AddSession_ ( WorldSession s)
private

Definition at line 189 of file World.cpp.

References AddQueuedPlayer(), ASSERT, AUTH_OK, WorldSession::Expansion(), WorldSession::GetAccountId(), GetActiveAndQueuedSessionCount(), GetActiveSessionCount(), GetPlayerAmountLimit(), GetQueueSize(), WorldSession::GetSecurity(), HasRecentlyDisconnected(), WorldSession::KickPlayer(), LoginDatabase, m_sessions, Database::PExecute(), realmID, RemoveQueuedPlayer(), RemoveSession(), SEC_PLAYER, WorldSession::SendPacket(), sLog, SMSG_AUTH_RESPONSE, and UpdateMaxSessionCounters().

Referenced by UpdateSessions().

190 {
191  ASSERT (s);
192 
193  //NOTE - Still there is race condition in WorldSession* being used in the Sockets
194 
195  // kick already loaded player with same account (if any) and remove session
196  // if player is in loading and want to load again, return
197  if (!RemoveSession (s->GetAccountId ()))
198  {
199  s->KickPlayer ();
200  delete s; // session not added yet in session list, so not listed in queue
201  return;
202  }
203 
204  // decrease session counts only at not reconnection case
205  bool decrease_session = true;
206 
207  // if session already exist, prepare to it deleting at next world update
208  // NOTE - KickPlayer() should be called on "old" in RemoveSession()
209  {
210  SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ());
211 
212  if (old != m_sessions.end())
213  {
214  // prevent decrease sessions count if session queued
215  if (RemoveQueuedPlayer(old->second))
216  decrease_session = false;
217  // not remove replaced session form queue if listed
218  delete old->second;
219  }
220  }
221 
222  m_sessions[s->GetAccountId ()] = s;
223 
225  uint32 pLimit = GetPlayerAmountLimit ();
226  uint32 QueueSize = GetQueueSize (); //number of players in the queue
227 
228  //so we don't count the user trying to
229  //login as a session and queue the socket that we are using
230  if (decrease_session)
231  --Sessions;
232 
233  if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER && !HasRecentlyDisconnected(s))
234  {
235  AddQueuedPlayer (s);
237  sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize);
238  return;
239  }
240 
241  WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
242  packet << uint8 (AUTH_OK);
243  packet << uint32 (0); // BillingTimeRemaining
244  packet << uint8 (0); // BillingPlanFlags
245  packet << uint32 (0); // BillingTimeRested
246  packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
247  s->SendPacket (&packet);
248 
250 
251  // Updates the population
252  if (pLimit > 0)
253  {
254  float popu = GetActiveSessionCount (); // updated number of users on the server
255  popu /= pLimit;
256  popu *= 2;
257  LoginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
258  sLog.outDetail ("Server Population (%f).", popu);
259  }
260 }
uint8 Expansion() const
Definition: WorldSession.h:121
void UpdateMaxSessionCounters()
Definition: World.cpp:2578
uint32 GetActiveAndQueuedSessionCount() const
Definition: World.h:472
SessionMap m_sessions
Definition: World.h:807
#define sLog
Log class singleton.
Definition: Log.h:187
bool HasRecentlyDisconnected(WorldSession *)
Definition: World.cpp:262
uint32 GetAccountId() const
Definition: WorldSession.h:100
void SendPacket(WorldPacket const *packet)
ACE_UINT8 uint8
Definition: Define.h:73
uint32 GetQueueSize() const
Definition: World.h:522
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
bool RemoveQueuedPlayer(WorldSession *session)
Definition: World.cpp:312
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
uint32 GetPlayerAmountLimit() const
Definition: World.h:500
uint32 realmID
Id of the realm.
Definition: Main.cpp:57
bool RemoveSession(uint32 id)
Definition: World.cpp:168
void AddQueuedPlayer(WorldSession *)
Definition: World.cpp:294
#define ASSERT
Definition: Errors.h:33
void uint32 GetSecurity() const
Definition: WorldSession.h:96
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetActiveSessionCount() const
Definition: World.h:476
Weather * World::AddWeather ( uint32  zone_id)

Definition at line 387 of file World.cpp.

References Weather::GetZone(), m_weathers, Weather::ReGenerate(), sObjectMgr, and Weather::UpdateWeather().

388 {
389  WeatherZoneChances const* weatherChances = sObjectMgr.GetWeatherChances(zone_id);
390 
391  // zone not have weather, ignore
392  if (!weatherChances)
393  return NULL;
394 
395  Weather* w = new Weather(zone_id, weatherChances);
396  m_weathers[w->GetZone()] = w;
397  w->ReGenerate();
398  w->UpdateWeather();
399  return w;
400 }
WeatherMap m_weathers
Definition: World.h:805
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool ReGenerate()
Definition: Weather.cpp:60
bool UpdateWeather()
Definition: Weather.cpp:198
uint32 GetZone()
Definition: Weather.h:57
BanReturn World::BanAccount ( BanMode  mode,
std::string  nameOrIP,
std::string  duration,
std::string  reason,
std::string  author 
)

Definition at line 2203 of file World.cpp.

References BAN_ACCOUNT, BAN_CHARACTER, BAN_IP, BAN_NOTFOUND, BAN_SUCCESS, BAN_SYNTAX_ERROR, CharacterDatabase, Database::escape_string(), FindSession(), LoginDatabase, Database::PExecute(), Database::PQuery(), and TimeStringToSecs().

2204 {
2205  LoginDatabase.escape_string(nameOrIP);
2206  LoginDatabase.escape_string(reason);
2207  std::string safe_author = author;
2208  LoginDatabase.escape_string(safe_author);
2209 
2210  uint32 duration_secs = TimeStringToSecs(duration);
2211  QueryResult_AutoPtr resultAccounts = QueryResult_AutoPtr(NULL); //used for kicking
2212 
2213  // Update the database with ban information
2214  switch (mode)
2215  {
2216  case BAN_IP:
2217  //No SQL injection as strings are escaped
2218  resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'", nameOrIP.c_str());
2219  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());
2220  break;
2221  case BAN_ACCOUNT:
2222  //No SQL injection as string is escaped
2223  resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", nameOrIP.c_str());
2224  break;
2225  case BAN_CHARACTER:
2226  //No SQL injection as string is escaped
2227  resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str());
2228  break;
2229  default:
2230  return BAN_SYNTAX_ERROR;
2231  }
2232 
2233  if (!resultAccounts)
2234  {
2235  if (mode == BAN_IP)
2236  return BAN_SUCCESS; // ip correctly banned but nobody affected (yet)
2237  else
2238  return BAN_NOTFOUND; // Nobody to ban
2239  }
2240 
2241  // Disconnect all affected players (for IP it can be several)
2242  do
2243  {
2244  Field* fieldsAccount = resultAccounts->Fetch();
2245  uint32 account = fieldsAccount->GetUInt32();
2246 
2247  if (mode != BAN_IP)
2248  {
2249  //No SQL injection as strings are escaped
2250  LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
2251  account, duration_secs, safe_author.c_str(), reason.c_str());
2252  }
2253 
2254  if (WorldSession* sess = FindSession(account))
2255  if (std::string(sess->GetPlayerName()) != author)
2256  sess->KickPlayer();
2257  }
2258  while (resultAccounts->NextRow());
2259 
2260  return BAN_SUCCESS;
2261 }
WorldSession * FindSession(uint32 id) const
Definition: World.cpp:157
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:400
Definition: Field.h:24
unsigned long escape_string(char *to, const char *from, unsigned long length)
Definition: Database.cpp:212
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:171
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
uint32 World::DecreaseScheduledScriptCount ( )
inline

Definition at line 693 of file World.h.

694  {
695  return (uint32)--m_scheduledScripts;
696  }
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
Definition: World.h:792
ACE_UINT32 uint32
Definition: Define.h:71
uint32 World::DecreaseScheduledScriptCount ( size_t  count)
inline

Definition at line 697 of file World.h.

698  {
699  return (uint32)(m_scheduledScripts -= count);
700  }
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
Definition: World.h:792
ACE_UINT32 uint32
Definition: Define.h:71
void World::DetectDBCLang ( )
private

Definition at line 1652 of file World.cpp.

References LOCALE_enUS, localeNames, m_availableDbcLocaleMask, m_defaultDbcLocale, MAX_LOCALE, ChrRacesEntry::name, sChrRacesStore, sConfig, and sLog.

Referenced by SetInitialWorldSettings().

1653 {
1654  uint8 m_lang_confid = sConfig.GetIntDefault("DBC.Locale", 255);
1655 
1656  if (m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE)
1657  {
1658  sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", MAX_LOCALE);
1659  m_lang_confid = LOCALE_enUS;
1660  }
1661 
1662  ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1);
1663 
1664  std::string availableLocalsStr;
1665 
1666  uint8 default_locale = MAX_LOCALE;
1667  for (uint8 i = default_locale - 1; i < MAX_LOCALE; --i) // -1 will be 255 due to uint8
1668  {
1669  if (strlen(race->name[i]) > 0) // check by race names
1670  {
1671  default_locale = i;
1672  m_availableDbcLocaleMask |= (1 << i);
1673  availableLocalsStr += localeNames[i];
1674  availableLocalsStr += " ";
1675  }
1676  }
1677 
1678  if (default_locale != m_lang_confid && m_lang_confid < MAX_LOCALE &&
1679  (m_availableDbcLocaleMask & (1 << m_lang_confid)))
1680  default_locale = m_lang_confid;
1681 
1682  if (default_locale >= MAX_LOCALE)
1683  sLog.outFatal("Unable to determine your DBC Locale! (corrupt DBC?)");
1684 
1685  m_defaultDbcLocale = LocaleConstant(default_locale);
1686 
1687  sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[m_defaultDbcLocale], availableLocalsStr.empty() ? "<none>" : availableLocalsStr.c_str());
1688 }
#define sConfig
Definition: Config.h:52
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 m_availableDbcLocaleMask
Definition: World.h:820
char const * localeNames[MAX_LOCALE]
Definition: Common.cpp:20
ACE_UINT8 uint8
Definition: Define.h:73
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesEntryfmt)
const uint8 MAX_LOCALE
Definition: Common.h:224
LocaleConstant m_defaultDbcLocale
Definition: World.h:819
char * name[16]
Definition: DBCStructure.h:164
LocaleConstant
Definition: Common.h:211
Player * World::FindPlayerInZone ( uint32  zone)

Definition at line 139 of file World.cpp.

References Unit::GetPlayer(), WorldObject::GetZoneId(), Object::IsInWorld(), and m_sessions.

140 {
141  // circle through active sessions and return the first player found in the zone
142  SessionMap::iterator itr;
143  for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
144  {
145  if (!itr->second)
146  continue;
147  Player* player = itr->second->GetPlayer();
148  if (!player)
149  continue;
150  if (player->IsInWorld() && player->GetZoneId() == zone)
151  return player;
152  }
153  return NULL;
154 }
SessionMap m_sessions
Definition: World.h:807
uint32 GetZoneId() const
Definition: Object.cpp:1176
const bool & IsInWorld() const
Definition: Object.h:129
static Player * GetPlayer(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10597
Definition: Player.h:922
WorldSession * World::FindSession ( uint32  id) const

Definition at line 157 of file World.cpp.

References m_sessions.

Referenced by BanAccount().

158 {
159  SessionMap::const_iterator itr = m_sessions.find(id);
160 
161  if (itr != m_sessions.end())
162  return itr->second; // also can return NULL for kicked session
163  else
164  return NULL;
165 }
SessionMap m_sessions
Definition: World.h:807
Weather * World::FindWeather ( uint32  id) const

Definition at line 363 of file World.cpp.

References m_weathers.

364 {
365  WeatherMap::const_iterator itr = m_weathers.find(id);
366 
367  if (itr != m_weathers.end())
368  return itr->second;
369  else
370  return 0;
371 }
WeatherMap m_weathers
Definition: World.h:805
void World::ForceGameEventUpdate ( )

Definition at line 1962 of file World.cpp.

References m_timers, IntervalTimer::Reset(), IntervalTimer::SetInterval(), sGameEventMgr, and WUPDATE_EVENTS.

1963 {
1964  m_timers[WUPDATE_EVENTS].Reset(); // to give time for Update() to be processed
1965  uint32 nextGameEvent = sGameEventMgr.Update();
1966  m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
1968 }
void SetInterval(time_t interval)
Definition: Timer.h:122
IntervalTimer m_timers[WUPDATE_COUNT]
Definition: World.h:796
#define sGameEventMgr
Definition: GameEventMgr.h:179
void Reset()
Definition: Timer.h:113
ACE_UINT32 uint32
Definition: Define.h:71
uint32 World::GetActiveAndQueuedSessionCount ( ) const
inline

Definition at line 472 of file World.h.

Referenced by _UpdateGameTime(), AddSession_(), and ShutdownServ().

473  {
474  return m_sessions.size();
475  }
SessionMap m_sessions
Definition: World.h:807
uint32 World::GetActiveSessionCount ( ) const
inline

Definition at line 476 of file World.h.

Referenced by AddSession_(), RemoveQueuedPlayer(), and Update().

477  {
478  return m_sessions.size() - m_QueuedPlayer.size();
479  }
SessionMap m_sessions
Definition: World.h:807
Queue m_QueuedPlayer
Definition: World.h:843
bool World::getAllowMovement ( ) const
inline

Definition at line 529 of file World.h.

530  {
531  return m_allowMovement;
532  }
bool m_allowMovement
Definition: World.h:822
const SessionMap& World::GetAllSessions ( ) const
inline

Definition at line 471 of file World.h.

471 { return m_sessions; }
SessionMap m_sessions
Definition: World.h:807
LocaleConstant World::GetAvailableDbcLocale ( LocaleConstant  locale) const
inline

Definition at line 748 of file World.h.

749  {
750  if (m_availableDbcLocaleMask & (1 << locale)) return locale;
751  else return m_defaultDbcLocale;
752  }
uint32 m_availableDbcLocaleMask
Definition: World.h:820
LocaleConstant m_defaultDbcLocale
Definition: World.h:819
uint32 World::getConfig ( uint32  index) const
inline

Definition at line 665 of file World.h.

References CONFIG_VALUE_COUNT.

Referenced by HasRecentlyDisconnected(), LoadConfigSettings(), SetInitialWorldSettings(), and UpdateSessions().

666  {
667  if (index < CONFIG_VALUE_COUNT)
668  return m_configs[index];
669  else
670  return 0;
671  }
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
uint16 World::GetConfigMaxSkillValue ( ) const
inline

Definition at line 598 of file World.h.

References CONFIG_MAX_PLAYER_LEVEL.

599  {
601  return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl * 5;
602  }
uint32 getConfig(uint32 index) const
Definition: World.h:665
ACE_UINT32 uint32
Definition: Define.h:71
std::string World::GetDataPath ( ) const
inline

Definition at line 567 of file World.h.

568  {
569  return m_dataPath;
570  }
std::string m_dataPath
Definition: World.h:824
char const* World::GetDBVersion ( )
inline

Definition at line 756 of file World.h.

757  {
758  return m_DBVersion.c_str();
759  }
std::string m_DBVersion
Definition: World.h:850
uint32 World::GetDefaultDbcLocale ( ) const
inline

Definition at line 561 of file World.h.

Referenced by SetInitialWorldSettings().

562  {
563  return m_defaultDbcLocale;
564  }
LocaleConstant m_defaultDbcLocale
Definition: World.h:819
static uint8 World::GetExitCode ( )
inlinestatic

Definition at line 628 of file World.h.

Referenced by Master::Run().

629  {
630  return m_ExitCode;
631  }
static uint8 m_ExitCode
Definition: World.h:787
time_t const& World::GetGameTime ( ) const
inline

Definition at line 578 of file World.h.

579  {
580  return m_gameTime;
581  }
time_t m_gameTime
Definition: World.h:795
uint32 World::GetMaxActiveSessionCount ( ) const
inline

Definition at line 489 of file World.h.

490  {
492  }
uint32 m_maxActiveSessionCount
Definition: World.h:810
uint32 World::GetMaxQueuedSessionCount ( ) const
inline

Definition at line 485 of file World.h.

486  {
488  }
uint32 m_maxQueuedSessionCount
Definition: World.h:811
static float World::GetMaxVisibleDistanceInBGArenas ( )
inlinestatic

Definition at line 715 of file World.h.

716  {
718  }
static float m_MaxVisibleDistanceInBGArenas
Definition: World.h:829
static float World::GetMaxVisibleDistanceInInstances ( )
inlinestatic

Definition at line 711 of file World.h.

712  {
714  }
static float m_MaxVisibleDistanceInInstances
Definition: World.h:828
static float World::GetMaxVisibleDistanceOnContinents ( )
inlinestatic

Definition at line 707 of file World.h.

708  {
710  }
static float m_MaxVisibleDistanceOnContinents
Definition: World.h:827
const char* World::GetMotd ( ) const
inline

Definition at line 545 of file World.h.

546  {
547  return m_motd.c_str();
548  }
std::string m_motd
Definition: World.h:823
const std::string& World::GetNewCharString ( ) const
inline

Definition at line 556 of file World.h.

557  {
558  return m_newCharString;
559  }
std::string m_newCharString
Definition: World.h:813
uint32 World::GetPlayerAmountLimit ( ) const
inline

Definition at line 500 of file World.h.

Referenced by AddSession_().

501  {
502  return m_playerLimit >= 0 ? m_playerLimit : 0;
503  }
int32 m_playerLimit
Definition: World.h:817
AccountTypes World::GetPlayerSecurityLimit ( ) const
inline

Definition at line 504 of file World.h.

References SEC_PLAYER.

505  {
507  }
AccountTypes m_allowedSecurityLevel
Definition: World.h:818
ProtectedOpcodeProperties const & World::GetProtectedOpcodeProperties ( uint32  opcode)

Definition at line 1789 of file World.cpp.

References _protectedOpcodesProperties.

1790 {
1791  return _protectedOpcodesProperties[opcode];
1792 }
UNORDERED_MAP< uint32, ProtectedOpcodeProperties > _protectedOpcodesProperties
Definition: World.h:855
uint32 World::GetQueuedSessionCount ( ) const
inline

Definition at line 480 of file World.h.

481  {
482  return m_QueuedPlayer.size();
483  }
Queue m_QueuedPlayer
Definition: World.h:843
int32 World::GetQueuePos ( WorldSession sess)

Definition at line 283 of file World.cpp.

References m_QueuedPlayer.

Referenced by AddQueuedPlayer().

284 {
285  uint32 position = 1;
286 
287  for (Queue::iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position)
288  if ((*iter) == sess)
289  return position;
290 
291  return 0;
292 }
Queue m_QueuedPlayer
Definition: World.h:843
ACE_UINT32 uint32
Definition: Define.h:71
uint32 World::GetQueueSize ( ) const
inline

Definition at line 522 of file World.h.

Referenced by AddSession_().

523  {
524  return m_QueuedPlayer.size();
525  }
Queue m_QueuedPlayer
Definition: World.h:843
float World::getRate ( Rates  rate) const
inline

Definition at line 652 of file World.h.

653  {
654  return rate_values[rate];
655  }
float rate_values[MAX_RATES]
Definition: World.h:815
char const* World::GetScriptsVersion ( )
inline

Definition at line 766 of file World.h.

767  {
768  return m_ScriptsVersion.c_str();
769  }
std::string m_ScriptsVersion
Definition: World.h:851
uint32 World::GetShutDownTimeLeft ( )
inline

Definition at line 621 of file World.h.

622  {
623  return m_ShutdownTimer;
624  }
uint32 m_ShutdownTimer
Definition: World.h:788
time_t const& World::GetStartTime ( ) const
inline

Definition at line 573 of file World.h.

574  {
575  return m_startTime;
576  }
time_t m_startTime
Definition: World.h:794
uint32 World::GetUpdateTime ( ) const
inline

Definition at line 588 of file World.h.

589  {
590  return m_updateTime;
591  }
uint32 m_updateTime
Definition: World.h:800
uint32 World::GetUptime ( ) const
inline

Definition at line 583 of file World.h.

584  {
585  return uint32(m_gameTime - m_startTime);
586  }
time_t m_gameTime
Definition: World.h:795
time_t m_startTime
Definition: World.h:794
ACE_UINT32 uint32
Definition: Define.h:71
static int32 World::GetVisibilityNotifyPeriodInBGArenas ( )
inlinestatic

Definition at line 728 of file World.h.

Referenced by BattlegroundMap::InitVisibilityDistance().

729  {
731  }
static int32 m_visibility_notify_periodInBGArenas
Definition: World.h:833
static int32 World::GetVisibilityNotifyPeriodInInstances ( )
inlinestatic

Definition at line 724 of file World.h.

Referenced by InstanceMap::InitVisibilityDistance().

725  {
727  }
static int32 m_visibility_notify_periodInInstances
Definition: World.h:832
static int32 World::GetVisibilityNotifyPeriodOnContinents ( )
inlinestatic

Definition at line 720 of file World.h.

Referenced by Map::InitVisibilityDistance().

721  {
723  }
static int32 m_visibility_notify_periodOnContinents
Definition: World.h:831
bool World::HasRecentlyDisconnected ( WorldSession session)

Definition at line 262 of file World.cpp.

References CONFIG_INTERVAL_DISCONNECT_TOLERANCE, WorldSession::GetAccountId(), getConfig(), and m_disconnects.

Referenced by AddSession_().

263 {
264  if (!session) return false;
265 
267  {
268  for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();)
269  {
270  if (difftime(i->second, time(NULL)) < tolerance)
271  {
272  if (i->first == session->GetAccountId())
273  return true;
274  ++i;
275  }
276  else
277  i = m_disconnects.erase(i++);
278  }
279  }
280  return false;
281 }
uint32 GetAccountId() const
Definition: WorldSession.h:100
DisconnectMap m_disconnects
Definition: World.h:809
uint32 getConfig(uint32 index) const
Definition: World.h:665
ACE_UINT32 uint32
Definition: Define.h:71
uint32 World::IncreaseScheduledScriptsCount ( )
inline

Definition at line 689 of file World.h.

690  {
691  return (uint32)++m_scheduledScripts;
692  }
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
Definition: World.h:792
ACE_UINT32 uint32
Definition: Define.h:71
void World::InitDailyQuestResetTime ( )
protected

Definition at line 2514 of file World.cpp.

References CharacterDatabase, DAY, m_NextDailyQuestReset, and Database::Query().

Referenced by SetInitialWorldSettings().

2515 {
2516  time_t mostRecentQuestTime;
2517 
2518  QueryResult_AutoPtr result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily");
2519  if (result)
2520  {
2521  Field* fields = result->Fetch();
2522  mostRecentQuestTime = (time_t)fields[0].GetUInt64();
2523  }
2524  else
2525  mostRecentQuestTime = 0;
2526 
2527  // client built-in time for reset is 6:00 AM
2528  // FIX ME: client not show day start time
2529  time_t curTime = time(NULL);
2530  tm localTm = *localtime(&curTime);
2531  localTm.tm_hour = 6;
2532  localTm.tm_min = 0;
2533  localTm.tm_sec = 0;
2534 
2535  // current day reset time
2536  time_t curDayResetTime = mktime(&localTm);
2537 
2538  // last reset time before current moment
2539  time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime;
2540 
2541  // need reset (if we have quest time before last reset time (not processed by some reason)
2542  if (mostRecentQuestTime && mostRecentQuestTime <= resetTime)
2543  m_NextDailyQuestReset = mostRecentQuestTime;
2544  else
2545  {
2546  // plan next reset time
2547  m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + DAY : curDayResetTime;
2548  }
2549 }
time_t m_NextDailyQuestReset
Definition: World.h:840
Definition: Field.h:24
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
Definition: Common.h:181
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void World::InitResultQueue ( )

Definition at line 2485 of file World.cpp.

References CharacterDatabase, m_resultQueue, and Database::SetResultQueue().

2486 {
2489 }
void SetResultQueue(SqlResultQueue *queue)
Definition: Database.cpp:332
SqlResultQueue * m_resultQueue
Definition: World.h:837
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
bool World::IsFFAPvPRealm ( )
inline

Definition at line 678 of file World.h.

References CONFIG_GAME_TYPE, and REALM_TYPE_FFA_PVP.

Referenced by SetInitialWorldSettings().

679  {
681  }
uint32 getConfig(uint32 index) const
Definition: World.h:665
bool World::IsPvPRealm ( )
inline
bool World::IsScriptScheduled ( ) const
inline

Definition at line 701 of file World.h.

702  {
703  return m_scheduledScripts > 0;
704  }
ACE_Atomic_Op< ACE_Thread_Mutex, long > m_scheduledScripts
Definition: World.h:792
bool World::IsShuttingDown ( ) const
inline

Definition at line 617 of file World.h.

618  {
619  return m_ShutdownTimer > 0;
620  }
uint32 m_ShutdownTimer
Definition: World.h:788
static bool World::IsStopped ( )
inlinestatic

Definition at line 638 of file World.h.

Referenced by Console::MainLoop(), Master::MainLoop(), RARunnable::run(), OCSoapRunnable::run(), Console::RunCommandLoop(), and Console::RunLogViewLoop().

639  {
640  return m_stopEvent;
641  }
static volatile bool m_stopEvent
Definition: World.h:786
void World::KickAll ( )

Definition at line 2159 of file World.cpp.

References m_QueuedPlayer, and m_sessions.

2160 {
2161  m_QueuedPlayer.clear(); // prevent send queue update packet and login queued sessions
2162 
2163  // session not removed at kick and will removed in next update tick
2164  for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2165  itr->second->KickPlayer();
2166 }
SessionMap m_sessions
Definition: World.h:807
Queue m_QueuedPlayer
Definition: World.h:843
void World::KickAllLess ( AccountTypes  sec)

Definition at line 2169 of file World.cpp.

References m_sessions.

2170 {
2171  // session not removed at kick and will removed in next update tick
2172  for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2173  if (itr->second->GetSecurity() < sec)
2174  itr->second->KickPlayer();
2175 }
SessionMap m_sessions
Definition: World.h:807
bool World::KickPlayer ( const std::string &  playerName)

Definition at line 2178 of file World.cpp.

References WorldObject::GetName(), Unit::GetPlayer(), Object::IsInWorld(), and m_sessions.

2179 {
2180  SessionMap::iterator itr;
2181 
2182  // session not removed at kick and will removed in next update tick
2183  for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2184  {
2185  if (!itr->second)
2186  continue;
2187  Player* player = itr->second->GetPlayer();
2188  if (!player)
2189  continue;
2190  if (player->IsInWorld())
2191  {
2192  if (playerName == player->GetName())
2193  {
2194  itr->second->KickPlayer();
2195  return true;
2196  }
2197  }
2198  }
2199  return false;
2200 }
SessionMap m_sessions
Definition: World.h:807
const bool & IsInWorld() const
Definition: Object.h:129
const char * GetName() const
Definition: Object.h:692
static Player * GetPlayer(WorldObject &object, uint64 guid)
Definition: Unit.cpp:10597
Definition: Player.h:922
void World::LoadAutobroadcasts ( )

Definition at line 1716 of file World.cpp.

References Field::GetCppString(), m_Autobroadcasts, Database::Query(), sLog, and WorldDatabase.

Referenced by SetInitialWorldSettings().

1717 {
1718  m_Autobroadcasts.clear();
1719 
1720  QueryResult_AutoPtr result = WorldDatabase.Query("SELECT text FROM autobroadcast");
1721 
1722  if (!result)
1723  {
1724  sLog.outString(">> Loaded 0 autobroadcasts definitions");
1725  return;
1726  }
1727 
1728  uint32 count = 0;
1729 
1730  do
1731  {
1732  Field* fields = result->Fetch();
1733  std::string message = fields[0].GetCppString();
1734  m_Autobroadcasts.push_back(message);
1735  ++count;
1736  }
1737 
1738  while (result->NextRow());
1739 
1740  sLog.outString( ">> Loaded %u autobroadcasts definitions", count);
1741 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
Definition: Field.h:24
std::list< std::string > m_Autobroadcasts
Definition: World.h:853
#define sLog
Log class singleton.
Definition: Log.h:187
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
std::string GetCppString() const
Definition: Field.h:52
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
ACE_UINT32 uint32
Definition: Define.h:71
void World::LoadConfigSettings ( bool  reload = false)
  • Load the CharDelete related config options
  • Read the "Data" directory from the config file

Definition at line 403 of file World.cpp.

References CONFIG_ADDON_CHANNEL, CONFIG_ALL_TAXI_PATHS, CONFIG_ALLOW_GM_FRIEND, CONFIG_ALLOW_GM_GROUP, CONFIG_ALLOW_TWO_SIDE_ACCOUNTS, CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND, CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION, CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT, CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP, CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD, CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL, CONFIG_ALLOW_TWO_SIDE_TRADE, CONFIG_ALLOW_TWO_SIDE_WHO_LIST, CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL, CONFIG_ALWAYS_MAXSKILL, CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_ARENA_HIDE_FROM_SOCIAL, CONFIG_ARENA_LOG_EXTENDED_INFO, CONFIG_ARENA_MAX_RATING_DIFFERENCE, CONFIG_ARENA_RATING_DISCARD_TIMER, CONFIG_AUTOBROADCAST_CENTER, CONFIG_AUTOBROADCAST_ENABLED, CONFIG_AUTOBROADCAST_TIMER, CONFIG_BATTLEGROUND_CAST_DESERTER, CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER, CONFIG_BATTLEGROUND_PREMATURE_REWARD, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ONSTART, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, CONFIG_BATTLEGROUND_WRATH_LEAVE_MODE, CONFIG_BG_START_MUSIC, CONFIG_BOOL_MMAP_ENABLED, CONFIG_CAST_UNSTUCK, CONFIG_CHANCE_OF_GM_SURVEY, CONFIG_CHARACTERS_CREATING_DISABLED, CONFIG_CHARACTERS_PER_ACCOUNT, CONFIG_CHARACTERS_PER_REALM, CONFIG_CHARDELETE_KEEP_DAYS, CONFIG_CHARDELETE_METHOD, CONFIG_CHARDELETE_MIN_LEVEL, CONFIG_CHAT_FAKE_MESSAGE_PREVENTING, CONFIG_CHAT_STRICT_LINK_CHECKING_KICK, CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY, CONFIG_CHATFLOOD_MESSAGE_COUNT, CONFIG_CHATFLOOD_MESSAGE_DELAY, CONFIG_CHATFLOOD_MUTE_TIME, CONFIG_CHATLOG_ADDON, CONFIG_CHATLOG_BGROUND, CONFIG_CHATLOG_CHANNEL, CONFIG_CHATLOG_GUILD, CONFIG_CHATLOG_PARTY, CONFIG_CHATLOG_PUBLIC, CONFIG_CHATLOG_RAID, CONFIG_CHATLOG_SYSCHAN, CONFIG_CHATLOG_WHISPER, CONFIG_COMPRESSION, CONFIG_CORPSE_DECAY_ELITE, CONFIG_CORPSE_DECAY_NORMAL, CONFIG_CORPSE_DECAY_RARE, CONFIG_CORPSE_DECAY_RAREELITE, CONFIG_CORPSE_DECAY_WORLDBOSS, CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY, CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS, CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS, CONFIG_CREATURE_FAMILY_FLEE_DELAY, CONFIG_CREATURE_PICKPOCKET_REFILL, CONFIG_DEATH_BONES_BG_OR_ARENA, CONFIG_DEATH_BONES_WORLD, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE, CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP, CONFIG_DEATH_SICKNESS_LEVEL, CONFIG_DECLINED_NAMES_USED, CONFIG_DETECT_POS_COLLISION, CONFIG_DIE_COMMAND_MODE, CONFIG_DISABLE_BREATHING, CONFIG_DUEL_CD_RESET, CONFIG_DUEL_MOD, CONFIG_ENABLE_SINFO_LOGIN, CONFIG_EVENT_ANNOUNCE, CONFIG_EXPANSION, CONFIG_EXTERNAL_MAIL, CONFIG_EXTERNAL_MAIL_INTERVAL, CONFIG_GAME_TYPE, CONFIG_GM_CHAT, CONFIG_GM_IN_GM_LIST, CONFIG_GM_IN_WHO_LIST, CONFIG_GM_LOG_TRADE, CONFIG_GM_LOGIN_STATE, CONFIG_GM_MAIL, CONFIG_GM_VISIBLE_STATE, CONFIG_GM_WISPERING_TO, CONFIG_GRID_UNLOAD, CONFIG_GROUP_VISIBILITY, CONFIG_GROUP_XP_DISTANCE, CONFIG_HEALTH_IN_PERCENTS, CONFIG_HONOR_AFTER_DUEL, CONFIG_INSTANCE_IGNORE_LEVEL, CONFIG_INSTANCE_IGNORE_RAID, CONFIG_INSTANCE_RESET_TIME_HOUR, CONFIG_INSTANCE_UNLOAD_DELAY, CONFIG_INSTANT_LOGOUT, CONFIG_INSTANT_TAXI, CONFIG_INTERVAL_CHANGEWEATHER, CONFIG_INTERVAL_DISCONNECT_TOLERANCE, CONFIG_INTERVAL_GRIDCLEAN, CONFIG_INTERVAL_LOG_UPDATE, CONFIG_INTERVAL_MAPUPDATE, CONFIG_INTERVAL_SAVE, CONFIG_LISTEN_RANGE_SAY, CONFIG_LISTEN_RANGE_TEXTEMOTE, CONFIG_LISTEN_RANGE_YELL, CONFIG_LOGDB_CLEARINTERVAL, CONFIG_LOGDB_CLEARTIME, CONFIG_MAIL_DELIVERY_DELAY, CONFIG_MAX_ARENA_POINTS, CONFIG_MAX_HONOR_POINTS, CONFIG_MAX_OVERSPEED_PINGS, CONFIG_MAX_PLAYER_LEVEL, CONFIG_MAX_PRIMARY_TRADE_SKILL, CONFIG_MAX_RESULTS_LOOKUP_COMMANDS, CONFIG_MAX_WHO, CONFIG_MIN_LOG_UPDATE, CONFIG_MIN_PETITION_SIGNS, CONFIG_NO_RESET_TALENT_COST, CONFIG_NUMTHREADS, CONFIG_PET_LOS, CONFIG_PORT_WORLD, CONFIG_PVP_TOKEN_COUNT, CONFIG_PVP_TOKEN_ENABLE, CONFIG_PVP_TOKEN_ID, CONFIG_PVP_TOKEN_MAP_TYPE, CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF, CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF, CONFIG_RAF_LEVEL_LIMIT, CONFIG_REALM_ZONE, CONFIG_RESTRICTED_LFG_CHANNEL, CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, CONFIG_SESSION_ADD_DELAY, CONFIG_SHOW_KICK_IN_WORLD, CONFIG_SIGHT_GUARDER, CONFIG_SIGHT_MONSTER, CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, CONFIG_SKILL_CHANCE_GREEN, CONFIG_SKILL_CHANCE_GREY, CONFIG_SKILL_CHANCE_MINING_STEPS, CONFIG_SKILL_CHANCE_ORANGE, CONFIG_SKILL_CHANCE_SKINNING_STEPS, CONFIG_SKILL_CHANCE_YELLOW, CONFIG_SKILL_GAIN_CRAFTING, CONFIG_SKILL_GAIN_DEFENSE, CONFIG_SKILL_GAIN_GATHERING, CONFIG_SKILL_GAIN_WEAPON, CONFIG_SKILL_PROSPECTING, CONFIG_SKIP_CINEMATICS, CONFIG_SOCKET_SELECTTIME, CONFIG_SOCKET_TIMEOUTTIME, CONFIG_SQLUPDATER_ENABLED, CONFIG_START_ALL_EXPLORED, CONFIG_START_ALL_REP, CONFIG_START_ALL_SPELLS, CONFIG_START_ARENA_POINTS, CONFIG_START_GM_LEVEL, CONFIG_START_HONOR_POINTS, CONFIG_START_PLAYER_LEVEL, CONFIG_START_PLAYER_MONEY, CONFIG_STRICT_CHARTER_NAMES, CONFIG_STRICT_PET_NAMES, CONFIG_STRICT_PLAYER_NAMES, CONFIG_TALENTS_INSPECTING, CONFIG_THREAT_RADIUS, CONFIG_UI_QUESTLEVELS_IN_DIALOGS, CONFIG_UPTIME_UPDATE, CONFIG_VMAP_TOTEM, CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF, CONFIG_WARDEN_CLIENT_RESPONSE_DELAY, CONFIG_WARDEN_ENABLED, CONFIG_WARDEN_KICK, CONFIG_WARDEN_NUM_CHECKS, CONFIG_WEATHER, CONFIG_WORLD_BOSS_LEVEL_DIFF, CONTACT_DISTANCE, VMAP::VMapFactory::createOrGetVMapManager(), DEFAULT_MAX_LEVEL, DEFAULT_PLAYER_LIMIT, DEFAULT_SOCKET_SELECT_TIME, DEFAULT_VISIBILITY_BGARENAS, DEFAULT_VISIBILITY_DISTANCE, DEFAULT_VISIBILITY_INSTANCE, DEFAULT_VISIBILITY_NOTIFY_PERIOD, DEFAULT_WORLDSERVER_PORT, getConfig(), HOUR, IN_MILLISECONDS, Oregon::Singleton< MapManager, Oregon::ClassLevelLockable< MapManager, ACE_Thread_Mutex > >::Instance(), m_configs, m_dataPath, m_MaxVisibleDistanceInBGArenas, m_MaxVisibleDistanceInInstances, m_MaxVisibleDistanceOnContinents, m_SQLUpdatesPath, m_timers, m_visibility_notify_periodInBGArenas, m_visibility_notify_periodInInstances, m_visibility_notify_periodOnContinents, MAX_LEVEL, MAX_MONEY_AMOUNT, MAX_VISIBILITY_DISTANCE, MIN_MAP_UPDATE_DELAY, MINUTE, NOMINAL_MELEE_RANGE, MMAP::MMapFactory::preventPathfindingOnMaps(), VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(), RATE_AUCTION_CUT, RATE_AUCTION_DEPOSIT, RATE_AUCTION_TIME, RATE_CORPSE_DECAY_LOOTED, RATE_CREATURE_AGGRO, RATE_CREATURE_ELITE_ELITE_DAMAGE, RATE_CREATURE_ELITE_ELITE_HP, RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE, RATE_CREATURE_ELITE_RARE_DAMAGE, RATE_CREATURE_ELITE_RARE_HP, RATE_CREATURE_ELITE_RARE_SPELLDAMAGE, RATE_CREATURE_ELITE_RAREELITE_DAMAGE, RATE_CREATURE_ELITE_RAREELITE_HP, RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE, RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE, RATE_CREATURE_ELITE_WORLDBOSS_HP, RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE, RATE_CREATURE_NORMAL_DAMAGE, RATE_CREATURE_NORMAL_HP, RATE_CREATURE_NORMAL_SPELLDAMAGE, RATE_DAMAGE_FALL, RATE_DROP_ITEM_ARTIFACT, RATE_DROP_ITEM_EPIC, RATE_DROP_ITEM_LEGENDARY, RATE_DROP_ITEM_NORMAL, RATE_DROP_ITEM_POOR, RATE_DROP_ITEM_RARE, RATE_DROP_ITEM_REFERENCED, RATE_DROP_ITEM_UNCOMMON, RATE_DROP_MONEY, RATE_DURABILITY_LOSS_ABSORB, RATE_DURABILITY_LOSS_BLOCK, RATE_DURABILITY_LOSS_DAMAGE, RATE_DURABILITY_LOSS_PARRY, RATE_HEALTH, RATE_HONOR, RATE_INSTANCE_RESET_TIME, RATE_LOYALTY, RATE_MINING_AMOUNT, RATE_MINING_NEXT, RATE_POWER_ENERGY, RATE_POWER_FOCUS, RATE_POWER_MANA, RATE_POWER_RAGE_INCOME, RATE_POWER_RAGE_LOSS, RATE_RAF_BONUS_XP, RATE_RAF_GRANTABLE_LEVELS_PER_LEVEL, RATE_REPUTATION_GAIN, RATE_REST_INGAME, RATE_REST_OFFLINE_IN_TAVERN_OR_CITY, RATE_REST_OFFLINE_IN_WILDERNESS, RATE_SKILL_DISCOVERY, RATE_TALENT, RATE_TARGET_POS_RECALCULATION_RANGE, rate_values, RATE_XP_EXPLORE, RATE_XP_KILL, RATE_XP_PAST_70, RATE_XP_QUEST, REALM_ZONE_DEVELOPMENT, REALM_ZONE_RUSSIAN, IntervalTimer::Reset(), sConfig, SEC_CONSOLE, SEC_MODERATOR, VMAP::IVMapManager::setEnableHeightCalc(), VMAP::IVMapManager::setEnableLineOfSightCalc(), MapManager::SetGridCleanUpDelay(), IntervalTimer::SetInterval(), MapManager::SetMapUpdateInterval(), SetMotd(), SetNewCharString(), SetPlayerLimit(), sLog, sWorld, WUPDATE_CLEANDB, and WUPDATE_UPTIME.

Referenced by SetInitialWorldSettings().

404 {
405  if (reload)
406  {
407  if (!sConfig.Reload())
408  {
409  sLog.outError("World settings reload fail: can't read settings from %s.", sConfig.GetFilename().c_str());
410  return;
411  }
412  }
413 
414  // Read the player limit and the Message of the day from the config file
415  SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT), true);
416  SetMotd(sConfig.GetStringDefault("Motd", "Welcome to a Oregon Core Server."));
417 
418  // Get string for new logins (newly created characters)
419  SetNewCharString(sConfig.GetStringDefault("PlayerStart.String", ""));
420 
421  // Send server info on login?
422  m_configs[CONFIG_ENABLE_SINFO_LOGIN] = sConfig.GetIntDefault("Server.LoginInfo", 0);
423 
424  // Read all rates from the config file
425  rate_values[RATE_HEALTH] = sConfig.GetFloatDefault("Rate.Health", 1);
426  if (rate_values[RATE_HEALTH] < 0)
427  {
428  sLog.outError("Rate.Health (%f) must be > 0. Using 1 instead.", rate_values[RATE_HEALTH]);
430  }
431  rate_values[RATE_POWER_MANA] = sConfig.GetFloatDefault("Rate.Mana", 1);
432  if (rate_values[RATE_POWER_MANA] < 0)
433  {
434  sLog.outError("Rate.Mana (%f) must be > 0. Using 1 instead.", rate_values[RATE_POWER_MANA]);
436  }
437  rate_values[RATE_POWER_RAGE_INCOME] = sConfig.GetFloatDefault("Rate.Rage.Income", 1);
438  rate_values[RATE_POWER_RAGE_LOSS] = sConfig.GetFloatDefault("Rate.Rage.Loss", 1);
440  {
441  sLog.outError("Rate.Rage.Loss (%f) must be > 0. Using 1 instead.", rate_values[RATE_POWER_RAGE_LOSS]);
443  }
444  rate_values[RATE_POWER_FOCUS] = sConfig.GetFloatDefault("Rate.Focus", 1.0f);
445  rate_values[RATE_POWER_ENERGY] = sConfig.GetFloatDefault("Rate.Energy", 1.0f);
446  rate_values[RATE_LOYALTY] = sConfig.GetFloatDefault("Rate.Loyalty", 1.0f);
447  rate_values[RATE_SKILL_DISCOVERY] = sConfig.GetFloatDefault("Rate.Skill.Discovery", 1.0f);
448  rate_values[RATE_DROP_ITEM_POOR] = sConfig.GetFloatDefault("Rate.Drop.Item.Poor", 1.0f);
449  rate_values[RATE_DROP_ITEM_NORMAL] = sConfig.GetFloatDefault("Rate.Drop.Item.Normal", 1.0f);
450  rate_values[RATE_DROP_ITEM_UNCOMMON] = sConfig.GetFloatDefault("Rate.Drop.Item.Uncommon", 1.0f);
451  rate_values[RATE_DROP_ITEM_RARE] = sConfig.GetFloatDefault("Rate.Drop.Item.Rare", 1.0f);
452  rate_values[RATE_DROP_ITEM_EPIC] = sConfig.GetFloatDefault("Rate.Drop.Item.Epic", 1.0f);
453  rate_values[RATE_DROP_ITEM_LEGENDARY] = sConfig.GetFloatDefault("Rate.Drop.Item.Legendary", 1.0f);
454  rate_values[RATE_DROP_ITEM_ARTIFACT] = sConfig.GetFloatDefault("Rate.Drop.Item.Artifact", 1.0f);
455  rate_values[RATE_DROP_ITEM_REFERENCED] = sConfig.GetFloatDefault("Rate.Drop.Item.Referenced", 1.0f);
456  rate_values[RATE_DROP_MONEY] = sConfig.GetFloatDefault("Rate.Drop.Money", 1.0f);
457  rate_values[RATE_XP_KILL] = sConfig.GetFloatDefault("Rate.XP.Kill", 1.0f);
458  rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f);
459  rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f);
460  rate_values[RATE_XP_PAST_70] = sConfig.GetFloatDefault("Rate.XP.PastLevel70", 1.0f);
461  rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f);
462  rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f);
463  rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f);
464  rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.Damage", 1.0f);
465  rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.Damage", 1.0f);
466  rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.Damage", 1.0f);
467  rate_values[RATE_CREATURE_NORMAL_HP] = sConfig.GetFloatDefault("Rate.Creature.Normal.HP", 1.0f);
468  rate_values[RATE_CREATURE_ELITE_ELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.HP", 1.0f);
469  rate_values[RATE_CREATURE_ELITE_RAREELITE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.HP", 1.0f);
470  rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.HP", 1.0f);
471  rate_values[RATE_CREATURE_ELITE_RARE_HP] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.HP", 1.0f);
472  rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.SpellDamage", 1.0f);
473  rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.SpellDamage", 1.0f);
474  rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.SpellDamage", 1.0f);
475  rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.WORLDBOSS.SpellDamage", 1.0f);
476  rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RARE.SpellDamage", 1.0f);
477  rate_values[RATE_CREATURE_AGGRO] = sConfig.GetFloatDefault("Rate.Creature.Aggro", 1.0f);
478  rate_values[RATE_REST_INGAME] = sConfig.GetFloatDefault("Rate.Rest.InGame", 1.0f);
479  rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = sConfig.GetFloatDefault("Rate.Rest.Offline.InTavernOrCity", 1.0f);
480  rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = sConfig.GetFloatDefault("Rate.Rest.Offline.InWilderness", 1.0f);
481  rate_values[RATE_DAMAGE_FALL] = sConfig.GetFloatDefault("Rate.Damage.Fall", 1.0f);
482  rate_values[RATE_AUCTION_TIME] = sConfig.GetFloatDefault("Rate.Auction.Time", 1.0f);
483  rate_values[RATE_AUCTION_DEPOSIT] = sConfig.GetFloatDefault("Rate.Auction.Deposit", 1.0f);
484  rate_values[RATE_AUCTION_CUT] = sConfig.GetFloatDefault("Rate.Auction.Cut", 1.0f);
485  rate_values[RATE_HONOR] = sConfig.GetFloatDefault("Rate.Honor", 1.0f);
486  rate_values[RATE_MINING_AMOUNT] = sConfig.GetFloatDefault("Rate.Mining.Amount", 1.0f);
487  rate_values[RATE_MINING_NEXT] = sConfig.GetFloatDefault("Rate.Mining.Next", 1.0f);
488  rate_values[RATE_INSTANCE_RESET_TIME] = sConfig.GetFloatDefault("Rate.InstanceResetTime", 1.0f);
489  rate_values[RATE_TALENT] = sConfig.GetFloatDefault("Rate.Talent", 1.0f);
490  if (rate_values[RATE_TALENT] < 0.0f)
491  {
492  sLog.outError("Rate.Talent (%f) must be > 0. Using 1 instead.", rate_values[RATE_TALENT]);
493  rate_values[RATE_TALENT] = 1.0f;
494  }
495  rate_values[RATE_RAF_BONUS_XP] = sConfig.GetIntDefault("RAF.BonusXPGain", 3);
496  if (rate_values[RATE_TALENT] < 0.0f)
497  {
498  sLog.outError("RAF.BonusXPGain (%f) must be > 0. Using 3 instead.", rate_values[RATE_RAF_BONUS_XP]);
500  }
501  rate_values[RATE_RAF_GRANTABLE_LEVELS_PER_LEVEL] = std::max<float>(0.f, sConfig.GetFloatDefault("RAF.GrantableLevelsPerLevel", .5f));
502  rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted", 0.5f);
503 
504  rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetFloatDefault("TargetPosRecalculateRange", 1.5f);
506  {
507  sLog.outError("TargetPosRecalculateRange (%f) must be >= %f. Using %f instead.", rate_values[RATE_TARGET_POS_RECALCULATION_RANGE], CONTACT_DISTANCE, CONTACT_DISTANCE);
509  }
511  {
512  sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.",
515  }
516 
517  rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage", 0.5f);
518  if (rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f)
519  {
520  sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_DAMAGE]);
521  rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f;
522  }
523  rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb", 0.5f);
524  if (rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f)
525  {
526  sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_ABSORB]);
527  rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f;
528  }
529  rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry", 0.05f);
530  if (rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f)
531  {
532  sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_PARRY]);
533  rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f;
534  }
535  rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block", 0.05f);
536  if (rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f)
537  {
538  sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_BLOCK]);
539  rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f;
540  }
541 
542  // Read other configuration items from the config file
543 
544  m_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1);
545  if (m_configs[CONFIG_COMPRESSION] < 1 || m_configs[CONFIG_COMPRESSION] > 9)
546  {
547  sLog.outError("Compression level (%i) must be in range 1..9. Using default compression level (1).", m_configs[CONFIG_COMPRESSION]);
548  m_configs[CONFIG_COMPRESSION] = 1;
549  }
550  m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true);
551  m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true);
552  m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 900000);
553  m_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfig.GetIntDefault("DisconnectToleranceInterval", 0);
554 
555  m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 60000);
556  //if (m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY)
557  //{
558  // sLog.outError("GridCleanUpDelay (%i) must be greater %u. Use this minimal value.", m_configs[CONFIG_INTERVAL_GRIDCLEAN], MIN_GRID_DELAY);
559  // m_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY;
560  //}
561  if (reload)
563 
564  m_configs[CONFIG_INTERVAL_MAPUPDATE] = sConfig.GetIntDefault("MapUpdateInterval", 100);
566  {
567  sLog.outError("MapUpdateInterval (%i) must be greater %u. Use this minimal value.", m_configs[CONFIG_INTERVAL_MAPUPDATE], MIN_MAP_UPDATE_DELAY);
569  }
570  if (reload)
572 
573  m_configs[CONFIG_INTERVAL_CHANGEWEATHER] = sConfig.GetIntDefault("ChangeWeatherInterval", 10 * MINUTE * IN_MILLISECONDS);
574 
575  if (reload)
576  {
577  uint32 val = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT);
578  if (val != m_configs[CONFIG_PORT_WORLD])
579  sLog.outError("WorldServerPort option can't be changed at Oregond.conf reload, using current value (%u).", m_configs[CONFIG_PORT_WORLD]);
580  }
581  else
582  m_configs[CONFIG_PORT_WORLD] = sConfig.GetIntDefault("WorldServerPort", DEFAULT_WORLDSERVER_PORT);
583 
584  if (reload)
585  {
586  uint32 val = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME);
587  if (val != m_configs[CONFIG_SOCKET_SELECTTIME])
588  sLog.outError("SocketSelectTime option can't be changed at Oregond.conf reload, using current value (%u).", m_configs[CONFIG_SOCKET_SELECTTIME]);
589  }
590  else
591  m_configs[CONFIG_SOCKET_SELECTTIME] = sConfig.GetIntDefault("SocketSelectTime", DEFAULT_SOCKET_SELECT_TIME);
592 
593  m_configs[CONFIG_SOCKET_TIMEOUTTIME] = sConfig.GetIntDefault("SocketTimeOutTime", 900000);
594  m_configs[CONFIG_SESSION_ADD_DELAY] = sConfig.GetIntDefault("SessionAddDelay", 10000);
595 
596  m_configs[CONFIG_GROUP_XP_DISTANCE] = sConfig.GetIntDefault("MaxGroupXPDistance", 74);
597  // todo Add MonsterSight and GuarderSight (with meaning) in Oregond.conf or put them as define
598  m_configs[CONFIG_SIGHT_MONSTER] = sConfig.GetIntDefault("MonsterSight", 50);
599  m_configs[CONFIG_SIGHT_GUARDER] = sConfig.GetIntDefault("GuarderSight", 50);
600 
601  if (reload)
602  {
603  uint32 val = sConfig.GetIntDefault("GameType", 0);
604  if (val != m_configs[CONFIG_GAME_TYPE])
605  sLog.outError("GameType option can't be changed at Oregond.conf reload, using current value (%u).", m_configs[CONFIG_GAME_TYPE]);
606  }
607  else
608  m_configs[CONFIG_GAME_TYPE] = sConfig.GetIntDefault("GameType", 0);
609 
610  if (reload)
611  {
612  uint32 val = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT);
613  if (val != m_configs[CONFIG_REALM_ZONE])
614  sLog.outError("RealmZone option can't be changed at Oregond.conf reload, using current value (%u).", m_configs[CONFIG_REALM_ZONE]);
615  }
616  else
617  m_configs[CONFIG_REALM_ZONE] = sConfig.GetIntDefault("RealmZone", REALM_ZONE_DEVELOPMENT);
618 
619  m_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfig.GetBoolDefault("AllowTwoSide.Accounts", false);
620  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Chat", false);
621  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Channel", false);
622  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Group", false);
623  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Guild", false);
624  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Auction", false);
625  m_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = sConfig.GetBoolDefault("AllowTwoSide.Interaction.Mail", false);
626  m_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = sConfig.GetBoolDefault("AllowTwoSide.WhoList", false);
627  m_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = sConfig.GetBoolDefault("AllowTwoSide.AddFriend", false);
628  m_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = sConfig.GetBoolDefault("AllowTwoSide.trade", false);
629  m_configs[CONFIG_STRICT_PLAYER_NAMES] = sConfig.GetIntDefault ("StrictPlayerNames", 0);
630  m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault ("StrictCharterNames", 0);
631  m_configs[CONFIG_STRICT_PET_NAMES] = sConfig.GetIntDefault ("StrictPetNames", 0);
632 
633  m_configs[CONFIG_CHARACTERS_CREATING_DISABLED] = sConfig.GetIntDefault ("CharactersCreatingDisabled", 0);
634 
635  m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10);
636  if (m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10)
637  {
638  sLog.outError("CharactersPerRealm (%i) must be in range 1..10. Set to 10.", m_configs[CONFIG_CHARACTERS_PER_REALM]);
639  m_configs[CONFIG_CHARACTERS_PER_REALM] = 10;
640  }
641 
642  // must be after CONFIG_CHARACTERS_PER_REALM
643  m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50);
645  {
646  sLog.outError("CharactersPerAccount (%i) can't be less than CharactersPerRealm (%i).", m_configs[CONFIG_CHARACTERS_PER_ACCOUNT], m_configs[CONFIG_CHARACTERS_PER_REALM]);
648  }
649 
650  m_configs[CONFIG_SKIP_CINEMATICS] = sConfig.GetIntDefault("SkipCinematics", 0);
651  if (int32(m_configs[CONFIG_SKIP_CINEMATICS]) < 0 || m_configs[CONFIG_SKIP_CINEMATICS] > 2)
652  {
653  sLog.outError("SkipCinematics (%i) must be in range 0..2. Set to 0.", m_configs[CONFIG_SKIP_CINEMATICS]);
654  m_configs[CONFIG_SKIP_CINEMATICS] = 0;
655  }
656 
657  if (reload)
658  {
659  uint32 val = sConfig.GetIntDefault("MaxPlayerLevel", DEFAULT_MAX_LEVEL);
660  if (val != m_configs[CONFIG_MAX_PLAYER_LEVEL])
661  sLog.outError("MaxPlayerLevel option can't be changed at config reload, using current value (%u).", m_configs[CONFIG_MAX_PLAYER_LEVEL]);
662  }
663  else
664  m_configs[CONFIG_MAX_PLAYER_LEVEL] = sConfig.GetIntDefault("MaxPlayerLevel", DEFAULT_MAX_LEVEL);
665 
666  if (m_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL)
667  {
668  sLog.outError("MaxPlayerLevel (%i) must be in range 1..%u. Set to %u.", m_configs[CONFIG_MAX_PLAYER_LEVEL], MAX_LEVEL, MAX_LEVEL);
669  m_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL;
670  }
671 
672  m_configs[CONFIG_START_PLAYER_LEVEL] = sConfig.GetIntDefault("StartPlayerLevel", 1);
673  if (m_configs[CONFIG_START_PLAYER_LEVEL] < 1)
674  {
675  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]);
676  m_configs[CONFIG_START_PLAYER_LEVEL] = 1;
677  }
678  else if (m_configs[CONFIG_START_PLAYER_LEVEL] > m_configs[CONFIG_MAX_PLAYER_LEVEL])
679  {
680  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]);
681  m_configs[CONFIG_START_PLAYER_LEVEL] = m_configs[CONFIG_MAX_PLAYER_LEVEL];
682  }
683 
684  m_configs[CONFIG_START_PLAYER_MONEY] = sConfig.GetIntDefault("StartPlayerMoney", 0);
685  if (int32(m_configs[CONFIG_START_PLAYER_MONEY]) < 0)
686  {
687  sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.", m_configs[CONFIG_START_PLAYER_MONEY], MAX_MONEY_AMOUNT, 0);
688  m_configs[CONFIG_START_PLAYER_MONEY] = 0;
689  }
690  else if (m_configs[CONFIG_START_PLAYER_MONEY] > MAX_MONEY_AMOUNT)
691  {
692  sLog.outError("StartPlayerMoney (%i) must be in range 0..%u. Set to %u.",
693  m_configs[CONFIG_START_PLAYER_MONEY], MAX_MONEY_AMOUNT, MAX_MONEY_AMOUNT);
695  }
696 
697  m_configs[CONFIG_MAX_HONOR_POINTS] = sConfig.GetIntDefault("MaxHonorPoints", 75000);
698  if (int32(m_configs[CONFIG_MAX_HONOR_POINTS]) < 0)
699  {
700  sLog.outError("MaxHonorPoints (%i) can't be negative. Set to 0.", m_configs[CONFIG_MAX_HONOR_POINTS]);
701  m_configs[CONFIG_MAX_HONOR_POINTS] = 0;
702  }
703 
704  m_configs[CONFIG_START_HONOR_POINTS] = sConfig.GetIntDefault("StartHonorPoints", 0);
705  if (int32(m_configs[CONFIG_START_HONOR_POINTS]) < 0)
706  {
707  sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.",
708  m_configs[CONFIG_START_HONOR_POINTS], m_configs[CONFIG_MAX_HONOR_POINTS], 0);
709  m_configs[CONFIG_START_HONOR_POINTS] = 0;
710  }
711  else if (m_configs[CONFIG_START_HONOR_POINTS] > m_configs[CONFIG_MAX_HONOR_POINTS])
712  {
713  sLog.outError("StartHonorPoints (%i) must be in range 0..MaxHonorPoints(%u). Set to %u.",
714  m_configs[CONFIG_START_HONOR_POINTS], m_configs[CONFIG_MAX_HONOR_POINTS], m_configs[CONFIG_MAX_HONOR_POINTS]);
715  m_configs[CONFIG_START_HONOR_POINTS] = m_configs[CONFIG_MAX_HONOR_POINTS];
716  }
717 
718  m_configs[CONFIG_MAX_ARENA_POINTS] = sConfig.GetIntDefault("MaxArenaPoints", 5000);
719  if (int32(m_configs[CONFIG_MAX_ARENA_POINTS]) < 0)
720  {
721  sLog.outError("MaxArenaPoints (%i) can't be negative. Set to 0.", m_configs[CONFIG_MAX_ARENA_POINTS]);
722  m_configs[CONFIG_MAX_ARENA_POINTS] = 0;
723  }
724 
725  m_configs[CONFIG_START_ARENA_POINTS] = sConfig.GetIntDefault("StartArenaPoints", 0);
726  if (int32(m_configs[CONFIG_START_ARENA_POINTS]) < 0)
727  {
728  sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.",
729  m_configs[CONFIG_START_ARENA_POINTS], m_configs[CONFIG_MAX_ARENA_POINTS], 0);
730  m_configs[CONFIG_START_ARENA_POINTS] = 0;
731  }
732  else if (m_configs[CONFIG_START_ARENA_POINTS] > m_configs[CONFIG_MAX_ARENA_POINTS])
733  {
734  sLog.outError("StartArenaPoints (%i) must be in range 0..MaxArenaPoints(%u). Set to %u.",
735  m_configs[CONFIG_START_ARENA_POINTS], m_configs[CONFIG_MAX_ARENA_POINTS], m_configs[CONFIG_MAX_ARENA_POINTS]);
736  m_configs[CONFIG_START_ARENA_POINTS] = m_configs[CONFIG_MAX_ARENA_POINTS];
737  }
738 
739  // Custom Flight Path Config Options
740  m_configs[CONFIG_ALL_TAXI_PATHS] = sConfig.GetBoolDefault("AllFlightPaths", false);
741  m_configs[CONFIG_INSTANT_TAXI] = sConfig.GetBoolDefault("InstantFlightPaths", false);
742 
743  m_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = sConfig.GetBoolDefault("Instance.IgnoreLevel", false);
744  m_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfig.GetBoolDefault("Instance.IgnoreRaid", false);
745 
746  m_configs[CONFIG_CAST_UNSTUCK] = sConfig.GetBoolDefault("CastUnstuck", true);
747  m_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfig.GetIntDefault("Instance.ResetTimeHour", 4);
748  m_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = sConfig.GetIntDefault("Instance.UnloadDelay", 30 * MINUTE * IN_MILLISECONDS);
749 
750  m_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfig.GetIntDefault("MaxPrimaryTradeSkill", 2);
751  m_configs[CONFIG_MIN_PETITION_SIGNS] = sConfig.GetIntDefault("MinPetitionSigns", 9);
752  if (m_configs[CONFIG_MIN_PETITION_SIGNS] > 9)
753  {
754  sLog.outError("MinPetitionSigns (%i) must be in range 0..9. Set to 9.", m_configs[CONFIG_MIN_PETITION_SIGNS]);
755  m_configs[CONFIG_MIN_PETITION_SIGNS] = 9;
756  }
757 
758  m_configs[CONFIG_GM_LOGIN_STATE] = sConfig.GetIntDefault("GM.LoginState", 2);
759  m_configs[CONFIG_GM_VISIBLE_STATE] = sConfig.GetIntDefault("GM.Visible", 2);
760  m_configs[CONFIG_GM_CHAT] = sConfig.GetIntDefault("GM.Chat", 2);
761  m_configs[CONFIG_GM_WISPERING_TO] = sConfig.GetIntDefault("GM.WhisperingTo", 2);
762  m_configs[CONFIG_GM_IN_GM_LIST] = sConfig.GetBoolDefault("GM.InGMList", false);
763  m_configs[CONFIG_GM_IN_WHO_LIST] = sConfig.GetBoolDefault("GM.InWhoList", false);
764  m_configs[CONFIG_GM_MAIL] = sConfig.GetBoolDefault("GM.Mail", false);
765  m_configs[CONFIG_GM_LOG_TRADE] = sConfig.GetBoolDefault("GM.LogTrade", false);
766  m_configs[CONFIG_START_GM_LEVEL] = sConfig.GetIntDefault("GM.StartLevel", 1);
767  m_configs[CONFIG_ALLOW_GM_GROUP] = sConfig.GetBoolDefault("GM.AllowInvite", false);
768  m_configs[CONFIG_ALLOW_GM_FRIEND] = sConfig.GetBoolDefault("GM.AllowFriend", false);
769  if (m_configs[CONFIG_START_GM_LEVEL] < m_configs[CONFIG_START_PLAYER_LEVEL])
770  {
771  sLog.outError("GM.StartLevel (%i) must be in range StartPlayerLevel(%u)..%u. Set to %u.",
772  m_configs[CONFIG_START_GM_LEVEL], m_configs[CONFIG_START_PLAYER_LEVEL], MAX_LEVEL, m_configs[CONFIG_START_PLAYER_LEVEL]);
773  m_configs[CONFIG_START_GM_LEVEL] = m_configs[CONFIG_START_PLAYER_LEVEL];
774  }
775  else if (m_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL)
776  {
777  sLog.outError("GM.StartLevel (%i) must be in range 1..%u. Set to %u.", m_configs[CONFIG_START_GM_LEVEL], MAX_LEVEL, MAX_LEVEL);
778  m_configs[CONFIG_START_GM_LEVEL] = MAX_LEVEL;
779  }
780 
781  m_configs[CONFIG_CHANCE_OF_GM_SURVEY] = sConfig.GetFloatDefault("GM.TicketSystem.ChanceOfGMSurvey", 0.0f);
782 
783  m_configs[CONFIG_GROUP_VISIBILITY] = sConfig.GetIntDefault("Visibility.GroupMode", 1);
784 
785  m_configs[CONFIG_MAIL_DELIVERY_DELAY] = sConfig.GetIntDefault("MailDeliveryDelay", HOUR);
786 
787  m_configs[CONFIG_EXTERNAL_MAIL] = sConfig.GetIntDefault("ExternalMail", 0);
788  m_configs[CONFIG_EXTERNAL_MAIL_INTERVAL] = sConfig.GetIntDefault("ExternalMailInterval", 1);
789 
790  m_configs[CONFIG_UPTIME_UPDATE] = sConfig.GetIntDefault("UpdateUptimeInterval", 10);
791  if (int32(m_configs[CONFIG_UPTIME_UPDATE]) <= 0)
792  {
793  sLog.outError("UpdateUptimeInterval (%i) must be > 0, set to default 10.", m_configs[CONFIG_UPTIME_UPDATE]);
794  m_configs[CONFIG_UPTIME_UPDATE] = 10;
795  }
796  if (reload)
797  {
798  m_timers[WUPDATE_UPTIME].SetInterval(m_configs[CONFIG_UPTIME_UPDATE]*MINUTE * IN_MILLISECONDS);
800  }
801 
802  // log db cleanup interval
803  m_configs[CONFIG_LOGDB_CLEARINTERVAL] = sConfig.GetIntDefault("LogDB.Opt.ClearInterval", 10);
804  if (int32(m_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0)
805  {
806  sLog.outError("LogDB.Opt.ClearInterval (%i) must be > 0, set to default 10.", m_configs[CONFIG_LOGDB_CLEARINTERVAL]);
807  m_configs[CONFIG_LOGDB_CLEARINTERVAL] = 10;
808  }
809  if (reload)
810  {
811  m_timers[WUPDATE_CLEANDB].SetInterval(m_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILLISECONDS);
813  }
814  m_configs[CONFIG_LOGDB_CLEARTIME] = sConfig.GetIntDefault("LogDB.Opt.ClearTime", 1209600); // 14 days default
815  sLog.outString("Will clear `logs` table of entries older than %i seconds every %u minutes.",
816  m_configs[CONFIG_LOGDB_CLEARTIME], m_configs[CONFIG_LOGDB_CLEARINTERVAL]);
817 
818  m_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfig.GetIntDefault("SkillChance.Orange", 100);
819  m_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfig.GetIntDefault("SkillChance.Yellow", 75);
820  m_configs[CONFIG_SKILL_CHANCE_GREEN] = sConfig.GetIntDefault("SkillChance.Green", 25);
821  m_configs[CONFIG_SKILL_CHANCE_GREY] = sConfig.GetIntDefault("SkillChance.Grey", 0);
822 
823  m_configs[CONFIG_SKILL_CHANCE_MINING_STEPS] = sConfig.GetIntDefault("SkillChance.MiningSteps", 75);
824  m_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS] = sConfig.GetIntDefault("SkillChance.SkinningSteps", 75);
825 
826  m_configs[CONFIG_SKILL_PROSPECTING] = sConfig.GetBoolDefault("SkillChance.Prospecting", false);
827 
828  m_configs[CONFIG_SKILL_GAIN_CRAFTING] = sConfig.GetIntDefault("SkillGain.Crafting", 1);
829  m_configs[CONFIG_SKILL_GAIN_DEFENSE] = sConfig.GetIntDefault("SkillGain.Defense", 1);
830  m_configs[CONFIG_SKILL_GAIN_GATHERING] = sConfig.GetIntDefault("SkillGain.Gathering", 1);
831  m_configs[CONFIG_SKILL_GAIN_WEAPON] = sConfig.GetIntDefault("SkillGain.Weapon", 1);
832  m_configs[CONFIG_MAX_OVERSPEED_PINGS] = sConfig.GetIntDefault("MaxOverspeedPings", 2);
833  m_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY] = sConfig.GetBoolDefault("SaveRespawnTimeImmediately", true);
834  m_configs[CONFIG_WEATHER] = sConfig.GetBoolDefault("ActivateWeather", true);
835 
836  m_configs[CONFIG_DISABLE_BREATHING] = sConfig.GetIntDefault("DisableWaterBreath", SEC_CONSOLE);
837 
838  m_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL] = sConfig.GetBoolDefault("AlwaysMaxSkillForLevel", false);
839 
840  if (reload)
841  {
842  uint32 val = sConfig.GetIntDefault("Expansion", 1);
843  if (val != m_configs[CONFIG_EXPANSION])
844  sLog.outError("Expansion option can't be changed at Oregond.conf reload, using current value (%u).", m_configs[CONFIG_EXPANSION]);
845  }
846  else
847  m_configs[CONFIG_EXPANSION] = sConfig.GetIntDefault("Expansion", 1);
848 
849  m_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT] = sConfig.GetIntDefault("ChatFlood.MessageCount", 10);
850  m_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY] = sConfig.GetIntDefault("ChatFlood.MessageDelay", 1);
851  m_configs[CONFIG_CHATFLOOD_MUTE_TIME] = sConfig.GetIntDefault("ChatFlood.MuteTime", 10);
852 
853  m_configs[CONFIG_EVENT_ANNOUNCE] = sConfig.GetIntDefault("Event.Announce", 0);
854 
855  m_configs[CONFIG_CREATURE_PICKPOCKET_REFILL] = sConfig.GetIntDefault("Creature.PickPocketRefillDelay", 10 * MINUTE);
856 
857  m_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyFleeAssistanceRadius", 30);
858  m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS] = sConfig.GetIntDefault("CreatureFamilyAssistanceRadius", 10);
859  m_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = sConfig.GetIntDefault("CreatureFamilyAssistanceDelay", 1500);
860  m_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY] = sConfig.GetIntDefault("CreatureFamilyFleeDelay", 7000);
861 
862  m_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = sConfig.GetIntDefault("WorldBossLevelDiff", 3);
863 
864  // note: disable value (-1) will assigned as 0xFFFFFFF, to prevent overflow at calculations limit it to max possible player level MAX_LEVEL(100)
865  m_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.LowLevelHideDiff", 4);
868  m_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = sConfig.GetIntDefault("Quests.HighLevelHideDiff", 7);
871 
872  m_configs[CONFIG_DETECT_POS_COLLISION] = sConfig.GetBoolDefault("DetectPosCollision", true);
873 
874  m_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = sConfig.GetBoolDefault("Channel.RestrictedLfg", true);
875  m_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = sConfig.GetBoolDefault("Channel.SilentlyGMJoin", false);
876 
877  m_configs[CONFIG_TALENTS_INSPECTING] = sConfig.GetBoolDefault("TalentsInspecting", true);
878  m_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING] = sConfig.GetBoolDefault("ChatFakeMessagePreventing", false);
879  m_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY] = sConfig.GetIntDefault("ChatStrictLinkChecking.Severity", 0);
880  m_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_KICK] = sConfig.GetIntDefault("ChatStrictLinkChecking.Kick", 0);
881 
882  m_configs[CONFIG_CORPSE_DECAY_NORMAL] = sConfig.GetIntDefault("Corpse.Decay.NORMAL", 60);
883  m_configs[CONFIG_CORPSE_DECAY_RARE] = sConfig.GetIntDefault("Corpse.Decay.RARE", 300);
884  m_configs[CONFIG_CORPSE_DECAY_ELITE] = sConfig.GetIntDefault("Corpse.Decay.ELITE", 300);
885  m_configs[CONFIG_CORPSE_DECAY_RAREELITE] = sConfig.GetIntDefault("Corpse.Decay.RAREELITE", 300);
886  m_configs[CONFIG_CORPSE_DECAY_WORLDBOSS] = sConfig.GetIntDefault("Corpse.Decay.WORLDBOSS", 3600);
887 
888  m_configs[CONFIG_DEATH_SICKNESS_LEVEL] = sConfig.GetIntDefault ("Death.SicknessLevel", 11);
889  m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvP", true);
890  m_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE] = sConfig.GetBoolDefault("Death.CorpseReclaimDelay.PvE", true);
891  m_configs[CONFIG_DEATH_BONES_WORLD] = sConfig.GetBoolDefault("Death.Bones.World", true);
892  m_configs[CONFIG_DEATH_BONES_BG_OR_ARENA] = sConfig.GetBoolDefault("Death.Bones.BattlegroundOrArena", true);
893 
894  m_configs[CONFIG_DIE_COMMAND_MODE] = sConfig.GetBoolDefault("Die.Command.Mode", true);
895 
896  m_configs[CONFIG_THREAT_RADIUS] = sConfig.GetIntDefault("ThreatRadius", 60);
897 
898  // always use declined names in the russian client
899  m_configs[CONFIG_DECLINED_NAMES_USED] =
900  (m_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) ? true : sConfig.GetBoolDefault("DeclinedNames", false);
901 
902  m_configs[CONFIG_LISTEN_RANGE_SAY] = sConfig.GetIntDefault("ListenRange.Say", 25);
903  m_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfig.GetIntDefault("ListenRange.TextEmote", 25);
904  m_configs[CONFIG_LISTEN_RANGE_YELL] = sConfig.GetIntDefault("ListenRange.Yell", 300);
905 
906  m_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfig.GetBoolDefault("Battleground.CastDeserter", true);
907  m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.Enable", false);
908  m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.PlayerOnly", false);
909  m_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ONSTART] = sConfig.GetBoolDefault("Battleground.QueueAnnouncer.OnStart", false);
910  m_configs[CONFIG_BATTLEGROUND_PREMATURE_REWARD] = sConfig.GetBoolDefault("Battleground.PrematureReward", true);
911  m_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfig.GetIntDefault("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS);
912  m_configs[CONFIG_BATTLEGROUND_WRATH_LEAVE_MODE] = sConfig.GetBoolDefault("Battleground.LeaveWrathMode", false);
913  m_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = sConfig.GetIntDefault("Arena.MaxRatingDifference", 0);
914  m_configs[CONFIG_ARENA_RATING_DISCARD_TIMER] = sConfig.GetIntDefault("Arena.RatingDiscardTimer", 10 * MINUTE * IN_MILLISECONDS);
915  m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS] = sConfig.GetBoolDefault("Arena.AutoDistributePoints", false);
916  m_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS] = sConfig.GetIntDefault("Arena.AutoDistributeInterval", 7);
917  m_configs[CONFIG_ARENA_HIDE_FROM_SOCIAL] = sConfig.GetBoolDefault("Arena.HideFromSocial", false);
918  m_configs[CONFIG_ARENA_LOG_EXTENDED_INFO] = sConfig.GetBoolDefault("ArenaLogExtendedInfo", false);
919  m_configs[CONFIG_INSTANT_LOGOUT] = sConfig.GetIntDefault("InstantLogout", SEC_MODERATOR);
920 
921  //visibility on continents
922  m_MaxVisibleDistanceOnContinents = sConfig.GetFloatDefault("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE);
924  {
925  sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
927  }
929  {
930  sLog.outError("Visibility.Distance.Continents can't be greater %f", MAX_VISIBILITY_DISTANCE);
932  }
933 
934  //visibility in instances
935  m_MaxVisibleDistanceInInstances = sConfig.GetFloatDefault("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE);
937  {
938  sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
940  }
942  {
943  sLog.outError("Visibility.Distance.Instances can't be greater %f",MAX_VISIBILITY_DISTANCE);
945  }
946 
947  //visibility in BG/Arenas
948  m_MaxVisibleDistanceInBGArenas = sConfig.GetFloatDefault("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS);
950  {
951  sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
953  }
955  {
956  sLog.outError("Visibility.Distance.BGArenas can't be greater %f",MAX_VISIBILITY_DISTANCE);
958  }
959 
961  m_configs[CONFIG_CHARDELETE_METHOD] = sConfig.GetIntDefault("CharDelete.Method", 0);
962  m_configs[CONFIG_CHARDELETE_MIN_LEVEL] = sConfig.GetIntDefault("CharDelete.MinLevel", 0);
963  m_configs[CONFIG_CHARDELETE_KEEP_DAYS] = sConfig.GetIntDefault("CharDelete.KeepDays", 30);
964 
965  m_visibility_notify_periodOnContinents = sConfig.GetIntDefault("Visibility.Notify.Period.OnContinents", DEFAULT_VISIBILITY_NOTIFY_PERIOD);
966  m_visibility_notify_periodInInstances = sConfig.GetIntDefault("Visibility.Notify.Period.InInstances", DEFAULT_VISIBILITY_NOTIFY_PERIOD);
967  m_visibility_notify_periodInBGArenas = sConfig.GetIntDefault("Visibility.Notify.Period.InBGArenas", DEFAULT_VISIBILITY_NOTIFY_PERIOD);
968 
970  std::string dataPath = sConfig.GetStringDefault("DataDir", "./");
971  if (dataPath.empty() || (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\'))
972  dataPath.append("/");
973 
974  if (reload)
975  {
976  if (dataPath != m_dataPath)
977  sLog.outError("DataDir option can't be changed at oregoncore.conf reload, using current value (%s).", m_dataPath.c_str());
978  }
979  else
980  {
981  m_dataPath = dataPath;
982  sLog.outString("Using DataDir %s", m_dataPath.c_str());
983  }
984 
985  bool enableIndoor = sConfig.GetBoolDefault("vmap.enableIndoorCheck", true);
986  bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", true);
987  bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", true);
988  bool enablePetLOS = sConfig.GetBoolDefault("vmap.petLOS", true);
989  std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", "");
990 
991  if (!enableHeight)
992  sLog.outError("VMap height checking disabled! Creatures movements and other various things WILL be broken! Expect no support.");
993 
997  sLog.outString("WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i, PetLOS:%i", enableLOS, enableHeight, enableIndoor, enablePetLOS);
998  sLog.outString("WORLD: VMap data directory is: %svmaps", m_dataPath.c_str());
999 
1000  m_configs[CONFIG_PET_LOS] = enablePetLOS;
1001  m_configs[CONFIG_VMAP_TOTEM] = sConfig.GetBoolDefault("vmap.totem", false);
1002  m_configs[CONFIG_MAX_WHO] = sConfig.GetIntDefault("MaxWhoListReturns", 49);
1003 
1004  m_configs[CONFIG_BG_START_MUSIC] = sConfig.GetBoolDefault("MusicInBattleground", false);
1005  m_configs[CONFIG_START_ALL_SPELLS] = sConfig.GetBoolDefault("PlayerStart.AllSpells", false);
1006  m_configs[CONFIG_HONOR_AFTER_DUEL] = sConfig.GetIntDefault("HonorPointsAfterDuel", 0);
1007  m_configs[CONFIG_START_ALL_EXPLORED] = sConfig.GetBoolDefault("PlayerStart.MapsExplored", false);
1008  m_configs[CONFIG_START_ALL_REP] = sConfig.GetBoolDefault("PlayerStart.AllReputation", false);
1009  m_configs[CONFIG_ALWAYS_MAXSKILL] = sConfig.GetBoolDefault("AlwaysMaxWeaponSkill", false);
1010  m_configs[CONFIG_PVP_TOKEN_ENABLE] = sConfig.GetBoolDefault("PvPToken.Enable", false);
1011  m_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = sConfig.GetIntDefault("PvPToken.MapAllowType", 4);
1012  m_configs[CONFIG_PVP_TOKEN_ID] = sConfig.GetIntDefault("PvPToken.ItemID", 29434);
1013  m_configs[CONFIG_PVP_TOKEN_COUNT] = sConfig.GetIntDefault("PvPToken.ItemCount", 1);
1014  m_configs[CONFIG_NO_RESET_TALENT_COST] = sConfig.GetBoolDefault("NoResetTalentsCost", false);
1015  m_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfig.GetBoolDefault("ShowKickInWorld", false);
1016  m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000);
1017  m_configs[CONFIG_MIN_LOG_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeDiff", 100);
1018  m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads", 1);
1019  m_configs[CONFIG_DUEL_MOD] = sConfig.GetBoolDefault("DuelMod.Enable", false);
1020  m_configs[CONFIG_DUEL_CD_RESET] = sConfig.GetBoolDefault("DuelMod.Cooldowns", false);
1021  m_configs[CONFIG_AUTOBROADCAST_TIMER] = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000);
1022  m_configs[CONFIG_AUTOBROADCAST_ENABLED] = sConfig.GetIntDefault("AutoBroadcast.On", 0);
1023  m_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
1024 
1025  m_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS] = sConfig.GetIntDefault("Command.LookupMaxResults", 0);
1026 
1027  // chat logging
1028  m_configs[CONFIG_CHATLOG_CHANNEL] = sConfig.GetBoolDefault("ChatLogs.Channel", false);
1029  m_configs[CONFIG_CHATLOG_WHISPER] = sConfig.GetBoolDefault("ChatLogs.Whisper", false);
1030  m_configs[CONFIG_CHATLOG_SYSCHAN] = sConfig.GetBoolDefault("ChatLogs.SysChan", false);
1031  m_configs[CONFIG_CHATLOG_PARTY] = sConfig.GetBoolDefault("ChatLogs.Party", false);
1032  m_configs[CONFIG_CHATLOG_RAID] = sConfig.GetBoolDefault("ChatLogs.Raid", false);
1033  m_configs[CONFIG_CHATLOG_GUILD] = sConfig.GetBoolDefault("ChatLogs.Guild", false);
1034  m_configs[CONFIG_CHATLOG_PUBLIC] = sConfig.GetBoolDefault("ChatLogs.Public", false);
1035  m_configs[CONFIG_CHATLOG_ADDON] = sConfig.GetBoolDefault("ChatLogs.Addon", false);
1036  m_configs[CONFIG_CHATLOG_BGROUND] = sConfig.GetBoolDefault("ChatLogs.Battleground", false);
1037 
1038  // warden
1039  m_configs[CONFIG_WARDEN_ENABLED] = sConfig.GetBoolDefault("Warden.Enabled", false);
1040  m_configs[CONFIG_WARDEN_KICK] = sConfig.GetBoolDefault("Warden.Kick", false);
1041  m_configs[CONFIG_WARDEN_NUM_CHECKS] = sConfig.GetIntDefault("Warden.NumChecks", 3);
1042  m_configs[CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF] = sConfig.GetIntDefault("Warden.ClientCheckHoldOff", 30);
1043  m_configs[CONFIG_WARDEN_CLIENT_RESPONSE_DELAY] = sConfig.GetIntDefault("Warden.ClientResponseDelay", 15);
1044 
1045  // Refer-A-Friend
1046  m_configs[CONFIG_RAF_LEVEL_LIMIT] = sConfig.GetIntDefault("RAF.LevelLimit", 60);
1047 
1048  // mmaps
1049  m_configs[CONFIG_BOOL_MMAP_ENABLED] = sConfig.GetBoolDefault("mmap.enabled", true);
1050  std::string ignoreMMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", "");
1051  MMAP::MMapFactory::preventPathfindingOnMaps(ignoreMMapIds.c_str());
1052  sLog.outString("WORLD: MMap pathfinding %sabled.", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
1053 
1054  // Misc
1055  m_configs[CONFIG_UI_QUESTLEVELS_IN_DIALOGS] = sConfig.GetBoolDefault("UI.ShowQuestLevelsInDialogs", false);
1056  m_configs[CONFIG_HEALTH_IN_PERCENTS] = sConfig.GetBoolDefault("HealthInPercents", true);
1057 
1058  // SQLUpdater
1059  m_configs[CONFIG_SQLUPDATER_ENABLED] = sConfig.GetBoolDefault("DatabaseUpdater.Enabled", false);
1060  m_SQLUpdatesPath = sConfig.GetStringDefault("DatabaseUpdater.PathToUpdates", "");
1061  if (!m_SQLUpdatesPath.size() || (*m_SQLUpdatesPath.rbegin() != '\\' && *m_SQLUpdatesPath.rbegin() != '/'))
1062  #if PLATFORM == PLATFORM_WINDOWS
1063  m_SQLUpdatesPath += '\\';
1064  #else
1065  m_SQLUpdatesPath += '/';
1066  #endif
1067 }
void SetNewCharString(std::string str)
Definition: World.h:551
#define sConfig
Definition: Config.h:52
void setEnableLineOfSightCalc(bool pVal)
Definition: IVMapManager.h:78
std::string m_SQLUpdatesPath
Definition: World.h:854
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:41
static float m_MaxVisibleDistanceInInstances
Definition: World.h:828
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD
Definition: NGrid.h:28
#define sLog
Log class singleton.
Definition: Log.h:187
#define MAX_MONEY_AMOUNT
Definition: Player.h:742
ACE_INT32 int32
Definition: Define.h:67
#define DEFAULT_SOCKET_SELECT_TIME
Definition: SystemConfig.h:49
void SetInterval(time_t interval)
Definition: Timer.h:122
#define DEFAULT_MAX_LEVEL
Definition: DBCEnums.h:24
Definition: Common.h:179
IntervalTimer m_timers[WUPDATE_COUNT]
Definition: World.h:796
#define DEFAULT_VISIBILITY_BGARENAS
Definition: Object.h:42
static int32 m_visibility_notify_periodInBGArenas
Definition: World.h:833
std::string m_dataPath
Definition: World.h:824
static int32 m_visibility_notify_periodOnContinents
Definition: World.h:831
void SetPlayerLimit(int32 limit, bool needUpdate=false)
Definition: World.cpp:2573
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
#define MIN_MAP_UPDATE_DELAY
Definition: GridDefines.h:41
static int32 m_visibility_notify_periodInInstances
Definition: World.h:832
float rate_values[MAX_RATES]
Definition: World.h:815
static float m_MaxVisibleDistanceInBGArenas
Definition: World.h:829
#define DEFAULT_PLAYER_LIMIT
Definition: SystemConfig.h:46
void setEnableHeightCalc(bool pVal)
Definition: IVMapManager.h:83
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
void SetMotd(std::string motd)
Definition: World.h:540
static void preventSpellsFromBeingTestedForLoS(const char *pSpellIdString)
Definition: VMapFactory.cpp:77
void Reset()
Definition: Timer.h:113
Definition: Common.h:180
#define NOMINAL_MELEE_RANGE
Definition: Object.h:47
static void preventPathfindingOnMaps(const char *ignoreMapIds)
Definition: MoveMap.cpp:42
static IVMapManager * createOrGetVMapManager()
void SetMapUpdateInterval(uint32 t)
Definition: MapManager.h:72
uint32 getConfig(uint32 index) const
Definition: World.h:665
void SetGridCleanUpDelay(uint32 t)
Definition: MapManager.h:64
#define sWorld
Definition: World.h:860
#define CONTACT_DISTANCE
Definition: Object.h:34
ACE_UINT32 uint32
Definition: Define.h:71
static float m_MaxVisibleDistanceOnContinents
Definition: World.h:827
#define MAX_LEVEL
Definition: DBCEnums.h:28
#define DEFAULT_WORLDSERVER_PORT
Definition: SystemConfig.h:47
#define DEFAULT_VISIBILITY_DISTANCE
Definition: Object.h:40
void World::LoadDBVersion ( )

Definition at line 2584 of file World.cpp.

References Field::GetString(), m_DBVersion, Database::Query(), and WorldDatabase.

2585 {
2586  QueryResult_AutoPtr result = WorldDatabase.Query("SELECT db_version FROM version LIMIT 1");
2587  if (result)
2588  {
2589  Field* fields = result->Fetch();
2590 
2591  m_DBVersion = fields[0].GetString();
2592  }
2593  else
2594  m_DBVersion = "unknown world database";
2595 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
Definition: Field.h:24
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
std::string m_DBVersion
Definition: World.h:850
const char * GetString() const
Definition: Field.h:41
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
void World::LoadIp2nation ( )

Definition at line 1744 of file World.cpp.

References Database::Query(), sLog, and WorldDatabase.

Referenced by SetInitialWorldSettings().

1745 {
1746  QueryResult_AutoPtr result = WorldDatabase.Query("SELECT count(c.code) FROM ip2nationCountries c, ip2nation i WHERE c.code = i.country");
1747  uint32 count = 0;
1748 
1749  if (result)
1750  {
1751  Field* fields = result->Fetch();
1752  count = fields[0].GetUInt32();
1753  }
1754 
1755  sLog.outString(">> Loaded %u ip2nation definitions", count);
1756 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
Definition: Field.h:24
#define sLog
Log class singleton.
Definition: Log.h:187
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
ACE_UINT32 uint32
Definition: Define.h:71
void World::LoadOpcodeProtection ( )

Definition at line 1758 of file World.cpp.

References _protectedOpcodesProperties, ProtectedOpcodeProperties::interval, NUM_MSG_TYPES, opcodeTable, ProtectedOpcodeProperties::penalty, Database::Query(), sLog, OpcodeHandler::status, STATUS_PROTECTED, ProtectedOpcodeProperties::threshold, and WorldDatabase.

Referenced by SetInitialWorldSettings().

1759 {
1760  QueryResult_AutoPtr result = WorldDatabase.Query("SELECT `opcode`, `threshold`, `interval`, `penalty` FROM opcode_protection");
1761  uint64 count = 0;
1762 
1763  if (result)
1764  {
1765  do
1766  {
1767  Field* field = result->Fetch();
1769 
1770  uint32 opcode = field[0].GetUInt32();
1771  if (opcode >= NUM_MSG_TYPES)
1772  continue;
1773 
1774  prop.threshold = field[1].GetUInt32();
1775  prop.interval = field[2].GetUInt32();
1776  prop.penalty = (OpcodePenalty) field[3].GetUInt8();
1777 
1778  opcodeTable[opcode].status |= STATUS_PROTECTED;
1779  _protectedOpcodesProperties[opcode] = prop;
1780 
1781  count++;
1782  }
1783  while (result->NextRow());
1784  }
1785 
1786  sLog.outString(">> Loaded %lu opcode protections.", count);
1787 }
OpcodePenalty
What should happen if the threshold per interval is passed.
Definition: World.h:440
Using this opcode is time protected.
Definition: Opcodes.h:1104
OpcodeHandler opcodeTable[NUM_MSG_TYPES]
Definition: Opcodes.cpp:22
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
Definition: Field.h:24
#define sLog
Log class singleton.
Definition: Log.h:187
QueryResult_AutoPtr Query(const char *sql)
Definition: Database.cpp:383
unsigned long status
Definition: Opcodes.h:1112
uint32 threshold
Sets the maximum count one protected packet per Interval can be processed per session.
Definition: World.h:449
OpcodePenalty penalty
What should happen if the threshold per interval is passed.
Definition: World.h:451
Protected Opcode.
Definition: World.h:447
ACE_UINT64 uint64
Definition: Define.h:70
#define NUM_MSG_TYPES
Definition: Opcodes.h:1095
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
uint32 interval
Interval for threshold, in milliseconds.&#39;.
Definition: World.h:450
ACE_UINT32 uint32
Definition: Define.h:71
UNORDERED_MAP< uint32, ProtectedOpcodeProperties > _protectedOpcodesProperties
Definition: World.h:855
void World::LoadSQLUpdates ( )

Definition at line 1069 of file World.cpp.

References CharacterDatabase, LoadGameObjectModelList(), LoginDatabase, m_SQLUpdatesPath, sConsole, sLog, and WorldDatabase.

Referenced by SetInitialWorldSettings().

1070 {
1071  const struct
1072  {
1073  // db pointer
1074  Database* db;
1075  // path - sql/updates/(path)
1076  const char* path;
1077  } updates[]
1078  =
1079  {
1080  { &LoginDatabase, "realmd" },
1081  { &WorldDatabase, "world" },
1082  { &CharacterDatabase, "characters" }
1083  };
1084 
1085  // directory path
1086  std::string path;
1087  // label used for console output
1088  std::stringstream label;
1089  // files to be applied
1090  std::vector<std::string> files;
1091  // already applied before (from db)
1092  std::set<std::string> alreadyAppliedFiles;
1093 
1094  // iterate all three databases
1095  for (uint32 i = 0; i < 3; i++)
1096  {
1097  // clear from previous iteration
1098  files.clear();
1099  // clear from previous iteration
1100  alreadyAppliedFiles.clear();
1101 
1102  // refresh path
1103  path = m_SQLUpdatesPath;
1104  path += updates[i].path;
1105 
1106  // Get updates that were alraedy applied before
1107  if (QueryResult_AutoPtr result = updates[i].db->Query("SELECT `update` FROM `updates`"))
1108  {
1109  do
1110  alreadyAppliedFiles.insert(result->Fetch()[0].GetString());
1111  while (result->NextRow());
1112  }
1113 
1114  // Record current working directory
1115  char cwd[PATH_MAX];
1116  ACE_OS::getcwd(cwd, PATH_MAX);
1117 
1118  // Change current directory to sql/updates/(path)
1119  if (-1 == ACE_OS::chdir(path.c_str()))
1120  sLog.outFatal("Can't change directory to %s: %s", path.c_str(), strerror(errno));
1121 
1122  // get files in sql/updates/(path)/ directory
1123  if (ACE_DIR* dir = ACE_OS::opendir(path.c_str()))
1124  {
1125  while (ACE_DIRENT* entry = ACE_OS::readdir(dir))
1126  // continue only if file is not already applied
1127  if (alreadyAppliedFiles.find(entry->d_name) == alreadyAppliedFiles.end())
1128  // make sure the file is an .sql one
1129  if (!strcmp(entry->d_name + strlen(entry->d_name) - 4, ".sql"))
1130  files.push_back(entry->d_name);
1131 
1132  ACE_OS::closedir(dir);
1133  }
1134  else
1135  sLog.outFatal("Can't open %s: %s", path.c_str(), strerror(errno));
1136 
1137  // sort our files in ascending order
1138  std::sort(files.begin(), files.end());
1139 
1140  // iterate not applied files now
1141  for (size_t j = 0; j < files.size(); ++j)
1142  {
1143  label.str("");
1144  label << "Applying " << files[j].c_str() << " (" << (j + 1) << '/' << files.size() << ')';
1145  sConsole.SetLoadingLabel(label.str().c_str());
1146 
1147  if (updates[i].db->ExecuteFile(files[j].c_str()))
1148  {
1149  updates[i].db->escape_string(files[j]);
1150  updates[i].db->DirectPExecute("INSERT INTO `updates` VALUES ('%s', NOW())", files[j].c_str());
1151  }
1152  else
1153  sLog.outFatal("Failed to apply %s. See db_errors.log for more details.", files[j].c_str());
1154  }
1155 
1156  // Return to original working directory
1157  if (-1 == ACE_OS::chdir(cwd))
1158  sLog.outFatal("Can't change directory to %s: %s", cwd, strerror(errno));
1159  }
1160 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
std::string m_SQLUpdatesPath
Definition: World.h:854
#define sConsole
Definition: Console.h:99
#define sLog
Log class singleton.
Definition: Log.h:187
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
ACE_UINT32 uint32
Definition: Define.h:71
void World::ProcessCliCommands ( )

Definition at line 2430 of file World.cpp.

References cliCmdQueue, ChatHandler::HasSentErrorMessage(), CliCommandHolder::m_callbackArg, CliCommandHolder::m_command, CliCommandHolder::m_commandFinished, CliCommandHolder::m_print, ACE_Based::LockedQueue< T, LockType, StorageType >::next(), ChatHandler::ParseCommands(), and sLog.

Referenced by Update().

2431 {
2432  CliCommandHolder::Print* zprint = NULL;
2433  void* callbackArg = NULL;
2434  CliCommandHolder* command;
2435  while (cliCmdQueue.next(command))
2436  {
2437  sLog.outDebug("CLI command under processing...");
2438  zprint = command->m_print;
2439  callbackArg = command->m_callbackArg;
2440  CliHandler handler(callbackArg, zprint);
2441  handler.ParseCommands(command->m_command);
2442 
2443  if (command->m_commandFinished)
2444  command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage());
2445 
2446  delete command;
2447  }
2448 }
CommandFinished * m_commandFinished
Definition: World.h:423
char * m_command
Definition: World.h:420
ACE_Based::LockedQueue< CliCommandHolder *, ACE_Thread_Mutex > cliCmdQueue
Definition: World.h:836
#define sLog
Log class singleton.
Definition: Log.h:187
bool next(T &result)
Definition: LockedQueue.h:68
void Print(void *, const char *)
Definition: World.h:416
Print * m_print
Definition: World.h:421
void * m_callbackArg
Definition: World.h:419
void World::QueueCliCommand ( CliCommandHolder commandHolder)
inline

Definition at line 734 of file World.h.

735  {
736  cliCmdQueue.add(commandHolder);
737  }
ACE_Based::LockedQueue< CliCommandHolder *, ACE_Thread_Mutex > cliCmdQueue
Definition: World.h:836
void add(const T &item)
Definition: LockedQueue.h:55
void World::RecordTimeDiff ( const char *  text,
  ... 
)

Definition at line 1690 of file World.cpp.

References CONFIG_MIN_LOG_UPDATE, getMSTime(), getMSTimeDiff(), m_configs, m_currentTime, m_updateTimeCount, sLog, and vsnprintf.

Referenced by Update().

1691 {
1692  if (m_updateTimeCount != 1)
1693  return;
1694  if (!text)
1695  {
1697  return;
1698  }
1699 
1700  uint32 thisTime = getMSTime();
1701  uint32 diff = getMSTimeDiff(m_currentTime, thisTime);
1702 
1703  if (diff >= m_configs[CONFIG_MIN_LOG_UPDATE])
1704  {
1705  va_list ap;
1706  char str[256];
1707  va_start(ap, text);
1708  vsnprintf(str, 256, text, ap);
1709  va_end(ap);
1710  sLog.outDetail("Difftime %s: %u.", str, diff);
1711  }
1712 
1713  m_currentTime = thisTime;
1714 }
uint32 m_updateTimeCount
Definition: World.h:801
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:78
uint32 getMSTime()
Definition: Timer.h:32
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
uint32 m_currentTime
Definition: World.h:802
ACE_UINT32 uint32
Definition: Define.h:71
#define vsnprintf
Definition: Common.h:131
bool World::RemoveBanAccount ( BanMode  mode,
std::string  nameOrIP 
)

Definition at line 2264 of file World.cpp.

References BAN_ACCOUNT, BAN_CHARACTER, BAN_IP, Database::escape_string(), LoginDatabase, Database::PExecute(), sAccountMgr, and sObjectMgr.

2265 {
2266  if (mode == BAN_IP)
2267  {
2268  LoginDatabase.escape_string(nameOrIP);
2269  LoginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'", nameOrIP.c_str());
2270  }
2271  else
2272  {
2273  uint32 account = 0;
2274  if (mode == BAN_ACCOUNT)
2275  account = sAccountMgr->GetId (nameOrIP);
2276  else if (mode == BAN_CHARACTER)
2277  account = sObjectMgr.GetPlayerAccountIdByPlayerName (nameOrIP);
2278 
2279  if (!account)
2280  return false;
2281 
2282  //NO SQL injection as account is uint32
2283  LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'", account);
2284  }
2285  return true;
2286 }
unsigned long escape_string(char *to, const char *from, unsigned long length)
Definition: Database.cpp:212
#define sObjectMgr
Definition: ObjectMgr.h:1285
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
#define sAccountMgr
Definition: AccountMgr.h:60
ACE_UINT32 uint32
Definition: Define.h:71
bool World::RemoveQueuedPlayer ( WorldSession session)

Definition at line 312 of file World.cpp.

References GetActiveSessionCount(), m_playerLimit, m_QueuedPlayer, WorldSession::SendAuthWaitQue(), and WorldSession::SetInQueue().

Referenced by AddSession_(), and UpdateSessions().

313 {
314  // sessions count including queued to remove (if removed_session set)
315  uint32 sessions = GetActiveSessionCount();
316 
317  uint32 position = 1;
318  Queue::iterator iter = m_QueuedPlayer.begin();
319 
320  // search to remove and count skipped positions
321  bool found = false;
322 
323  for (; iter != m_QueuedPlayer.end(); ++iter, ++position)
324  {
325  if (*iter == sess)
326  {
327  sess->SetInQueue(false);
328  iter = m_QueuedPlayer.erase(iter);
329  found = true; // removing queued session
330  break;
331  }
332  }
333 
334  // iter point to next socked after removed or end()
335  // position store position of removed socket and then new position next socket after removed
336 
337  // if session not queued then we need decrease sessions count
338  if (!found && sessions)
339  --sessions;
340 
341  // accept first in queue
342  if ((!m_playerLimit || sessions < uint32(m_playerLimit)) && !m_QueuedPlayer.empty())
343  {
344  WorldSession* pop_sess = m_QueuedPlayer.front();
345  pop_sess->SetInQueue(false);
346  pop_sess->SendAuthWaitQue(0);
347  m_QueuedPlayer.pop_front();
348 
349  // update iter to point first queued socket or end() if queue is empty now
350  iter = m_QueuedPlayer.begin();
351  position = 1;
352  }
353 
354  // update position from iter to end()
355  // iter point to first not updated socket, position store new position
356  for (; iter != m_QueuedPlayer.end(); ++iter, ++position)
357  (*iter)->SendAuthWaitQue(position);
358 
359  return found;
360 }
void SendAuthWaitQue(uint32 position)
void SetInQueue(bool state)
Definition: WorldSession.h:129
Queue m_QueuedPlayer
Definition: World.h:843
ACE_UINT32 uint32
Definition: Define.h:71
int32 m_playerLimit
Definition: World.h:817
uint32 GetActiveSessionCount() const
Definition: World.h:476
bool World::RemoveSession ( uint32  id)

Definition at line 168 of file World.cpp.

References m_sessions.

Referenced by AddSession_().

169 {
170  // Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation
171  SessionMap::iterator itr = m_sessions.find(id);
172 
173  if (itr != m_sessions.end() && itr->second)
174  {
175  if (itr->second->PlayerLoading())
176  return false;
177  itr->second->KickPlayer();
178  }
179 
180  return true;
181 }
SessionMap m_sessions
Definition: World.h:807
void World::RemoveWeather ( uint32  zone_id)

Definition at line 374 of file World.cpp.

References m_weathers.

375 {
376  // not called at the moment. Kept for completeness
377  WeatherMap::iterator itr = m_weathers.find(id);
378 
379  if (itr != m_weathers.end())
380  {
381  delete itr->second;
382  m_weathers.erase(itr);
383  }
384 }
WeatherMap m_weathers
Definition: World.h:805
void World::ResetDailyQuests ( )
protected

Definition at line 2561 of file World.cpp.

References CharacterDatabase, Database::Execute(), m_sessions, sLog, and sPoolMgr.

Referenced by Update().

2562 {
2563  sLog.outDetail("Daily quests reset for all characters.");
2564  CharacterDatabase.Execute("DELETE FROM character_queststatus_daily");
2565  for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2566  if (itr->second->GetPlayer())
2567  itr->second->GetPlayer()->ResetDailyQuestStatus();
2568 
2569  // change available dailies
2570  sPoolMgr.ChangeDailyQuests();
2571 }
SessionMap m_sessions
Definition: World.h:807
bool Execute(const char *sql)
Definition: Database.cpp:420
#define sLog
Log class singleton.
Definition: Log.h:187
#define sPoolMgr
Definition: PoolMgr.h:162
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void World::SendAutoBroadcast ( )

Definition at line 2450 of file World.cpp.

References LANG_AUTO_BROADCAST, m_Autobroadcasts, sConfig, sLog, SMSG_NOTIFICATION, and sWorld.

Referenced by Update().

2451 {
2452  if (m_Autobroadcasts.empty())
2453  return;
2454 
2455  std::string msg;
2456 
2457  std::list<std::string>::const_iterator itr = m_Autobroadcasts.begin();
2458  std::advance(itr, rand() % m_Autobroadcasts.size());
2459  msg = *itr;
2460 
2461  uint32 abcenter = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
2462 
2463  if (abcenter == 0)
2464  sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
2465 
2466  else if (abcenter == 1)
2467  {
2468  WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
2469  data << msg;
2470  sWorld.SendGlobalMessage(&data);
2471  }
2472 
2473  else if (abcenter == 2)
2474  {
2475  sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());
2476 
2477  WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
2478  data << msg;
2479  sWorld.SendGlobalMessage(&data);
2480  }
2481 
2482  sLog.outString("AutoBroadcast: '%s'", msg.c_str());
2483 }
#define sConfig
Definition: Config.h:52
std::list< std::string > m_Autobroadcasts
Definition: World.h:853
#define sLog
Log class singleton.
Definition: Log.h:187
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
void World::SendGlobalGMMessage ( WorldPacket packet,
WorldSession self = 0,
uint32  team = 0 
)

Definition at line 1986 of file World.cpp.

References m_sessions, and SEC_PLAYER.

1987 {
1988  SessionMap::iterator itr;
1989  for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
1990  {
1991  if (itr->second &&
1992  itr->second->GetPlayer() &&
1993  itr->second->GetPlayer()->IsInWorld() &&
1994  itr->second != self &&
1995  itr->second->GetSecurity() > SEC_PLAYER &&
1996  (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
1997  itr->second->SendPacket(packet);
1998  }
1999 }
SessionMap m_sessions
Definition: World.h:807
void World::SendGlobalMessage ( WorldPacket packet,
WorldSession self = 0,
uint32  team = 0 
)

Definition at line 1971 of file World.cpp.

References m_sessions.

Referenced by SendGlobalText(), and SendServerMessage().

1972 {
1973  SessionMap::iterator itr;
1974  for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
1975  {
1976  if (itr->second &&
1977  itr->second->GetPlayer() &&
1978  itr->second->GetPlayer()->IsInWorld() &&
1979  itr->second != self &&
1980  (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
1981  itr->second->SendPacket(packet);
1982  }
1983 }
SessionMap m_sessions
Definition: World.h:807
void World::SendGlobalText ( const char *  text,
WorldSession self 
)

Definition at line 2110 of file World.cpp.

References CHAT_MSG_SYSTEM, ChatHandler::FillMessageData(), LANG_UNIVERSAL, ChatHandler::LineFromMessage(), and SendGlobalMessage().

2111 {
2112  WorldPacket data;
2113 
2114  // need copy to prevent corruption by strtok call in LineFromMessage original string
2115  char* buf = strdup(text);
2116  char* pos = buf;
2117 
2118  while (char* line = ChatHandler::LineFromMessage(pos))
2119  {
2120  ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL);
2121  SendGlobalMessage(&data, self);
2122  }
2123 
2124  free(buf);
2125 }
void SendGlobalMessage(WorldPacket *packet, WorldSession *self=0, uint32 team=0)
Definition: World.cpp:1971
static char * LineFromMessage(char *&pos)
Definition: Chat.h:61
static void FillMessageData(WorldPacket *data, WorldSession *session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker)
Definition: Chat.cpp:1515
void World::SendGMText ( int32  string_id,
  ... 
)

Definition at line 2055 of file World.cpp.

References CHAT_MSG_SYSTEM, ChatHandler::FillMessageData(), LANG_UNIVERSAL, ChatHandler::LineFromMessage(), m_sessions, SEC_PLAYER, sObjectMgr, and vsnprintf.

2056 {
2057  std::vector<std::vector<WorldPacket*> > data_cache; // 0 = default, i => i-1 locale index
2058 
2059  for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2060  {
2061  if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
2062  continue;
2063 
2064  uint32 loc_idx = itr->second->GetSessionDbLocaleIndex();
2065  uint32 cache_idx = loc_idx + 1;
2066 
2067  std::vector<WorldPacket*>* data_list;
2068 
2069  // create if not cached yet
2070  if (data_cache.size() < cache_idx + 1 || data_cache[cache_idx].empty())
2071  {
2072  if (data_cache.size() < cache_idx + 1)
2073  data_cache.resize(cache_idx + 1);
2074 
2075  data_list = &data_cache[cache_idx];
2076 
2077  char const* text = sObjectMgr.GetOregonString(string_id, loc_idx);
2078 
2079  char buf[1000];
2080 
2081  va_list argptr;
2082  va_start(argptr, string_id);
2083  vsnprintf(buf, 1000, text, argptr);
2084  va_end(argptr);
2085 
2086  char* pos = &buf[0];
2087 
2088  while (char* line = ChatHandler::LineFromMessage(pos))
2089  {
2090  WorldPacket* data = new WorldPacket();
2091  ChatHandler::FillMessageData(data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL);
2092  data_list->push_back(data);
2093  }
2094  }
2095  else
2096  data_list = &data_cache[cache_idx];
2097 
2098  for (uint32 i = 0; i < data_list->size(); ++i)
2099  if (itr->second->GetSecurity() > SEC_PLAYER)
2100  itr->second->SendPacket((*data_list)[i]);
2101  }
2102 
2103  // free memory
2104  for (uint32 i = 0; i < data_cache.size(); ++i)
2105  for (uint32 j = 0; j < data_cache[i].size(); ++j)
2106  delete data_cache[i][j];
2107 }
static char * LineFromMessage(char *&pos)
Definition: Chat.h:61
SessionMap m_sessions
Definition: World.h:807
#define sObjectMgr
Definition: ObjectMgr.h:1285
ACE_UINT32 uint32
Definition: Define.h:71
#define vsnprintf
Definition: Common.h:131
static void FillMessageData(WorldPacket *data, WorldSession *session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker)
Definition: Chat.cpp:1515
void World::SendServerMessage ( ServerMessageType  type,
const char *  text = "",
Player player = NULL 
)

Definition at line 2389 of file World.cpp.

References Player::GetSession(), SendGlobalMessage(), WorldSession::SendPacket(), SERVER_MSG_STRING, and SMSG_SERVER_MESSAGE.

Referenced by ShutdownCancel(), and ShutdownMsg().

2390 {
2391  WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size
2392  data << uint32(type);
2393  if (type <= SERVER_MSG_STRING)
2394  data << text;
2395 
2396  if (player)
2397  player->GetSession()->SendPacket(&data);
2398  else
2399  SendGlobalMessage(&data);
2400 }
void SendGlobalMessage(WorldPacket *packet, WorldSession *self=0, uint32 team=0)
Definition: World.cpp:1971
void SendPacket(WorldPacket const *packet)
WorldSession * GetSession() const
Definition: Player.h:1959
ACE_UINT32 uint32
Definition: Define.h:71
void World::SendWorldText ( int32  string_id,
  ... 
)

Definition at line 2002 of file World.cpp.

References CHAT_MSG_SYSTEM, ChatHandler::FillMessageData(), LANG_UNIVERSAL, ChatHandler::LineFromMessage(), m_sessions, sObjectMgr, and vsnprintf.

2003 {
2004  std::vector<std::vector<WorldPacket*> > data_cache; // 0 = default, i => i-1 locale index
2005 
2006  for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2007  {
2008  if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
2009  continue;
2010 
2011  uint32 loc_idx = itr->second->GetSessionDbLocaleIndex();
2012  uint32 cache_idx = loc_idx + 1;
2013 
2014  std::vector<WorldPacket*>* data_list;
2015 
2016  // create if not cached yet
2017  if (data_cache.size() < cache_idx + 1 || data_cache[cache_idx].empty())
2018  {
2019  if (data_cache.size() < cache_idx + 1)
2020  data_cache.resize(cache_idx + 1);
2021 
2022  data_list = &data_cache[cache_idx];
2023 
2024  char const* text = sObjectMgr.GetOregonString(string_id, loc_idx);
2025 
2026  char buf[1000];
2027 
2028  va_list argptr;
2029  va_start(argptr, string_id);
2030  vsnprintf(buf, 1000, text, argptr);
2031  va_end(argptr);
2032 
2033  char* pos = &buf[0];
2034 
2035  while (char* line = ChatHandler::LineFromMessage(pos))
2036  {
2037  WorldPacket* data = new WorldPacket();
2038  ChatHandler::FillMessageData(data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL);
2039  data_list->push_back(data);
2040  }
2041  }
2042  else
2043  data_list = &data_cache[cache_idx];
2044 
2045  for (uint32 i = 0; i < data_list->size(); ++i)
2046  itr->second->SendPacket((*data_list)[i]);
2047  }
2048 
2049  // free memory
2050  for (uint32 i = 0; i < data_cache.size(); ++i)
2051  for (uint32 j = 0; j < data_cache[i].size(); ++j)
2052  delete data_cache[i][j];
2053 }
static char * LineFromMessage(char *&pos)
Definition: Chat.h:61
SessionMap m_sessions
Definition: World.h:807
#define sObjectMgr
Definition: ObjectMgr.h:1285
ACE_UINT32 uint32
Definition: Define.h:71
#define vsnprintf
Definition: Common.h:131
static void FillMessageData(WorldPacket *data, WorldSession *session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker)
Definition: Chat.cpp:1515
bool World::SendZoneMessage ( uint32  zone,
WorldPacket packet,
WorldSession self = 0,
uint32  team = 0 
)

Definition at line 2128 of file World.cpp.

References m_sessions.

Referenced by SendZoneText().

2129 {
2130  bool foundPlayerToSend = false;
2131  SessionMap::iterator itr;
2132 
2133  for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
2134  {
2135  if (itr->second &&
2136  itr->second->GetPlayer() &&
2137  itr->second->GetPlayer()->IsInWorld() &&
2138  itr->second->GetPlayer()->GetZoneId() == zone &&
2139  itr->second != self &&
2140  (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
2141  {
2142  itr->second->SendPacket(packet);
2143  foundPlayerToSend = true;
2144  }
2145  }
2146 
2147  return foundPlayerToSend;
2148 }
SessionMap m_sessions
Definition: World.h:807
void World::SendZoneText ( uint32  zone,
const char *  text,
WorldSession self = 0,
uint32  team = 0 
)

Definition at line 2151 of file World.cpp.

References CHAT_MSG_SYSTEM, ChatHandler::FillMessageData(), LANG_UNIVERSAL, and SendZoneMessage().

2152 {
2153  WorldPacket data;
2154  ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, text, NULL);
2155  SendZoneMessage(zone, &data, self, team);
2156 }
bool SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self=0, uint32 team=0)
Definition: World.cpp:2128
static void FillMessageData(WorldPacket *data, WorldSession *session, uint8 type, uint32 language, const char *channelName, uint64 target_guid, const char *message, Unit *speaker)
Definition: Chat.cpp:1515
void World::SetAllowMovement ( bool  allow)
inline

Definition at line 534 of file World.h.

535  {
536  m_allowMovement = allow;
537  }
bool m_allowMovement
Definition: World.h:822
void World::setConfig ( uint32  index,
uint32  value 
)
inline

Definition at line 658 of file World.h.

References CONFIG_VALUE_COUNT, and value.

659  {
660  if (index < CONFIG_VALUE_COUNT)
661  m_configs[index] = value;
662  }
etc mysql my cnf *Then change max_allowed_packet to a bigger value
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
void World::SetInitialWorldSettings ( )

Definition at line 1165 of file World.cpp.

References _FULLVERSION, auctionbot, CharacterDatabase, CONFIG_AUTOBROADCAST_TIMER, CONFIG_EXPANSION, CONFIG_EXTERNAL_MAIL_INTERVAL, CONFIG_GAME_TYPE, CONFIG_LOGDB_CLEARINTERVAL, CONFIG_REALM_ZONE, CONFIG_SQLUPDATER_ENABLED, CONFIG_UPTIME_UPDATE, MMAP::MMapFactory::createOrGetMMapManager(), VMAP::VMapFactory::createOrGetVMapManager(), CreatureEAI_Mgr, DAY, Player::DeleteOldCharacters(), DetectDBCLang(), dtCustomAlloc(), dtCustomFree(), Database::Execute(), MapManager::ExistMapAndVMap(), extmail_timer, getConfig(), GetDefaultDbcLocale(), GetLiquidFlags(), getMSTime(), getMSTimeDiff(), HOUR, IN_MILLISECONDS, CWardenDataStorage::Init(), InitDailyQuestResetTime(), AIRegistry::Initialize(), MapManager::Initialize(), MMAP::MMapManager::InitializeThreadUnsafe(), Player::InitVisibleBits(), Oregon::Singleton< MapManager, Oregon::ClassLevelLockable< MapManager, ACE_Thread_Mutex > >::Instance(), IsFFAPvPRealm(), LoadAutobroadcasts(), LoadConfigSettings(), LoadDBCStores(), LoadGameObjectModelList(), LoadIp2nation(), LoadLootTables(), LoadM2Cameras(), LoadOpcodeProtection(), LoadRandomEnchantmentsTable(), LoadSkillDiscoveryTable(), LoadSkillExtraItemTable(), LoadSQLUpdates(), MapManager::LoadTransports(), LoginDatabase, m_configs, m_dataPath, m_gameTime, m_startTime, m_timers, mail_timer, mail_timer_expires, MINUTE, Database::PExecute(), REALM_TYPE_PVP, realmID, sAuctionMgr, sBattlegroundMgr, sConditionMgr, sConsole, sCreatureTextMgr, sDisableMgr, IntervalTimer::SetInterval(), sFormationMgr, sGameEventMgr, sInstanceSaveMgr, sLog, sMapStore, sObjectMgr, sOutdoorPvPMgr, sPoolMgr, sScriptMgr, sSmartScriptMgr, sSmartWaypointMgr, sSpellMgr, sWaypointMgr, ticketmgr, UI64FMTD, WardenDataStorage, WUPDATE_AUCTIONS, WUPDATE_AUTOBROADCAST, WUPDATE_CLEANDB, WUPDATE_CORPSES, WUPDATE_DELETECHARS, WUPDATE_EVENTS, WUPDATE_OBJECTS, WUPDATE_SESSIONS, WUPDATE_UPTIME, and WUPDATE_WEATHERS.

1166 {
1167  // Initialize the random number generator
1168  srand((unsigned int)time(NULL));
1169 
1170  // Initialize VMapManager's function pointers to fix linking between game/collision
1171  if (VMAP::VMapManager2* vmapMgr = dynamic_cast<VMAP::VMapManager2*>(VMAP::VMapFactory::createOrGetVMapManager()))
1172  vmapMgr->GetLiquidFlagsPtr = &GetLiquidFlags; // implemented in DBCStores.cpp
1173 
1174  // Time for server startup
1175  uint32 uStartTime = getMSTime();
1176 
1177  // Initialize detour memory management
1178  dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
1179 
1180  // Initialize config settings
1182 
1183  // Init highest guids before any table loading to prevent using not initialized guids in some code.
1184  sObjectMgr.SetHighestGuids();
1185 
1186  // Check the existence of the map files for all races' startup areas.
1187  if ((!MapManager::ExistMapAndVMap(0, -6240.32f, 331.033f)
1188  || !MapManager::ExistMapAndVMap(0, -8949.95f, -132.493f)
1189  || !MapManager::ExistMapAndVMap(1, -618.518f, -4251.67f)
1190  || !MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f)
1191  || !MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f)
1192  || !MapManager::ExistMapAndVMap(1, -2917.58f, -257.98f)
1193  || m_configs[CONFIG_EXPANSION]) &&
1194  (!MapManager::ExistMapAndVMap(530, 10349.6f, -6357.29f) || !MapManager::ExistMapAndVMap(530, -3961.64f, -13931.2f)))
1195  sLog.outError("Correct *.map files not found in path '%smaps' or *.vmtree/*.vmtile files in '%svmaps'. Please place *.map/*.vmtree/*.vmtile files in appropriate directories or correct the DataDir value in the oregoncore.conf file.", m_dataPath.c_str(), m_dataPath.c_str());
1196 
1197  // Loading strings. Getting no records means core load has to be canceled because no error message can be output.
1198  sConsole.SetLoadingLabel("Loading Oregon strings...");
1199  if (!sObjectMgr.LoadOregonStrings())
1200  exit(1); // Error message displayed in function already
1201 
1202  // Update the realm entry in the database with the realm type from the config file
1203  //No SQL injection as values are treated as integers
1204 
1205  // not send custom type REALM_FFA_PVP to realm list
1207  uint32 realm_zone = getConfig(CONFIG_REALM_ZONE);
1208  LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID);
1209 
1210  // Remove the bones (they should not exist in DB though) and old corpses after a restart
1211  CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3 * DAY);
1212 
1214  {
1215  sConsole.SetLoadingLabel("Applying SQL Updates...");
1216  LoadSQLUpdates();
1217  }
1218 
1219  // Load the DBC files
1220  sConsole.SetLoadingLabel("Initialize data stores...");
1222  DetectDBCLang();
1223 
1224  std::vector<uint32> mapIds;
1225  for (uint32 mapId = 0; mapId < sMapStore.GetNumRows(); mapId++)
1226  if (sMapStore.LookupEntry(mapId))
1227  mapIds.push_back(mapId);
1228 
1229  if (VMAP::VMapManager2* vmmgr2 = dynamic_cast<VMAP::VMapManager2*>(VMAP::VMapFactory::createOrGetVMapManager()))
1230  vmmgr2->InitializeThreadUnsafe(mapIds);
1231 
1233  mmmgr->InitializeThreadUnsafe(mapIds);
1234 
1236 
1237  sConsole.SetLoadingLabel("Loading Script Names...");
1238  sObjectMgr.LoadScriptNames();
1239 
1240  sConsole.SetLoadingLabel("Loading Instance Template...");
1241  sObjectMgr.LoadInstanceTemplate();
1242 
1243  sConsole.SetLoadingLabel("Loading SkillLineAbilityMultiMap Data...");
1244  sSpellMgr.LoadSkillLineAbilityMap();
1245 
1246  // Clean up and pack instances
1247  sConsole.SetLoadingLabel("Cleaning up instances...");
1248  sInstanceSaveMgr.CleanupInstances(); // must be called before `creature_respawn`/`gameobject_respawn` tables
1249 
1250  sConsole.SetLoadingLabel("Packing instances...");
1251  sInstanceSaveMgr.PackInstances();
1252 
1253  sConsole.SetLoadingLabel("Loading Localization strings...");
1254  sObjectMgr.LoadCreatureLocales();
1255  sObjectMgr.LoadGameObjectLocales();
1256  sObjectMgr.LoadItemLocales();
1257  sObjectMgr.LoadQuestLocales();
1258  sObjectMgr.LoadNpcTextLocales();
1259  sObjectMgr.LoadPageTextLocales();
1260  sObjectMgr.LoadGossipMenuItemsLocales();
1261  sObjectMgr.SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts)
1262  sConsole.SetLoadingLabel(">>> Localization strings loaded");
1263 
1264  sConsole.SetLoadingLabel("Loading Page Texts...");
1265  sObjectMgr.LoadPageTexts();
1266 
1267  sConsole.SetLoadingLabel("Loading Game Object Templates..."); // must be after LoadPageTexts
1268  sObjectMgr.LoadGameobjectInfo();
1269 
1270  sConsole.SetLoadingLabel("Loading Spell Chain Data...");
1271  sSpellMgr.LoadSpellChains();
1272 
1273  sConsole.SetLoadingLabel("Loading Spell Required Data...");
1274  sSpellMgr.LoadSpellRequired();
1275 
1276  sConsole.SetLoadingLabel("Loading Spell Group types...");
1277  sSpellMgr.LoadSpellGroups();
1278 
1279  sConsole.SetLoadingLabel("Loading Spell Learn Skills...");
1280  sSpellMgr.LoadSpellLearnSkills(); // must be after LoadSpellChains
1281 
1282  sConsole.SetLoadingLabel("Loading Spell Learn Spells...");
1283  sSpellMgr.LoadSpellLearnSpells();
1284 
1285  sConsole.SetLoadingLabel("Loading Spell Proc Event conditions...");
1286  sSpellMgr.LoadSpellProcEvents();
1287 
1288  sConsole.SetLoadingLabel("Loading Spell Dummy Conditions...");
1289  sSpellMgr.LoadSpellDummyCondition();
1290 
1291  sConsole.SetLoadingLabel("Loading Aggro Spells Definitions...");
1292  sSpellMgr.LoadSpellThreats();
1293 
1294  sConsole.SetLoadingLabel("Loading NPC Texts...");
1295  sObjectMgr.LoadGossipText();
1296 
1297  sConsole.SetLoadingLabel("Loading Spell Group Stack Rules...");
1298  sSpellMgr.LoadSpellGroupStackRules();
1299 
1300  sConsole.SetLoadingLabel("Loading Enchant Spells Proc datas...");
1301  sSpellMgr.LoadSpellEnchantProcData();
1302 
1303  sConsole.SetLoadingLabel("Loading Item Random Enchantments Table...");
1305 
1306  sConsole.SetLoadingLabel("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
1307  sObjectMgr.LoadItemTemplates();
1308 
1309  sConsole.SetLoadingLabel("Loading Item Texts...");
1310  sObjectMgr.LoadItemTexts();
1311 
1312  sConsole.SetLoadingLabel("Loading Creature Model Based Info Data...");
1313  sObjectMgr.LoadCreatureModelInfo();
1314 
1315  sConsole.SetLoadingLabel("Loading Equipment templates...");
1316  sObjectMgr.LoadEquipmentTemplates();
1317 
1318  sConsole.SetLoadingLabel("Loading Creature Base Stats...");
1319  sObjectMgr.LoadCreatureClassLevelStats();
1320 
1321  sConsole.SetLoadingLabel("Loading Creature templates...");
1322  sObjectMgr.LoadCreatureTemplates();
1323 
1324  sConsole.SetLoadingLabel("Loading Creature Reputation OnKill Data...");
1325  sObjectMgr.LoadReputationOnKill();
1326 
1327  sConsole.SetLoadingLabel("Loading Reputation Spillover Data...");
1328  sObjectMgr.LoadReputationSpilloverTemplate();
1329 
1330  sConsole.SetLoadingLabel("Loading Pet Create Spells...");
1331  sObjectMgr.LoadPetCreateSpells();
1332 
1333  sConsole.SetLoadingLabel("Loading Creature Data...");
1334  sObjectMgr.LoadCreatures();
1335 
1336  sConsole.SetLoadingLabel("Loading Temporary Summon Data...");
1337  sObjectMgr.LoadTempSummons(); // must be after LoadCreatureTemplates() and LoadGameObjectTemplates()
1338 
1339  sConsole.SetLoadingLabel("Loading Creature Linked Respawn...");
1340  sObjectMgr.LoadCreatureLinkedRespawn(); // must be after LoadCreatures()
1341 
1342  sConsole.SetLoadingLabel("Loading Creature Addon Data...");
1343  sObjectMgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
1344 
1345  sConsole.SetLoadingLabel("Loading Creature Respawn Data..."); // must be after PackInstances()
1346  sObjectMgr.LoadCreatureRespawnTimes();
1347 
1348  sConsole.SetLoadingLabel("Loading Gameobject Data...");
1349  sObjectMgr.LoadGameobjects();
1350 
1351  sConsole.SetLoadingLabel("Loading Gameobject Respawn Data..."); // must be after PackInstances()
1352  sObjectMgr.LoadGameobjectRespawnTimes();
1353 
1354  sConsole.SetLoadingLabel("Loading Objects Pooling Data...");
1355  sPoolMgr.LoadFromDB();
1356 
1357  sConsole.SetLoadingLabel("Loading Weather Data...");
1358  sObjectMgr.LoadWeatherZoneChances();
1359 
1360  sConsole.SetLoadingLabel("Loading Disables");
1361  sDisableMgr.LoadDisables(); // must be before loading quests
1362 
1363  sConsole.SetLoadingLabel("Loading Quests...");
1364  sObjectMgr.LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables
1365 
1366  sConsole.SetLoadingLabel("Checking Quest Disables");
1367  sDisableMgr.CheckQuestDisables(); // must be after loading quests
1368 
1369  sConsole.SetLoadingLabel("Loading Quests Relations...");
1370  sObjectMgr.LoadQuestRelations(); // must be after quest load
1371 
1372  sConsole.SetLoadingLabel("Loading Quest Pooling Data...");
1373  sPoolMgr.LoadQuestPools();
1374 
1375  sConsole.SetLoadingLabel("Loading Game Event Data..."); // must be after loading pools fully
1376  sGameEventMgr.LoadFromDB();
1377 
1378  sConsole.SetLoadingLabel("Loading AreaTrigger definitions...");
1379  sObjectMgr.LoadAreaTriggerTeleports();
1380 
1381  sConsole.SetLoadingLabel("Loading Access Requirements...");
1382  sObjectMgr.LoadAccessRequirements(); // must be after item template load
1383 
1384  sConsole.SetLoadingLabel("Loading Quest Area Triggers...");
1385  sObjectMgr.LoadQuestAreaTriggers(); // must be after LoadQuests
1386 
1387  sConsole.SetLoadingLabel("Loading Tavern Area Triggers...");
1388  sObjectMgr.LoadTavernAreaTriggers();
1389 
1390  sConsole.SetLoadingLabel("Loading AreaTrigger script names...");
1391  sObjectMgr.LoadAreaTriggerScripts();
1392 
1393  sConsole.SetLoadingLabel("Loading Graveyard-zone links...");
1394  sObjectMgr.LoadGraveyardZones();
1395 
1396  sConsole.SetLoadingLabel("Loading Spell target coordinates...");
1397  sSpellMgr.LoadSpellTargetPositions();
1398 
1399  sConsole.SetLoadingLabel("Loading SpellAffect definitions...");
1400  sSpellMgr.LoadSpellAffects();
1401 
1402  sConsole.SetLoadingLabel("Loading spell pet auras...");
1403  sSpellMgr.LoadSpellPetAuras();
1404 
1405  sConsole.SetLoadingLabel("Loading spell extra attributes...");
1406  sSpellMgr.LoadSpellCustomAttr();
1407 
1408  sLog.outString("Loading GameObject models...");
1410 
1411  sConsole.SetLoadingLabel("Loading linked spells...");
1412  sSpellMgr.LoadSpellLinked();
1413 
1414  sConsole.SetLoadingLabel("Loading custom spell cooldowns...");
1415  sSpellMgr.LoadSpellCustomCooldowns();
1416 
1417  sConsole.SetLoadingLabel("Loading Player Create Data...");
1418  sObjectMgr.LoadPlayerInfo();
1419 
1420  sConsole.SetLoadingLabel("Loading Exploration BaseXP Data...");
1421  sObjectMgr.LoadExplorationBaseXP();
1422 
1423  sConsole.SetLoadingLabel("Loading Pet Name Parts...");
1424  sObjectMgr.LoadPetNames();
1425 
1426  sConsole.SetLoadingLabel("Loading the max pet number...");
1427  sObjectMgr.LoadPetNumber();
1428 
1429  sConsole.SetLoadingLabel("Loading pet level stats...");
1430  sObjectMgr.LoadPetLevelInfo();
1431 
1432  sConsole.SetLoadingLabel("Loading Player Corpses...");
1433  sObjectMgr.LoadCorpses();
1434 
1435  sConsole.SetLoadingLabel("Loading Loot Tables...");
1436  LoadLootTables();
1437 
1438  sConsole.SetLoadingLabel("Loading Skill Discovery Table...");
1440 
1441  sConsole.SetLoadingLabel("Loading Skill Extra Item Table...");
1443 
1444  sConsole.SetLoadingLabel("Loading Skill Fishing base level requirements...");
1445  sObjectMgr.LoadFishingBaseSkillLevel();
1446 
1447  // Load dynamic data tables from the database
1448  sConsole.SetLoadingLabel("Loading Item Auctions...");
1449  sAuctionMgr->LoadAuctionItems();
1450  sConsole.SetLoadingLabel("Loading Auctions...");
1451  sAuctionMgr->LoadAuctions();
1452 
1453  sConsole.SetLoadingLabel("Loading Guilds...");
1454  sObjectMgr.LoadGuilds();
1455 
1456  sConsole.SetLoadingLabel("Loading ArenaTeams...");
1457  sObjectMgr.LoadArenaTeams();
1458 
1459  sConsole.SetLoadingLabel("Loading Groups...");
1460  sObjectMgr.LoadGroups();
1461 
1462  sConsole.SetLoadingLabel("Loading ReservedNames...");
1463  sObjectMgr.LoadReservedPlayersNames();
1464 
1465  sConsole.SetLoadingLabel("Loading GameObjects for quests...");
1466  sObjectMgr.LoadGameObjectForQuests();
1467 
1468  sConsole.SetLoadingLabel("Loading BattleMasters...");
1469  sObjectMgr.LoadBattleMastersEntry();
1470 
1471  sConsole.SetLoadingLabel("Loading GameTeleports...");
1472  sObjectMgr.LoadGameTele();
1473 
1474  sConsole.SetLoadingLabel("Loading Npc Text Id...");
1475  sObjectMgr.LoadNpcTextId(); // must be after load Creature and NpcText
1476 
1477  sConsole.SetLoadingLabel( "Loading Gossip scripts...");
1478  sObjectMgr.LoadGossipScripts(); // must be before gossip menu options
1479 
1480  sConsole.SetLoadingLabel("Loading Gossip menu...");
1481  sObjectMgr.LoadGossipMenu();
1482 
1483  sConsole.SetLoadingLabel("Loading Gossip menu options...");
1484  sObjectMgr.LoadGossipMenuItems();
1485 
1486  sConsole.SetLoadingLabel("Loading Vendors...");
1487  sObjectMgr.LoadVendors(); // must be after load CreatureTemplate and ItemTemplate
1488 
1489  sConsole.SetLoadingLabel("Loading Trainers...");
1490  sObjectMgr.LoadTrainerSpell(); // must be after load CreatureTemplate
1491 
1492  sConsole.SetLoadingLabel("Loading Waypoints...");
1493  sWaypointMgr->Load();
1494 
1495  sConsole.SetLoadingLabel("Loading SmartAI Waypoints...");
1496  sSmartWaypointMgr->LoadFromDB();
1497 
1498  sConsole.SetLoadingLabel("Loading Creature Formations...");
1499  sFormationMgr.LoadCreatureFormations();
1500 
1501  sConsole.SetLoadingLabel("Loading Conditions...");
1502  sConditionMgr.LoadConditions();
1503 
1504  sConsole.SetLoadingLabel("Loading GM tickets...");
1505  ticketmgr.LoadGMTickets();
1506 
1507  sConsole.SetLoadingLabel("Loading GM surveys...");
1508  ticketmgr.LoadGMSurveys();
1509 
1510  // Handle outdated emails (delete/return)
1511  sConsole.SetLoadingLabel("Returning old mails...");
1512  sObjectMgr.ReturnOrDeleteOldMails(false);
1513 
1514  sConsole.SetLoadingLabel("Loading Autobroadcasts...");
1516 
1517  sConsole.SetLoadingLabel("Loading Ip2nation...");
1518  LoadIp2nation();
1519 
1520  sConsole.SetLoadingLabel("Loading Refer-A-Friend...");
1521  sObjectMgr.LoadReferredFriends();
1522 
1523  sConsole.SetLoadingLabel("Loading Opcode Protection...");
1525 
1526  // Load and initialize scripts
1527  sConsole.SetLoadingLabel("Loading Scripts...");
1528  sObjectMgr.LoadQuestStartScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
1529  sObjectMgr.LoadQuestEndScripts(); // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
1530  sObjectMgr.LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data)
1531  sObjectMgr.LoadGameObjectScripts(); // must be after load Creature/Gameobject(Template/Data)
1532  sObjectMgr.LoadEventScripts(); // must be after load Creature/Gameobject(Template/Data)
1533  sObjectMgr.LoadWaypointScripts();
1534 
1535  sConsole.SetLoadingLabel("Loading Scripts text locales..."); // must be after Load*Scripts calls
1536  sObjectMgr.LoadDbScriptStrings();
1537 
1538  sConsole.SetLoadingLabel("Loading CreatureEventAI Texts...");
1539  CreatureEAI_Mgr.LoadCreatureEventAI_Texts(false); // false, will checked in LoadCreatureEventAI_Scripts
1540 
1541  sConsole.SetLoadingLabel("Loading CreatureEventAI Summons...");
1542  CreatureEAI_Mgr.LoadCreatureEventAI_Summons(false); // false, will checked in LoadCreatureEventAI_Scripts
1543 
1544  sConsole.SetLoadingLabel("Loading CreatureEventAI Scripts...");
1545  CreatureEAI_Mgr.LoadCreatureEventAI_Scripts();
1546 
1547  sConsole.SetLoadingLabel("Loading Creature Texts...");
1548  sCreatureTextMgr->LoadCreatureTexts();
1549 
1550  sConsole.SetLoadingLabel("Loading Creature Text Locales...");
1551  sCreatureTextMgr->LoadCreatureTextLocales();
1552 
1553  sConsole.SetLoadingLabel("Loading SmartAI scripts...");
1554  sSmartScriptMgr->LoadSmartAIFromDB();
1555 
1556  sConsole.SetLoadingLabel("Initializing Scripts...");
1557  sScriptMgr.ScriptsInit();
1558 
1559  // Initialize game time and timers
1560  sLog.outDebug("DEBUG:: Initialize game time and timers");
1561  m_gameTime = time(NULL);
1563 
1564  tm local;
1565  time_t curr;
1566  time(&curr);
1567  local = *(localtime(&curr)); // dereference and assign
1568 
1569  LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, uptime, revision) VALUES(%u, " UI64FMTD ", 0, '%s')",
1571 
1578  //Update "uptime" table based on configuration entry in minutes.
1579  m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS);
1580  //erase corpses every 20 minutes
1582  // clean logs table every 14 days by default
1583 
1584  m_timers[WUPDATE_DELETECHARS].SetInterval(DAY * IN_MILLISECONDS); // check for chars to delete every day
1585 
1586  //to set mailtimer to return mails every day between 4 and 5 am
1587  //mailtimer is increased when updating auctions
1588  //one second is 1000 -(tested on win system)
1589 
1590  // handle timer for external mail
1592 
1593  mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24) * HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval());
1594  //1440
1595  mail_timer_expires = ((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
1596  sLog.outDebug("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires);
1597 
1598  // Initialize static helper structures
1601 
1602  // Initialize MapManager
1603  sConsole.SetLoadingLabel("Starting Map System");
1605 
1606  sConsole.SetLoadingLabel("Starting Game Event system...");
1607  uint32 nextGameEvent = sGameEventMgr.Initialize();
1608  m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent); //depend on next event
1609 
1610  // Load Warden Data
1611  sConsole.SetLoadingLabel("Loading Warden Data..." );
1613 
1614  // Initialize Battlegrounds
1615  sConsole.SetLoadingLabel("Starting Battleground System");
1616  sBattlegroundMgr.CreateInitialBattlegrounds();
1617  sBattlegroundMgr.InitAutomaticArenaPointDistribution();
1618 
1619  // Initialize outdoor pvp
1620  sConsole.SetLoadingLabel("Starting Outdoor PvP System");
1621  sOutdoorPvPMgr.InitOutdoorPvP();
1622 
1623  //Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager
1624  sConsole.SetLoadingLabel("Loading Transports...");
1626 
1627  sConsole.SetLoadingLabel("Loading Transports Events...");
1628  sObjectMgr.LoadTransportEvents();
1629 
1630  sConsole.SetLoadingLabel("Deleting expired bans...", false);
1631  LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate");
1632 
1633  sConsole.SetLoadingLabel("Starting objects Pooling system...", false);
1634  sPoolMgr.Initialize();
1635 
1636  sConsole.SetLoadingLabel("Calculate next daily quest reset time...", false);
1638 
1639  sConsole.SetLoadingLabel("Initialize AuctionHouseBot...", false);
1640  auctionbot.Initialize();
1641 
1642  // Delete all characters which have been deleted X days before
1644 
1645  sConsole.SetLoadingLabel("WORLD: World initialized");
1646 
1647  // Print startup time
1648  uint32 uStartInterval = getMSTimeDiff(uStartTime, getMSTime());
1649  sLog.outString( "SERVER STARTUP TIME: %i minutes %i seconds", uStartInterval / 60000, (uStartInterval % 60000) / 1000 );
1650 }
uint32 mail_timer_expires
Definition: World.h:799
void LoadOpcodeProtection()
Definition: World.cpp:1758
uint32 GetLiquidFlags(uint32 liquidType)
Definition: DBCStores.cpp:714
void LoadLootTables()
Definition: LootMgr.h:431
#define CreatureEAI_Mgr
void LoadConfigSettings(bool reload=false)
Definition: World.cpp:403
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:79
#define sDisableMgr
Definition: DisableMgr.h:73
static void InitVisibleBits()
Definition: Player.cpp:3649
void * dtCustomAlloc(int size, dtAllocHint)
Definition: MoveMap.h:29
#define auctionbot
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:78
IntervalTimer extmail_timer
Definition: World.h:797
void DetectDBCLang()
Definition: World.cpp:1652
#define sConsole
Definition: Console.h:99
bool Execute(const char *sql)
Definition: Database.cpp:420
uint32 getMSTime()
Definition: Timer.h:32
#define sLog
Log class singleton.
Definition: Log.h:187
time_t m_gameTime
Definition: World.h:795
static bool ExistMapAndVMap(uint32 mapid, float x, float y)
Definition: MapManager.cpp:256
uint32 mail_timer
Definition: World.h:798
void LoadAutobroadcasts()
Definition: World.cpp:1716
void LoadSkillExtraItemTable()
#define sObjectMgr
Definition: ObjectMgr.h:1285
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
void SetInterval(time_t interval)
Definition: Timer.h:122
Definition: Common.h:181
void InitDailyQuestResetTime()
Definition: World.cpp:2514
Definition: Common.h:179
IntervalTimer m_timers[WUPDATE_COUNT]
Definition: World.h:796
void LoadGameObjectModelList()
void LoadSkillDiscoveryTable()
#define sWaypointMgr
#define UI64FMTD
Definition: Common.h:149
time_t m_startTime
Definition: World.h:794
#define sPoolMgr
Definition: PoolMgr.h:162
DatabaseType LoginDatabase
Accessor to the realm/login database.
Definition: Main.cpp:55
void InitializeThreadUnsafe(const std::vector< uint32 > &mapIds)
Definition: MoveMap.cpp:92
#define sSpellMgr
Definition: SpellMgr.h:1239
std::string m_dataPath
Definition: World.h:824
#define sCreatureTextMgr
CWardenDataStorage WardenDataStorage
Definition: WardenWin.cpp:35
void dtCustomFree(void *ptr)
Definition: MoveMap.h:34
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
#define sSmartWaypointMgr
#define sConditionMgr
Definition: ConditionMgr.h:312
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
#define _FULLVERSION
Definition: SystemConfig.h:40
static void DeleteOldCharacters()
Definition: Player.cpp:4109
#define sInstanceSaveMgr
bool IsFFAPvPRealm()
Definition: World.h:678
void LoadRandomEnchantmentsTable()
ACE_UINT64 uint64
Definition: Define.h:70
void Init(bool reload=false)
#define sGameEventMgr
Definition: GameEventMgr.h:179
void LoadTransports()
Definition: Transports.cpp:26
uint32 realmID
Id of the realm.
Definition: Main.cpp:57
Definition: Common.h:180
#define sFormationMgr
#define sAuctionMgr
#define sBattlegroundMgr
uint32 GetDefaultDbcLocale() const
Definition: World.h:561
static IVMapManager * createOrGetVMapManager()
void LoadSQLUpdates()
Definition: World.cpp:1069
void Initialize(void)
Definition: MapManager.cpp:53
static MMapManager * createOrGetMMapManager()
Definition: MoveMap.cpp:34
#define sScriptMgr
Definition: Group.h:526
uint32 getConfig(uint32 index) const
Definition: World.h:665
void LoadM2Cameras(std::string const &dataPath)
Definition: M2Stores.cpp:164
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54
void LoadDBCStores(const std::string &dataPath)
Definition: DBCStores.cpp:220
ACE_UINT32 uint32
Definition: Define.h:71
#define ticketmgr
Definition: TicketMgr.h:94
#define sSmartScriptMgr
void LoadIp2nation()
Definition: World.cpp:1744
void World::SetMotd ( std::string  motd)
inline

Definition at line 540 of file World.h.

Referenced by LoadConfigSettings().

541  {
542  m_motd = motd;
543  }
std::string m_motd
Definition: World.h:823
void World::SetNewCharString ( std::string  str)
inline

Definition at line 551 of file World.h.

Referenced by LoadConfigSettings().

552  {
553  m_newCharString = str;
554  }
std::string m_newCharString
Definition: World.h:813
void World::SetPlayerLimit ( int32  limit,
bool  needUpdate = false 
)

Definition at line 2573 of file World.cpp.

References m_playerLimit.

Referenced by LoadConfigSettings().

2574 {
2575  m_playerLimit = limit;
2576 }
int32 m_playerLimit
Definition: World.h:817
void World::SetPlayerSecurityLimit ( AccountTypes  sec)
inline

Definition at line 508 of file World.h.

References SEC_PLAYER.

509  {
510  m_allowedSecurityLevel = (sec < SEC_PLAYER ? SEC_PLAYER : sec);
511  }
AccountTypes m_allowedSecurityLevel
Definition: World.h:818
void World::setRate ( Rates  rate,
float  value 
)
inline

Definition at line 647 of file World.h.

References value.

648  {
649  rate_values[rate] = value;
650  }
etc mysql my cnf *Then change max_allowed_packet to a bigger value
float rate_values[MAX_RATES]
Definition: World.h:815
void World::SetRecordDiffInterval ( int32  t)
inline

Definition at line 592 of file World.h.

References CONFIG_INTERVAL_LOG_UPDATE.

593  {
594  if (t >= 0) m_configs[CONFIG_INTERVAL_LOG_UPDATE] = (uint32)t;
595  }
uint32 m_configs[CONFIG_VALUE_COUNT]
Definition: World.h:816
ACE_UINT32 uint32
Definition: Define.h:71
void World::SetScriptsVersion ( char const *  version)
inline

Definition at line 762 of file World.h.

763  {
764  m_ScriptsVersion = version ? version : "unknown scripting library";
765  }
std::string m_ScriptsVersion
Definition: World.h:851
void World::ShutdownCancel ( )

Definition at line 2372 of file World.cpp.

References DEBUG_LOG, m_ExitCode, m_ShutdownMask, m_ShutdownTimer, m_stopEvent, SendServerMessage(), SERVER_MSG_RESTART_CANCELLED, SERVER_MSG_SHUTDOWN_CANCELLED, SHUTDOWN_EXIT_CODE, and SHUTDOWN_MASK_RESTART.

2373 {
2374  // nothing cancel or too later
2375  if (!m_ShutdownTimer || m_stopEvent)
2376  return;
2377 
2379 
2380  m_ShutdownMask = 0;
2381  m_ShutdownTimer = 0;
2382  m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value
2383  SendServerMessage(msgid);
2384 
2385  DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown"));
2386 }
static uint8 m_ExitCode
Definition: World.h:787
uint32 m_ShutdownMask
Definition: World.h:789
#define DEBUG_LOG(...)
Definition: Log.h:194
void SendServerMessage(ServerMessageType type, const char *text="", Player *player=NULL)
Definition: World.cpp:2389
static volatile bool m_stopEvent
Definition: World.h:786
uint32 m_ShutdownTimer
Definition: World.h:788
ServerMessageType
Definition: World.h:43
void World::ShutdownMsg ( bool  show = false,
Player player = NULL 
)

Definition at line 2347 of file World.cpp.

References DEBUG_LOG, HOUR, m_ShutdownMask, m_ShutdownTimer, MINUTE, secsToTimeString(), SendServerMessage(), SERVER_MSG_RESTART_TIME, SERVER_MSG_SHUTDOWN_TIME, SHUTDOWN_MASK_IDLE, and SHUTDOWN_MASK_RESTART.

Referenced by _UpdateGameTime(), and ShutdownServ().

2348 {
2349  // not show messages for idle shutdown mode
2351  return;
2352 
2353  // Display a message every 12 hours, 1 hour, 5 minutes, 1 minute and 15 seconds
2354  if (show ||
2355  (m_ShutdownTimer <= 15) || // every sec down from 15 secs
2356  (m_ShutdownTimer < 5 * MINUTE && (m_ShutdownTimer % 15) == 0) || // < 5 min; every 15 sec
2357  (m_ShutdownTimer < 15 * MINUTE && (m_ShutdownTimer % MINUTE) == 0) || // < 15 min; every 1 min
2358  (m_ShutdownTimer < 30 * MINUTE && (m_ShutdownTimer % (5 * MINUTE)) == 0) || // < 30 min; every 5 min
2359  (m_ShutdownTimer < 12 * HOUR && (m_ShutdownTimer % HOUR) == 0) || // < 12 h; every 1 h
2360  (m_ShutdownTimer >= 12 * HOUR && (m_ShutdownTimer % (12 * HOUR)) == 0)) // >= 12 h; every 12 h
2361  {
2362  std::string str = secsToTimeString(m_ShutdownTimer);
2363 
2365 
2366  SendServerMessage(msgid, str.c_str(), player);
2367  DEBUG_LOG("Server is %s in %s", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutting down"), str.c_str());
2368  }
2369 }
Definition: Common.h:179
uint32 m_ShutdownMask
Definition: World.h:789
#define DEBUG_LOG(...)
Definition: Log.h:194
std::string secsToTimeString(uint32 timeInSecs, bool shortText, bool hoursOnly)
Definition: Util.cpp:148
void SendServerMessage(ServerMessageType type, const char *text="", Player *player=NULL)
Definition: World.cpp:2389
Definition: Common.h:180
uint32 m_ShutdownTimer
Definition: World.h:788
ServerMessageType
Definition: World.h:43
void World::ShutdownServ ( uint32  time,
uint32  options,
uint8  exitcode 
)

Definition at line 2321 of file World.cpp.

References GetActiveAndQueuedSessionCount(), m_ExitCode, m_ShutdownMask, m_ShutdownTimer, m_stopEvent, SHUTDOWN_MASK_IDLE, and ShutdownMsg().

2322 {
2323  // ignore if server shutdown at next tick
2324  if (m_stopEvent)
2325  return;
2326 
2327  m_ShutdownMask = options;
2328  m_ExitCode = exitcode;
2329 
2330  // If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
2331  if (time == 0)
2332  {
2333  if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
2334  m_stopEvent = true; // exist code already set
2335  else
2336  m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick
2337  }
2338  // Else set the shutdown timer and warn users
2339  else
2340  {
2341  m_ShutdownTimer = time;
2342  ShutdownMsg(true);
2343  }
2344 }