From 71d31db8843fb6d9b517e47deff58eca8d66228b Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 14:37:35 +0100 Subject: [PATCH] GAMELOGIC - Fixed a minor major huge issue with no problems --- Code/Game/DanBiasServer/GameServer.cpp | 5 ++-- Code/Game/GameProtocols/TEST_PROTOCOLS.h | 35 +++++++++++++++++++++++ Code/Network/NetworkAPI/NetworkClient.cpp | 2 +- Code/Network/NetworkAPI/Translator.cpp | 6 ++-- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Code/Game/GameProtocols/TEST_PROTOCOLS.h diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index df352a75..1c1dff3b 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -18,9 +18,10 @@ namespace DanBias { printf("Client connected!\n"); GameLogic::Protocol_TEST t; - t.text = "Hello"; + t.text = 'A'; client.Send(t); - c = client; + Sleep(50000); + this->mainLobby->AttachClient(Utility::DynamicMemory::SmartPointer(new NetworkClient(client))); } GameServer::GameServer() : initiated(0) diff --git a/Code/Game/GameProtocols/TEST_PROTOCOLS.h b/Code/Game/GameProtocols/TEST_PROTOCOLS.h new file mode 100644 index 00000000..df171c1f --- /dev/null +++ b/Code/Game/GameProtocols/TEST_PROTOCOLS.h @@ -0,0 +1,35 @@ +#ifndef GAMESERVER_TEST_H +#define GAMESERVER_TEST_H + +#include +#include "ProtocolIdentificationID.h" + + + +namespace GameLogic +{ + struct Protocol_TEST :public Oyster::Network::CustomProtocolObject + { + int ProtocolID; + char text; + + Protocol_TEST() + { + this->protocol[0].value = ProtocolID = PROTOCOL_TEST; + + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + } + Oyster::Network::CustomNetProtocol* GetProtocol() override + { + this->protocol[1].value = text; + + return &protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; +} + +#endif // !GAMESERVER_TEST_H \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 94077d52..d7b907fb 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -125,7 +125,7 @@ int NetworkClient::PrivateData::Send() postBoxMutex.lock(); if(sendPostBox->IsFull()) { - SmartPointer temp = new OysterByte; + SmartPointer temp = new OysterByte(); this->translator.Pack(temp, sendPostBox->FetchMessage()); errorCode = this->connection->Send(temp); } diff --git a/Code/Network/NetworkAPI/Translator.cpp b/Code/Network/NetworkAPI/Translator.cpp index ba42ea66..032fbfdb 100644 --- a/Code/Network/NetworkAPI/Translator.cpp +++ b/Code/Network/NetworkAPI/Translator.cpp @@ -56,7 +56,9 @@ struct Translator::PrivateData auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); - size = 4 + 2; //size(int) + number of chars(short) + size = 4; //size(int) + bytes->AddSize(4); + message.SetSize(size); //Find all the data types @@ -81,7 +83,7 @@ struct Translator::PrivateData auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); - for(int i = 0; i < (int)headerString.size(); i++) + for(int i = 0; i < (int)headerString.size(); i++, it++) { switch((int)headerString.at(i)) {