Skip to content
Permalink
Browse files

Fixed #8744 (Player socket / slot override bug)

  • Loading branch information...
ccw808 committed Jul 1, 2015
1 parent 215d31b commit 7770e1427c986069091a975c951be80e53178fa0
@@ -52,8 +52,6 @@ CPlayer::CPlayer ( CPlayerManager* pPlayerManager, class CScriptDebugging* pScri

m_uiScriptDebugLevel = 0;

m_ullTimeConnected = GetTickCount64_ ();

m_tNickChange = 0;

m_pPlayerTextManager = new CPlayerTextManager ( this );
@@ -106,7 +104,8 @@ CPlayer::CPlayer ( CPlayerManager* pPlayerManager, class CScriptDebugging* pScri
m_pPlayerStatsPacket = new CPlayerStatsPacket ( );

m_UpdateNearListTimer.SetMaxIncrement ( 500, true );
m_LastReceivedSyncTimer.SetMaxIncrement( 2000, true );
m_LastReceivedSyncTimer.SetUseModuleTickCount( true );
m_ConnectedTimer.SetUseModuleTickCount( true );
}


@@ -101,7 +101,7 @@ class CPlayer : public CPed, public CClient
inline void SetDoNotSendEntities ( bool bDont ) { m_bDoNotSendEntities = bDont; };

inline int GetClientType ( void ) { return CClient::CLIENT_PLAYER; };
inline unsigned long long GetTimeConnected ( void ) const { return m_ullTimeConnected; };
unsigned long long GetTimeSinceConnected ( void ) { return m_ConnectedTimer.Get(); }

inline const char* GetNick ( void ) { return m_strNick; };
void SetNick ( const char* szNick );
@@ -380,7 +380,7 @@ class CPlayer : public CPed, public CClient

bool m_bAkimboArmUp;

unsigned long long m_ullTimeConnected;
CElapsedTime m_ConnectedTimer;

NetServerPlayerID m_PlayerSocket;
uint m_uiPing;
@@ -18,6 +18,7 @@ CPlayerManager::CPlayerManager ( void )
{
// Init
m_pScriptDebugging = NULL;
m_ZombieCheckTimer.SetUseModuleTickCount( true );
}


@@ -29,21 +30,7 @@ CPlayerManager::~CPlayerManager ( void )

void CPlayerManager::DoPulse ( void )
{
// TODO: Low Priorityy: No need to do this every frame. Could be done every minute or so.
// Remove any players that have been connected for very long (90 sec) but hasn't reached the verifying step
unsigned long long ullTimeNow = GetTickCount64_ ();
for ( list < CPlayer* > ::const_iterator iter = m_Players.begin () ; iter != m_Players.end (); iter++ )
{
if ( (*iter)->GetStatus () == STATUS_CONNECTED && ullTimeNow > (*iter)->GetTimeConnected () + 90000 )
{
// Tell the console he timed out due during connect
CLogger::LogPrintf ( "INFO: %s (%s) timed out during connect\n", (*iter)->GetNick (), (*iter)->GetSourceIP () );

// Remove him
delete *iter;
break;
}
}
PulseZombieCheck();

list < CPlayer* > ::const_iterator iter = m_Players.begin ();
for ( ; iter != m_Players.end (); iter++ )
@@ -53,6 +40,43 @@ void CPlayerManager::DoPulse ( void )
}


void CPlayerManager::PulseZombieCheck( void )
{
// Only check once a second
if ( m_ZombieCheckTimer.Get() < 1000 )
return;
m_ZombieCheckTimer.Reset();

for ( std::list < CPlayer* > ::const_iterator iter = m_Players.begin() ; iter != m_Players.end(); iter++ )
{
CPlayer* pPlayer = *iter;

if ( pPlayer->GetStatus() == STATUS_CONNECTED )
{
// Remove any players that have been connected for very long (90 sec) but haven't reached the verifying step
if ( pPlayer->GetTimeSinceConnected() > 90000 )
{
CLogger::LogPrintf( "INFO: %s (%s) timed out during connect\n", pPlayer->GetNick(), pPlayer->GetSourceIP() );
g_pGame->QuitPlayer( *pPlayer, CClient::QUIT_QUIT, false );
}
}
else
{
// Remove any players that are joined, but not sending sync and have incorrect connection info
if ( pPlayer->GetTimeSinceReceivedSync() > 20000 )
{
if ( !g_pRealNetServer->IsValidSocket( pPlayer->GetSocket() ) )
{
CLogger::LogPrintf( "INFO: %s (%s) connection gone away\n", pPlayer->GetNick(), pPlayer->GetSourceIP() );
pPlayer->Send( CPlayerDisconnectedPacket( CPlayerDisconnectedPacket::KICK, "hacky code" ) );
g_pGame->QuitPlayer( *pPlayer, CClient::QUIT_TIMEOUT );
}
}
}
}
}


CPlayer* CPlayerManager::Create ( const NetServerPlayerID& PlayerSocket )
{
// Check socket is free
@@ -30,6 +30,7 @@ class CPlayerManager
~CPlayerManager ( void );

void DoPulse ( void );
void PulseZombieCheck ( void );

inline void SetScriptDebugging ( class CScriptDebugging* pScriptDebugging ) { m_pScriptDebugging = pScriptDebugging; };

@@ -70,6 +71,7 @@ class CPlayerManager
CMappedList < CPlayer* > m_Players;
std::map < NetServerPlayerID, CPlayer* > m_SocketPlayerMap;
SString m_strLowestConnectedPlayerVersion;
CElapsedTime m_ZombieCheckTimer;
};

#endif
@@ -22,6 +22,7 @@ namespace
bool ms_bNetStatisticsLastSavedValid = false;
NetStatistics ms_NetStatisticsLastSaved;
NetServerPlayerID ms_NetStatisticsLastFor;
bool ms_bNetStatisticsLastResult;
bool ms_bBandwidthStatisticsLastSavedValid = false;
SBandwidthStatistics ms_BandwidthStatisticsLastSaved;
bool ms_bPingStatusLastSavedValid = false;
@@ -310,8 +311,9 @@ bool CNetServerBuffer::GetNetworkStatistics ( NetStatistics* pDest, const NetSer
// Save results
ms_NetStatisticsLastSaved = *pDest;
ms_NetStatisticsLastFor = PlayerID;
ms_bNetStatisticsLastResult = pArgs->result;
ms_bNetStatisticsLastSavedValid = true;
return pArgs->result;
return ms_bNetStatisticsLastResult;
}

// Start a new async read,
@@ -321,7 +323,7 @@ bool CNetServerBuffer::GetNetworkStatistics ( NetStatistics* pDest, const NetSer

// but use results from previous
*pDest = ms_NetStatisticsLastSaved;
return true;
return ms_bNetStatisticsLastResult;
}


@@ -145,7 +145,8 @@ class CNetServer
virtual bool GetScriptInfo ( const char* cpInBuffer, uint uiInSize, SScriptInfo* pOutInfo ) { return false; }
virtual bool DecryptScript ( const char* cpInBuffer, uint uiInSize, const char** pcpOutBuffer, uint* puiOutSize, const char* szScriptName ) { return false; }
virtual bool GetPlayerPacketUsageStats ( uchar* packetIdList, uint uiNumPacketIds, SPlayerPacketUsage* pOutStats, uint uiTopCount ) { return false; }
virtual const char* GetLogOutput ( void ) { return NULL; }
virtual const char* GetLogOutput ( void ) { return NULL; }
virtual bool IsValidSocket ( const NetServerPlayerID& playerID ) { assert( 0 ); return false; }
};

#endif
@@ -78,7 +78,7 @@

#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
#define _SERVER_NET_MODULE_VERSION 0x090 // (0x000 - 0xfff) Lvl9 wizards only
#define _SERVER_NET_MODULE_VERSION 0x091 // (0x000 - 0xfff) Lvl9 wizards only
#define _NETCODE_VERSION 0x1D8 // (0x000 - 0xfff) Increment when net messages change (pre-release)
#define MTA_DM_BITSTREAM_VERSION 0x060 // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).

0 comments on commit 7770e14

Please sign in to comment.
You can’t perform that action at this time.