Skip to content

Commit d032257

Browse files
committed
- Improve direct connectivity
- Better punchthrough impl - Test larger DMA pool
1 parent 05fc13a commit d032257

2 files changed

Lines changed: 42 additions & 12 deletions

File tree

GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,13 +2022,23 @@ void DynamicMemoryAllocator::init(MemoryPoolFactory *factory, Int numSubPools, c
20222022
{
20232023
const PoolInitRec defaultDMA[7] =
20242024
{
2025+
#if defined(GENERALS_ONLINE) && defined(GENERALS_ONLINE_USE_LARGER_DMAPOOL)
2026+
{ "dmaPool_16", 64, 64, 64 },
2027+
{ "dmaPool_32", 64, 64, 64 },
2028+
{ "dmaPool_64", 64, 64, 64 },
2029+
{ "dmaPool_128", 128, 64, 64 },
2030+
{ "dmaPool_256", 256, 64, 64 },
2031+
{ "dmaPool_2048", 2048, 64, 64 },
2032+
{ "dmaPool_4096", 4096, 64, 64 },
2033+
#else
20252034
{ "dmaPool_16", 16, 64, 64 },
20262035
{ "dmaPool_32", 32, 64, 64 },
20272036
{ "dmaPool_64", 64, 64, 64 },
20282037
{ "dmaPool_128", 128, 64, 64 },
20292038
{ "dmaPool_256", 256, 64, 64 },
20302039
{ "dmaPool_512", 512, 64, 64 },
20312040
{ "dmaPool_1024", 1024, 64, 64 }
2041+
#endif
20322042
};
20332043

20342044
if (numSubPools == 0 || pParms == NULL)

GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/NetworkMesh.cpp

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ void NetworkMesh::SendToMesh(NetworkPacket& packet, std::vector<int64_t> vecTarg
192192
}
193193
else
194194
{
195-
NetworkLog("Packet Failed To Send! %s:%d", ip.c_str(), peer->address.port);
195+
NetworkLog("Packet Failed To Send! %s:%d, result was %d", ip.c_str(), peer->address.port, ret);
196196
}
197197
}
198198
}
@@ -430,6 +430,21 @@ void NetworkMesh::ConnectToSingleUser(ENetAddress addr, Int64 user_id, bool bIsR
430430
/* Initiate the connection, allocating the 3 channels. */
431431

432432
ENetPeer* peer = enet_host_connect(enetInstance, &addr, 3, 0);
433+
enet_peer_timeout(peer, 3, 1000, 1000);
434+
435+
#if defined(NETWORK_CONNECTION_DEBUG)
436+
char ip1[INET_ADDRSTRLEN + 1] = { 0 };
437+
char ip2[INET_ADDRSTRLEN + 1] = { 0 };
438+
if (enet_address_get_host_ip(&peer->host->receivedAddress, ip1, sizeof(ip1)) == 0 && enet_address_get_host_ip(&peer->host->address, ip2, sizeof(ip2)) == 0)
439+
{
440+
NetworkLog("[DEBUG] New enet_host_connect with address %s:%u. and received address %s:%u",
441+
ip1,
442+
peer->host->receivedAddress.port,
443+
ip2,
444+
peer->address.port);
445+
}
446+
#endif
447+
433448

434449
// don't care about in-game
435450
if (!TheGameLogic->isInGame())
@@ -1058,8 +1073,16 @@ void NetworkMesh::Tick()
10581073
{
10591074
if (pConnection->m_State == EConnectionState::CONNECTING_DIRECT)
10601075
{
1061-
NetworkLog("[SERVER] %d timed out while connecting directly, attempting to use relay\n", pConnection->m_userID);
1062-
ConnectToUserViaRelay(pConnection->m_userID);
1076+
if (pConnection->m_ConnectionAttempts < 3)
1077+
{
1078+
NetworkLog("[SERVER] Attempting to connect to %d, attempt number %d\n", pConnection->m_userID, pConnection->m_ConnectionAttempts + 1);
1079+
ConnectToSingleUser(pConnection->m_address, pConnection->m_userID, true);
1080+
}
1081+
else
1082+
{
1083+
NetworkLog("[SERVER] %d timed out while connecting directly, attempting to use relay\n", pConnection->m_userID);
1084+
ConnectToUserViaRelay(pConnection->m_userID);
1085+
}
10631086
}
10641087
else
10651088
{
@@ -1157,7 +1180,7 @@ PlayerConnection::PlayerConnection(int64_t userID, ENetAddress addr, ENetPeer* p
11571180
}
11581181
// otherwise, keep whatever start we were in, its just a connection update
11591182

1160-
enet_peer_timeout(m_peer, 5, 1000, 1000);
1183+
enet_peer_timeout(m_peer, 3, 1000, 1000);
11611184

11621185
NetworkMesh* pMesh = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetNetworkMesh();
11631186
if (pMesh != nullptr)
@@ -1243,18 +1266,15 @@ int PlayerConnection::SendPacket(NetworkPacket& packet, int channel)
12431266
if (m_State != EConnectionState::CONNECTED_DIRECT && m_State != EConnectionState::CONNECTED_RELAY)
12441267
{
12451268
NetworkLog("WARNING: Attempting to send packet before connected, state is %d", m_State);
1246-
return 0;
1269+
return -7;
12471270
}
12481271
}
1249-
1272+
12501273
auto currentLobby = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetCurrentLobby();
12511274

1252-
if (m_State == EConnectionState::NOT_CONNECTED
1253-
|| m_State == EConnectionState::CONNECTION_FAILED)
1254-
{
1255-
return -1;
1256-
}
1257-
else if (m_State == EConnectionState::CONNECTING_DIRECT || m_State == EConnectionState::CONNECTED_DIRECT)
1275+
// Allow handshake in all stages
1276+
if ((m_State == EConnectionState::CONNECTING_DIRECT || m_State == EConnectionState::CONNECTED_DIRECT) || ((m_State == EConnectionState::NOT_CONNECTED
1277+
|| m_State == EConnectionState::CONNECTION_FAILED) && channel == 2))
12581278
{
12591279
CBitStream* pBitStream = packet.Serialize();
12601280
pBitStream->Encrypt(currentLobby.EncKey, currentLobby.EncIV);

0 commit comments

Comments
 (0)