Skip to content

Commit 5b244d9

Browse files
committed
- Added debug commands to force relays
- RA changes
1 parent d34c724 commit 5b244d9

5 files changed

Lines changed: 71 additions & 4 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/NetworkMesh.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ class NetworkMesh
105105
m_cbOnConnected = nullptr;
106106
}
107107

108+
int getMaximumLatency()
109+
{
110+
int highestLatency = 0;
111+
112+
for (auto& kvPair : m_mapConnections)
113+
{
114+
PlayerConnection& conn = kvPair.second;
115+
if (conn.GetLatency() > highestLatency)
116+
{
117+
highestLatency = conn.GetLatency();
118+
}
119+
}
120+
121+
return highestLatency;
122+
}
123+
124+
108125
std::queue<QueuedGamePacket> m_queueQueuedGamePackets;
109126

110127
bool HasGamePacket();

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,26 @@ Bool handleLobbySlashCommands(UnicodeString uText)
195195

196196
return TRUE; // was a slash command
197197
}
198+
else if (token == "forcerelay")
199+
{
200+
extern bool g_bForceRelay;
201+
extern UnsignedInt m_exeCRCOriginal;
202+
g_bForceRelay = true;
203+
m_exeCRCOriginal = TheWritableGlobalData->m_exeCRC;
204+
TheWritableGlobalData->m_exeCRC = 123456;
205+
GadgetListBoxAddEntryText(listboxLobbyChat, UnicodeString(L"Relays are now forced on. You will only be able to join lobbies where the same option has been set. Use /allowrelay to reset this"), GameMakeColor(255, 0, 0, 255), -1, -1);
206+
return TRUE; // was a slash command
207+
}
208+
else if (token == "allowrelay")
209+
{
210+
extern bool g_bForceRelay;
211+
extern UnsignedInt m_exeCRCOriginal;
212+
g_bForceRelay = false;
213+
TheWritableGlobalData->m_exeCRC = m_exeCRCOriginal;
214+
m_exeCRCOriginal = 0;
215+
GadgetListBoxAddEntryText(listboxLobbyChat, UnicodeString(L"Relays are now optional again. You will only be able to join lobbies where the same option has been set. Use /forcerelay to reset this"), GameMakeColor(255, 0, 0, 255), -1, -1);
216+
return TRUE; // was a slash command
217+
}
198218
else if (token == "refresh")
199219
{
200220
// Added 2/19/03 added the game refresh

GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,10 +1279,30 @@ void ConnectionManager::updateRunAhead(Int oldRunAhead, Int frameRate, Bool didS
12791279
#endif
12801280

12811281
DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::updateRunAhead - minFps after adjustment is %d", minFps));
1282-
Int newRunAhead = (Int)((getMaximumLatency() / 2.0) * (Real)minFps);
1282+
Int newRunAhead = 0;
1283+
if (TheNGMPGame == nullptr)
1284+
{
1285+
newRunAhead = (Int)((getMaximumLatency() / 2.0) * (Real)minFps);
1286+
NetworkLog(ELogVerbosity::LOG_DEBUG, "New run ahead is %d, formula is maxlat is %f (div 2: %f), minfps is %d", newRunAhead, getMaximumLatency(), getMaximumLatency() / 2.f, minFps);
1287+
}
1288+
else
1289+
{
1290+
// for NGMP use our data, its more accurate
1291+
NetworkMesh* pMesh = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetNetworkMesh();
1292+
1293+
if (pMesh != nullptr)
1294+
{
1295+
float maxLatency = (float)pMesh->getMaximumLatency();
1296+
newRunAhead = (Int)(maxLatency * (1000.f / TheNetwork->getFrameRate()));
1297+
1298+
NetworkLog(ELogVerbosity::LOG_DEBUG, "New run ahead is %d, formula is maxlat is %f, minfps is %d", newRunAhead, maxLatency, minFps);
1299+
}
1300+
1301+
}
1302+
12831303
newRunAhead += (newRunAhead * TheGlobalData->m_networkRunAheadSlack) / 100; // Add in 10% of slack to the run ahead in case of network hiccups.
12841304

1285-
NetworkLog(ELogVerbosity::LOG_DEBUG, "New run ahead is %d, formula is maxlat is %f (div 2: %f), minfps is %d", newRunAhead, getMaximumLatency(), getMaximumLatency()/2.f, minFps);
1305+
12861306
if (newRunAhead < MIN_RUNAHEAD) {
12871307
newRunAhead = MIN_RUNAHEAD; // make sure its at least MIN_RUNAHEAD.
12881308
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void NGMPGame::launchGame(void)
356356
TheWritableGlobalData->m_showMetrics = true;
357357
#endif
358358

359-
TheWritableGlobalData->m_networkRunAheadSlack = 12;
359+
TheWritableGlobalData->m_networkRunAheadSlack = 10;
360360

361361
#if defined(GENERALS_ONLINE_HIGH_FPS_RENDER)
362362
TheWritableGlobalData->m_horizontalScrollSpeedFactor = NGMP_OnlineServicesManager::Settings.Camera_MoveSpeedRatio();

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "ValveNetworkingSockets/steam/isteamnetworkingutils.h"
1414
#include "ValveNetworkingSockets/steam/steamnetworkingcustomsignaling.h"
1515

16+
bool g_bForceRelay = false;
17+
UnsignedInt m_exeCRCOriginal = 0;
18+
1619
// Called when a connection undergoes a state transition
1720
void OnSteamNetConnectionStatusChanged(SteamNetConnectionStatusChangedCallback_t* pInfo)
1821
{
@@ -436,7 +439,14 @@ NetworkMesh::NetworkMesh()
436439
SteamNetworkingUtils()->SetGlobalConfigValueString(k_ESteamNetworkingConfig_P2P_TURN_PassList, NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetLobbyTurnToken().c_str());
437440

438441
// Allow sharing of any kind of ICE address.
439-
SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_P2P_Transport_ICE_Enable, k_nSteamNetworkingConfig_P2P_Transport_ICE_Enable_All);
442+
if (g_bForceRelay)
443+
{
444+
SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_P2P_Transport_ICE_Enable, k_nSteamNetworkingConfig_P2P_Transport_ICE_Enable_Relay);
445+
}
446+
else
447+
{
448+
SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_P2P_Transport_ICE_Enable, k_nSteamNetworkingConfig_P2P_Transport_ICE_Enable_All);
449+
}
440450

441451
m_hListenSock = k_HSteamListenSocket_Invalid;
442452

0 commit comments

Comments
 (0)