* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
83 lines
1.8 KiB
C++
83 lines
1.8 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "SQRNetworkManager.h"
|
|
|
|
bool SQRNetworkManager::s_safeToRespondToGameBootInvite = false;
|
|
|
|
void SQRNetworkManager::SafeToRespondToGameBootInvite()
|
|
{
|
|
s_safeToRespondToGameBootInvite = true;
|
|
}
|
|
|
|
int SQRNetworkManager::GetSendQueueSizeBytes()
|
|
{
|
|
int queueSize = 0;
|
|
int playerCount = GetPlayerCount();
|
|
for(int i = 0; i < playerCount; ++i)
|
|
{
|
|
SQRNetworkPlayer *player = GetPlayerByIndex( i );
|
|
if( player != nullptr )
|
|
{
|
|
queueSize += player->GetTotalSendQueueBytes();
|
|
}
|
|
}
|
|
return queueSize;
|
|
}
|
|
|
|
int SQRNetworkManager::GetSendQueueSizeMessages()
|
|
{
|
|
int queueSize = 0;
|
|
int playerCount = GetPlayerCount();
|
|
for(int i = 0; i < playerCount; ++i)
|
|
{
|
|
SQRNetworkPlayer *player = GetPlayerByIndex( i );
|
|
if( player != nullptr )
|
|
{
|
|
queueSize += player->GetTotalSendQueueMessages();
|
|
}
|
|
}
|
|
return queueSize;
|
|
}
|
|
|
|
int SQRNetworkManager::GetOutstandingAckCount(SQRNetworkPlayer *pSQRPlayer)
|
|
{
|
|
int ackCount = 0;
|
|
int playerCount = GetPlayerCount();
|
|
for(int i = 0; i < playerCount; ++i)
|
|
{
|
|
SQRNetworkPlayer *pSQRPlayer2 = GetPlayerByIndex( i );
|
|
if( pSQRPlayer2 )
|
|
{
|
|
if( ( pSQRPlayer == pSQRPlayer2 ) || (pSQRPlayer->IsSameSystem(pSQRPlayer2) ) )
|
|
{
|
|
ackCount += pSQRPlayer2->m_acksOutstanding;
|
|
}
|
|
}
|
|
}
|
|
return ackCount;
|
|
}
|
|
|
|
void SQRNetworkManager::RequestWriteAck(int smallId)
|
|
{
|
|
EnterCriticalSection(&m_csAckQueue);
|
|
m_queuedAckRequests.push(smallId);
|
|
LeaveCriticalSection(&m_csAckQueue);
|
|
}
|
|
|
|
void SQRNetworkManager::TickWriteAcks()
|
|
{
|
|
EnterCriticalSection(&m_csAckQueue);
|
|
while(m_queuedAckRequests.size() > 0)
|
|
{
|
|
int smallId = m_queuedAckRequests.front();
|
|
m_queuedAckRequests.pop();
|
|
SQRNetworkPlayer *player = GetPlayerBySmallId(smallId);
|
|
if( player )
|
|
{
|
|
LeaveCriticalSection(&m_csAckQueue);
|
|
player->WriteAck();
|
|
EnterCriticalSection(&m_csAckQueue);
|
|
}
|
|
}
|
|
LeaveCriticalSection(&m_csAckQueue);
|
|
} |