Skip to content

Commit 1a7c1ef

Browse files
authored
chore(network): Remove legacy Send Delay (#3007)
1 parent f3051c0 commit 1a7c1ef

14 files changed

Lines changed: 30 additions & 243 deletions

File tree

Core/GameEngine/Include/Common/OptionPreferences.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class OptionPreferences : public UserPreferences
8484
Bool getScreenEdgeScrollEnabledInWindowedApp() const;
8585
Bool getScreenEdgeScrollEnabledInFullscreenApp() const;
8686
ScreenEdgeScrollMode getScreenEdgeScrollMode() const;
87-
Bool getSendDelay();
8887
Int getFirewallBehavior();
8988
Short getFirewallPortAllocationDelta();
9089
UnsignedShort getFirewallPortOverride();

Core/GameEngine/Include/GameNetwork/FirewallHelper.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ class FirewallHelperClass {
143143
*/
144144
FIREWALL_TYPE_SMART_MANGLING = 4,
145145

146-
/*
147-
** This is a firewall that exhibits the bug as seen in the Netgear firewalls. A previously good
148-
** source port mapping will change in response to unsolicited traffic from a known IP.
149-
*/
150-
FIREWALL_TYPE_NETGEAR_BUG = 8,
146+
FIREWALL_TYPE_UNUSED = 8,
151147

152148
/*
153149
** This firewall has a simple absolute offset port allocation scheme.
@@ -225,20 +221,6 @@ class FirewallHelperClass {
225221
return(TRUE);
226222
};
227223

228-
Bool isNetgear(FirewallBehaviorType behavior) {
229-
if ((behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
230-
return(TRUE);
231-
}
232-
return(FALSE);
233-
};
234-
235-
Bool isNetgear() {
236-
if ((m_behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
237-
return(TRUE);
238-
}
239-
return(FALSE);
240-
};
241-
242224

243225

244226
private:

Core/GameEngine/Include/GameNetwork/NAT.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ enum NATStateType CPP_11(: Int) {
4747
enum NATConnectionState CPP_11(: Int) {
4848
NATCONNECTIONSTATE_NOSTATE,
4949
NATCONNECTIONSTATE_WAITINGTOBEGIN,
50-
// NATCONNECTIONSTATE_NETGEARDELAY,
5150
NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE,
5251
NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT,
5352
NATCONNECTIONSTATE_WAITINGFORRESPONSE,

Core/GameEngine/Source/Common/OptionPreferences.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -451,18 +451,6 @@ Int OptionPreferences::getStaticGameDetail()
451451
return TheGameLODManager->getStaticGameLODIndex(it->second);
452452
}
453453

454-
Bool OptionPreferences::getSendDelay()
455-
{
456-
OptionPreferences::const_iterator it = find("SendDelay");
457-
if (it == end())
458-
return TheGlobalData->m_firewallSendDelay;
459-
460-
if (stricmp(it->second.str(), "yes") == 0) {
461-
return TRUE;
462-
}
463-
return FALSE;
464-
}
465-
466454
Int OptionPreferences::getFirewallBehavior()
467455
{
468456
OptionPreferences::const_iterator it = find("FirewallBehavior");

Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,6 @@ Bool FirewallHelperClass::detectionBeginUpdate() {
626626
m_behavior = FIREWALL_TYPE_SIMPLE;
627627
DEBUG_LOG(("Source port %d specified by user", TheGlobalData->m_firewallPortOverride));
628628

629-
if (TheGlobalData->m_firewallSendDelay) {
630-
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
631-
addbehavior |= (UnsignedInt)m_behavior;
632-
m_behavior = (FirewallBehaviorType) addbehavior;
633-
DEBUG_LOG(("Netgear bug specified by command line or SendDelay flag"));
634-
}
635629
m_currentState = DETECTIONSTATE_DONE;
636630
return TRUE;
637631
}
@@ -714,20 +708,6 @@ Bool FirewallHelperClass::detectionBeginUpdate() {
714708
// memcpy(&(m_manglers[i]), &mangler_addresses[i][0], 4);
715709
}
716710

717-
DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Testing for Netgear bug"));
718-
719-
/*
720-
** See if the user specified a netgear firewall - that will save us the trouble.
721-
*/
722-
if (TheGlobalData->m_firewallSendDelay) {
723-
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
724-
addbehavior |= (UnsignedInt)m_behavior;
725-
m_behavior = (FirewallBehaviorType) addbehavior;
726-
DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Netgear bug specified by command line or SendDelay flag"));
727-
} else {
728-
DEBUG_LOG(("FirewallHelperClass::detectionBeginUpdate - Netgear bug not specified"));
729-
}
730-
731711
/*
732712
** OK, we have our manglers.
733713
**
@@ -1173,28 +1153,7 @@ Bool FirewallHelperClass::detectionTest4Stage2Update() {
11731153
Bool FirewallHelperClass::detectionTest5Update() {
11741154
/*
11751155
** We have done all the tests we *have* to. There's other info that it would be nice to know though.
1176-
**
1177-
** Test for the netgear bug behavior.
11781156
*/
1179-
#if (0)
1180-
// moved to before test 1. Moved because this flag could be specified for another firewall
1181-
// for testing purposes and never get this far because it has behavior that doesn't require
1182-
// all the tests to be performed.
1183-
// BGC 10/1/02
1184-
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Testing for Netgear bug"));
1185-
1186-
/*
1187-
** See if the user specified a netgear firewall - that will save us the trouble.
1188-
*/
1189-
if (TheGlobalData->m_firewallSendDelay) {
1190-
UnsignedInt addbehavior = FIREWALL_TYPE_NETGEAR_BUG;
1191-
addbehavior |= (UnsignedInt)m_behavior;
1192-
m_behavior = (FirewallBehaviorType) addbehavior;
1193-
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Netgear bug specified by command line or SendDelay flag"));
1194-
} else {
1195-
DEBUG_LOG(("FirewallHelperClass::detectionTest5Update - Netgear bug not specified"));
1196-
}
1197-
#endif // #if (0)
11981157

11991158
DEBUG_LOG_RAW(("FirewallHelperClass::detectionTest5Update - All done, behavior is: "));
12001159

@@ -1207,9 +1166,6 @@ Bool FirewallHelperClass::detectionTest5Update() {
12071166
if ((m_behavior & FIREWALL_TYPE_SMART_MANGLING) != 0) {
12081167
DEBUG_LOG_RAW((" FIREWALL_TYPE_SMART_MANGLING "));
12091168
}
1210-
if ((m_behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) {
1211-
DEBUG_LOG_RAW((" FIREWALL_TYPE_NETGEAR_BUG "));
1212-
}
12131169
if ((m_behavior & FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION) != 0) {
12141170
DEBUG_LOG_RAW((" FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION "));
12151171
}
@@ -1433,10 +1389,6 @@ Int FirewallHelperClass::getFirewallHardness(FirewallBehaviorType behavior)
14331389
hardness += 3;
14341390
}
14351391

1436-
if (((UnsignedInt)FIREWALL_TYPE_NETGEAR_BUG & fw) != 0) {
1437-
hardness += 10;
1438-
}
1439-
14401392
if (((UnsignedInt)FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION & fw) != 0) {
14411393
hardness += 1;
14421394
}
@@ -1486,10 +1438,6 @@ Int FirewallHelperClass::getFirewallRetries(FirewallBehaviorType behavior)
14861438
retries += 1;
14871439
}
14881440

1489-
if (((UnsignedInt)FIREWALL_TYPE_NETGEAR_BUG & fw) != 0) {
1490-
//retries += 10;
1491-
}
1492-
14931441
if (((UnsignedInt)FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION & fw) != 0) {
14941442
//retries += 1;
14951443
}

Core/GameEngine/Source/GameNetwork/NAT.cpp

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ NATConnectionState NAT::connectionUpdate() {
404404
mangledPort = TheFirewallHelper->getManglerResponse(m_packetID);
405405
}
406406
if (mangledPort != 0) {
407-
// we got a response. now we need to start probing (unless of course we have a netgear)
407+
// we got a response. now we need to start probing
408408
processManglerResponse(mangledPort);
409409

410410
// we know there is a firewall helper if we got here.
@@ -499,50 +499,7 @@ void NAT::establishConnectionPaths() {
499499

500500
m_previousSourcePort = 0;
501501

502-
// check for netgear bug behavior.
503-
// as an aside, if there are more than 2 netgear bug firewall's in the game,
504-
// it probably isn't going to work so well. stupid netgear.
505-
506-
// nodes with a netgear bug behavior need to be matched up first. This prevents
507-
// the NAT table from being reset for connections to other nodes. This also happens
508-
// to be the reason why I call them "nodes" rather than "slots" or "players" as the
509-
// ordering has to be messed with to get the netgears to make love, not war.
510502
DEBUG_LOG(("NAT::establishConnectionPaths - about to set up the node list"));
511-
DEBUG_LOG(("NAT::establishConnectionPaths - doing the netgear stuff"));
512-
UnsignedInt otherNetgearNum = -1;
513-
for (i = 0; i < MAX_SLOTS; ++i) {
514-
if ((m_slotList != nullptr) && (m_slotList[i] != nullptr)) {
515-
if ((m_slotList[i]->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) {
516-
if (otherNetgearNum == -1) {
517-
// this is the start of a new pair, put it in as the first non -1 node connection pair thing.
518-
Int nodeindex = 0;
519-
while ((m_connectionPairs[m_connectionPairIndex][0][nodeindex] == -1) || (m_connectionNodes[nodeindex].m_slotIndex != -1)) {
520-
++nodeindex;
521-
}
522-
m_connectionNodes[nodeindex].m_slotIndex = i;
523-
m_connectionNodes[nodeindex].m_behavior = m_slotList[i]->getNATBehavior();
524-
connectionAssigned[i] = TRUE;
525-
otherNetgearNum = nodeindex;
526-
DEBUG_LOG(("NAT::establishConnectionPaths - first netgear in pair. assigning node %d to slot %d (%ls)", nodeindex, i, m_slotList[i]->getName().str()));
527-
} else {
528-
// this is the second in the pair of netgears, pair this up with the other one
529-
// for the first round.
530-
Int nodeindex = 0;
531-
while (m_connectionPairs[m_connectionPairIndex][0][nodeindex] != otherNetgearNum) {
532-
++nodeindex;
533-
}
534-
m_connectionNodes[nodeindex].m_slotIndex = i;
535-
m_connectionNodes[nodeindex].m_behavior = m_slotList[i]->getNATBehavior();
536-
connectionAssigned[i] = TRUE;
537-
otherNetgearNum = -1;
538-
DEBUG_LOG(("NAT::establishConnectionPaths - second netgear in pair. assigning node %d to slot %d (%ls)", nodeindex, i, m_slotList[i]->getName().str()));
539-
}
540-
}
541-
}
542-
}
543-
544-
// fill in the rest of the nodes with the remaining slots.
545-
DEBUG_LOG(("NAT::establishConnectionPaths - doing the non-Netgear nodes"));
546503
for (i = 0; i < MAX_SLOTS; ++i) {
547504
if (connectionAssigned[i] == TRUE) {
548505
continue;
@@ -664,6 +621,7 @@ void NAT::doThisConnectionRound() {
664621
if (i == m_localNodeNumber) {
665622
m_targetNodeNumber = targetNodeNumber;
666623
DEBUG_LOG(("NAT::doThisConnectionRound - Local node is connecting to node %d", m_targetNodeNumber));
624+
#if defined(DEBUG_LOGGING) || defined(DEBUG_CRASHING)
667625
UnsignedInt targetSlotIndex = m_connectionNodes[(m_connectionPairs[m_connectionPairIndex][m_connectionRound][i])].m_slotIndex;
668626
GameSlot *targetSlot = m_slotList[targetSlotIndex];
669627
GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex];
@@ -672,25 +630,10 @@ void NAT::doThisConnectionRound() {
672630
DEBUG_ASSERTCRASH(targetSlot != nullptr, ("trying to negotiate with a null target slot, slot is %d", m_connectionPairs[m_connectionPairIndex][m_connectionRound][i]));
673631
DEBUG_LOG(("NAT::doThisConnectionRound - Target slot index = %d (%ls)", targetSlotIndex, m_slotList[targetSlotIndex]->getName().str()));
674632
DEBUG_LOG(("NAT::doThisConnectionRound - Target slot has NAT behavior 0x%8X, local slot has NAT behavior 0x%8X", targetSlot->getNATBehavior(), localSlot->getNATBehavior()));
675-
676-
#if defined(DEBUG_LOGGING)
677-
UnsignedInt targetIP = targetSlot->getIP();
678-
UnsignedInt localIP = localSlot->getIP();
679-
#endif
680-
681633
DEBUG_LOG(("NAT::doThisConnectionRound - Target slot has IP %d.%d.%d.%d Local slot has IP %d.%d.%d.%d",
682-
PRINTF_IP_AS_4_INTS(targetIP),
683-
PRINTF_IP_AS_4_INTS(localIP)));
684-
685-
if (((targetSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) == 0) &&
686-
((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0)) {
687-
688-
// we have a netgear bug type behavior and the target does not, so we need them to send to us
689-
// first to avoid having our NAT table reset.
690-
691-
DEBUG_LOG(("NAT::doThisConnectionRound - Local node has a netgear and the target node does not, need to delay our probe."));
692-
m_timeTillNextSend = -1;
693-
}
634+
PRINTF_IP_AS_4_INTS(targetSlot->getIP()),
635+
PRINTF_IP_AS_4_INTS(localSlot->getIP())));
636+
#endif
694637

695638
// figure out which port number I'm using for this connection
696639
// this merely starts to talk to the mangler server, we have to keep calling
@@ -943,26 +886,6 @@ void NAT::probed(Int nodeNumber) {
943886
if (m_beenProbed == FALSE) {
944887
m_beenProbed = TRUE;
945888
DEBUG_LOG(("NAT::probed - just got probed for the first time."));
946-
if ((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) {
947-
DEBUG_LOG(("NAT::probed - we have a NETGEAR and we were just probed for the first time"));
948-
GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex];
949-
DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::probed - targetSlot is null"));
950-
if (targetSlot == nullptr) {
951-
DEBUG_LOG(("NAT::probed - targetSlot is null, failed this connection"));
952-
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED);
953-
return;
954-
}
955-
956-
if (targetSlot->getPort() == 0) {
957-
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT);
958-
DEBUG_LOG(("NAT::probed - still waiting for mangled port"));
959-
} else {
960-
DEBUG_LOG(("NAT::probed - sending a probe to %ls", targetSlot->getName().str()));
961-
sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
962-
notifyTargetOfProbe(targetSlot);
963-
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
964-
}
965-
}
966889
}
967890
}
968891

@@ -998,20 +921,12 @@ void NAT::gotMangledPort(Int nodeNumber, UnsignedShort mangledPort) {
998921

999922
targetSlot->setPort(mangledPort);
1000923
DEBUG_LOG(("NAT::gotMangledPort - got mangled port number %d from our target node (%ls)", mangledPort, targetSlot->getName().str()));
1001-
if (((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) == 0) || (m_beenProbed == TRUE) ||
1002-
(((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) && ((targetSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0))) {
1003-
#ifdef DEBUG_LOGGING
1004-
UnsignedInt ip = targetSlot->getIP();
1005-
#endif
1006-
DEBUG_LOG(("NAT::gotMangledPort - don't have a netgear or we have already been probed, or both my target and I have a netgear, send a PROBE. Sending to %d.%d.%d.%d:%d",
1007-
PRINTF_IP_AS_4_INTS(ip), targetSlot->getPort()));
924+
DEBUG_LOG(("NAT::gotMangledPort - Send a PROBE to %d.%d.%d.%d:%d",
925+
PRINTF_IP_AS_4_INTS(targetSlot->getIP()), targetSlot->getPort()));
1008926

1009-
sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
1010-
notifyTargetOfProbe(targetSlot);
1011-
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
1012-
} else {
1013-
DEBUG_LOG(("NAT::gotMangledPort - we are a netgear, not sending a PROBE yet."));
1014-
}
927+
sendAProbe(targetSlot->getIP(), targetSlot->getPort(), m_localNodeNumber);
928+
notifyTargetOfProbe(targetSlot);
929+
setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE);
1015930
}
1016931

1017932
void NAT::gotInternalAddress(Int nodeNumber, UnsignedInt address) {
@@ -1173,8 +1088,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
11731088
DEBUG_LOG(("NAT::processGlobalMessage - got message from slot %d, message is \"%s\"", slotNum, ptr));
11741089
if (strncmp(ptr, "PROBED", strlen("PROBED")) == 0) {
11751090
// format: PROBED<node number>
1176-
// a probe has been sent at us, if we are waiting because of a netgear or something, we
1177-
// should start sending our own probes.
1091+
// a probe has been sent at us; notify probed node.
11781092
Int node = atoi(ptr + strlen("PROBED"));
11791093
if (node == m_targetNodeNumber) {
11801094
// make sure we're being probed by who we're supposed to be probed by.

Generals/Code/GameEngine/Include/Common/GlobalData.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ class GlobalData : public SubsystemInterface
324324

325325
UnsignedInt m_defaultIP; ///< preferred IP address for LAN
326326
UnsignedInt m_firewallBehavior; ///< Last detected firewall behavior
327-
Bool m_firewallSendDelay; ///< Use send delay for firewall connection negotiations
328327
UnsignedInt m_firewallPortOverride; ///< User-specified port to be used
329328
Short m_firewallPortAllocationDelta; ///< the port allocation delta last detected.
330329

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,6 @@ GlobalData::GlobalData()
939939
// m_languageFilterPref = false;
940940
m_languageFilterPref = true;
941941
m_firewallBehavior = FirewallHelperClass::FIREWALL_TYPE_UNKNOWN;
942-
m_firewallSendDelay = FALSE;
943942
m_firewallPortOverride = 0;
944943
m_firewallPortAllocationDelta = 0;
945944
m_loadScreenDemo = FALSE;
@@ -1205,7 +1204,6 @@ void GlobalData::parseGameDataDefinition( INI* ini )
12051204
TheWritableGlobalData->m_drawScrollAnchor = optionPref.getDrawScrollAnchor();
12061205
TheWritableGlobalData->m_moveScrollAnchor = optionPref.getMoveScrollAnchor();
12071206
TheWritableGlobalData->m_defaultIP = optionPref.getLANIPAddress();
1208-
TheWritableGlobalData->m_firewallSendDelay = optionPref.getSendDelay();
12091207
TheWritableGlobalData->m_firewallBehavior = optionPref.getFirewallBehavior();
12101208
TheWritableGlobalData->m_firewallPortAllocationDelta = optionPref.getFirewallPortAllocationDelta();
12111209
TheWritableGlobalData->m_firewallPortOverride = optionPref.getFirewallPortOverride();

Generals/Code/GameEngine/Source/GameClient/GUI/EstablishConnectionsMenu/EstablishConnectionsMenu.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ void EstablishConnectionsMenu::setPlayerStatus(Int slot, NATConnectionState stat
124124
DEBUG_ASSERTCRASH(control != nullptr, ("player status control for slot %d is null", slot));
125125
return;
126126
}
127-
// if (state == NATCONNECTIONSTATE_NETGEARDELAY) {
128-
// GadgetStaticTextSetText(control, TheGameText->fetch("GUI:NetgearDelay"));
129127
if (state == NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE) {
130128
GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingForManglerResponse"));
131129
} else if (state == NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT) {

0 commit comments

Comments
 (0)