From 43b111f0d34a199c4f8b6d40829e37a9290fcceb Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 27 Nov 2013 11:28:11 +0100 Subject: [PATCH] Pull MiscBranch --- Code/Network/NetworkDependencies/Connection.cpp | 10 ++++------ Code/Network/NetworkDependencies/Connection.h | 4 ++-- Code/Network/NetworkDependencies/IConnection.h | 2 +- .../NetworkDependencies/Messages/MessageHeader.cpp | 4 ++-- .../NetworkDependencies/Messages/MessageTest.cpp | 2 -- Code/Network/NetworkDependencies/OysterByte.cpp | 2 +- Code/Network/NetworkDependencies/Packing.cpp | 4 ++-- Code/Network/NetworkDependencies/WinsockFunctions.cpp | 2 ++ Code/Network/OysterNetworkServer/ServerMain.cpp | 6 +++--- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Code/Network/NetworkDependencies/Connection.cpp b/Code/Network/NetworkDependencies/Connection.cpp index 522caa24..1cf5efb1 100644 --- a/Code/Network/NetworkDependencies/Connection.cpp +++ b/Code/Network/NetworkDependencies/Connection.cpp @@ -37,7 +37,7 @@ int Connection::InitiateServer(unsigned short port) { int errorCode = 0; - if((errorCode = initiateSocket()) != 0) + if((errorCode = InitiateSocket()) != 0) { return errorCode; } @@ -68,9 +68,7 @@ int Connection::InitiateServer(unsigned short port) int Connection::InitiateClient() { - int errorCode; - return initiateSocket(); - + return InitiateSocket(); } int Connection::Disconnect() @@ -80,7 +78,7 @@ int Connection::Disconnect() return WSAGetLastError(); } -bool Connection::Send(OysterByte& bytes) +int Connection::Send(OysterByte& bytes) { int nBytes; @@ -129,7 +127,7 @@ int Connection::Listen() /////////////////////////////////////// //Private functions /////////////////////////////////////// -int Connection::initiateSocket() +int Connection::InitiateSocket() { this->socket = ::socket(AF_INET, SOCK_STREAM, 0); if(this->socket == SOCKET_ERROR) diff --git a/Code/Network/NetworkDependencies/Connection.h b/Code/Network/NetworkDependencies/Connection.h index ddb3f8b7..34569807 100644 --- a/Code/Network/NetworkDependencies/Connection.h +++ b/Code/Network/NetworkDependencies/Connection.h @@ -23,7 +23,7 @@ namespace Oyster virtual int InitiateServer( unsigned short port ); virtual int InitiateClient(); - virtual bool Send( OysterByte& bytes ); + virtual int Send( OysterByte& bytes ); virtual int Recieve( OysterByte& bytes ); virtual int Disconnect(); @@ -31,7 +31,7 @@ namespace Oyster virtual int Listen(); private: - int initiateSocket(); + int InitiateSocket(); int socket; diff --git a/Code/Network/NetworkDependencies/IConnection.h b/Code/Network/NetworkDependencies/IConnection.h index e836a9c0..2ca895b1 100644 --- a/Code/Network/NetworkDependencies/IConnection.h +++ b/Code/Network/NetworkDependencies/IConnection.h @@ -15,7 +15,7 @@ namespace Oyster public: virtual int Disconnect() = 0; - virtual bool Send( OysterByte& bytes ) = 0; + virtual int Send( OysterByte& bytes ) = 0; virtual int Recieve( OysterByte& bytes) = 0; virtual int InitiateServer( unsigned short port ) { return false; }; virtual int InitiateClient() { return false; }; diff --git a/Code/Network/NetworkDependencies/Messages/MessageHeader.cpp b/Code/Network/NetworkDependencies/Messages/MessageHeader.cpp index 97c1d12f..97acf526 100644 --- a/Code/Network/NetworkDependencies/Messages/MessageHeader.cpp +++ b/Code/Network/NetworkDependencies/Messages/MessageHeader.cpp @@ -116,7 +116,7 @@ void MessageHeader::PackFloat(float i[], unsigned int elementCount, OysterByte& PackUnsignedInt(elementCount, bytes); //Pack all elements - for(int j = 0; j < elementCount; j++) + for(int j = 0; j < (int)elementCount; j++) { PackFloat(i[j], bytes); } @@ -226,7 +226,7 @@ float* MessageHeader::UnpackFloat(unsigned int& elementCount, OysterByte& bytes) elementCount = UnpackUnsignedInt(bytes); i = new float[elementCount]; - for(int j = 0; j < elementCount; j++) + for(int j = 0; j < (int)elementCount; j++) { i[j] = UnpackFloat(bytes); } diff --git a/Code/Network/NetworkDependencies/Messages/MessageTest.cpp b/Code/Network/NetworkDependencies/Messages/MessageTest.cpp index 71f53223..7fcb1a71 100644 --- a/Code/Network/NetworkDependencies/Messages/MessageTest.cpp +++ b/Code/Network/NetworkDependencies/Messages/MessageTest.cpp @@ -15,8 +15,6 @@ MessageTest::~MessageTest() void MessageTest::Pack(ProtocolHeader& header, OysterByte& bytes) { MessageHeader::Pack(header, bytes); - unsigned char asd[1000]; - //strcpy_s(asd, bytes.GetSize(), bytes); PackStr(static_cast(&header)->textMessage, bytes); PackFloat(static_cast(&header)->f, static_cast(&header)->numOfFloats, bytes); diff --git a/Code/Network/NetworkDependencies/OysterByte.cpp b/Code/Network/NetworkDependencies/OysterByte.cpp index 6f3ecb92..ef7aa434 100644 --- a/Code/Network/NetworkDependencies/OysterByte.cpp +++ b/Code/Network/NetworkDependencies/OysterByte.cpp @@ -84,7 +84,7 @@ void OysterByte::IncreaseCapacity(unsigned int oldSize) capacity = size * 2; unsigned char* temp = new unsigned char[capacity]; - for(int i = 0; i < oldSize; i++) + for(int i = 0; i < (int)oldSize; i++) { temp[i] = byteArray[i]; } diff --git a/Code/Network/NetworkDependencies/Packing.cpp b/Code/Network/NetworkDependencies/Packing.cpp index bd827cfb..f636f891 100644 --- a/Code/Network/NetworkDependencies/Packing.cpp +++ b/Code/Network/NetworkDependencies/Packing.cpp @@ -87,7 +87,7 @@ namespace Oyster //floating point (32, 64-bit) void Pack(unsigned char buffer[], float i) { - int tempFloat = Pack754(i, 32, 8); + __int64 tempFloat = Pack754(i, 32, 8); Pack(buffer, tempFloat); } @@ -269,7 +269,7 @@ namespace Oyster float Unpackf(unsigned char buffer[]) { int tempFloat = Unpacki(buffer); - return Unpack754(tempFloat, 32, 8); + return (float)Unpack754(tempFloat, 32, 8); } double Unpackd(unsigned char buffer[]) diff --git a/Code/Network/NetworkDependencies/WinsockFunctions.cpp b/Code/Network/NetworkDependencies/WinsockFunctions.cpp index 3419965b..ea3c3b00 100644 --- a/Code/Network/NetworkDependencies/WinsockFunctions.cpp +++ b/Code/Network/NetworkDependencies/WinsockFunctions.cpp @@ -34,4 +34,6 @@ std::wstring GetErrorMessage(int errorCode) return retVal; } + //Added this if bufLen is 0 + return retVal; } \ No newline at end of file diff --git a/Code/Network/OysterNetworkServer/ServerMain.cpp b/Code/Network/OysterNetworkServer/ServerMain.cpp index f7b358ed..ad8e06b9 100644 --- a/Code/Network/OysterNetworkServer/ServerMain.cpp +++ b/Code/Network/OysterNetworkServer/ServerMain.cpp @@ -50,7 +50,7 @@ int main() test.numOfFloats = 35; test.f = new float[test.numOfFloats]; float temp = 395.456f; - for(int i = 0; i < test.numOfFloats; i++) + for(int i = 0; i < (int)test.numOfFloats; i++) { test.f[i] = temp; temp--; @@ -67,7 +67,7 @@ int main() t.Unpack(set, recvBuffer); cout << set->Protocol.pTest->clientID << ' ' << set->Protocol.pTest->packageType << ' ' << set->Protocol.pTest->size << endl; cout << "Client1: " << set->Protocol.pTest->textMessage << endl; - for(int i = 0; i < set->Protocol.pTest->numOfFloats; i++) + for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++) { cout << set->Protocol.pTest->f[i] << ' '; } @@ -80,7 +80,7 @@ int main() t.Unpack(set, recvBuffer); cout << set->Protocol.pTest->clientID << ' ' << set->Protocol.pTest->packageType << ' ' << set->Protocol.pTest->size << endl; cout << "Client2: " << set->Protocol.pTest->textMessage << endl; - for(int i = 0; i < set->Protocol.pTest->numOfFloats; i++) + for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++) { cout << set->Protocol.pTest->f[i] << ' '; }