mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 10:37:01 +00:00
Minor styling tidy up
This commit is contained in:
parent
f959ae40b6
commit
63e73a18fa
2 changed files with 183 additions and 55 deletions
|
|
@ -128,16 +128,24 @@ World::World(): mail_timer(0), mail_timer_expires(0), m_NextMonthlyQuestReset(0)
|
||||||
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
|
||||||
|
|
@ -197,9 +205,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
|
||||||
|
|
@ -211,7 +223,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,7 +267,11 @@ 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
|
||||||
|
delete old->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,7 +284,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)
|
||||||
{
|
{
|
||||||
|
|
@ -323,7 +343,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;
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +401,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())
|
||||||
|
|
@ -406,7 +430,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;
|
||||||
}
|
}
|
||||||
|
|
@ -551,22 +577,32 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
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", true);
|
setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_ACCOUNTS, "AllowTwoSide.Accounts", true);
|
||||||
setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT, "AllowTwoSide.Interaction.Chat", false);
|
setConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT, "AllowTwoSide.Interaction.Chat", false);
|
||||||
|
|
@ -601,7 +637,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, (uint32)getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
setConfigMinMax(CONFIG_UINT32_START_PLAYER_LEVEL, "StartPlayerLevel", 1, 1, (uint32)getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
||||||
setConfigMinMax(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, "StartHeroicPlayerLevel", 55, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
setConfigMinMax(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, "StartHeroicPlayerLevel", 55, 1, getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
|
||||||
|
|
@ -889,9 +927,13 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
setConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID, "Raid.MinLevel", 10);
|
setConfig(CONFIG_UINT32_MIN_LEVEL_FOR_RAID, "Raid.MinLevel", 10);
|
||||||
|
|
||||||
|
|
@ -900,15 +942,21 @@ void World::LoadConfigSettings(bool reload)
|
||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
|
|
@ -922,7 +970,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);
|
||||||
|
|
@ -1595,9 +1645,13 @@ 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///- Update the game time and check for shutdown time
|
///- Update the game time and check for shutdown time
|
||||||
|
|
@ -1728,10 +1782,17 @@ 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* start = strtok(pos, "\n"); pos = NULL; return start; }
|
char* lineFromMessage(char*& pos)
|
||||||
|
{
|
||||||
|
char* start = strtok(pos, "\n");
|
||||||
|
pos = NULL;
|
||||||
|
return start;
|
||||||
|
}
|
||||||
void do_helper(WorldPacketList& data_list, char* text)
|
void do_helper(WorldPacketList& data_list, char* text)
|
||||||
{
|
{
|
||||||
char* pos = text;
|
char* pos = text;
|
||||||
|
|
@ -1763,9 +1824,11 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
@ -1779,9 +1842,11 @@ void World::SendGlobalMessage(WorldPacket* packet)
|
||||||
{
|
{
|
||||||
Player* player = session->GetPlayer();
|
Player* player = session->GetPlayer();
|
||||||
if (player && player->IsInWorld())
|
if (player && player->IsInWorld())
|
||||||
|
{
|
||||||
session->SendPacket(packet);
|
session->SendPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a server message to the specified or all players
|
/// Sends a server message to the specified or all players
|
||||||
|
|
@ -1792,9 +1857,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
|
||||||
|
|
@ -1809,9 +1878,11 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a world defense message to all players not in an instance
|
/// Sends a world defense message to all players not in an instance
|
||||||
|
|
@ -1844,7 +1915,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`
|
||||||
|
|
@ -1854,7 +1927,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
|
||||||
|
|
@ -1890,9 +1965,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)
|
||||||
|
|
@ -1910,15 +1989,15 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Remove a ban from an account or IP address
|
/// Remove a ban from an account or IP address
|
||||||
bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
||||||
{
|
{
|
||||||
|
|
@ -1931,12 +2010,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);
|
||||||
|
|
@ -1959,9 +2044,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
|
||||||
|
|
@ -1978,7 +2067,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;
|
||||||
|
|
@ -1989,7 +2080,9 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
|
||||||
if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
|
if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
|
||||||
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
|
||||||
|
|
@ -1997,6 +2090,7 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
|
||||||
m_ShutdownTimer = time;
|
m_ShutdownTimer = time;
|
||||||
ShutdownMsg(true);
|
ShutdownMsg(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
///- Used by Eluna
|
///- Used by Eluna
|
||||||
#ifdef ENABLE_ELUNA
|
#ifdef ENABLE_ELUNA
|
||||||
sEluna->OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options));
|
sEluna->OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options));
|
||||||
|
|
@ -2008,7 +2102,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 ||
|
||||||
|
|
@ -2032,7 +2128,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;
|
||||||
|
|
||||||
|
|
@ -2095,7 +2193,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;
|
||||||
}
|
}
|
||||||
|
|
@ -2375,7 +2475,9 @@ void World::ResetCurrencyWeekCounts()
|
||||||
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);
|
||||||
|
|
@ -2415,7 +2517,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(eConfigUInt64Values index, char const* fieldname, uint64 defvalue)
|
void World::setConfig(eConfigUInt64Values index, char const* fieldname, uint64 defvalue)
|
||||||
|
|
@ -2596,11 +2700,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;
|
||||||
}
|
}
|
||||||
|
|
@ -2608,11 +2716,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;
|
||||||
}
|
}
|
||||||
|
|
@ -2620,11 +2732,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;
|
||||||
}
|
}
|
||||||
|
|
@ -2632,11 +2748,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -422,13 +422,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;
|
||||||
|
|
||||||
|
|
@ -437,7 +443,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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue