mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04: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
|
||||
{
|
||||
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);
|
||||
money = plr.GetMoney();
|
||||
total_player_time = plr.GetTotalPlayedTime();
|
||||
|
|
|
|||
|
|
@ -178,67 +178,67 @@ bool World::RemoveSession(uint32 id)
|
|||
|
||||
void World::AddSession(WorldSession* s)
|
||||
{
|
||||
addSessQueue.add(s);
|
||||
addSessQueue.add(s);
|
||||
}
|
||||
|
||||
void
|
||||
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
|
||||
///- if player is in loading and want to load again, return
|
||||
if (!RemoveSession (s->GetAccountId ()))
|
||||
///- kick already loaded player with same account (if any) and remove session
|
||||
///- if player is in loading and want to load again, return
|
||||
if (!RemoveSession (s->GetAccountId ()))
|
||||
{
|
||||
s->KickPlayer ();
|
||||
m_kicked_sessions.insert (s);
|
||||
return;
|
||||
s->KickPlayer ();
|
||||
m_kicked_sessions.insert (s);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldSession* old = m_sessions[s->GetAccountId ()];
|
||||
m_sessions[s->GetAccountId ()] = s;
|
||||
WorldSession* old = m_sessions[s->GetAccountId ()];
|
||||
m_sessions[s->GetAccountId ()] = s;
|
||||
|
||||
// if session already exist, prepare to it deleting at next world update
|
||||
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
|
||||
if (old)
|
||||
m_kicked_sessions.insert (old);
|
||||
// if session already exist, prepare to it deleting at next world update
|
||||
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
|
||||
if (old)
|
||||
m_kicked_sessions.insert (old);
|
||||
|
||||
uint32 Sessions = GetActiveAndQueuedSessionCount ();
|
||||
uint32 pLimit = GetPlayerAmountLimit ();
|
||||
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
||||
bool inQueue = false;
|
||||
//so we don't count the user trying to
|
||||
//login as a session and queue the socket that we are using
|
||||
--Sessions;
|
||||
uint32 Sessions = GetActiveAndQueuedSessionCount ();
|
||||
uint32 pLimit = GetPlayerAmountLimit ();
|
||||
uint32 QueueSize = GetQueueSize (); //number of players in the queue
|
||||
bool inQueue = false;
|
||||
//so we don't count the user trying to
|
||||
//login as a session and queue the socket that we are using
|
||||
--Sessions;
|
||||
|
||||
if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER )
|
||||
if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER )
|
||||
{
|
||||
AddQueuedPlayer (s);
|
||||
UpdateMaxSessionCounters ();
|
||||
sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize);
|
||||
return;
|
||||
AddQueuedPlayer (s);
|
||||
UpdateMaxSessionCounters ();
|
||||
sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize);
|
||||
return;
|
||||
}
|
||||
|
||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||
packet << uint8 (AUTH_OK);
|
||||
packet << uint32 (0); // unknown random value...
|
||||
packet << uint8 (0);
|
||||
packet << uint32 (0);
|
||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
s->SendPacket (&packet);
|
||||
WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1 + 4 + 1);
|
||||
packet << uint8 (AUTH_OK);
|
||||
packet << uint32 (0); // unknown random value...
|
||||
packet << uint8 (0);
|
||||
packet << uint32 (0);
|
||||
packet << uint8 (s->Expansion()); // 0 - normal, 1 - TBC, must be set in database manually for each account
|
||||
s->SendPacket (&packet);
|
||||
|
||||
UpdateMaxSessionCounters ();
|
||||
UpdateMaxSessionCounters ();
|
||||
|
||||
// Updates the population
|
||||
if (pLimit > 0)
|
||||
// Updates the population
|
||||
if (pLimit > 0)
|
||||
{
|
||||
float popu = GetActiveSessionCount (); //updated number of users on the server
|
||||
popu /= pLimit;
|
||||
popu *= 2;
|
||||
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||
sLog.outDetail ("Server Population (%f).", popu);
|
||||
float popu = GetActiveSessionCount (); //updated number of users on the server
|
||||
popu /= pLimit;
|
||||
popu *= 2;
|
||||
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
|
||||
sLog.outDetail ("Server Population (%f).", popu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2414,7 +2414,10 @@ void World::UpdateSessions( time_t diff )
|
|||
|
||||
///- Delete kicked sessions at add new session
|
||||
for (std::set<WorldSession*>::iterator itr = m_kicked_sessions.begin(); itr != m_kicked_sessions.end(); ++itr)
|
||||
{
|
||||
RemoveQueuedPlayer (*itr);
|
||||
delete *itr;
|
||||
}
|
||||
m_kicked_sessions.clear();
|
||||
|
||||
///- Then send an update signal to remaining ones
|
||||
|
|
|
|||
|
|
@ -58,25 +58,23 @@ _logoutTime(0), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyL
|
|||
WorldSession::~WorldSession()
|
||||
{
|
||||
///- unload player if not unloaded
|
||||
if(_player)
|
||||
LogoutPlayer(true);
|
||||
if (_player)
|
||||
LogoutPlayer (true);
|
||||
|
||||
/// - If have unclosed socket, close it
|
||||
if (m_Socket)
|
||||
if (m_Socket)
|
||||
{
|
||||
m_Socket->CloseSocket ();
|
||||
m_Socket->RemoveReference ();
|
||||
m_Socket = NULL;
|
||||
m_Socket->CloseSocket ();
|
||||
m_Socket->RemoveReference ();
|
||||
m_Socket = NULL;
|
||||
}
|
||||
|
||||
///- empty incoming packet queue
|
||||
while(!_recvQueue.empty())
|
||||
{
|
||||
WorldPacket *packet = _recvQueue.next();
|
||||
WorldPacket *packet = _recvQueue.next ();
|
||||
delete packet;
|
||||
}
|
||||
|
||||
sWorld.RemoveQueuedPlayer(this);
|
||||
}
|
||||
|
||||
void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue