mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
Fixied crash at .pinfo command use from console.
Also apply mangos code style to related code.
This commit is contained in:
parent
a26b72411a
commit
0bf682fdbd
3 changed files with 54 additions and 52 deletions
|
|
@ -1794,7 +1794,8 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
|
accId = objmgr.GetPlayerAccountIdByGUID(targetGUID);
|
||||||
Player plr(m_session); // use current session for temporary load
|
WorldSession session(0,NULL,SEC_PLAYER,0,0,LOCALE_enUS);
|
||||||
|
Player plr(&session); // use fake session for temporary load
|
||||||
plr.MinimalLoadFromDB(NULL, targetGUID);
|
plr.MinimalLoadFromDB(NULL, targetGUID);
|
||||||
money = plr.GetMoney();
|
money = plr.GetMoney();
|
||||||
total_player_time = plr.GetTotalPlayedTime();
|
total_player_time = plr.GetTotalPlayedTime();
|
||||||
|
|
|
||||||
|
|
@ -178,67 +178,67 @@ bool World::RemoveSession(uint32 id)
|
||||||
|
|
||||||
void World::AddSession(WorldSession* s)
|
void World::AddSession(WorldSession* s)
|
||||||
{
|
{
|
||||||
addSessQueue.add(s);
|
addSessQueue.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
World::AddSession_ (WorldSession* s)
|
World::AddSession_ (WorldSession* s)
|
||||||
{
|
{
|
||||||
ASSERT (s);
|
ASSERT (s);
|
||||||
|
|
||||||
//NOTE - Still there is race condition in WorldSession* being used in the Sockets
|
//NOTE - Still there is race condition in WorldSession* being used in the Sockets
|
||||||
|
|
||||||
///- kick already loaded player with same account (if any) and remove session
|
///- kick already loaded player with same account (if any) and remove session
|
||||||
///- if player is in loading and want to load again, return
|
///- if player is in loading and want to load again, return
|
||||||
if (!RemoveSession (s->GetAccountId ()))
|
if (!RemoveSession (s->GetAccountId ()))
|
||||||
{
|
{
|
||||||
s->KickPlayer ();
|
s->KickPlayer ();
|
||||||
m_kicked_sessions.insert (s);
|
m_kicked_sessions.insert (s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldSession* old = m_sessions[s->GetAccountId ()];
|
WorldSession* old = m_sessions[s->GetAccountId ()];
|
||||||
m_sessions[s->GetAccountId ()] = s;
|
m_sessions[s->GetAccountId ()] = s;
|
||||||
|
|
||||||
// if session already exist, prepare to it deleting at next world update
|
// if session already exist, prepare to it deleting at next world update
|
||||||
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
|
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
|
||||||
if (old)
|
if (old)
|
||||||
m_kicked_sessions.insert (old);
|
m_kicked_sessions.insert (old);
|
||||||
|
|
||||||
uint32 Sessions = GetActiveAndQueuedSessionCount ();
|
uint32 Sessions = GetActiveAndQueuedSessionCount ();
|
||||||
uint32 pLimit = GetPlayerAmountLimit ();
|
uint32 pLimit = GetPlayerAmountLimit ();
|
||||||
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
||||||
bool inQueue = false;
|
bool inQueue = false;
|
||||||
//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
|
||||||
--Sessions;
|
--Sessions;
|
||||||
|
|
||||||
if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER )
|
if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER )
|
||||||
{
|
{
|
||||||
AddQueuedPlayer (s);
|
AddQueuedPlayer (s);
|
||||||
UpdateMaxSessionCounters ();
|
UpdateMaxSessionCounters ();
|
||||||
sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize);
|
sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||||
packet << uint8 (AUTH_OK);
|
packet << uint8 (AUTH_OK);
|
||||||
packet << uint32 (0); // unknown random value...
|
packet << uint32 (0); // unknown random value...
|
||||||
packet << uint8 (0);
|
packet << uint8 (0);
|
||||||
packet << uint32 (0);
|
packet << uint32 (0);
|
||||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||||
s->SendPacket (&packet);
|
s->SendPacket (&packet);
|
||||||
|
|
||||||
UpdateMaxSessionCounters ();
|
UpdateMaxSessionCounters ();
|
||||||
|
|
||||||
// Updates the population
|
// Updates the population
|
||||||
if (pLimit > 0)
|
if (pLimit > 0)
|
||||||
{
|
{
|
||||||
float popu = GetActiveSessionCount (); //updated number of users on the server
|
float popu = GetActiveSessionCount (); //updated number of users on the server
|
||||||
popu /= pLimit;
|
popu /= pLimit;
|
||||||
popu *= 2;
|
popu *= 2;
|
||||||
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||||
sLog.outDetail ("Server Population (%f).", popu);
|
sLog.outDetail ("Server Population (%f).", popu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2414,7 +2414,10 @@ void World::UpdateSessions( time_t diff )
|
||||||
|
|
||||||
///- Delete kicked sessions at add new session
|
///- Delete kicked sessions at add new session
|
||||||
for (std::set<WorldSession*>::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr)
|
for (std::set<WorldSession*>::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr)
|
||||||
|
{
|
||||||
|
RemoveQueuedPlayer (*itr);
|
||||||
delete *itr;
|
delete *itr;
|
||||||
|
}
|
||||||
m_kicked_sessions.clear();
|
m_kicked_sessions.clear();
|
||||||
|
|
||||||
///- Then send an update signal to remaining ones
|
///- Then send an update signal to remaining ones
|
||||||
|
|
|
||||||
|
|
@ -58,25 +58,23 @@ _logoutTime(0), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyL
|
||||||
WorldSession::~WorldSession()
|
WorldSession::~WorldSession()
|
||||||
{
|
{
|
||||||
///- unload player if not unloaded
|
///- unload player if not unloaded
|
||||||
if(_player)
|
if (_player)
|
||||||
LogoutPlayer(true);
|
LogoutPlayer (true);
|
||||||
|
|
||||||
/// - If have unclosed socket, close it
|
/// - If have unclosed socket, close it
|
||||||
if (m_Socket)
|
if (m_Socket)
|
||||||
{
|
{
|
||||||
m_Socket->CloseSocket ();
|
m_Socket->CloseSocket ();
|
||||||
m_Socket->RemoveReference ();
|
m_Socket->RemoveReference ();
|
||||||
m_Socket = NULL;
|
m_Socket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
///- empty incoming packet queue
|
///- empty incoming packet queue
|
||||||
while(!_recvQueue.empty())
|
while(!_recvQueue.empty())
|
||||||
{
|
{
|
||||||
WorldPacket *packet = _recvQueue.next();
|
WorldPacket *packet = _recvQueue.next ();
|
||||||
delete packet;
|
delete packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
sWorld.RemoveQueuedPlayer(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const
|
void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue