Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2015 Compile fix. #38

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions CmakeIncludes/CmakeMacros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion Lib/DLL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Lib/LibStatic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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 06-January-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]
------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions Samples/DirectoryDeltaTransfer/DirectoryDeltaTransferTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions Samples/TeamManager/TeamManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "SocketLayer.h"
#include "ReplicaManager3.h"
#include "NetworkIDManager.h"
#include "Gets.h"

using namespace RakNet;

Expand Down Expand Up @@ -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)));
Expand All @@ -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')))
{
Expand All @@ -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])
Expand All @@ -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);
Expand All @@ -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')
{
Expand Down
14 changes: 6 additions & 8 deletions Samples/Tests/CommonFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<millisecondsToWait)
Expand All @@ -90,8 +87,9 @@ void CommonFunctions::DisconnectAndWait(RakPeerInterface *peer,char* ip,unsigned
{
SystemAddress targetAddress;

targetAddress.SetBinaryAddress(ip);
targetAddress.port=port;
std::string address(ip);
address += ":" + std::to_string(port);
targetAddress.SetBinaryAddress(address.c_str());

while(CommonFunctions::ConnectionStateMatchesOptions (peer,targetAddress,true,true,true,true))//disconnect client
{
Expand Down
10 changes: 5 additions & 5 deletions Samples/Tests/ComprehensiveConvertTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List<RakString> params,boo
printf("%i: ", 60000+numSystems);
for (i=0; i < numSystems; i++)
{
printf("%i: ", remoteSystems[i].port);
printf("%i: ", remoteSystems[i].GetPort());
}
printf("\n");
}
Expand Down Expand Up @@ -189,7 +189,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List<RakString> 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));
Expand Down Expand Up @@ -224,7 +224,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List<RakString> 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
Expand Down Expand Up @@ -273,7 +273,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List<RakString> 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);

}

Expand All @@ -282,7 +282,7 @@ int ComprehensiveConvertTest::RunTest(DataStructures::List<RakString> 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);

}
}
Expand Down
7 changes: 3 additions & 4 deletions Samples/Tests/ConnectWithSocketTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List<RakString> 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))
Expand Down Expand Up @@ -88,7 +87,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List<RakString> 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);
Expand Down Expand Up @@ -129,7 +128,7 @@ int ConnectWithSocketTest::RunTest(DataStructures::List<RakString> 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);
Expand Down
4 changes: 2 additions & 2 deletions Samples/Tests/CrossConnectionConvertTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int CrossConnectionConvertTest::RunTest(DataStructures::List<RakString> 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)
Expand Down Expand Up @@ -143,7 +143,7 @@ int CrossConnectionConvertTest::RunTest(DataStructures::List<RakString> 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)
Expand Down
1 change: 1 addition & 0 deletions Samples/Tests/DebugTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/

#define NOMINMAX
#include <iostream>
#include <limits>

Expand Down
13 changes: 6 additions & 7 deletions Samples/Tests/DroppedConnectionConvertTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ int DroppedConnectionConvertTest::RunTest(DataStructures::List<RakString> 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_);
Expand Down Expand Up @@ -296,31 +295,31 @@ int DroppedConnectionConvertTest::RunTest(DataStructures::List<RakString> 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;


case ID_CONNECTION_LOST:
// 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:
Expand Down
9 changes: 4 additions & 5 deletions Samples/Tests/LocalIsConnectedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List<RakString> 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)
Expand All @@ -69,7 +68,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List<RakString> 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);
Expand Down Expand Up @@ -98,7 +97,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List<RakString> 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))
{
Expand All @@ -115,7 +114,7 @@ int LocalIsConnectedTest::RunTest(DataStructures::List<RakString> 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);
Expand Down
9 changes: 3 additions & 6 deletions Samples/Tests/ManyClientsOneServerBlockingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void ManyClientsOneServerBlockingTest::WaitForConnectionRequestsToComplete(RakPe
for (int i=0;i<clientNum;i++)
{

currentSystem.SetBinaryAddress("127.0.0.1");
currentSystem.port=60000;
currentSystem.SetBinaryAddress("127.0.0.1:60000");

while (CommonFunctions::ConnectionStateMatchesOptions (clientList[i],currentSystem,false,true,true) )
{
Expand Down Expand Up @@ -279,8 +278,7 @@ int ManyClientsOneServerBlockingTest::RunTest(DataStructures::List<RakString> pa
for (int i=0;i<clientNum;i++)
{

currentSystem.SetBinaryAddress("127.0.0.1");
currentSystem.port=60000;
currentSystem.SetBinaryAddress("127.0.0.1:60000");
if(!CommonFunctions::ConnectionStateMatchesOptions (clientList[i],currentSystem,true,true,true,true) )//Are we connected or is there a pending operation ?
{

Expand Down Expand Up @@ -310,8 +308,7 @@ int ManyClientsOneServerBlockingTest::RunTest(DataStructures::List<RakString> pa
for (int i=0;i<clientNum;i++)
{

currentSystem.SetBinaryAddress("127.0.0.1");
currentSystem.port=60000;
currentSystem.SetBinaryAddress("127.0.0.1:60000");

if(!CommonFunctions::ConnectionStateMatchesOptions (clientList[i],currentSystem,true,true,true,true) )//Are we connected or is there a pending operation ?
{
Expand Down
Loading