Minor styling tidy up

This commit is contained in:
Antz 2017-02-13 21:54:53 +00:00
parent 54dfa8af3b
commit cf04a9518e
2 changed files with 230 additions and 80 deletions

View File

@ -128,16 +128,24 @@ World::World()
m_availableDbcLocaleMask = 0; m_availableDbcLocaleMask = 0;
for (int i = 0; i < CONFIG_UINT32_VALUE_COUNT; ++i) for (int i = 0; i < CONFIG_UINT32_VALUE_COUNT; ++i)
{ m_configUint32Values[i] = 0; } {
m_configUint32Values[i] = 0;
}
for (int i = 0; i < CONFIG_INT32_VALUE_COUNT; ++i) for (int i = 0; i < CONFIG_INT32_VALUE_COUNT; ++i)
{ m_configInt32Values[i] = 0; } {
m_configInt32Values[i] = 0;
}
for (int i = 0; i < CONFIG_FLOAT_VALUE_COUNT; ++i) for (int i = 0; i < CONFIG_FLOAT_VALUE_COUNT; ++i)
{ m_configFloatValues[i] = 0.0f; } {
m_configFloatValues[i] = 0.0f;
}
for (int i = 0; i < CONFIG_BOOL_VALUE_COUNT; ++i) for (int i = 0; i < CONFIG_BOOL_VALUE_COUNT; ++i)
{ m_configBoolValues[i] = false; } {
m_configBoolValues[i] = false;
}
} }
/// World destructor /// World destructor
@ -153,11 +161,15 @@ World::~World()
CliCommandHolder* command = NULL; CliCommandHolder* command = NULL;
while (cliCmdQueue.next(command)) while (cliCmdQueue.next(command))
{ delete command; } {
delete command;
}
WorldSession* session = NULL; WorldSession* session = NULL;
while (addSessQueue.next(session)) while (addSessQueue.next(session))
{ delete session; } {
delete session;
}
VMAP::VMapFactory::clear(); VMAP::VMapFactory::clear();
MMAP::MMapFactory::clear(); MMAP::MMapFactory::clear();
@ -177,9 +189,13 @@ WorldSession* World::FindSession(uint32 id) const
SessionMap::const_iterator itr = m_sessions.find(id); SessionMap::const_iterator itr = m_sessions.find(id);
if (itr != m_sessions.end()) if (itr != m_sessions.end())
{ return itr->second; } // also can return NULL for kicked session {
return itr->second;
} // also can return NULL for kicked session
else else
{ return NULL; } {
return NULL;
}
} }
/// Remove a given session /// Remove a given session
@ -191,7 +207,9 @@ bool World::RemoveSession(uint32 id)
if (itr != m_sessions.end() && itr->second) if (itr != m_sessions.end() && itr->second)
{ {
if (itr->second->PlayerLoading()) if (itr->second->PlayerLoading())
{ return false; } {
return false;
}
itr->second->KickPlayer(); itr->second->KickPlayer();
} }
@ -231,7 +249,9 @@ World::AddSession_(WorldSession* s)
{ {
// prevent decrease sessions count if session queued // prevent decrease sessions count if session queued
if (RemoveQueuedSession(old->second)) if (RemoveQueuedSession(old->second))
{ decrease_session = false; } {
decrease_session = false;
}
// not remove replaced session form queue if listed // not remove replaced session form queue if listed
delete old->second; delete old->second;
} }
@ -246,7 +266,9 @@ World::AddSession_(WorldSession* s)
// so we don't count the user trying to // so we don't count the user trying to
// login as a session and queue the socket that we are using // login as a session and queue the socket that we are using
if (decrease_session) if (decrease_session)
{ --Sessions; } {
--Sessions;
}
if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity() == SEC_PLAYER) if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity() == SEC_PLAYER)
{ {
@ -288,7 +310,9 @@ int32 World::GetQueuedSessionPos(WorldSession* sess)
for (Queue::const_iterator iter = m_QueuedSessions.begin(); iter != m_QueuedSessions.end(); ++iter, ++position) for (Queue::const_iterator iter = m_QueuedSessions.begin(); iter != m_QueuedSessions.end(); ++iter, ++position)
if ((*iter) == sess) if ((*iter) == sess)
{ return position; } {
return position;
}
return 0; return 0;
} }
@ -336,7 +360,9 @@ bool World::RemoveQueuedSession(WorldSession* sess)
// if session not queued then we need decrease sessions count // if session not queued then we need decrease sessions count
if (!found && sessions) if (!found && sessions)
{ --sessions; } {
--sessions;
}
// accept first in queue // accept first in queue
if ((!m_playerLimit || (int32)sessions < m_playerLimit) && !m_QueuedSessions.empty()) if ((!m_playerLimit || (int32)sessions < m_playerLimit) && !m_QueuedSessions.empty())
@ -354,7 +380,9 @@ bool World::RemoveQueuedSession(WorldSession* sess)
// update position from iter to end() // update position from iter to end()
// iter point to first not updated socket, position store new position // iter point to first not updated socket, position store new position
for (; iter != m_QueuedSessions.end(); ++iter, ++position) for (; iter != m_QueuedSessions.end(); ++iter, ++position)
{ (*iter)->SendAuthWaitQue(position); } {
(*iter)->SendAuthWaitQue(position);
}
return found; return found;
} }
@ -485,12 +513,18 @@ void World::LoadConfigSettings(bool reload)
setConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL, "AutoBroadcast", 600); setConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL, "AutoBroadcast", 600);
if (getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) > 0) if (getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) > 0)
{ m_broadcastEnable = true; } {
m_broadcastEnable = true;
}
else else
{ m_broadcastEnable = false; } {
m_broadcastEnable = false;
}
if (reload && m_broadcastEnable) if (reload && m_broadcastEnable)
{ m_broadcastTimer.SetInterval(getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) * IN_MILLISECONDS); } {
m_broadcastTimer.SetInterval(getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) * IN_MILLISECONDS);
}
std::string forceLoadGridOnMaps = sConfig.GetStringDefault("LoadAllGridsOnMaps", ""); std::string forceLoadGridOnMaps = sConfig.GetStringDefault("LoadAllGridsOnMaps", "");
@ -509,24 +543,34 @@ void World::LoadConfigSettings(bool reload)
setConfigMin(CONFIG_UINT32_INTERVAL_GRIDCLEAN, "GridCleanUpDelay", 5 * MINUTE * IN_MILLISECONDS, MIN_GRID_DELAY); setConfigMin(CONFIG_UINT32_INTERVAL_GRIDCLEAN, "GridCleanUpDelay", 5 * MINUTE * IN_MILLISECONDS, MIN_GRID_DELAY);
if (reload) if (reload)
{ sMapMgr.SetGridCleanUpDelay(getConfig(CONFIG_UINT32_INTERVAL_GRIDCLEAN)); } {
sMapMgr.SetGridCleanUpDelay(getConfig(CONFIG_UINT32_INTERVAL_GRIDCLEAN));
}
setConfig(CONFIG_UINT32_NUMTHREADS, "MapUpdateThreads", 2); setConfig(CONFIG_UINT32_NUMTHREADS, "MapUpdateThreads", 2);
setConfigMin(CONFIG_UINT32_INTERVAL_MAPUPDATE, "MapUpdateInterval", 100, MIN_MAP_UPDATE_DELAY); setConfigMin(CONFIG_UINT32_INTERVAL_MAPUPDATE, "MapUpdateInterval", 100, MIN_MAP_UPDATE_DELAY);
if (reload) if (reload)
{ sMapMgr.SetMapUpdateInterval(getConfig(CONFIG_UINT32_INTERVAL_MAPUPDATE)); } {
sMapMgr.SetMapUpdateInterval(getConfig(CONFIG_UINT32_INTERVAL_MAPUPDATE));
}
setConfig(CONFIG_UINT32_INTERVAL_CHANGEWEATHER, "ChangeWeatherInterval", 10 * MINUTE * IN_MILLISECONDS); setConfig(CONFIG_UINT32_INTERVAL_CHANGEWEATHER, "ChangeWeatherInterval", 10 * MINUTE * IN_MILLISECONDS);
if (configNoReload(reload, CONFIG_UINT32_PORT_WORLD, "WorldServerPort", DEFAULT_WORLDSERVER_PORT)) if (configNoReload(reload, CONFIG_UINT32_PORT_WORLD, "WorldServerPort", DEFAULT_WORLDSERVER_PORT))
{ setConfig(CONFIG_UINT32_PORT_WORLD, "WorldServerPort", DEFAULT_WORLDSERVER_PORT); } {
setConfig(CONFIG_UINT32_PORT_WORLD, "WorldServerPort", DEFAULT_WORLDSERVER_PORT);
}
if (configNoReload(reload, CONFIG_UINT32_GAME_TYPE, "GameType", 0)) if (configNoReload(reload, CONFIG_UINT32_GAME_TYPE, "GameType", 0))
{ setConfig(CONFIG_UINT32_GAME_TYPE, "GameType", 0); } {
setConfig(CONFIG_UINT32_GAME_TYPE, "GameType", 0);
}
if (configNoReload(reload, CONFIG_UINT32_REALM_ZONE, "RealmZone", REALM_ZONE_DEVELOPMENT)) if (configNoReload(reload, CONFIG_UINT32_REALM_ZONE, "RealmZone", REALM_ZONE_DEVELOPMENT))
{ setConfig(CONFIG_UINT32_REALM_ZONE, "RealmZone", REALM_ZONE_DEVELOPMENT); } {
setConfig(CONFIG_UINT32_REALM_ZONE, "RealmZone", REALM_ZONE_DEVELOPMENT);
}
setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ACCOUNTS, "AllowTwoSide.Accounts", false); setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ACCOUNTS, "AllowTwoSide.Accounts", false);
setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT, "AllowTwoSide.Interaction.Chat", false); setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT, "AllowTwoSide.Interaction.Chat", false);
@ -559,7 +603,9 @@ void World::LoadConfigSettings(bool reload)
setConfigMinMax(CONFIG_UINT32_SKIP_CINEMATICS, "SkipCinematics", 0, 0, 2); setConfigMinMax(CONFIG_UINT32_SKIP_CINEMATICS, "SkipCinematics", 0, 0, 2);
if (configNoReload(reload, CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", DEFAULT_MAX_LEVEL)) if (configNoReload(reload, CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", DEFAULT_MAX_LEVEL))
{ setConfigMinMax(CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", DEFAULT_MAX_LEVEL, 1, DEFAULT_MAX_LEVEL); } {
setConfigMinMax(CONFIG_UINT32_MAX_PLAYER_LEVEL, "MaxPlayerLevel", DEFAULT_MAX_LEVEL, 1, DEFAULT_MAX_LEVEL);
}
setConfigMinMax(CONFIG_UINT32_START_PLAYER_LEVEL, "StartPlayerLevel", 1, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); setConfigMinMax(CONFIG_UINT32_START_PLAYER_LEVEL, "StartPlayerLevel", 1, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
@ -834,24 +880,34 @@ void World::LoadConfigSettings(bool reload)
setConfig(CONFIG_UINT32_CHARDELETE_KEEP_DAYS, "CharDelete.KeepDays", 30); setConfig(CONFIG_UINT32_CHARDELETE_KEEP_DAYS, "CharDelete.KeepDays", 30);
if (configNoReload(reload, CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE, "GuidReserveSize.Creature", 100)) if (configNoReload(reload, CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE, "GuidReserveSize.Creature", 100))
{ setConfig(CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE, "GuidReserveSize.Creature", 100); } {
setConfig(CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE, "GuidReserveSize.Creature", 100);
}
if (configNoReload(reload, CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT, "GuidReserveSize.GameObject", 100)) if (configNoReload(reload, CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT, "GuidReserveSize.GameObject", 100))
{ setConfig(CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT, "GuidReserveSize.GameObject", 100); } {
setConfig(CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT, "GuidReserveSize.GameObject", 100);
}
///- Read the "Data" directory from the config file ///- Read the "Data" directory from the config file
std::string dataPath = sConfig.GetStringDefault("DataDir", "./"); std::string dataPath = sConfig.GetStringDefault("DataDir", "./");
// for empty string use current dir as for absent case // for empty string use current dir as for absent case
if (dataPath.empty()) if (dataPath.empty())
{ dataPath = "./"; } {
dataPath = "./";
}
// normalize dir path to path/ or path\ form // normalize dir path to path/ or path\ form
else if (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\') else if (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\')
{ dataPath.append("/"); } {
dataPath.append("/");
}
if (reload) if (reload)
{ {
if (dataPath != m_dataPath) if (dataPath != m_dataPath)
{ sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).", m_dataPath.c_str()); } {
sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).", m_dataPath.c_str());
}
} }
else else
{ {
@ -865,7 +921,9 @@ void World::LoadConfigSettings(bool reload)
std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", "");
if (!enableHeight) if (!enableHeight)
{ sLog.outError("VMAP height use disabled! Creatures movements and other things will be in broken state."); } {
sLog.outError("VMAP height use disabled! Creatures movements and other things will be in broken state.");
}
VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS);
VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight); VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(enableHeight);
@ -1343,13 +1401,19 @@ void World::SetInitialWorldSettings()
// for AutoBroadcast // for AutoBroadcast
sLog.outString("Starting AutoBroadcast System"); sLog.outString("Starting AutoBroadcast System");
if (m_broadcastEnable) if (m_broadcastEnable)
{ LoadBroadcastStrings(); } {
LoadBroadcastStrings();
}
else else
{ sLog.outString("AutoBroadcast is disabled");} {
sLog.outString("AutoBroadcast is disabled");
}
sLog.outString(); sLog.outString();
if (m_broadcastEnable) if (m_broadcastEnable)
{ m_broadcastTimer.SetInterval(getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) * IN_MILLISECONDS); } {
m_broadcastTimer.SetInterval(getConfig(CONFIG_UINT32_AUTOBROADCAST_INTERVAL) * IN_MILLISECONDS);
}
// to set mailtimer to return mails every day between 4 and 5 am // to set mailtimer to return mails every day between 4 and 5 am
// mailtimer is increased when updating auctions // mailtimer is increased when updating auctions
@ -1490,17 +1554,25 @@ void World::Update(uint32 diff)
for (int i = 0; i < WUPDATE_COUNT; ++i) for (int i = 0; i < WUPDATE_COUNT; ++i)
{ {
if (m_timers[i].GetCurrent() >= 0) if (m_timers[i].GetCurrent() >= 0)
{ m_timers[i].Update(diff); } {
m_timers[i].Update(diff);
}
else else
{ m_timers[i].SetCurrent(0); } {
m_timers[i].SetCurrent(0);
}
} }
if (m_broadcastEnable) if (m_broadcastEnable)
{ {
if (m_broadcastTimer.GetCurrent() >= 0) if (m_broadcastTimer.GetCurrent() >= 0)
{ m_broadcastTimer.Update(diff); } {
m_broadcastTimer.Update(diff);
}
else else
{ m_broadcastTimer.SetCurrent(0); } {
m_broadcastTimer.SetCurrent(0);
}
if (m_broadcastTimer.Passed()) if (m_broadcastTimer.Passed())
{ {
@ -1613,7 +1685,9 @@ void World::Update(uint32 diff)
m_MaintenanceTimeChecker = 600000; // check 10 minutes m_MaintenanceTimeChecker = 600000; // check 10 minutes
} }
else else
{ m_MaintenanceTimeChecker -= diff; } {
m_MaintenanceTimeChecker -= diff;
}
// And last, but not least handle the issued cli commands // And last, but not least handle the issued cli commands
ProcessCliCommands(); ProcessCliCommands();
@ -1646,7 +1720,9 @@ namespace MaNGOS
do_helper(data_list, &str[0]); do_helper(data_list, &str[0]);
} }
else else
{ do_helper(data_list, (char*)text); } {
do_helper(data_list, (char*)text);
}
} }
private: private:
char* lineFromMessage(char*& pos) char* lineFromMessage(char*& pos)
@ -1686,7 +1762,9 @@ void World::SendWorldText(int32 string_id, ...)
{ {
Player* player = session->GetPlayer(); Player* player = session->GetPlayer();
if (player && player->IsInWorld()) if (player && player->IsInWorld())
{ wt_do(player); } {
wt_do(player);
}
} }
} }
@ -1704,7 +1782,9 @@ void World::SendGlobalMessage(WorldPacket* packet, AccountTypes minSec)
continue; continue;
Player* player = session->GetPlayer(); Player* player = session->GetPlayer();
if (player && player->IsInWorld()) if (player && player->IsInWorld())
{ session->SendPacket(packet); } {
session->SendPacket(packet);
}
} }
} }
} }
@ -1717,9 +1797,13 @@ void World::SendServerMessage(ServerMessageType type, const char* text /*=""*/,
data << text; data << text;
if (player) if (player)
{ player->GetSession()->SendPacket(&data); } {
player->GetSession()->SendPacket(&data);
}
else else
{ SendGlobalMessage(&data); } {
SendGlobalMessage(&data);
}
} }
/// Sends a zone under attack message to all players not in an instance /// Sends a zone under attack message to all players not in an instance
@ -1734,7 +1818,9 @@ void World::SendZoneUnderAttackMessage(uint32 zoneId, Team team)
{ {
Player* player = session->GetPlayer(); Player* player = session->GetPlayer();
if (player && player->IsInWorld() && player->GetTeam() == team && !player->GetMap()->Instanceable()) if (player && player->IsInWorld() && player->GetTeam() == team && !player->GetMap()->Instanceable())
{ itr->second->SendPacket(&data); } {
itr->second->SendPacket(&data);
}
} }
} }
} }
@ -1769,7 +1855,9 @@ void World::KickAll()
// session not removed at kick and will removed in next update tick // session not removed at kick and will removed in next update tick
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
{ itr->second->KickPlayer(); } {
itr->second->KickPlayer();
}
} }
/// Kick (and save) all players with security level less `sec` /// Kick (and save) all players with security level less `sec`
@ -1779,7 +1867,9 @@ void World::KickAllLess(AccountTypes sec)
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (WorldSession* session = itr->second) if (WorldSession* session = itr->second)
if (session->GetSecurity() < sec) if (session->GetSecurity() < sec)
{ session->KickPlayer(); } {
session->KickPlayer();
}
} }
/// Ban an account or ban an IP address, duration_secs if it is positive used, otherwise permban /// Ban an account or ban an IP address, duration_secs if it is positive used, otherwise permban
@ -1815,9 +1905,13 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_
if (!resultAccounts) if (!resultAccounts)
{ {
if (mode == BAN_IP) if (mode == BAN_IP)
{ return BAN_SUCCESS; } // ip correctly banned but nobody affected (yet) {
return BAN_SUCCESS;
} // ip correctly banned but nobody affected (yet)
else else
{ return BAN_NOTFOUND; } // Nobody to ban {
return BAN_NOTFOUND;
} // Nobody to ban
} }
///- Disconnect all affected players (for IP it can be several) ///- Disconnect all affected players (for IP it can be several)
@ -1835,9 +1929,10 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_
if (WorldSession* sess = FindSession(account)) if (WorldSession* sess = FindSession(account))
if (std::string(sess->GetPlayerName()) != author) if (std::string(sess->GetPlayerName()) != author)
{ sess->KickPlayer(); } {
sess->KickPlayer();
} }
while (resultAccounts->NextRow()); } while (resultAccounts->NextRow());
delete resultAccounts; delete resultAccounts;
return BAN_SUCCESS; return BAN_SUCCESS;
@ -1855,12 +1950,18 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
{ {
uint32 account = 0; uint32 account = 0;
if (mode == BAN_ACCOUNT) if (mode == BAN_ACCOUNT)
{ account = sAccountMgr.GetId(nameOrIP); } {
account = sAccountMgr.GetId(nameOrIP);
}
else if (mode == BAN_CHARACTER) else if (mode == BAN_CHARACTER)
{ account = sObjectMgr.GetPlayerAccountIdByPlayerName(nameOrIP); } {
account = sObjectMgr.GetPlayerAccountIdByPlayerName(nameOrIP);
}
if (!account) if (!account)
{ return false; } {
return false;
}
// NO SQL injection as account is uint32 // NO SQL injection as account is uint32
LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'", account); LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'", account);
@ -1883,9 +1984,13 @@ void World::_UpdateGameTime()
if (m_ShutdownTimer <= elapsed) if (m_ShutdownTimer <= elapsed)
{ {
if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0) if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
{ m_stopEvent = true; } // exist code already set {
m_stopEvent = true;
} // exist code already set
else else
{ m_ShutdownTimer = 1; } // minimum timer value to wait idle state {
m_ShutdownTimer = 1;
} // minimum timer value to wait idle state
} }
///- ... else decrease it and if necessary display a shutdown countdown to the users ///- ... else decrease it and if necessary display a shutdown countdown to the users
else else
@ -1902,7 +2007,9 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
{ {
// ignore if server shutdown at next tick // ignore if server shutdown at next tick
if (m_stopEvent) if (m_stopEvent)
{ return; } {
return;
}
m_ShutdownMask = options; m_ShutdownMask = options;
m_ExitCode = exitcode; m_ExitCode = exitcode;
@ -1916,7 +2023,9 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
m_stopEvent = true; // exist code already set m_stopEvent = true; // exist code already set
} }
else else
{ m_ShutdownTimer = 1; } // So that the session count is re-evaluated at next world tick {
m_ShutdownTimer = 1;
} // So that the session count is re-evaluated at next world tick
} }
///- Else set the shutdown timer and warn users ///- Else set the shutdown timer and warn users
else else
@ -1940,7 +2049,9 @@ void World::ShutdownMsg(bool show /*= false*/, Player* player /*= NULL*/)
{ {
// not show messages for idle shutdown mode // not show messages for idle shutdown mode
if (m_ShutdownMask & SHUTDOWN_MASK_IDLE) if (m_ShutdownMask & SHUTDOWN_MASK_IDLE)
{ return; } {
return;
}
///- Display a message every 12 hours, 1 hour, 5 minutes, 1 minute and 15 seconds ///- Display a message every 12 hours, 1 hour, 5 minutes, 1 minute and 15 seconds
if (show || if (show ||
@ -1964,7 +2075,9 @@ void World::ShutdownCancel()
{ {
// nothing cancel or too later // nothing cancel or too later
if (!m_ShutdownTimer || m_stopEvent) if (!m_ShutdownTimer || m_stopEvent)
{ return; } {
return;
}
ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED; ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED;
@ -1986,7 +2099,9 @@ void World::UpdateSessions(uint32 /*diff*/)
///- Add new sessions ///- Add new sessions
WorldSession* sess; WorldSession* sess;
while (addSessQueue.next(sess)) while (addSessQueue.next(sess))
{ AddSession_(sess); } {
AddSession_(sess);
}
///- Then send an update signal to remaining ones ///- Then send an update signal to remaining ones
for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next) for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next)
@ -2012,7 +2127,9 @@ void World::ServerMaintenanceStart()
m_NextMaintenanceDate = LastWeekEnd + 7; // next maintenance begin m_NextMaintenanceDate = LastWeekEnd + 7; // next maintenance begin
if (m_NextMaintenanceDate <= GetDateToday()) // avoid loop in manually case, maybe useless if (m_NextMaintenanceDate <= GetDateToday()) // avoid loop in manually case, maybe useless
{ m_NextMaintenanceDate += 7; } {
m_NextMaintenanceDate += 7;
}
// flushing rank points list ( standing must be reloaded after server maintenance ) // flushing rank points list ( standing must be reloaded after server maintenance )
sObjectMgr.FlushRankPoints(LastWeekEnd); sObjectMgr.FlushRankPoints(LastWeekEnd);
@ -2020,7 +2137,9 @@ void World::ServerMaintenanceStart()
// save and update all online players // save and update all online players
for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld()) if (itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld())
{ itr->second->GetPlayer()->SaveToDB(); } {
itr->second->GetPlayer()->SaveToDB();
}
CharacterDatabase.PExecute("UPDATE saved_variables SET NextMaintenanceDate = '" UI64FMTD "'", uint64(m_NextMaintenanceDate)); CharacterDatabase.PExecute("UPDATE saved_variables SET NextMaintenanceDate = '" UI64FMTD "'", uint64(m_NextMaintenanceDate));
} }
@ -2042,7 +2161,9 @@ void World::InitServerMaintenanceCheck()
} }
if (m_NextMaintenanceDate <= GetDateToday()) if (m_NextMaintenanceDate <= GetDateToday())
{ ServerMaintenanceStart(); } {
ServerMaintenanceStart();
}
DEBUG_LOG("Server maintenance check initialized."); DEBUG_LOG("Server maintenance check initialized.");
} }
@ -2060,7 +2181,9 @@ void World::ProcessCliCommands()
handler.ParseCommands(command->m_command); handler.ParseCommands(command->m_command);
if (command->m_commandFinished) if (command->m_commandFinished)
{ command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage()); } {
command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage());
}
delete command; delete command;
} }
@ -2102,7 +2225,9 @@ void World::_UpdateRealmCharCount(QueryResult* resultCharCount, uint32 accountId
void World::SetPlayerLimit(int32 limit, bool needUpdate) void World::SetPlayerLimit(int32 limit, bool needUpdate)
{ {
if (limit < -SEC_ADMINISTRATOR) if (limit < -SEC_ADMINISTRATOR)
{ limit = -SEC_ADMINISTRATOR; } {
limit = -SEC_ADMINISTRATOR;
}
// lock update need // lock update need
bool db_update_need = needUpdate || (limit < 0) != (m_playerLimit < 0) || (limit < 0 && m_playerLimit < 0 && limit != m_playerLimit); bool db_update_need = needUpdate || (limit < 0) != (m_playerLimit < 0) || (limit < 0 && m_playerLimit < 0 && limit != m_playerLimit);
@ -2140,7 +2265,9 @@ void World::LoadDBVersion()
} }
if (m_DBVersion.empty()) if (m_DBVersion.empty())
{ m_DBVersion = "Unknown world database."; } {
m_DBVersion = "Unknown world database.";
}
} }
void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue) void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue)
@ -2256,11 +2383,15 @@ void World::setConfigMinMax(eConfigFloatValues index, char const* fieldname, flo
bool World::configNoReload(bool reload, eConfigUInt32Values index, char const* fieldname, uint32 defvalue) bool World::configNoReload(bool reload, eConfigUInt32Values index, char const* fieldname, uint32 defvalue)
{ {
if (!reload) if (!reload)
{ return true; } {
return true;
}
uint32 val = sConfig.GetIntDefault(fieldname, defvalue); uint32 val = sConfig.GetIntDefault(fieldname, defvalue);
if (val != getConfig(index)) if (val != getConfig(index))
{ sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%u).", fieldname, getConfig(index)); } {
sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%u).", fieldname, getConfig(index));
}
return false; return false;
} }
@ -2268,11 +2399,15 @@ bool World::configNoReload(bool reload, eConfigUInt32Values index, char const* f
bool World::configNoReload(bool reload, eConfigInt32Values index, char const* fieldname, int32 defvalue) bool World::configNoReload(bool reload, eConfigInt32Values index, char const* fieldname, int32 defvalue)
{ {
if (!reload) if (!reload)
{ return true; } {
return true;
}
int32 val = sConfig.GetIntDefault(fieldname, defvalue); int32 val = sConfig.GetIntDefault(fieldname, defvalue);
if (val != getConfig(index)) if (val != getConfig(index))
{ sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%i).", fieldname, getConfig(index)); } {
sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%i).", fieldname, getConfig(index));
}
return false; return false;
} }
@ -2280,11 +2415,15 @@ bool World::configNoReload(bool reload, eConfigInt32Values index, char const* fi
bool World::configNoReload(bool reload, eConfigFloatValues index, char const* fieldname, float defvalue) bool World::configNoReload(bool reload, eConfigFloatValues index, char const* fieldname, float defvalue)
{ {
if (!reload) if (!reload)
{ return true; } {
return true;
}
float val = sConfig.GetFloatDefault(fieldname, defvalue); float val = sConfig.GetFloatDefault(fieldname, defvalue);
if (val != getConfig(index)) if (val != getConfig(index))
{ sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%f).", fieldname, getConfig(index)); } {
sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%f).", fieldname, getConfig(index));
}
return false; return false;
} }
@ -2292,11 +2431,15 @@ bool World::configNoReload(bool reload, eConfigFloatValues index, char const* fi
bool World::configNoReload(bool reload, eConfigBoolValues index, char const* fieldname, bool defvalue) bool World::configNoReload(bool reload, eConfigBoolValues index, char const* fieldname, bool defvalue)
{ {
if (!reload) if (!reload)
{ return true; } {
return true;
}
bool val = sConfig.GetBoolDefault(fieldname, defvalue); bool val = sConfig.GetBoolDefault(fieldname, defvalue);
if (val != getConfig(index)) if (val != getConfig(index))
{ sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%s).", fieldname, getConfig(index) ? "'true'" : "'false'"); } {
sLog.outError("%s option can't be changed at mangosd.conf reload, using current value (%s).", fieldname, getConfig(index) ? "'true'" : "'false'");
}
return false; return false;
} }
@ -2345,8 +2488,7 @@ void World::LoadBroadcastStrings()
bs.text = fields[1].GetString(); bs.text = fields[1].GetString();
bs.freq = m_broadcastWeight; bs.freq = m_broadcastWeight;
m_broadcastList.push_back(bs); m_broadcastList.push_back(bs);
} } while (result->NextRow());
while (result->NextRow());
delete result; delete result;
if (m_broadcastWeight == 0) if (m_broadcastWeight == 0)

View File

@ -421,13 +421,19 @@ void Log::outString(const char* str, ...)
void Log::outError(const char* err, ...) void Log::outError(const char* err, ...)
{ {
if (!err) if (!err)
{ return; } {
return;
}
if (m_colored) if (m_colored)
{ SetColor(false, m_colors[LogError]); } {
SetColor(false, m_colors[LogError]);
}
if (m_includeTime) if (m_includeTime)
{ outTime(); } {
outTime();
}
va_list ap; va_list ap;
@ -436,7 +442,9 @@ void Log::outError(const char* err, ...)
va_end(ap); va_end(ap);
if (m_colored) if (m_colored)
{ ResetColor(false); } {
ResetColor(false);
}
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (logfile) if (logfile)