the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "SQRNetworkManager.h"
4
5bool SQRNetworkManager::s_safeToRespondToGameBootInvite = false;
6
7void SQRNetworkManager::SafeToRespondToGameBootInvite()
8{
9 s_safeToRespondToGameBootInvite = true;
10}
11
12int SQRNetworkManager::GetSendQueueSizeBytes()
13{
14 int queueSize = 0;
15 int playerCount = GetPlayerCount();
16 for(int i = 0; i < playerCount; ++i)
17 {
18 SQRNetworkPlayer *player = GetPlayerByIndex( i );
19 if( player != NULL )
20 {
21 queueSize += player->GetTotalSendQueueBytes();
22 }
23 }
24 return queueSize;
25}
26
27int SQRNetworkManager::GetSendQueueSizeMessages()
28{
29 int queueSize = 0;
30 int playerCount = GetPlayerCount();
31 for(int i = 0; i < playerCount; ++i)
32 {
33 SQRNetworkPlayer *player = GetPlayerByIndex( i );
34 if( player != NULL )
35 {
36 queueSize += player->GetTotalSendQueueMessages();
37 }
38 }
39 return queueSize;
40}
41
42int SQRNetworkManager::GetOutstandingAckCount(SQRNetworkPlayer *pSQRPlayer)
43{
44 int ackCount = 0;
45 int playerCount = GetPlayerCount();
46 for(int i = 0; i < playerCount; ++i)
47 {
48 SQRNetworkPlayer *pSQRPlayer2 = GetPlayerByIndex( i );
49 if( pSQRPlayer2 )
50 {
51 if( ( pSQRPlayer == pSQRPlayer2 ) || (pSQRPlayer->IsSameSystem(pSQRPlayer2) ) )
52 {
53 ackCount += pSQRPlayer2->m_acksOutstanding;
54 }
55 }
56 }
57 return ackCount;
58}
59
60void SQRNetworkManager::RequestWriteAck(int smallId)
61{
62 EnterCriticalSection(&m_csAckQueue);
63 m_queuedAckRequests.push(smallId);
64 LeaveCriticalSection(&m_csAckQueue);
65}
66
67void SQRNetworkManager::TickWriteAcks()
68{
69 EnterCriticalSection(&m_csAckQueue);
70 while(m_queuedAckRequests.size() > 0)
71 {
72 int smallId = m_queuedAckRequests.front();
73 m_queuedAckRequests.pop();
74 SQRNetworkPlayer *player = GetPlayerBySmallId(smallId);
75 if( player )
76 {
77 LeaveCriticalSection(&m_csAckQueue);
78 player->WriteAck();
79 EnterCriticalSection(&m_csAckQueue);
80 }
81 }
82 LeaveCriticalSection(&m_csAckQueue);
83}