From 5b6a48576648453820983ee40094107c2999b8c4 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Fri, 3 Feb 2017 13:19:44 -0600 Subject: [PATCH 01/11] VS2015 Compile fix. --- Source/CCRakNetSlidingWindow.cpp | 8 ++++---- Source/CCRakNetSlidingWindow.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/CCRakNetSlidingWindow.cpp b/Source/CCRakNetSlidingWindow.cpp index d8c25d3d6..1749cace7 100644 --- a/Source/CCRakNetSlidingWindow.cpp +++ b/Source/CCRakNetSlidingWindow.cpp @@ -198,9 +198,9 @@ void CCRakNetSlidingWindow::OnNAK(CCTimeType curTime, DatagramSequenceNumberType } } // ---------------------------------------------------------------------------------------------------------------------------- -void CCRakNetSlidingWindow::OnAck(CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _BB, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber ) +void CCRakNetSlidingWindow::OnAck(CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _bpms, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber ) { - (void) _BB; + (void) _bpms; (void) totalUserDataBytesAcked; (void) _AS; (void) hasBAndAS; @@ -261,10 +261,10 @@ void CCRakNetSlidingWindow::OnDuplicateAck( CCTimeType curTime, DatagramSequence (void) sequenceNumber; } // ---------------------------------------------------------------------------------------------------------------------------- -void CCRakNetSlidingWindow::OnSendAckGetBAndAS(CCTimeType curTime, bool *hasBAndAS, BytesPerMicrosecond *_BB, BytesPerMicrosecond *_AS) +void CCRakNetSlidingWindow::OnSendAckGetBAndAS(CCTimeType curTime, bool *hasBAndAS, BytesPerMicrosecond *_bpms, BytesPerMicrosecond *_AS) { (void) curTime; - (void) _BB; + (void) _bpms; (void) _AS; *hasBAndAS=false; diff --git a/Source/CCRakNetSlidingWindow.h b/Source/CCRakNetSlidingWindow.h index 9fe7a6371..a5ce1f396 100644 --- a/Source/CCRakNetSlidingWindow.h +++ b/Source/CCRakNetSlidingWindow.h @@ -129,12 +129,12 @@ class CCRakNetSlidingWindow /// hasBAndAS are possibly written with the ack, see OnSendAck() /// B and AS are used in the calculations in UpdateWindowSizeAndAckOnAckPerSyn /// B and AS are updated at most once per SYN - void OnAck(CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _BB, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber ); + void OnAck(CCTimeType curTime, CCTimeType rtt, bool hasBAndAS, BytesPerMicrosecond _bpms, BytesPerMicrosecond _AS, double totalUserDataBytesAcked, bool isContinuousSend, DatagramSequenceNumberType sequenceNumber ); void OnDuplicateAck( CCTimeType curTime, DatagramSequenceNumberType sequenceNumber ); /// Call when you send an ack, to see if the ack should have the B and AS parameters transmitted /// Call before calling OnSendAck() - void OnSendAckGetBAndAS(CCTimeType curTime, bool *hasBAndAS, BytesPerMicrosecond *_BB, BytesPerMicrosecond *_AS); + void OnSendAckGetBAndAS(CCTimeType curTime, bool *hasBAndAS, BytesPerMicrosecond *_bpms, BytesPerMicrosecond *_AS); /// Call when we send an ack, to write B and AS if needed /// B and AS are only written once per SYN, to prevent slow calculations From 8ca50250dae4557a8a0f6833020e3b0ea0e83f1d Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Fri, 3 Feb 2017 13:45:19 -0600 Subject: [PATCH 02/11] Enabled c++ exceptions to get rid of warnings. --- CmakeIncludes/CmakeMacros.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CmakeIncludes/CmakeMacros.txt b/CmakeIncludes/CmakeMacros.txt index 6acc83061..1ef03d324 100644 --- a/CmakeIncludes/CmakeMacros.txt +++ b/CmakeIncludes/CmakeMacros.txt @@ -84,8 +84,8 @@ MACRO(FIXCOMPILEOPTIONS)#Fix added compile options that may cause problems, also SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") ENDIF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")# -nowarn 4018 -nowarn 4305 -nowarn 4244") - ENDIF(WIN32 AND NOT UNIX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w /EHsc")# -nowarn 4018 -nowarn 4305 -nowarn 4244 + ENDIF(WIN32 AND NOT UNIX) ENDIF(NOT ${CMAKE_GENERATOR} STREQUAL "MSYS Makefiles") ENDMACRO(FIXCOMPILEOPTIONS) From aaae49eb7ac27174ff0bbdd18330ba534f17ddbd Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Sun, 5 Feb 2017 16:38:17 -0600 Subject: [PATCH 03/11] Fix for not being able to use strings easily with the DirectoryDeltaTransfer plugin on windows. --- Source/FileList.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Source/FileList.cpp b/Source/FileList.cpp index 4d6174966..2404e1978 100644 --- a/Source/FileList.cpp +++ b/Source/FileList.cpp @@ -270,7 +270,7 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha strcat(fullPath, "*"); - dir=_findfirst(fullPath, &fileInfo ); + dir=_findfirst(fullPath, &fileInfo ); if (dir==-1) { _findclose(dir); @@ -281,7 +281,7 @@ void FileList::AddFilesFromDirectory(const char *applicationDirectory, const cha return; } -// RAKNET_DEBUG_PRINTF("Adding %s. %i remaining.\n", fullPath, dirList.Size()); + // RAKNET_DEBUG_PRINTF("Adding %s. %i remaining.\n", fullPath, dirList.Size()); for (unsigned int flpcIndex=0; flpcIndex < fileListProgressCallbacks.Size(); flpcIndex++) fileListProgressCallbacks[flpcIndex]->OnDirectory(this, fullPath, dirList.Size()); @@ -792,23 +792,13 @@ void FileList::GetCallbacks(DataStructures::List &callbacks) callbacks = fileListProgressCallbacks; } - bool FileList::FixEndingSlash(char *str) { -#ifdef _WIN32 - if (str[strlen(str)-1]!='/' && str[strlen(str)-1]!='\\') - { - strcat(str, "\\"); // Only \ works with system commands, used by AutopatcherClient - return true; - } -#else if (str[strlen(str)-1]!='\\' && str[strlen(str)-1]!='/') { strcat(str, "/"); // Only / works with Linux return true; } -#endif - return false; } From e3bd3063f62d6faa369a0888f739b28d1dc2d647 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 10:49:51 -0600 Subject: [PATCH 04/11] Specifically enabled exceptions for vs2015 compiler to get rid of warning. --- Lib/DLL/CMakeLists.txt | 2 +- Lib/LibStatic/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/DLL/CMakeLists.txt b/Lib/DLL/CMakeLists.txt index a64464926..4ceee0256 100644 --- a/Lib/DLL/CMakeLists.txt +++ b/Lib/DLL/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${RAKNET_INTERNAL_INCLUDE_DIRS} ) add_library(RakNetDLL SHARED ${ALL_CPP_SRCS} ${ALL_HEADER_SRCS} readme.txt) IF(WIN32 AND NOT UNIX) - SET( CMAKE_CXX_FLAGS "/D WIN32 /D _RAKNET_DLL /D _CRT_NONSTDC_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE /GS- /GR- ") + SET( CMAKE_CXX_FLAGS "/D WIN32 /D _RAKNET_DLL /D _CRT_NONSTDC_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE /GS- /GR- /EHsc") ENDIF(WIN32 AND NOT UNIX) IF(WIN32 AND NOT UNIX) diff --git a/Lib/LibStatic/CMakeLists.txt b/Lib/LibStatic/CMakeLists.txt index 859414627..0f0998886 100644 --- a/Lib/LibStatic/CMakeLists.txt +++ b/Lib/LibStatic/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories( ${RAKNET_INTERNAL_INCLUDE_DIRS} ) add_library(RakNetLibStatic STATIC ${ALL_CPP_SRCS} ${ALL_HEADER_SRCS} readme.txt) IF(WIN32 AND NOT UNIX) - SET( CMAKE_CXX_FLAGS "/D WIN32 /D _RAKNET_LIB /D _CRT_NONSTDC_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE /GS- /GR- ") + SET( CMAKE_CXX_FLAGS "/D WIN32 /D _RAKNET_LIB /D _CRT_NONSTDC_NO_DEPRECATE /D _CRT_SECURE_NO_DEPRECATE /GS- /GR- /EHsc") ENDIF(WIN32 AND NOT UNIX) IF(WIN32 AND NOT UNIX) From a4d2d24a3c5a83f6706ededb9f49384071383765 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 10:52:35 -0600 Subject: [PATCH 05/11] Fix for vs2015 team manager test to use custom Gets function supplied by occulus. --- Samples/TeamManager/TeamManagerTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Samples/TeamManager/TeamManagerTest.cpp b/Samples/TeamManager/TeamManagerTest.cpp index dd7605fba..dd6ec8b25 100644 --- a/Samples/TeamManager/TeamManagerTest.cpp +++ b/Samples/TeamManager/TeamManagerTest.cpp @@ -24,6 +24,7 @@ #include "SocketLayer.h" #include "ReplicaManager3.h" #include "NetworkIDManager.h" +#include "Gets.h" using namespace RakNet; @@ -398,7 +399,7 @@ int main(void) printf("Request specific team\n"); char buff1[256]; printf("Enter team index (0-2): "); - gets(buff1); + Gets(buff1, sizeof(buff1)); if (buff1[0]!=0 && buff1[0]>='0' && buff1[0]<='2') { success = user->tmTeamMember.RequestTeam(TeamSelection::SpecificTeam(&(teams[buff1[0]-'0'].tmTeam))); @@ -414,10 +415,10 @@ int main(void) printf("Request team switch\n"); char buff1[256]; printf("Enter team index to join (0-2): "); - gets(buff1); + Gets(buff1, sizeof(buff1)); char buff2[256]; printf("Enter team index to leave (0-2) or leave empty for all: "); - gets(buff2); + Gets(buff1, sizeof(buff2)); if (buff1[0]!=0 && buff1[0]>='0' && buff1[0]<='2' && (buff2[0]==0 || (buff2[0]>='0' && buff2[0]<='2'))) { @@ -437,7 +438,7 @@ int main(void) printf("Cancel request team\n"); char buff1[256]; printf("Enter team index to cancel (0-2) or leave empty for all: "); - gets(buff1); + Gets(buff1, sizeof(buff1)); if ((buff1[0]!=0 && buff1[0]>='0' && buff1[0]<='2') || buff1[0]==0) { if (buff1[0]) @@ -456,7 +457,7 @@ int main(void) printf("Leave specific team\n"); char buff1[256]; printf("Enter team index to leave (0-2): "); - gets(buff1); + Gets(buff1, sizeof(buff1)); if (buff1[0]!=0 && buff1[0]>='0' && buff1[0]<='2') { success = user->tmTeamMember.LeaveTeam(&(teams[buff1[0]-'0'].tmTeam),0); @@ -480,10 +481,10 @@ int main(void) printf("Set team member limit\n"); char buff1[256]; printf("Enter team index to operate on (0-2): "); - gets(buff1); + Gets(buff1, sizeof(buff1)); char buff2[256]; printf("Enter limit (0-9): "); - gets(buff2); + Gets(buff1, sizeof(buff2)); if (buff1[0]!=0 && buff1[0]>='0' && buff1[0]<='2' && buff2[0]!=0 && buff2[0]>='0' && buff2[0]<='9') { From 935ea6da8d2fc07298f70aebddcd4d877e4c6183 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 10:58:16 -0600 Subject: [PATCH 06/11] Fixes for security test functions. --- Samples/Tests/SecurityFunctionsTest.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Samples/Tests/SecurityFunctionsTest.cpp b/Samples/Tests/SecurityFunctionsTest.cpp index 1a697604b..49deda16a 100644 --- a/Samples/Tests/SecurityFunctionsTest.cpp +++ b/Samples/Tests/SecurityFunctionsTest.cpp @@ -97,8 +97,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i SystemAddress serverAddress; - serverAddress.SetBinaryAddress("127.0.0.1"); - serverAddress.port=60000; + serverAddress.SetBinaryAddress("127.0.0.1:60000"); TimeMS entryTime=GetTimeMS(); if (isVerbose) @@ -109,7 +108,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,0,0); + client->Connect("127.0.0.1",serverAddress.GetPort(),0,0); } RakSleep(100); @@ -133,7 +132,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,badPass,(int)strlen(badPass)); + client->Connect("127.0.0.1",serverAddress.GetPort(),badPass,(int)strlen(badPass)); } RakSleep(100); @@ -156,7 +155,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,thePassword,(int)strlen(thePassword)); + client->Connect("127.0.0.1",serverAddress.GetPort(),thePassword,(int)strlen(thePassword)); } RakSleep(100); @@ -187,7 +186,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,thePassword,(int)strlen(thePassword)); + client->Connect("127.0.0.1",serverAddress.GetPort(),thePassword,(int)strlen(thePassword)); } RakSleep(100); @@ -229,7 +228,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,thePassword,(int)strlen(thePassword)); + client->Connect("127.0.0.1",serverAddress.GetPort(),thePassword,(int)strlen(thePassword)); } RakSleep(100); @@ -260,7 +259,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,thePassword,(int)strlen(thePassword)); + client->Connect("127.0.0.1",serverAddress.GetPort(),thePassword,(int)strlen(thePassword)); } RakSleep(100); @@ -302,7 +301,7 @@ int SecurityFunctionsTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,thePassword,(int)strlen(thePassword)); + client->Connect("127.0.0.1",serverAddress.GetPort(),thePassword,(int)strlen(thePassword)); } RakSleep(100); From 879d7fe79d553a4869fdb039a2c02b8786cf4947 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 11:17:40 -0600 Subject: [PATCH 07/11] Fixed a bunch of tests because of API changes. --- Samples/Tests/CommonFunctions.cpp | 14 ++++++-------- Samples/Tests/ComprehensiveConvertTest.cpp | 10 +++++----- Samples/Tests/ConnectWithSocketTest.cpp | 7 +++---- Samples/Tests/CrossConnectionConvertTest.cpp | 4 ++-- Samples/Tests/DebugTools.cpp | 1 + Samples/Tests/DroppedConnectionConvertTest.cpp | 13 ++++++------- Samples/Tests/LocalIsConnectedTest.cpp | 9 ++++----- Samples/Tests/ManyClientsOneServerBlockingTest.cpp | 9 +++------ .../ManyClientsOneServerDeallocateBlockingTest.cpp | 9 +++------ .../Tests/ManyClientsOneServerNonBlockingTest.cpp | 6 ++---- Samples/Tests/PingTestsTest.cpp | 3 +-- Samples/Tests/SystemAddressAndGuidTest.cpp | 8 +++----- Samples/Tests/TestHelpers.cpp | 4 ++-- 13 files changed, 41 insertions(+), 56 deletions(-) diff --git a/Samples/Tests/CommonFunctions.cpp b/Samples/Tests/CommonFunctions.cpp index 63c007752..ce59ea709 100644 --- a/Samples/Tests/CommonFunctions.cpp +++ b/Samples/Tests/CommonFunctions.cpp @@ -39,10 +39,6 @@ bool CommonFunctions::ConnectionStateMatchesOptions(RakPeerInterface *peer,Syste return isDisconnecting; break; - case IS_LOOPBACK: - return isLoopBack; - break; - case IS_NOT_CONNECTED: return isNotConnected; break; @@ -62,8 +58,9 @@ bool CommonFunctions::WaitAndConnect(RakPeerInterface *peer,char* ip,unsigned sh SystemAddress connectToAddress; - connectToAddress.SetBinaryAddress(ip); - connectToAddress.port=port; + std::string address(ip); + address += ":" + std::to_string(port); + connectToAddress.SetBinaryAddress(address.c_str()); TimeMS entryTime=GetTimeMS(); while(!CommonFunctions::ConnectionStateMatchesOptions (peer,connectToAddress,true)&&GetTimeMS()-entryTime params,boo printf("%i: ", 60000+numSystems); for (i=0; i < numSystems; i++) { - printf("%i: ", remoteSystems[i].port); + printf("%i: ", remoteSystems[i].GetPort()); } printf("\n"); } @@ -189,7 +189,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List params,boo #endif peerIndex=randomMT()%NUM_PEERS; - sprintf(data+3, "dataLength=%i priority=%i reliability=%i orderingChannel=%i target=%i broadcast=%i\n", dataLength, priority, reliability, orderingChannel, target.port, broadcast); + sprintf(data+3, "dataLength=%i priority=%i reliability=%i orderingChannel=%i target=%i broadcast=%i\n", dataLength, priority, reliability, orderingChannel, target.GetPort(), broadcast); //unsigned short localPort=60000+i; #ifdef _VERIFY_RECIPIENTS memcpy((char*)data+1, (char*)&target.port, sizeof(unsigned short)); @@ -224,7 +224,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List params,boo broadcast=false; // Temporarily in so I can check recipients #endif - sprintf(data+3, "dataLength=%i priority=%i reliability=%i orderingChannel=%i target=%i broadcast=%i\n", dataLength, priority, reliability, orderingChannel, target.port, broadcast); + sprintf(data+3, "dataLength=%i priority=%i reliability=%i orderingChannel=%i target=%i broadcast=%i\n", dataLength, priority, reliability, orderingChannel, target.GetPort(), broadcast); #ifdef _VERIFY_RECIPIENTS memcpy((char*)data, (char*)&target.port, sizeof(unsigned short)); #endif @@ -273,7 +273,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List params,boo { StatisticsToString(rss, data, 0); if (isVerbose) - printf("Statistics for local system %i:\n%s", mySystemAddress.port, data); + printf("Statistics for local system %i:\n%s", mySystemAddress.GetPort(), data); } @@ -282,7 +282,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List params,boo { StatisticsToString(rss, data, 0); if (isVerbose) - printf("Statistics for target system %i:\n%s", target.port, data); + printf("Statistics for target system %i:\n%s", target.GetPort(), data); } } diff --git a/Samples/Tests/ConnectWithSocketTest.cpp b/Samples/Tests/ConnectWithSocketTest.cpp index bffcecc97..94998c1ef 100644 --- a/Samples/Tests/ConnectWithSocketTest.cpp +++ b/Samples/Tests/ConnectWithSocketTest.cpp @@ -47,8 +47,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List params,bool i SystemAddress serverAddress; - serverAddress.SetBinaryAddress("127.0.0.1"); - serverAddress.port=60000; + serverAddress.SetBinaryAddress("127.0.0.1:60000"); printf("Testing normal connect before test\n"); if (!TestHelpers::WaitAndConnectTwoPeersLocally(client,server,5000)) @@ -88,7 +87,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->ConnectWithSocket("127.0.0.1",serverAddress.port,0,0,theSocket); + client->ConnectWithSocket("127.0.0.1",serverAddress.GetPort(),0,0,theSocket); } RakSleep(100); @@ -129,7 +128,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List params,bool i if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->ConnectWithSocket("127.0.0.1",serverAddress.port,0,0,theSocket); + client->ConnectWithSocket("127.0.0.1",serverAddress.GetPort(),0,0,theSocket); } RakSleep(100); diff --git a/Samples/Tests/CrossConnectionConvertTest.cpp b/Samples/Tests/CrossConnectionConvertTest.cpp index 22580e0fc..2c55141d9 100644 --- a/Samples/Tests/CrossConnectionConvertTest.cpp +++ b/Samples/Tests/CrossConnectionConvertTest.cpp @@ -92,7 +92,7 @@ int CrossConnectionConvertTest::RunTest(DataStructures::List params,b printf("ID_PING\n"); connectionAttemptTime=GetTimeMS()+1000; p->systemAddress.ToString(false,clientIP); - clientPort=p->systemAddress.port; + clientPort=p->systemAddress.GetPort(); gotNotification=false; } else if (p->data[0]==ID_UNCONNECTED_PONG) @@ -143,7 +143,7 @@ int CrossConnectionConvertTest::RunTest(DataStructures::List params,b printf("ID_PING\n"); connectionAttemptTime=GetTimeMS()+1000; p->systemAddress.ToString(false,clientIP); - clientPort=p->systemAddress.port; + clientPort=p->systemAddress.GetPort(); gotNotification=false; } else if (p->data[0]==ID_UNCONNECTED_PONG) diff --git a/Samples/Tests/DebugTools.cpp b/Samples/Tests/DebugTools.cpp index e0369737c..74c5a5351 100644 --- a/Samples/Tests/DebugTools.cpp +++ b/Samples/Tests/DebugTools.cpp @@ -8,6 +8,7 @@ * */ +#define NOMINMAX #include #include diff --git a/Samples/Tests/DroppedConnectionConvertTest.cpp b/Samples/Tests/DroppedConnectionConvertTest.cpp index da00d578c..0d2ef6470 100644 --- a/Samples/Tests/DroppedConnectionConvertTest.cpp +++ b/Samples/Tests/DroppedConnectionConvertTest.cpp @@ -48,8 +48,7 @@ int DroppedConnectionConvertTest::RunTest(DataStructures::List params // Used to refer to systems. We already know the IP unsigned short serverPort = 20000; - serverID.binaryAddress=inet_addr("127.0.0.1"); - serverID.port=serverPort; + serverID.SetBinaryAddress("127.0.0.1:20000"); server=RakPeerInterface::GetInstance(); destroyList.Clear(false,_FILE_AND_LINE_); @@ -296,18 +295,18 @@ int DroppedConnectionConvertTest::RunTest(DataStructures::List params { case ID_CONNECTION_REQUEST_ACCEPTED: if (isVerbose) - printf("%i: %ID_CONNECTION_REQUEST_ACCEPTED from %i.\n",sender, p->systemAddress.port); + printf("%i: %ID_CONNECTION_REQUEST_ACCEPTED from %i.\n",sender, p->systemAddress.GetPort()); break; case ID_DISCONNECTION_NOTIFICATION: // Connection lost normally if (isVerbose) - printf("%i: ID_DISCONNECTION_NOTIFICATION from %i.\n",sender, p->systemAddress.port); + printf("%i: ID_DISCONNECTION_NOTIFICATION from %i.\n",sender, p->systemAddress.GetPort()); break; case ID_NEW_INCOMING_CONNECTION: // Somebody connected. We have their IP now if (isVerbose) - printf("%i: ID_NEW_INCOMING_CONNECTION from %i.\n",sender, p->systemAddress.port); + printf("%i: ID_NEW_INCOMING_CONNECTION from %i.\n",sender, p->systemAddress.GetPort()); break; @@ -315,12 +314,12 @@ int DroppedConnectionConvertTest::RunTest(DataStructures::List params // Couldn't deliver a reliable packet - i.e. the other system was abnormally // terminated if (isVerbose) - printf("%i: ID_CONNECTION_LOST from %i.\n",sender, p->systemAddress.port); + printf("%i: ID_CONNECTION_LOST from %i.\n",sender, p->systemAddress.GetPort()); break; case ID_NO_FREE_INCOMING_CONNECTIONS: if (isVerbose) - printf("%i: ID_NO_FREE_INCOMING_CONNECTIONS from %i.\n",sender, p->systemAddress.port); + printf("%i: ID_NO_FREE_INCOMING_CONNECTIONS from %i.\n",sender, p->systemAddress.GetPort()); break; default: diff --git a/Samples/Tests/LocalIsConnectedTest.cpp b/Samples/Tests/LocalIsConnectedTest.cpp index 965e1ffee..61d12bdc8 100644 --- a/Samples/Tests/LocalIsConnectedTest.cpp +++ b/Samples/Tests/LocalIsConnectedTest.cpp @@ -57,8 +57,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List params,bool is SystemAddress serverAddress; - serverAddress.SetBinaryAddress("127.0.0.1"); - serverAddress.port=60000; + serverAddress.SetBinaryAddress("127.0.0.1:60000"); TimeMS entryTime=GetTimeMS(); bool lastConnect=false; if (isVerbose) @@ -69,7 +68,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List params,bool is if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - lastConnect=client->Connect("127.0.0.1",serverAddress.port,0,0)==CONNECTION_ATTEMPT_STARTED; + lastConnect=client->Connect("127.0.0.1",serverAddress.GetPort(),0,0)==CONNECTION_ATTEMPT_STARTED; } RakSleep(100); @@ -98,7 +97,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List params,bool is } RakSleep(1000); - client->Connect("127.0.0.1",serverAddress.port,0,0); + client->Connect("127.0.0.1",serverAddress.GetPort(),0,0); if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true)) { @@ -115,7 +114,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List params,bool is if(!CommonFunctions::ConnectionStateMatchesOptions (client,serverAddress,true,true,true,true)) { - client->Connect("127.0.0.1",serverAddress.port,0,0); + client->Connect("127.0.0.1",serverAddress.GetPort(),0,0); } RakSleep(100); diff --git a/Samples/Tests/ManyClientsOneServerBlockingTest.cpp b/Samples/Tests/ManyClientsOneServerBlockingTest.cpp index 15e53d9c0..b72a15e14 100644 --- a/Samples/Tests/ManyClientsOneServerBlockingTest.cpp +++ b/Samples/Tests/ManyClientsOneServerBlockingTest.cpp @@ -18,8 +18,7 @@ void ManyClientsOneServerBlockingTest::WaitForConnectionRequestsToComplete(RakPe for (int i=0;i pa for (int i=0;i pa for (int i=0;i for (int i=0;i for (int i=0;i params,bool isVerbose SystemAddress currentSystem; - currentSystem.SetBinaryAddress("127.0.0.1"); - currentSystem.port=60000; + currentSystem.SetBinaryAddress("127.0.0.1:60000"); printf("Connecting sender2\n"); if (!TestHelpers::WaitAndConnectTwoPeersLocally(sender2,receiver,5000)) diff --git a/Samples/Tests/SystemAddressAndGuidTest.cpp b/Samples/Tests/SystemAddressAndGuidTest.cpp index 068bbd6cc..acdfa3260 100644 --- a/Samples/Tests/SystemAddressAndGuidTest.cpp +++ b/Samples/Tests/SystemAddressAndGuidTest.cpp @@ -190,8 +190,7 @@ int SystemAddressAndGuidTest::RunTest(DataStructures::List params,boo printf("Test GetSystemListValues of the system and guid list\n"); SystemAddress serverAddress; - serverAddress.SetBinaryAddress("127.0.0.1"); - serverAddress.port=60000; + serverAddress.SetBinaryAddress("127.0.0.1:60000"); if (!compareSystemAddresses(systemList[0],serverAddress)) { @@ -258,8 +257,7 @@ int SystemAddressAndGuidTest::RunTest(DataStructures::List params,boo } SystemAddress clientAddress; - clientAddress.SetBinaryAddress("127.0.0.1"); - clientAddress.port=60001; + clientAddress.SetBinaryAddress("127.0.0.1:60001"); printf("Test GetExternalID, automatic testing is not only required for this\nbecause of it's nature\nShould be supplemented by internet tests\n"); @@ -302,7 +300,7 @@ RakString SystemAddressAndGuidTest::ErrorCodeToString(int errorCode) bool SystemAddressAndGuidTest::compareSystemAddresses(SystemAddress ad1,SystemAddress ad2) { - if (ad1.binaryAddress!=ad2.binaryAddress||ad1.port!=ad2.port) + if (ad1!=ad2) { return 0; } diff --git a/Samples/Tests/TestHelpers.cpp b/Samples/Tests/TestHelpers.cpp index 572bdc6c9..176be721a 100644 --- a/Samples/Tests/TestHelpers.cpp +++ b/Samples/Tests/TestHelpers.cpp @@ -57,7 +57,7 @@ bool TestHelpers::WaitAndConnectTwoPeersLocally(RakPeerInterface *connector,RakP { SystemAddress connecteeAdd=connectee->GetInternalID(); - return CommonFunctions::WaitAndConnect(connector,"127.0.0.1",connecteeAdd.port,millisecondsToWait); + return CommonFunctions::WaitAndConnect(connector,"127.0.0.1",connecteeAdd.GetPort(),millisecondsToWait); } @@ -65,7 +65,7 @@ bool TestHelpers::WaitAndConnectTwoPeersLocally(RakPeerInterface *connector,RakP bool TestHelpers::ConnectTwoPeersLocally(RakPeerInterface *connector,RakPeerInterface *connectee) { SystemAddress connecteeAdd=connectee->GetInternalID(); - return connector->Connect("127.0.0.1",connecteeAdd.port,0,0); + return connector->Connect("127.0.0.1",connecteeAdd.GetPort(),0,0); } bool TestHelpers::BroadCastTestPacket(RakPeerInterface *sender,PacketReliability rel,PacketPriority pr,int typeNum)//returns send return value From 7a7d307d644f77e82e7d0709b07edb3149324c45 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 11:23:17 -0600 Subject: [PATCH 08/11] Updated README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 31e25adf9..d4cae91dd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ -Larku's fork of RakNet 4.081 +Aragonsr's fork of Larku's Fork of RakNet 4.081 ============ Copyright (c) 2014, Oculus VR, Inc. +Fork notes [updated 02-06-2017] +------------------------------------------ + +This fork contains quite a lot of compile error fixes for Visual Studio 2015. +This fork also contains other fixes I've needed to make. I also don't strictly adhere to C programming language. In some places I may use the standard library, such as for string manipulation. + Fork notes [updated 27-July-2015] ------------------------------------------ From 8ce77979fc15b0b1fa0e1dfcfa1127a50b7b4b78 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 11:24:39 -0600 Subject: [PATCH 09/11] Updated date on README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d4cae91dd..4c03ad78b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Aragonsr's fork of Larku's Fork of RakNet 4.081 Copyright (c) 2014, Oculus VR, Inc. -Fork notes [updated 02-06-2017] +Fork notes [updated 06-January-2017] ------------------------------------------ This fork contains quite a lot of compile error fixes for Visual Studio 2015. From cfac1c6a2ff13397c19abf776b60dd1e80b1db94 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 12:25:47 -0600 Subject: [PATCH 10/11] Fix for warning C4018: '<': signed/unsigned mismatch. --- Source/ReliabilityLayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ReliabilityLayer.h b/Source/ReliabilityLayer.h index 20b169016..cc10d75c1 100644 --- a/Source/ReliabilityLayer.h +++ b/Source/ReliabilityLayer.h @@ -92,7 +92,7 @@ class SortedSplittedPackets data = RakNet::OP_NEW_ARRAY(allocation_size, file, line); packetId = internalPacket->splitPacketId; - for (int i = 0; i < allocation_size; ++i) + for (unsigned i = 0; i < allocation_size; ++i) { data[i] = NULL; } From 93f4aa0d48f006267dd71828c352873d30778024 Mon Sep 17 00:00:00 2001 From: Todd Seiler Date: Mon, 6 Feb 2017 16:32:18 -0600 Subject: [PATCH 11/11] Initialized FileListReceiver with sane values so the user can get some feedback on whether or not the file already exists on the client in the OnDownloadComplete callback of the FileListTransferCBInteface. --- .../DirectoryDeltaTransferTest.cpp | 5 +++-- Source/FileListTransfer.cpp | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Samples/DirectoryDeltaTransfer/DirectoryDeltaTransferTest.cpp b/Samples/DirectoryDeltaTransfer/DirectoryDeltaTransferTest.cpp index 9ae231b67..b41a256b5 100644 --- a/Samples/DirectoryDeltaTransfer/DirectoryDeltaTransferTest.cpp +++ b/Samples/DirectoryDeltaTransfer/DirectoryDeltaTransferTest.cpp @@ -36,8 +36,7 @@ class TestCB : public RakNet::FileListTransferCBInterface { public: - bool OnFile( - OnFileStruct *onFileStruct) + bool OnFile(OnFileStruct *onFileStruct) { assert(onFileStruct->byteLengthOfThisFile >= onFileStruct->bytesDownloadedForThisFile); printf("%i. (100%%) %i/%i %s %ib / %ib\n", onFileStruct->setID, onFileStruct->fileIndex+1, onFileStruct->numberOfFilesInThisSet, onFileStruct->fileName, onFileStruct->byteLengthOfThisFile, onFileStruct->byteLengthOfThisSet); @@ -62,6 +61,8 @@ class TestCB : public RakNet::FileListTransferCBInterface virtual bool OnDownloadComplete(DownloadCompleteStruct *dcs) { printf("Download complete.\n"); + if (dcs->byteLengthOfThisSet == 0 && dcs->numberOfFilesInThisSet == 0) + printf("File already exists.\n"); // Returning false automatically deallocates the automatically allocated handler that was created by DirectoryDeltaTransfer return false; diff --git a/Source/FileListTransfer.cpp b/Source/FileListTransfer.cpp index 28dcab500..cc94a869c 100644 --- a/Source/FileListTransfer.cpp +++ b/Source/FileListTransfer.cpp @@ -63,7 +63,23 @@ struct FileListReceiver using namespace RakNet; -FileListReceiver::FileListReceiver() {filesReceived=0; setTotalDownloadedLength=0; partLength=1; DataStructures::Map::IMPLEMENT_DEFAULT_COMPARISON();} +FileListReceiver::FileListReceiver() + : downloadHandler(nullptr) + , allowedSender(UNASSIGNED_SYSTEM_ADDRESS) + , setID(0) + , setCount(0) + , setTotalCompressedTransmissionLength(0) + , setTotalFinalLength(0) + , setTotalDownloadedLength(0) + , gotSetHeader(false) + , deleteDownloadHandler(false) + , isCompressed(false) + , filesReceived(0) + , partLength(0) + +{ + DataStructures::Map::IMPLEMENT_DEFAULT_COMPARISON(); +} FileListReceiver::~FileListReceiver() { unsigned int i=0; for (i=0; i < pushedFiles.Size(); i++)