From 04c5898f4e720f03a53b48759cddd84792b2f6e4 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Tue, 14 Jan 2014 09:24:55 +0100 Subject: [PATCH] GL - sending string and createOBJ working --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 1 - Code/Game/DanBiasGame/GameClientState/GameState.cpp | 12 +++++++----- Code/Game/DanBiasServer/GameSession/GameSession.cpp | 3 +-- Code/Game/GameProtocols/ObjectProtocols.h | 3 ++- Code/Network/NetworkAPI/CustomNetProtocol.cpp | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 2a5daa3f..cd3783ff 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -70,7 +70,6 @@ namespace DanBias Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj; protocolData->object_ID = p[1].value.netInt; - char k = p[2].value.netChar; protocolData->path = p[2].value.netCharPtr; for(int i = 0; i< 16; i++) { diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index a93a8e91..d488808f 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -66,6 +66,8 @@ bool GameState::LoadModels(std::wstring mapFile) ModelInitData modelData; modelData.world = Oyster::Math3D::Float4x4::identity; + Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2)); + modelData.world = modelData.world * translate; modelData.visible = true; modelData.modelPath = L"..\\Content\\worldDummy"; modelData.id = 0; @@ -74,7 +76,7 @@ bool GameState::LoadModels(std::wstring mapFile) privData->object.push_back(obj); privData->object[privData->object.size() -1 ]->Init(modelData); - Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2)); + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2)); modelData.world = modelData.world * translate; modelData.modelPath = L"..\\Content\\worldDummy"; modelData.id ++; @@ -262,21 +264,21 @@ void GameState::Protocol( ObjPos* pos ) } } -void GameState::Protocol( NewObj* pos ) +void GameState::Protocol( NewObj* newObj ) { Oyster::Math::Float4x4 world; for(int i = 0; i<16; i++) { - world[i] = pos->worldPos[i]; + world[i] = newObj->worldPos[i]; } ModelInitData modelData; modelData.world = world; modelData.visible = true; - modelData.id = pos->object_ID; + modelData.id = newObj->object_ID; //not sure if this is good parsing rom char* to wstring - const char* path = pos->path; + const char* path = newObj->path; modelData.modelPath = std::wstring(path, path + strlen(path)); // load models C_Object* player = new C_Player(); diff --git a/Code/Game/DanBiasServer/GameSession/GameSession.cpp b/Code/Game/DanBiasServer/GameSession/GameSession.cpp index ed47f53c..853c13c7 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession.cpp @@ -136,8 +136,7 @@ namespace DanBias if(GetAsyncKeyState(VK_DOWN)) { Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity; - Protocol_CreateObject p(world, 2, "grdg"); - //p.path = "../Content/crate"; + Protocol_CreateObject p(world, 2, "../Content/crate"); Send(p.GetProtocol()); Sleep(100); } diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 880b645d..2a538714 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -34,8 +34,9 @@ namespace GameLogic this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray; - for (int i = 2; i <= 17; i++) + for (int i = 3; i <= 18; i++) { this->protocol[i].type = Oyster::Network::NetAttributeType_Float; } diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.cpp b/Code/Network/NetworkAPI/CustomNetProtocol.cpp index 91fb7267..d34832d7 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.cpp +++ b/Code/Network/NetworkAPI/CustomNetProtocol.cpp @@ -22,10 +22,10 @@ struct CustomNetProtocol::PrivateData size_t size = strlen(i->second.value.netCharPtr); if(size == 0) continue; - attributes[i->first]; attributes[i->first].value.netCharPtr = new char[size + 1]; //strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr); memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1); + attributes[i->first].type = NetAttributeType_CharArray; } else {