mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 06:47:45 +00:00
More fixes for bad sessions/incorrectly loaded players
This commit is contained in:
parent
93d2156549
commit
5bb4b8ba72
5 changed files with 23 additions and 3 deletions
Binary file not shown.
Before Width: | Height: | Size: 537 KiB After Width: | Height: | Size: 27 KiB |
|
@ -389,6 +389,13 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
session = g_serverZone.getSession( playerId );
|
||||
}
|
||||
|
||||
if( !session->isValid() ) //TODO: Catch more things in lobby and send real errors
|
||||
{
|
||||
g_log.error( "[" + std::string(id) + "] Session INVALID, disconnecting" );
|
||||
Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// if not set, set the session for this connection
|
||||
if( !m_pSession && session )
|
||||
m_pSession = session;
|
||||
|
@ -423,8 +430,6 @@ void Core::Network::GameConnection::handlePackets( const Core::Network::Packets:
|
|||
sendSinglePacket( &pPe );
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
Core::Session::Session( uint32_t sessionId )
|
||||
: m_sessionId( sessionId )
|
||||
, m_isValid( false )
|
||||
, m_lastDataTime( static_cast< uint32_t >( time( nullptr ) ) )
|
||||
{
|
||||
|
||||
|
@ -50,7 +51,12 @@ bool Core::Session::loadPlayer()
|
|||
m_pPlayer = Entity::PlayerPtr( new Entity::Player() );
|
||||
|
||||
if( !m_pPlayer->load( m_sessionId, shared_from_this() ) )
|
||||
{
|
||||
m_isValid = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isValid = true;
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -80,6 +86,11 @@ uint32_t Core::Session::getLastDataTime() const
|
|||
return m_lastDataTime;
|
||||
}
|
||||
|
||||
bool Core::Session::isValid() const
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
void Core::Session::updateLastDataTime()
|
||||
{
|
||||
m_lastDataTime = static_cast< uint32_t >( time( nullptr ) );
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace Core {
|
|||
|
||||
void update();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
Entity::PlayerPtr getPlayer() const;
|
||||
|
||||
private:
|
||||
|
@ -44,6 +46,8 @@ namespace Core {
|
|||
|
||||
uint32_t m_lastDataTime;
|
||||
|
||||
bool m_isValid;
|
||||
|
||||
Network::GameConnectionPtr m_pZoneConnection;
|
||||
Network::GameConnectionPtr m_pChatConnection;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue