converted all tabs to 4 spaces

This commit is contained in:
Yehonal
2016-06-26 19:23:57 +02:00
parent 52f305111c
commit f6eefedcd5
717 changed files with 132388 additions and 132388 deletions

View File

@@ -106,7 +106,7 @@ World::World()
m_ShutdownMask = 0;
m_ShutdownTimer = 0;
m_gameTime = time(NULL);
m_gameMSTime = getMSTime();
m_gameMSTime = getMSTime();
m_startTime = m_gameTime;
m_maxActiveSessionCount = 0;
m_maxQueuedSessionCount = 0;
@@ -145,11 +145,11 @@ World::~World()
m_sessions.erase(m_sessions.begin());
}
while (!m_offlineSessions.empty())
{
delete m_offlineSessions.begin()->second;
m_offlineSessions.erase(m_offlineSessions.begin());
}
while (!m_offlineSessions.empty())
{
delete m_offlineSessions.begin()->second;
m_offlineSessions.erase(m_offlineSessions.begin());
}
CliCommandHolder* command = NULL;
while (cliCmdQueue.next(command))
@@ -228,12 +228,12 @@ WorldSession* World::FindOfflineSession(uint32 id) const
WorldSession* World::FindOfflineSessionForCharacterGUID(uint32 guidLow) const
{
if (m_offlineSessions.empty())
return NULL;
for (SessionMap::const_iterator itr = m_offlineSessions.begin(); itr != m_offlineSessions.end(); ++itr)
if (itr->second->GetGuidLow() == guidLow)
return itr->second;
return NULL;
if (m_offlineSessions.empty())
return NULL;
for (SessionMap::const_iterator itr = m_offlineSessions.begin(); itr != m_offlineSessions.end(); ++itr)
if (itr->second->GetGuidLow() == guidLow)
return itr->second;
return NULL;
}
/// Remove a given session
@@ -279,26 +279,26 @@ void World::AddSession_(WorldSession* s)
if (!RemoveQueuedPlayer(oldSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
m_disconnects[s->GetAccountId()] = time(NULL);
// pussywizard:
if (oldSession->HandleSocketClosed())
{
// there should be no offline session if current one is logged onto a character
SessionMap::iterator iter;
if ((iter = m_offlineSessions.find(oldSession->GetAccountId())) != m_offlineSessions.end())
{
WorldSession* tmp = iter->second;
m_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
oldSession->SetOfflineTime(time(NULL));
m_offlineSessions[oldSession->GetAccountId()] = oldSession;
}
else
{
oldSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete oldSession;
}
// pussywizard:
if (oldSession->HandleSocketClosed())
{
// there should be no offline session if current one is logged onto a character
SessionMap::iterator iter;
if ((iter = m_offlineSessions.find(oldSession->GetAccountId())) != m_offlineSessions.end())
{
WorldSession* tmp = iter->second;
m_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
oldSession->SetOfflineTime(time(NULL));
m_offlineSessions[oldSession->GetAccountId()] = oldSession;
}
else
{
oldSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete oldSession;
}
}
m_sessions[s->GetAccountId()] = s;
@@ -427,7 +427,7 @@ void World::LoadConfigSettings(bool reload)
{
if (reload)
{
if (!sConfigMgr->Reload())
if (!sConfigMgr->Reload())
{
sLog->outError("World settings reload fail: can't read settings from %s.", sConfigMgr->GetFilename().c_str());
return;
@@ -437,8 +437,8 @@ void World::LoadConfigSettings(bool reload)
}
///- Read the player limit and the Message of the day from the config file
if (!reload)
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
if (!reload)
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to a Sunwell Core Server."));
///- Read ticket system setting from the config file
@@ -680,8 +680,8 @@ void World::LoadConfigSettings(bool reload)
m_int_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfigMgr->GetIntDefault ("StrictCharterNames", 0);
m_int_configs[CONFIG_STRICT_CHANNEL_NAMES] = sConfigMgr->GetIntDefault ("StrictChannelNames", 0);
m_int_configs[CONFIG_STRICT_PET_NAMES] = sConfigMgr->GetIntDefault ("StrictPetNames", 0);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfigMgr->GetBoolDefault("AllowTwoSide.Accounts", true);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = sConfigMgr->GetBoolDefault("AllowTwoSide.Accounts", true);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR]= sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Calendar", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Chat", false);
m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = sConfigMgr->GetBoolDefault("AllowTwoSide.Interaction.Channel", false);
@@ -863,7 +863,7 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_INSTANCE_IGNORE_RAID] = sConfigMgr->GetBoolDefault("Instance.IgnoreRaid", false);
m_int_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = sConfigMgr->GetIntDefault("Instance.ResetTimeHour", 4);
m_int_configs[CONFIG_INSTANCE_RESET_TIME_RELATIVE_TIMESTAMP] = sConfigMgr->GetIntDefault("Instance.ResetTimeRelativeTimestamp", 1135814400);
m_int_configs[CONFIG_INSTANCE_RESET_TIME_RELATIVE_TIMESTAMP] = sConfigMgr->GetIntDefault("Instance.ResetTimeRelativeTimestamp", 1135814400);
m_int_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = sConfigMgr->GetIntDefault("Instance.UnloadDelay", 30 * MINUTE * IN_MILLISECONDS);
m_int_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = sConfigMgr->GetIntDefault("MaxPrimaryTradeSkill", 2);
@@ -923,12 +923,12 @@ void World::LoadConfigSettings(bool reload)
m_timers[WUPDATE_CLEANDB].Reset();
}
m_int_configs[CONFIG_TELEPORT_TIMEOUT_NEAR] = sConfigMgr->GetIntDefault("TeleportTimeoutNear", 25); // pussywizard
m_int_configs[CONFIG_TELEPORT_TIMEOUT_FAR] = sConfigMgr->GetIntDefault("TeleportTimeoutFar", 45); // pussywizard
m_int_configs[CONFIG_MAX_ALLOWED_MMR_DROP] = sConfigMgr->GetIntDefault("MaxAllowedMMRDrop", 500); // pussywizard
m_bool_configs[CONFIG_ENABLE_LOGIN_AFTER_DC] = sConfigMgr->GetBoolDefault("EnableLoginAfterDC", true); // pussywizard
m_bool_configs[CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS] = sConfigMgr->GetBoolDefault("DontCacheRandomMovementPaths", true); // pussywizard
SetRealmName(sConfigMgr->GetStringDefault("RealmName", "X"));
m_int_configs[CONFIG_TELEPORT_TIMEOUT_NEAR] = sConfigMgr->GetIntDefault("TeleportTimeoutNear", 25); // pussywizard
m_int_configs[CONFIG_TELEPORT_TIMEOUT_FAR] = sConfigMgr->GetIntDefault("TeleportTimeoutFar", 45); // pussywizard
m_int_configs[CONFIG_MAX_ALLOWED_MMR_DROP] = sConfigMgr->GetIntDefault("MaxAllowedMMRDrop", 500); // pussywizard
m_bool_configs[CONFIG_ENABLE_LOGIN_AFTER_DC] = sConfigMgr->GetBoolDefault("EnableLoginAfterDC", true); // pussywizard
m_bool_configs[CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS] = sConfigMgr->GetBoolDefault("DontCacheRandomMovementPaths", true); // pussywizard
SetRealmName(sConfigMgr->GetStringDefault("RealmName", "X"));
m_int_configs[CONFIG_SKILL_CHANCE_ORANGE] = sConfigMgr->GetIntDefault("SkillChance.Orange", 100);
m_int_configs[CONFIG_SKILL_CHANCE_YELLOW] = sConfigMgr->GetIntDefault("SkillChance.Yellow", 75);
@@ -1249,8 +1249,8 @@ void World::SetInitialWorldSettings()
///- Initialize the random number generator
srand((unsigned int)time(NULL));
///- Initialize detour memory management
dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
///- Initialize detour memory management
dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
///- Initialize config settings
LoadConfigSettings();
@@ -1317,10 +1317,10 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading SpellInfo store...");
sSpellMgr->LoadSpellInfoStore();
sLog->outString("Loading Spell Rank Data...");
sLog->outString("Loading Spell Rank Data...");
sSpellMgr->LoadSpellRanks();
sLog->outString("Loading Spell Specific And Aura State...");
sLog->outString("Loading Spell Specific And Aura State...");
sSpellMgr->LoadSpellSpecificAndAuraState();
sLog->outString("Loading SkillLineAbilityMultiMap Data...");
@@ -1338,8 +1338,8 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading Instance Template...");
sObjectMgr->LoadInstanceTemplate();
// xinef: Global Storage, should be loaded asap
sLog->outString("Load Global Player Data...");
// xinef: Global Storage, should be loaded asap
sLog->outString("Load Global Player Data...");
sWorld->LoadGlobalPlayerDataStore();
// Must be called before `creature_respawn`/`gameobject_respawn` tables
@@ -1667,18 +1667,18 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading client addons...");
AddonMgr::LoadFromDB();
// pussywizard:
sLog->outString("Deleting invalid mail items...\n");
CharacterDatabase.Query("DELETE mi FROM mail_items mi LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE ii.guid IS NULL");
CharacterDatabase.Query("DELETE mi FROM mail_items mi LEFT JOIN mail m ON mi.mail_id = m.id WHERE m.id IS NULL");
CharacterDatabase.Query("UPDATE mail m LEFT JOIN mail_items mi ON m.id = mi.mail_id SET m.has_items=0 WHERE m.has_items<>0 AND mi.mail_id IS NULL");
// pussywizard:
sLog->outString("Deleting invalid mail items...\n");
CharacterDatabase.Query("DELETE mi FROM mail_items mi LEFT JOIN item_instance ii ON mi.item_guid = ii.guid WHERE ii.guid IS NULL");
CharacterDatabase.Query("DELETE mi FROM mail_items mi LEFT JOIN mail m ON mi.mail_id = m.id WHERE m.id IS NULL");
CharacterDatabase.Query("UPDATE mail m LEFT JOIN mail_items mi ON m.id = mi.mail_id SET m.has_items=0 WHERE m.has_items<>0 AND mi.mail_id IS NULL");
///- Handle outdated emails (delete/return)
sLog->outString("Returning old mails...");
sObjectMgr->ReturnOrDeleteOldMails(false);
///- Load AutoBroadCast
sLog->outString("Loading Autobroadcasts...");
///- Load AutoBroadCast
sLog->outString("Loading Autobroadcasts...");
LoadAutobroadcasts();
///- Load and initialize scripts
@@ -1711,8 +1711,8 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading Calendar data...");
sCalendarMgr->LoadFromDB();
sLog->outString("Initializing SpellInfo precomputed data..."); // must be called after loading items, professions, spells and pretty much anything
sObjectMgr->InitializeSpellInfoPrecomputedData();
sLog->outString("Initializing SpellInfo precomputed data..."); // must be called after loading items, professions, spells and pretty much anything
sObjectMgr->InitializeSpellInfoPrecomputedData();
///- Initialize game time and timers
sLog->outString("Initialize game time and timers");
@@ -1733,10 +1733,10 @@ void World::SetInitialWorldSettings()
m_timers[WUPDATE_PINGDB].SetInterval(getIntConfig(CONFIG_DB_PING_INTERVAL)*MINUTE*IN_MILLISECONDS); // Mysql ping time in minutes
// our speed up
m_timers[WUPDATE_5_SECS].SetInterval(5*IN_MILLISECONDS);
// our speed up
m_timers[WUPDATE_5_SECS].SetInterval(5*IN_MILLISECONDS);
mail_expire_check_timer = time(NULL) + 6*3600;
mail_expire_check_timer = time(NULL) + 6*3600;
///- Initilize static helper structures
AIRegistry::Initialize();
@@ -1801,30 +1801,30 @@ void World::SetInitialWorldSettings()
sLog->outString("Calculate Guild cap reset time...");
InitGuildResetTime();
sLog->outString("Load Petitions...");
sPetitionMgr->LoadPetitions();
sLog->outString("Load Petitions...");
sPetitionMgr->LoadPetitions();
sLog->outString("Load Petition Signs...");
sPetitionMgr->LoadSignatures();
sLog->outString("Load Petition Signs...");
sPetitionMgr->LoadSignatures();
sLog->outString("Load Stored Loot Items...");
sLootItemStorage->LoadStorageFromDB();
sLog->outString("Load Stored Loot Items...");
sLootItemStorage->LoadStorageFromDB();
sLog->outString("Load Channel Rights...");
ChannelMgr::LoadChannelRights();
sLog->outString("Load Channel Rights...");
ChannelMgr::LoadChannelRights();
sLog->outString("Load Channels...");
ChannelMgr* mgr = ChannelMgr::forTeam(TEAM_ALLIANCE);
mgr->LoadChannels();
mgr = ChannelMgr::forTeam(TEAM_HORDE);
mgr->LoadChannels();
sLog->outString("Load Channels...");
ChannelMgr* mgr = ChannelMgr::forTeam(TEAM_ALLIANCE);
mgr->LoadChannels();
mgr = ChannelMgr::forTeam(TEAM_HORDE);
mgr->LoadChannels();
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
sLog->outString();
sLog->outError("WORLD: World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000));
sLog->outString();
// possibly enable db logging; avoid massive startup spam by doing it here.
// possibly enable db logging; avoid massive startup spam by doing it here.
if (sConfigMgr->GetBoolDefault("EnableLogDB", false))
{
sLog->outString("Enabling database logging...");
@@ -1895,7 +1895,7 @@ void World::LoadAutobroadcasts()
/// Update the World !
void World::Update(uint32 diff)
{
m_updateTime = diff;
m_updateTime = diff;
if (m_int_configs[CONFIG_INTERVAL_LOG_UPDATE])
{
@@ -1907,7 +1907,7 @@ void World::Update(uint32 diff)
}
}
DynamicVisibilityMgr::Update(GetActiveSessionCount());
DynamicVisibilityMgr::Update(GetActiveSessionCount());
///- Update the different timers
for (int i = 0; i < WUPDATE_COUNT; ++i)
@@ -1918,18 +1918,18 @@ void World::Update(uint32 diff)
m_timers[i].SetCurrent(0);
}
// pussywizard: our speed up and functionality
if (m_timers[WUPDATE_5_SECS].Passed())
{
m_timers[WUPDATE_5_SECS].Reset();
// pussywizard: our speed up and functionality
if (m_timers[WUPDATE_5_SECS].Passed())
{
m_timers[WUPDATE_5_SECS].Reset();
// moved here from HandleCharEnumOpcode
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_BANS);
CharacterDatabase.Execute(stmt);
// moved here from HandleCharEnumOpcode
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EXPIRED_BANS);
CharacterDatabase.Execute(stmt);
// copy players hashmapholder to avoid mutex
WhoListCacheMgr::Update();
}
// copy players hashmapholder to avoid mutex
WhoListCacheMgr::Update();
}
///- Update the game time and check for shutdown time
_UpdateGameTime();
@@ -1952,34 +1952,34 @@ void World::Update(uint32 diff)
if (m_gameTime > m_NextGuildReset)
ResetGuildCap();
// pussywizard:
// acquire mutex now, this is kind of waiting for listing thread to finish it's work (since it can't process next packet)
// so we don't have to do it in every packet that modifies auctions
AsyncAuctionListingMgr::SetAuctionListingAllowed(false);
{
TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetLock());
// pussywizard:
// acquire mutex now, this is kind of waiting for listing thread to finish it's work (since it can't process next packet)
// so we don't have to do it in every packet that modifies auctions
AsyncAuctionListingMgr::SetAuctionListingAllowed(false);
{
TRINITY_GUARD(ACE_Thread_Mutex, AsyncAuctionListingMgr::GetLock());
// pussywizard: handle auctions when the timer has passed
if (m_timers[WUPDATE_AUCTIONS].Passed())
{
m_timers[WUPDATE_AUCTIONS].Reset();
// pussywizard: handle auctions when the timer has passed
if (m_timers[WUPDATE_AUCTIONS].Passed())
{
m_timers[WUPDATE_AUCTIONS].Reset();
// pussywizard: handle expired auctions, auctions expired when realm was offline are also handled here (not during loading when many required things aren't loaded yet)
sAuctionMgr->Update();
}
// pussywizard: handle expired auctions, auctions expired when realm was offline are also handled here (not during loading when many required things aren't loaded yet)
sAuctionMgr->Update();
}
AsyncAuctionListingMgr::Update(diff);
AsyncAuctionListingMgr::Update(diff);
if (m_gameTime > mail_expire_check_timer)
{
sObjectMgr->ReturnOrDeleteOldMails(true);
mail_expire_check_timer = m_gameTime + 6*3600;
}
if (m_gameTime > mail_expire_check_timer)
{
sObjectMgr->ReturnOrDeleteOldMails(true);
mail_expire_check_timer = m_gameTime + 6*3600;
}
UpdateSessions(diff);
}
// end of section with mutex
AsyncAuctionListingMgr::SetAuctionListingAllowed(true);
UpdateSessions(diff);
}
// end of section with mutex
AsyncAuctionListingMgr::SetAuctionListingAllowed(true);
/// <li> Handle weather updates when the timer has passed
if (m_timers[WUPDATE_WEATHERS].Passed())
@@ -1988,7 +1988,7 @@ void World::Update(uint32 diff)
WeatherMgr::Update(uint32(m_timers[WUPDATE_WEATHERS].GetInterval()));
}
sLFGMgr->Update(diff, 0); // pussywizard: remove obsolete stuff before finding compatibility during map update
sLFGMgr->Update(diff, 0); // pussywizard: remove obsolete stuff before finding compatibility during map update
sMapMgr->Update(diff);
@@ -2046,7 +2046,7 @@ void World::Update(uint32 diff)
sScriptMgr->OnWorldUpdate(diff);
SavingSystemMgr::Update(diff);
SavingSystemMgr::Update(diff);
}
void World::ForceGameEventUpdate()
@@ -2305,12 +2305,12 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, std::stri
if (mode != BAN_IP)
{
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
PreparedStatement* stmtx = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
stmtx->setUInt32(0, account);
PreparedQueryResult banresultx = LoginDatabase.Query(stmtx);
if (banresultx && ((*banresultx)[0].GetUInt32() == (*banresultx)[1].GetUInt32() || ((*banresultx)[1].GetUInt32() > time(NULL)+duration_secs && duration_secs)))
return BAN_LONGER_EXISTS;
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
PreparedStatement* stmtx = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
stmtx->setUInt32(0, account);
PreparedQueryResult banresultx = LoginDatabase.Query(stmtx);
if (banresultx && ((*banresultx)[0].GetUInt32() == (*banresultx)[1].GetUInt32() || ((*banresultx)[1].GetUInt32() > time(NULL)+duration_secs && duration_secs)))
return BAN_LONGER_EXISTS;
// make sure there is only one active ban
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
@@ -2378,9 +2378,9 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati
/// Pick a player to ban if not online
if (!pBanned)
{
guid = sWorld->GetGlobalPlayerGUID(name);
if (!guid)
return BAN_NOTFOUND;
guid = sWorld->GetGlobalPlayerGUID(name);
if (!guid)
return BAN_NOTFOUND;
}
else
guid = pBanned->GetGUIDLow();
@@ -2411,7 +2411,7 @@ bool World::RemoveBanCharacter(std::string const& name)
/// Pick a player to ban if not online
if (!pBanned)
guid = sWorld->GetGlobalPlayerGUID(name);
guid = sWorld->GetGlobalPlayerGUID(name);
else
guid = pBanned->GetGUIDLow();
@@ -2431,7 +2431,7 @@ void World::_UpdateGameTime()
time_t thisTime = time(NULL);
uint32 elapsed = uint32(thisTime - m_gameTime);
m_gameTime = thisTime;
m_gameMSTime = getMSTime();
m_gameMSTime = getMSTime();
///- if there is a shutdown timer
if (!IsStopped() && m_ShutdownTimer > 0 && elapsed > 0)
@@ -2556,54 +2556,54 @@ void World::UpdateSessions(uint32 diff)
WorldSession* pSession = itr->second;
WorldSessionFilter updater(pSession);
// pussywizard:
if (pSession->HandleSocketClosed())
{
// pussywizard:
if (pSession->HandleSocketClosed())
{
if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
m_disconnects[pSession->GetAccountId()] = time(NULL);
m_sessions.erase(itr);
// there should be no offline session if current one is logged onto a character
SessionMap::iterator iter;
if ((iter = m_offlineSessions.find(pSession->GetAccountId())) != m_offlineSessions.end())
{
WorldSession* tmp = iter->second;
m_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
pSession->SetOfflineTime(time(NULL));
m_offlineSessions[pSession->GetAccountId()] = pSession;
continue;
}
// there should be no offline session if current one is logged onto a character
SessionMap::iterator iter;
if ((iter = m_offlineSessions.find(pSession->GetAccountId())) != m_offlineSessions.end())
{
WorldSession* tmp = iter->second;
m_offlineSessions.erase(iter);
tmp->SetShouldSetOfflineInDB(false);
delete tmp;
}
pSession->SetOfflineTime(time(NULL));
m_offlineSessions[pSession->GetAccountId()] = pSession;
continue;
}
if (!pSession->Update(diff, updater))
{
if (!RemoveQueuedPlayer(pSession) && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
m_disconnects[pSession->GetAccountId()] = time(NULL);
m_sessions.erase(itr);
if (m_offlineSessions.find(pSession->GetAccountId()) != m_offlineSessions.end()) // pussywizard: don't set offline in db because offline session for that acc is present (character is in world)
pSession->SetShouldSetOfflineInDB(false);
if (m_offlineSessions.find(pSession->GetAccountId()) != m_offlineSessions.end()) // pussywizard: don't set offline in db because offline session for that acc is present (character is in world)
pSession->SetShouldSetOfflineInDB(false);
delete pSession;
}
}
// pussywizard:
if (m_offlineSessions.empty())
return;
uint32 currTime = time(NULL);
for (SessionMap::iterator itr = m_offlineSessions.begin(), next; itr != m_offlineSessions.end(); itr = next)
{
// pussywizard:
if (m_offlineSessions.empty())
return;
uint32 currTime = time(NULL);
for (SessionMap::iterator itr = m_offlineSessions.begin(), next; itr != m_offlineSessions.end(); itr = next)
{
next = itr;
++next;
WorldSession* pSession = itr->second;
if (!pSession->GetPlayer() || pSession->GetOfflineTime()+60 < currTime || pSession->IsKicked())
{
m_offlineSessions.erase(itr);
if (m_sessions.find(pSession->GetAccountId()) != m_sessions.end())
pSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete pSession;
}
}
WorldSession* pSession = itr->second;
if (!pSession->GetPlayer() || pSession->GetOfflineTime()+60 < currTime || pSession->IsKicked())
{
m_offlineSessions.erase(itr);
if (m_sessions.find(pSession->GetAccountId()) != m_sessions.end())
pSession->SetShouldSetOfflineInDB(false); // pussywizard: don't set offline in db because new session for that acc is already created
delete pSession;
}
}
}
// This handles the issued and queued CLI commands
@@ -2629,8 +2629,8 @@ void World::SendAutoBroadcast()
{
if (m_Autobroadcasts.empty())
return;
uint32 weight = 0;
uint32 weight = 0;
AutobroadcastsWeightMap selectionWeights;
std::string msg;
@@ -2721,46 +2721,46 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount)
// int8 dayOfWeek: 0 (sunday) to 6 (saturday)
time_t World::GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour)
{
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curr, &localTm);
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
uint32 add;
if (dayOfWeek < 0 || dayOfWeek > 6)
dayOfWeek = (localTm.tm_wday+1)%7;
if (localTm.tm_wday >= dayOfWeek)
add = (7 - (localTm.tm_wday - dayOfWeek)) * DAY;
else
add = (dayOfWeek - localTm.tm_wday) * DAY;
return mktime(&localTm) + add;
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curr, &localTm);
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
uint32 add;
if (dayOfWeek < 0 || dayOfWeek > 6)
dayOfWeek = (localTm.tm_wday+1)%7;
if (localTm.tm_wday >= dayOfWeek)
add = (7 - (localTm.tm_wday - dayOfWeek)) * DAY;
else
add = (dayOfWeek - localTm.tm_wday) * DAY;
return mktime(&localTm) + add;
}
// int8 month: 0 (january) to 11 (december)
time_t World::GetNextTimeWithMonthAndHour(int8 month, int8 hour)
{
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curr, &localTm);
localTm.tm_mday = 1;
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
if (month < 0 || month > 11)
{
month = (localTm.tm_mon+1)%12;
if (month == 0)
localTm.tm_year += 1;
}
else if (localTm.tm_mon >= month)
localTm.tm_year += 1;
localTm.tm_mon = month;
return mktime(&localTm);
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(NULL);
tm localTm;
ACE_OS::localtime_r(&curr, &localTm);
localTm.tm_mday = 1;
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
if (month < 0 || month > 11)
{
month = (localTm.tm_mon+1)%12;
if (month == 0)
localTm.tm_year += 1;
}
else if (localTm.tm_mon >= month)
localTm.tm_year += 1;
localTm.tm_mon = month;
return mktime(&localTm);
}
void World::InitWeeklyQuestResetTime()
@@ -3031,40 +3031,40 @@ void World::LoadGlobalPlayerDataStore()
uint32 count = 0;
// query to load number of mails by receiver
std::map<uint32, uint16> _mailCountMap;
QueryResult mailCountResult = CharacterDatabase.Query("SELECT receiver, COUNT(receiver) FROM mail GROUP BY receiver");
if (mailCountResult)
{
do
{
Field* fields = mailCountResult->Fetch();
_mailCountMap[fields[0].GetUInt32()] = uint16(fields[1].GetUInt64());
}
while (mailCountResult->NextRow());
}
// query to load number of mails by receiver
std::map<uint32, uint16> _mailCountMap;
QueryResult mailCountResult = CharacterDatabase.Query("SELECT receiver, COUNT(receiver) FROM mail GROUP BY receiver");
if (mailCountResult)
{
do
{
Field* fields = mailCountResult->Fetch();
_mailCountMap[fields[0].GetUInt32()] = uint16(fields[1].GetUInt64());
}
while (mailCountResult->NextRow());
}
do
{
Field* fields = result->Fetch();
uint32 guidLow = fields[0].GetUInt32();
uint32 guidLow = fields[0].GetUInt32();
// count mails
uint16 mailCount = 0;
std::map<uint32, uint16>::const_iterator itr = _mailCountMap.find(guidLow);
if (itr != _mailCountMap.end())
mailCount = itr->second;
// count mails
uint16 mailCount = 0;
std::map<uint32, uint16>::const_iterator itr = _mailCountMap.find(guidLow);
if (itr != _mailCountMap.end())
mailCount = itr->second;
AddGlobalPlayerData(
guidLow, /*guid*/
fields[1].GetUInt32(), /*accountId*/
fields[2].GetString(), /*name*/
AddGlobalPlayerData(
guidLow, /*guid*/
fields[1].GetUInt32(), /*accountId*/
fields[2].GetString(), /*name*/
fields[3].GetUInt8(), /*gender*/
fields[4].GetUInt8(), /*race*/
fields[5].GetUInt8(), /*class*/
fields[6].GetUInt8(), /*level*/
mailCount, /*mail count*/
0 /*guild id*/);
fields[4].GetUInt8(), /*race*/
fields[5].GetUInt8(), /*class*/
fields[6].GetUInt8(), /*level*/
mailCount, /*mail count*/
0 /*guild id*/);
++count;
}
@@ -3076,42 +3076,42 @@ void World::LoadGlobalPlayerDataStore()
void World::AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId)
{
GlobalPlayerData data;
GlobalPlayerData data;
data.guidLow = guid;
data.accountId = accountId;
data.name = name;
data.level = level;
data.guidLow = guid;
data.accountId = accountId;
data.name = name;
data.level = level;
data.race = race;
data.playerClass = playerClass;
data.gender = gender;
data.mailCount = mailCount;
data.guildId = guildId;
data.groupId = 0;
data.arenaTeamId[0] = 0;
data.arenaTeamId[1] = 0;
data.arenaTeamId[2] = 0;
data.playerClass = playerClass;
data.gender = gender;
data.mailCount = mailCount;
data.guildId = guildId;
data.groupId = 0;
data.arenaTeamId[0] = 0;
data.arenaTeamId[1] = 0;
data.arenaTeamId[2] = 0;
_globalPlayerDataStore[guid] = data;
_globalPlayerNameStore[name] = guid;
_globalPlayerDataStore[guid] = data;
_globalPlayerNameStore[name] = guid;
}
void World::UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& name, uint8 level, uint8 gender, uint8 race, uint8 playerClass)
{
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
if (itr == _globalPlayerDataStore.end())
return;
if (mask & PLAYER_UPDATE_DATA_LEVEL)
itr->second.level = level;
if (mask & PLAYER_UPDATE_DATA_RACE)
itr->second.race = race;
if (mask & PLAYER_UPDATE_DATA_CLASS)
itr->second.playerClass = playerClass;
if (mask & PLAYER_UPDATE_DATA_GENDER)
itr->second.gender = gender;
if (mask & PLAYER_UPDATE_DATA_NAME)
itr->second.name = name;
if (mask & PLAYER_UPDATE_DATA_LEVEL)
itr->second.level = level;
if (mask & PLAYER_UPDATE_DATA_RACE)
itr->second.race = race;
if (mask & PLAYER_UPDATE_DATA_CLASS)
itr->second.playerClass = playerClass;
if (mask & PLAYER_UPDATE_DATA_GENDER)
itr->second.gender = gender;
if (mask & PLAYER_UPDATE_DATA_NAME)
itr->second.name = name;
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
data << MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER);
@@ -3120,74 +3120,74 @@ void World::UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& n
void World::UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add)
{
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
if (itr == _globalPlayerDataStore.end())
return;
if (!add)
{
itr->second.mailCount = count;
return;
}
if (!add)
{
itr->second.mailCount = count;
return;
}
int16 icount = (int16)itr->second.mailCount;
if (count < 0 && abs(count) > icount)
count = -icount;
itr->second.mailCount = uint16(icount + count); // addition or subtraction
int16 icount = (int16)itr->second.mailCount;
if (count < 0 && abs(count) > icount)
count = -icount;
itr->second.mailCount = uint16(icount + count); // addition or subtraction
}
void World::UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId)
{
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
if (itr == _globalPlayerDataStore.end())
return;
itr->second.guildId = guildId;
itr->second.guildId = guildId;
}
void World::UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId)
{
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
if (itr == _globalPlayerDataStore.end())
return;
itr->second.groupId = groupId;
itr->second.groupId = groupId;
}
void World::UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId)
{
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
GlobalPlayerDataMap::iterator itr = _globalPlayerDataStore.find(guid);
if (itr == _globalPlayerDataStore.end())
return;
itr->second.arenaTeamId[slot] = arenaTeamId;
itr->second.arenaTeamId[slot] = arenaTeamId;
}
void World::UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName)
{
_globalPlayerNameStore.erase(oldName);
_globalPlayerNameStore[newName] = guidLow;
_globalPlayerNameStore.erase(oldName);
_globalPlayerNameStore[newName] = guidLow;
}
void World::DeleteGlobalPlayerData(uint32 guid, std::string const& name)
{
if (guid)
_globalPlayerDataStore.erase(guid);
if (!name.empty())
_globalPlayerNameStore.erase(name);
if (guid)
_globalPlayerDataStore.erase(guid);
if (!name.empty())
_globalPlayerNameStore.erase(name);
}
GlobalPlayerData const* World::GetGlobalPlayerData(uint32 guid) const
{
GlobalPlayerDataMap::const_iterator itr = _globalPlayerDataStore.find(guid);
if (itr != _globalPlayerDataStore.end())
return &itr->second;
return NULL;
GlobalPlayerDataMap::const_iterator itr = _globalPlayerDataStore.find(guid);
if (itr != _globalPlayerDataStore.end())
return &itr->second;
return NULL;
}
uint32 World::GetGlobalPlayerGUID(std::string const& name) const
{
GlobalPlayerNameMap::const_iterator itr = _globalPlayerNameStore.find(name);
if (itr != _globalPlayerNameStore.end())
return itr->second;
return 0;
GlobalPlayerNameMap::const_iterator itr = _globalPlayerNameStore.find(name);
if (itr != _globalPlayerNameStore.end())
return itr->second;
return 0;
}

View File

@@ -78,7 +78,7 @@ enum WorldTimers
WUPDATE_AUTOBROADCAST,
WUPDATE_MAILBOXQUEUE,
WUPDATE_PINGDB,
WUPDATE_5_SECS,
WUPDATE_5_SECS,
WUPDATE_COUNT
};
@@ -151,7 +151,7 @@ enum WorldBoolConfigs
CONFIG_FREE_DUAL_SPEC, // pussywizard
CONFIG_ENABLE_MMAPS, // pussywizard
CONFIG_ENABLE_LOGIN_AFTER_DC, // pussywizard
CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS, // pussywizard
CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS, // pussywizard
CONFIG_QUEST_IGNORE_AUTO_ACCEPT,
CONFIG_QUEST_IGNORE_AUTO_COMPLETE,
CONFIG_WARDEN_ENABLED,
@@ -211,7 +211,7 @@ enum WorldIntConfigs
CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL,
CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE,
CONFIG_INSTANCE_RESET_TIME_HOUR,
CONFIG_INSTANCE_RESET_TIME_RELATIVE_TIMESTAMP,
CONFIG_INSTANCE_RESET_TIME_RELATIVE_TIMESTAMP,
CONFIG_INSTANCE_UNLOAD_DELAY,
CONFIG_MAX_PRIMARY_TRADE_SKILL,
CONFIG_MIN_PETITION_SIGNS,
@@ -283,9 +283,9 @@ enum WorldIntConfigs
CONFIG_PLAYER_ALLOW_COMMANDS,
CONFIG_NUMTHREADS,
CONFIG_LOGDB_CLEARINTERVAL,
CONFIG_TELEPORT_TIMEOUT_NEAR, // pussywizard
CONFIG_TELEPORT_TIMEOUT_FAR, // pussywizard
CONFIG_MAX_ALLOWED_MMR_DROP, // pussywizard
CONFIG_TELEPORT_TIMEOUT_NEAR, // pussywizard
CONFIG_TELEPORT_TIMEOUT_FAR, // pussywizard
CONFIG_MAX_ALLOWED_MMR_DROP, // pussywizard
CONFIG_CLIENTCACHE_VERSION,
CONFIG_GUILD_EVENT_LOG_COUNT,
CONFIG_GUILD_BANK_EVENT_LOG_COUNT,
@@ -494,26 +494,26 @@ typedef UNORDERED_MAP<uint32, WorldSession*> SessionMap;
// xinef: global storage
struct GlobalPlayerData
{
uint32 guidLow;
uint32 accountId;
std::string name;
uint8 race;
uint8 playerClass;
uint8 gender;
uint8 level;
uint16 mailCount;
uint32 guildId;
uint32 groupId;
uint32 arenaTeamId[3];
uint32 guidLow;
uint32 accountId;
std::string name;
uint8 race;
uint8 playerClass;
uint8 gender;
uint8 level;
uint16 mailCount;
uint32 guildId;
uint32 groupId;
uint32 arenaTeamId[3];
};
enum GlobalPlayerUpdateMask
{
PLAYER_UPDATE_DATA_LEVEL = 0x01,
PLAYER_UPDATE_DATA_RACE = 0x02,
PLAYER_UPDATE_DATA_CLASS = 0x04,
PLAYER_UPDATE_DATA_GENDER = 0x08,
PLAYER_UPDATE_DATA_NAME = 0x10,
PLAYER_UPDATE_DATA_LEVEL = 0x01,
PLAYER_UPDATE_DATA_RACE = 0x02,
PLAYER_UPDATE_DATA_CLASS = 0x04,
PLAYER_UPDATE_DATA_GENDER = 0x08,
PLAYER_UPDATE_DATA_NAME = 0x10,
};
typedef UNORDERED_MAP<uint32, GlobalPlayerData> GlobalPlayerDataMap;
@@ -609,8 +609,8 @@ class World
time_t const& GetStartTime() const { return m_startTime; }
/// What time is it?
time_t const& GetGameTime() const { return m_gameTime; }
/// What time is it? in ms
static uint32 GetGameTimeMS() { return m_gameMSTime; }
/// What time is it? in ms
static uint32 GetGameTimeMS() { return m_gameMSTime; }
/// Uptime (in secs)
uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); }
/// Update time
@@ -718,27 +718,27 @@ class World
static float GetMaxVisibleDistanceInInstances() { return m_MaxVisibleDistanceInInstances; }
static float GetMaxVisibleDistanceInBGArenas() { return m_MaxVisibleDistanceInBGArenas; }
// our: needed for arena spectator subscriptions
uint32 GetNextWhoListUpdateDelaySecs()
{
if (m_timers[WUPDATE_5_SECS].Passed())
return 1;
uint32 t = m_timers[WUPDATE_5_SECS].GetInterval() - m_timers[WUPDATE_5_SECS].GetCurrent();
t = std::min(t, (uint32)m_timers[WUPDATE_5_SECS].GetInterval());
return uint32(ceil(t/1000.0f));
}
// our: needed for arena spectator subscriptions
uint32 GetNextWhoListUpdateDelaySecs()
{
if (m_timers[WUPDATE_5_SECS].Passed())
return 1;
uint32 t = m_timers[WUPDATE_5_SECS].GetInterval() - m_timers[WUPDATE_5_SECS].GetCurrent();
t = std::min(t, (uint32)m_timers[WUPDATE_5_SECS].GetInterval());
return uint32(ceil(t/1000.0f));
}
// xinef: Global Player Data Storage system
void LoadGlobalPlayerDataStore();
uint32 GetGlobalPlayerGUID(std::string const& name) const;
GlobalPlayerData const* GetGlobalPlayerData(uint32 guid) const;
// xinef: Global Player Data Storage system
void LoadGlobalPlayerDataStore();
uint32 GetGlobalPlayerGUID(std::string const& name) const;
GlobalPlayerData const* GetGlobalPlayerData(uint32 guid) const;
void AddGlobalPlayerData(uint32 guid, uint32 accountId, std::string const& name, uint8 gender, uint8 race, uint8 playerClass, uint8 level, uint16 mailCount, uint32 guildId);
void UpdateGlobalPlayerData(uint32 guid, uint8 mask, std::string const& name, uint8 level = 0, uint8 gender = 0, uint8 race = 0, uint8 playerClass = 0);
void UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add = true);
void UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId);
void UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId);
void UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId);
void UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName);
void UpdateGlobalPlayerMails(uint32 guid, int16 count, bool add = true);
void UpdateGlobalPlayerGuild(uint32 guid, uint32 guildId);
void UpdateGlobalPlayerGroup(uint32 guid, uint32 groupId);
void UpdateGlobalPlayerArenaTeam(uint32 guid, uint8 slot, uint32 arenaTeamId);
void UpdateGlobalNameData(uint32 guidLow, std::string const& oldName, std::string const& newName);
void DeleteGlobalPlayerData(uint32 guid, std::string const& name);
void ProcessCliCommands();
@@ -752,19 +752,19 @@ class World
void LoadDBVersion();
char const* GetDBVersion() const { return m_DBVersion.c_str(); }
void LoadAutobroadcasts();
void LoadAutobroadcasts();
void UpdateAreaDependentAuras();
uint32 GetCleaningFlags() const { return m_CleaningFlags; }
void SetCleaningFlags(uint32 flags) { m_CleaningFlags = flags; }
void ResetEventSeasonalQuests(uint16 event_id);
time_t GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour); // pussywizard
time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour); // pussywizard
time_t GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour); // pussywizard
time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour); // pussywizard
std::string const& GetRealmName() const { return _realmName; } // pussywizard
void SetRealmName(std::string name) { _realmName = name; } // pussywizard
std::string const& GetRealmName() const { return _realmName; } // pussywizard
void SetRealmName(std::string name) { _realmName = name; } // pussywizard
protected:
void _UpdateGameTime();
@@ -796,7 +796,7 @@ class World
IntervalTimer m_timers[WUPDATE_COUNT];
time_t mail_expire_check_timer;
uint32 m_updateTime, m_updateTimeSum;
static uint32 m_gameMSTime;
static uint32 m_gameMSTime;
SessionMap m_sessions;
SessionMap m_offlineSessions;
@@ -828,11 +828,11 @@ class World
static float m_MaxVisibleDistanceInInstances;
static float m_MaxVisibleDistanceInBGArenas;
// our speed ups
GlobalPlayerDataMap _globalPlayerDataStore; // xinef
GlobalPlayerNameMap _globalPlayerNameStore; // xinef
// our speed ups
GlobalPlayerDataMap _globalPlayerDataStore; // xinef
GlobalPlayerNameMap _globalPlayerNameStore; // xinef
std::string _realmName;
std::string _realmName;
// CLI command holder to be thread safe
ACE_Based::LockedQueue<CliCommandHolder*, ACE_Thread_Mutex> cliCmdQueue;