Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18c6c33

Browse files
committed
Add option to prepend network packets with 'mtasa' to help (or make worse) MTA traffic getting dropped
1 parent ec0ceb1 commit 18c6c33

File tree

6 files changed

+58
-16
lines changed

6 files changed

+58
-16
lines changed

MTA10/core/CClientVariables.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ void CClientVariables::LoadDefaults ( void )
295295
DEFAULT ( "mapalpha", 155 ); // map alpha
296296
DEFAULT ( "browser_speed", 1 ); // Browser speed
297297
DEFAULT ( "single_download", 0 ); // Single connection for downloads
298+
DEFAULT ( "packet_tag", 0 ); // Tag network packets
298299
DEFAULT ( "update_build_type", 0 ); // 0-stable 1-test 2-nightly
299300
DEFAULT ( "update_auto_install", 1 ); // 0-off 1-on
300301
DEFAULT ( "volumetric_shadows", 0 ); // Enable volumetric shadows

MTA10/core/CConnectManager.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool CConnectManager::Connect ( const char* szHost, unsigned short usPort, const
121121

122122
// Try to start a network to connect
123123
SString strAddress = inet_ntoa ( m_Address );
124-
if ( m_usPort && !pNet->StartNetwork ( strAddress, m_usPort ) )
124+
if ( m_usPort && !pNet->StartNetwork ( strAddress, m_usPort, CVARS_GET_VALUE < bool > ( "packet_tag" ) ) )
125125
{
126126
SString strBuffer ( _("Connecting to %s at port %u failed!"), m_strHost.c_str (), m_usPort );
127127
CCore::GetSingleton ().ShowMessageBox ( _("Error")+_E("CC22"), strBuffer, MB_BUTTON_OK | MB_ICON_ERROR ); // Failed to connect
@@ -251,7 +251,7 @@ void CConnectManager::DoPulse ( void )
251251
if ( time ( NULL ) >= m_tConnectStarted + 8 )
252252
{
253253
// Show a message that the connection timed out and abort
254-
g_pCore->ShowNetErrorMessageBox ( _("Error")+_E("CC23"), _("Connection timed out"), "connect-timed-out", true );
254+
g_pCore->ShowNetErrorMessageBox ( _("Error")+_E("CC23"), _("Connection timed out"), "connect-timed-out", true );
255255
Abort ();
256256
}
257257
else
@@ -267,6 +267,9 @@ void CConnectManager::DoPulse ( void )
267267
case RID_RSA_PUBLIC_KEY_MISMATCH:
268268
strError = _("Disconnected: unknown protocol error"); strErrorCode = _E("CC24"); // encryption key mismatch
269269
break;
270+
case RID_INCOMPATIBLE_PROTOCOL_VERSION:
271+
strError = _("Disconnected: unknown protocol error"); strErrorCode = _E("CC34"); // old raknet version
272+
break;
270273
case RID_REMOTE_DISCONNECTION_NOTIFICATION:
271274
strError = _("Disconnected: disconnected remotely"); strErrorCode = _E("CC25");
272275
break;

MTA10/core/CSettings.cpp

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,18 +1180,21 @@ void CSettings::CreateGUI ( void )
11801180
**/
11811181
vecTemp = CVector2D ( 12.f, 12.f );
11821182
float fComboWidth = 170.f;
1183+
float fHeaderHeight = 20;
1184+
float fLineHeight = 27;
11831185

11841186
// Misc section label
11851187
m_pAdvancedMiscLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Misc") ) );
11861188
m_pAdvancedMiscLabel->SetPosition ( CVector2D ( vecTemp.fX, vecTemp.fY ) );
11871189
m_pAdvancedMiscLabel->SetFont ( "default-bold-small" );
11881190
m_pAdvancedMiscLabel->AutoSize ( );
1189-
vecTemp.fY += 20;
1191+
vecTemp.fY += fHeaderHeight;
11901192

11911193
fIndentX = pManager->CGUI_GetMaxTextExtent( "default-normal",
11921194
_("Fast CJ clothes loading:"),
11931195
_("Browser speed:"),
11941196
_("Single connection:"),
1197+
_("Packet tag:"),
11951198
_("Fullscreen mode:"),
11961199
_("Process priority:"),
11971200
_("Debug setting:"),
@@ -1214,7 +1217,7 @@ void CSettings::CreateGUI ( void )
12141217
m_pFastClothesCombo->AddItem ( _("On") )->SetData ( (void*)CMultiplayer::FAST_CLOTHES_ON );
12151218
m_pFastClothesCombo->AddItem ( _("Auto") )->SetData ( (void*)CMultiplayer::FAST_CLOTHES_AUTO );
12161219
m_pFastClothesCombo->SetReadOnly ( true );
1217-
vecTemp.fY += 29;
1220+
vecTemp.fY += fLineHeight;
12181221

12191222
// Browser scan speed
12201223
m_pBrowserSpeedLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Browser speed:") ) );
@@ -1241,7 +1244,20 @@ void CSettings::CreateGUI ( void )
12411244
m_pSingleDownloadCombo->AddItem ( _("Default") )->SetData ( (void*)0 );
12421245
m_pSingleDownloadCombo->AddItem ( _("On") )->SetData ( (void*)1 );
12431246
m_pSingleDownloadCombo->SetReadOnly ( true );
1244-
vecTemp.fY += 29;
1247+
vecTemp.fY += fLineHeight;
1248+
1249+
// Packet tag
1250+
m_pPacketTagLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Packet tag:") ) );
1251+
m_pPacketTagLabel->SetPosition ( CVector2D ( vecTemp.fX, vecTemp.fY ) );
1252+
m_pPacketTagLabel->AutoSize ( );
1253+
1254+
m_pPacketTagCombo = reinterpret_cast < CGUIComboBox* > ( pManager->CreateComboBox ( pTabAdvanced, "" ) );
1255+
m_pPacketTagCombo->SetPosition ( CVector2D ( vecTemp.fX + fIndentX, vecTemp.fY - 1.0f ) );
1256+
m_pPacketTagCombo->SetSize ( CVector2D ( fComboWidth, 95.0f ) );
1257+
m_pPacketTagCombo->AddItem ( _("Default") )->SetData ( (void*)0 );
1258+
m_pPacketTagCombo->AddItem ( _("On") )->SetData ( (void*)1 );
1259+
m_pPacketTagCombo->SetReadOnly ( true );
1260+
vecTemp.fY += fLineHeight;
12451261

12461262
// Fullscreen mode
12471263
m_pFullscreenStyleLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Fullscreen mode:") ) );
@@ -1255,7 +1271,7 @@ void CSettings::CreateGUI ( void )
12551271
m_pFullscreenStyleCombo->AddItem ( _("Borderless window") )->SetData ( (void*)FULLSCREEN_BORDERLESS );
12561272
m_pFullscreenStyleCombo->AddItem ( _("Borderless keep res") )->SetData ( (void*)FULLSCREEN_BORDERLESS_KEEP_RES );
12571273
m_pFullscreenStyleCombo->SetReadOnly ( true );
1258-
vecTemp.fY += 29;
1274+
vecTemp.fY += fLineHeight;
12591275

12601276
// Process priority
12611277
m_pPriorityLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, "Process priority:" ) );
@@ -1287,7 +1303,7 @@ void CSettings::CreateGUI ( void )
12871303
m_pDebugSettingCombo->AddItem ( "#0000 Joystick" )->SetData ( (void*)EDiagnosticDebug::JOYSTICK_0000 );
12881304
m_pDebugSettingCombo->AddItem ( "#0000 Lua trace" )->SetData ( (void*)EDiagnosticDebug::LUA_TRACE_0000 );
12891305
m_pDebugSettingCombo->SetReadOnly ( true );
1290-
vecTemp.fY += 29;
1306+
vecTemp.fY += fLineHeight;
12911307

12921308
m_pDebugSettingCombo->SetText ( _("Default") );
12931309
SetApplicationSetting ( "diagnostics", "debug-setting", "none" );
@@ -1317,7 +1333,7 @@ void CSettings::CreateGUI ( void )
13171333
m_pStreamingMemoryMaxLabel->SetPosition ( CVector2D ( vecTemp.fX + vecSize.fX + 5.0f, vecTemp.fY ) );
13181334
m_pStreamingMemoryMaxLabel->AutoSize ( );
13191335
vecTemp.fX = 22.f;
1320-
vecTemp.fY += 29;
1336+
vecTemp.fY += fLineHeight;
13211337

13221338
// Windows 8 compatibility
13231339
m_pWin8Label = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Windows 8 compatibility:") ) );
@@ -1333,7 +1349,7 @@ void CSettings::CreateGUI ( void )
13331349
m_pWin8MouseCheckBox = reinterpret_cast < CGUICheckBox* > ( pManager->CreateCheckBox ( pTabAdvanced, _("Mouse fix") ) );
13341350
m_pWin8MouseCheckBox->SetPosition ( CVector2D ( vecTemp.fX + fIndentX, vecTemp.fY - 1.0f ) );
13351351
m_pWin8MouseCheckBox->AutoSize ( NULL, 20.0f );
1336-
vecTemp.fY += 29;
1352+
vecTemp.fY += fLineHeight;
13371353
vecTemp.fX -= 110;
13381354

13391355
if ( GetApplicationSetting ( "os-version" ) < "6.2" )
@@ -1342,7 +1358,7 @@ void CSettings::CreateGUI ( void )
13421358
m_pWin8Label->SetVisible ( false );
13431359
m_pWin8ColorCheckBox->SetVisible ( false );
13441360
m_pWin8MouseCheckBox->SetVisible ( false );
1345-
vecTemp.fY -= 29;
1361+
vecTemp.fY -= fLineHeight;
13461362
#endif
13471363
}
13481364

@@ -1351,7 +1367,7 @@ void CSettings::CreateGUI ( void )
13511367
m_pAdvancedUpdaterLabel->SetPosition ( CVector2D ( vecTemp.fX - 10.0f, vecTemp.fY ) );
13521368
m_pAdvancedUpdaterLabel->SetFont ( "default-bold-small" );
13531369
m_pAdvancedUpdaterLabel->AutoSize ( _("Auto updater") );
1354-
vecTemp.fY += 20;
1370+
vecTemp.fY += fHeaderHeight;
13551371

13561372
// UpdateAutoInstall
13571373
m_pUpdateAutoInstallLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Install important updates:") ) );
@@ -1364,7 +1380,7 @@ void CSettings::CreateGUI ( void )
13641380
m_pUpdateAutoInstallCombo->AddItem ( _("Off") )->SetData ( (void*)0 );
13651381
m_pUpdateAutoInstallCombo->AddItem ( _("Default") )->SetData ( (void*)1 );
13661382
m_pUpdateAutoInstallCombo->SetReadOnly ( true );
1367-
vecTemp.fY += 29;
1383+
vecTemp.fY += fLineHeight;
13681384

13691385
// Update build type
13701386
m_pUpdateBuildTypeLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, _("Update build type:") ) );
@@ -1386,11 +1402,11 @@ void CSettings::CreateGUI ( void )
13861402
m_pButtonUpdate->AutoSize ( NULL, 20.0f, 8.0f );
13871403
m_pButtonUpdate->SetClickHandler ( GUI_CALLBACK ( &CSettings::OnUpdateButtonClick, this ) );
13881404
m_pButtonUpdate->SetZOrderingEnabled ( false );
1389-
vecTemp.fY += 29;
1405+
vecTemp.fY += fLineHeight;
13901406
vecTemp.fX -= fComboWidth + 15;
13911407

13921408
// Description label
1393-
vecTemp.fY = 354;
1409+
vecTemp.fY = 354 + 10;
13941410
m_pAdvancedSettingDescriptionLabel = reinterpret_cast < CGUILabel* > ( pManager->CreateLabel ( pTabAdvanced, "" ) );
13951411
m_pAdvancedSettingDescriptionLabel->SetPosition ( CVector2D ( vecTemp.fX + 10.f, vecTemp.fY ) );
13961412
m_pAdvancedSettingDescriptionLabel->SetFont ( "default-bold-small" );
@@ -1454,6 +1470,12 @@ void CSettings::CreateGUI ( void )
14541470
m_pSingleDownloadCombo->SetMouseEnterHandler ( GUI_CALLBACK ( &CSettings::OnShowAdvancedSettingDescription, this ) );
14551471
m_pSingleDownloadCombo->SetMouseLeaveHandler ( GUI_CALLBACK ( &CSettings::OnHideAdvancedSettingDescription, this ) );
14561472

1473+
m_pPacketTagLabel->SetMouseEnterHandler ( GUI_CALLBACK ( &CSettings::OnShowAdvancedSettingDescription, this ) );
1474+
m_pPacketTagLabel->SetMouseLeaveHandler ( GUI_CALLBACK ( &CSettings::OnHideAdvancedSettingDescription, this ) );
1475+
1476+
m_pPacketTagCombo->SetMouseEnterHandler ( GUI_CALLBACK ( &CSettings::OnShowAdvancedSettingDescription, this ) );
1477+
m_pPacketTagCombo->SetMouseLeaveHandler ( GUI_CALLBACK ( &CSettings::OnHideAdvancedSettingDescription, this ) );
1478+
14571479
m_pFullscreenStyleLabel->SetMouseEnterHandler ( GUI_CALLBACK ( &CSettings::OnShowAdvancedSettingDescription, this ) );
14581480
m_pFullscreenStyleLabel->SetMouseLeaveHandler ( GUI_CALLBACK ( &CSettings::OnHideAdvancedSettingDescription, this ) );
14591481

@@ -2803,6 +2825,11 @@ void CSettings::LoadData ( void )
28032825
if ( iVar == 0 ) m_pSingleDownloadCombo->SetText ( _("Default") );
28042826
else if ( iVar == 1 ) m_pSingleDownloadCombo->SetText ( _("On") );
28052827

2828+
// Packet tag
2829+
CVARS_GET ( "packet_tag", iVar );
2830+
if ( iVar == 0 ) m_pPacketTagCombo->SetText ( _("Default") );
2831+
else if ( iVar == 1 ) m_pPacketTagCombo->SetText ( _("On") );
2832+
28062833
// Windows 8 16-bit color
28072834
iVar = GetApplicationSettingInt( "Win8Color16" );
28082835
m_pWin8ColorCheckBox->SetSelected ( iVar != 0 );
@@ -3065,6 +3092,13 @@ void CSettings::SaveData ( void )
30653092
CVARS_SET ( "single_download", iSelected );
30663093
}
30673094

3095+
// Packet tag
3096+
if ( CGUIListItem* pSelected = m_pPacketTagCombo->GetSelectedItem () )
3097+
{
3098+
int iSelected = ( int ) pSelected->GetData();
3099+
CVARS_SET ( "packet_tag", iSelected );
3100+
}
3101+
30683102
// Windows 8 16-bit color
30693103
SetApplicationSettingInt( "Win8Color16", m_pWin8ColorCheckBox->GetSelected() );
30703104

@@ -3943,6 +3977,8 @@ bool CSettings::OnShowAdvancedSettingDescription ( CGUIElement* pElement )
39433977
strText = std::string( _( "Browser speed:" ) ) + " " + std::string( _( "Older routers may require a slower scan speed." ) );
39443978
else if ( pLabel && pLabel == m_pSingleDownloadLabel || pComboBox && pComboBox == m_pSingleDownloadCombo )
39453979
strText = std::string( _( "Single connection:" ) ) + " " + std::string( _( "Switch on to use only one connection when downloading." ) );
3980+
else if ( pLabel && pLabel == m_pPacketTagLabel || pComboBox && pComboBox == m_pPacketTagCombo )
3981+
strText = std::string( _( "Packet tag:" ) ) + " " + std::string( _( "Tag network packets to help ISPs identify MTA traffic." ) );
39463982
else if ( pLabel && pLabel == m_pFullscreenStyleLabel || pComboBox && pComboBox == m_pFullscreenStyleCombo )
39473983
strText = std::string( _( "Fullscreen mode:" ) ) + " " + std::string( _( "Experimental feature." ) );
39483984
else if ( pLabel && pLabel == m_pDebugSettingLabel || pComboBox && pComboBox == m_pDebugSettingCombo )

MTA10/core/CSettings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class CSettings
215215
CGUIComboBox* m_pBrowserSpeedCombo;
216216
CGUILabel* m_pSingleDownloadLabel;
217217
CGUIComboBox* m_pSingleDownloadCombo;
218+
CGUILabel* m_pPacketTagLabel;
219+
CGUIComboBox* m_pPacketTagCombo;
218220
CGUILabel* m_pDebugSettingLabel;
219221
CGUIComboBox* m_pDebugSettingCombo;
220222
CGUILabel* m_pWin8Label;

MTA10/sdk/net/CNet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CNet
6464
};
6565

6666
virtual void ResetNetwork ( void ) = 0;
67-
virtual bool StartNetwork ( const char* szServerHost, unsigned short usServerPort, const char* szServerPassword = NULL ) = 0;
67+
virtual bool StartNetwork ( const char* szServerHost, unsigned short usServerPort, bool bPacketTag = false ) = 0;
6868
virtual void StopNetwork ( void ) = 0;
6969

7070
virtual void SetFakeLag ( unsigned short usPacketLoss, unsigned short usMinExtraPing, unsigned short usExtraPingVariance, int iKBPSLimit ) = 0;

MTA10/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
#define _ASE_VERSION QUOTE_DEFINE(MTASA_VERSION_MAJOR) "." QUOTE_DEFINE(MTASA_VERSION_MINOR)
7777
#define _NETCODE_VERSION_BRANCH_ID 0x4 // Use 0x1 - 0xF to indicate an incompatible branch is being used (0x0 is reserved, 0x4 is trunk)
78-
#define _CLIENT_NET_MODULE_VERSION 0x089 // (0x000 - 0xfff) Lvl9 wizards only
78+
#define _CLIENT_NET_MODULE_VERSION 0x08A // (0x000 - 0xfff) Lvl9 wizards only
7979
#define _NETCODE_VERSION 0x1DA // (0x000 - 0xfff) Increment when net messages change (pre-release)
8080
#define MTA_DM_BITSTREAM_VERSION 0x05E // (0x000 - 0xfff) Increment when net messages change (post-release). (Changing will also require additional backward compatibility code).
8181

0 commit comments

Comments
 (0)